/* ── Reset & Base ─────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:          #0d0d0f;
  --bg-surface:  #131316;
  --bg-raised:   #1a1a1f;
  --bg-hover:    #202028;
  --border:      #252530;
  --border-hi:   #35354a;
  --text:        #e8e8f0;
  --text-muted:  #60607a;
  --text-dim:    #40404f;
  --accent:      #ff5e5e;
  --accent-dim:  #8a2626;
  --sidebar-w:   62px;
  --radius:      10px;
  --radius-sm:   6px;
  --transition:  0.18s ease;
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  overflow-x: hidden;
}

/* ── Layout ───────────────────────────────────────────────────────────────── */
#app {
  display: flex;
  height: 100vh;
  width: 100vw;
  overflow: hidden;
}

/* Sidebar on left (default) */
#app.sidebar-left  { flex-direction: row; }
#app.sidebar-right { flex-direction: row-reverse; }

/* ── Sidebar ──────────────────────────────────────────────────────────────── */
#sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  max-width: var(--sidebar-w);
  height: 100vh;
  background: var(--bg-surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 12px 0;
  gap: 4px;
  flex-shrink: 0;
  z-index: 100;
  transition: border-color var(--transition);
}

#app.sidebar-right #sidebar {
  border-right: none;
  border-left: 1px solid var(--border);
}

.sidebar-top    { display: flex; flex-direction: column; align-items: center; gap: 4px; flex: 1; }
.sidebar-bottom { display: flex; flex-direction: column; align-items: center; gap: 4px; padding-bottom: 4px; }

/* Sidebar logo mark */
.sidebar-logo {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: var(--accent-dim);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 10px;
  color: var(--accent);
}

/* Sidebar nav button */
.nav-btn {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-sm);
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  transition: background var(--transition), color var(--transition);
  text-decoration: none;
}

.nav-btn:hover {
  background: var(--bg-hover);
  color: var(--text);
}

.nav-btn.active {
  background: var(--bg-raised);
  color: var(--accent);
}

.nav-btn svg {
  width: 22px;
  height: 22px;
  stroke-width: 1.7;
  flex-shrink: 0;
}

/* Cat nav icon — slightly larger so it stands out */
#nav-cats svg { width: 28px; height: 28px; }

/* Games nav icon — uses games.svg as a currentColor mask so it stays visible
   on the dark sidebar and recolors with the active/red accent. */
.nav-games-icon {
  width: 22px;
  height: 22px;
  display: inline-block;
  background-color: currentColor;
  -webkit-mask: url("/assets/img/games.svg") center / contain no-repeat;
          mask: url("/assets/img/games.svg") center / contain no-repeat;
}

/* Tooltip */
.nav-btn::after {
  content: attr(data-tip);
  position: absolute;
  left: calc(100% + 10px);
  top: 50%;
  transform: translateY(-50%);
  background: var(--bg-raised);
  color: var(--text);
  border: 1px solid var(--border-hi);
  border-radius: var(--radius-sm);
  padding: 4px 10px;
  font-size: 12px;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity var(--transition);
  z-index: 999;
}

#app.sidebar-right .nav-btn::after {
  left: auto;
  right: calc(100% + 10px);
}

.nav-btn:hover::after { opacity: 1; }

.sidebar-divider {
  width: 28px;
  height: 1px;
  background: var(--border);
  margin: 4px 0;
}

/* ── Main content ─────────────────────────────────────────────────────────── */
#main {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 32px 36px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* ── Page header ──────────────────────────────────────────────────────────── */
.page-header {
  display: flex;
  align-items: flex-start;
  gap: 14px;
}

.page-header-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
  flex-shrink: 0;
  margin-top: 2px;
}

.page-header-icon svg { width: 22px; height: 22px; stroke-width: 1.6; }

.page-header-text h1 {
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.3px;
  color: var(--text);
}

.page-header-text p {
  color: var(--text-muted);
  font-size: 13px;
  margin-top: 3px;
}

/* ── Section label ────────────────────────────────────────────────────────── */
.section-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: 10px;
}

/* ── Advertisement slots ───────────────────────────────────────────────────── */
.ad-slot {
  width: 100%; min-height: 0; margin: 16px 0; padding: 8px;
  background: var(--bg-surface); border: 1px solid var(--border);
  border-radius: var(--radius); color: var(--text-muted); text-align: center;
}
.ad-slot[hidden] { display: none; }
.ad-slot-label { display: block; margin-bottom: 6px; font-size: 11px; color: var(--text-dim); }
.ad-slot a { display: block; color: inherit; }
.ad-slot img { display: block; width: 100%; max-height: 180px; object-fit: contain; margin: 0 auto; }
.ad-slot video { display: block; width: 100%; max-height: 280px; object-fit: contain; margin: 0 auto; background: #000; }

/* ── Games toolbar ────────────────────────────────────────────────────────── */
.games-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.search-wrap {
  flex: 1;
  min-width: 160px;
  max-width: 360px;
  position: relative;
}

.search-wrap svg {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  stroke: var(--text-muted);
  pointer-events: none;
}

#game-search {
  width: 100%;
  padding: 8px 12px 8px 34px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 13px;
  outline: none;
  transition: border-color var(--transition);
}

#game-search:focus { border-color: var(--border-hi); }
#game-search::placeholder { color: var(--text-dim); }

/* Site selector */
.site-selector-wrap { position: relative; }

#site-selector-btn,
#launch-selector-btn {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 8px 13px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  cursor: pointer;
  font-size: 13px;
  white-space: nowrap;
  transition: border-color var(--transition), background var(--transition);
}

#site-selector-btn:hover,
#launch-selector-btn:hover { border-color: var(--border-hi); background: var(--bg-hover); }

#site-selector-btn svg,
#launch-selector-btn svg {
  width: 14px;
  height: 14px;
  stroke: var(--text-muted);
  transition: transform var(--transition);
}

#site-selector-btn.open svg,
#launch-selector-btn.open svg { transform: rotate(180deg); }

#launch-dropdown .site-option svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  stroke: var(--text-muted);
}

/* Launch menu sits further right than its button (36px = content padding,
   so its right edge lines up with the content edge without clipping) */
#launch-dropdown.site-dropdown {
  right: -36px;
}

/* Launch options text is always white (never tinted like site names) */
#launch-selector-btn,
#launch-selector-btn span,
#launch-dropdown .site-option,
#launch-dropdown .site-option span,
#launch-dropdown .site-option:hover,
#launch-dropdown .site-option.selected { color: #fff; }
#launch-dropdown .site-option svg { stroke: #fff; }

.site-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 190px;
  background: var(--bg-raised);
  border: 1px solid var(--border-hi);
  border-radius: var(--radius);
  padding: 6px;
  z-index: 200;
  display: none;
  flex-direction: column;
  gap: 2px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
}

.site-dropdown.open { display: flex; }

.site-option {
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 13px;
  transition: background var(--transition);
  border: none;
  background: transparent;
  text-align: left;
  width: 100%;
}

.site-option:hover { background: var(--bg-hover); }
.site-option.selected { background: var(--accent-dim); color: var(--text); }

/* ── Game grid ────────────────────────────────────────────────────────────── */
/* Fixed column count (--games-cols) so tiles SCALE with the viewport while
   keeping the same number of tiles per row. The JS row-break logic in games.js
   also forces a break every --games-cols cards (default 6). */
#games-grid {
  display: grid;
  --games-cols: 6;
  grid-template-columns: repeat(var(--games-cols), 1fr);
  gap: 16px;
}

/* ── Game card ────────────────────────────────────────────────────────────── */
.game-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: border-color var(--transition), transform var(--transition);
}

.game-card:hover {
  border-color: var(--border-hi);
  transform: translateY(-2px);
}

.game-card-img-wrap {
  width: 100%;
  aspect-ratio: 1 / 1;
  overflow: hidden;
  background: var(--bg-raised);
  flex-shrink: 0;
}

.game-card-img-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.game-card-body {
  padding: 12px 13px 14px;
}

.game-card-name {
  font-size: 16px;
  font-weight: 650;
  letter-spacing: 0.015em;
  line-height: 1.35;
  color: #f2f2f5;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Play button row — split: [Play label | arrow toggle] */
.game-card-play-row {
  display: flex;
  align-items: center;
  margin: 8px 12px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.play-launch-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 7px 10px;
  background: var(--bg-raised);
  border: none;
  border-right: 1px solid var(--border);
  color: var(--text);
  cursor: pointer;
  font-size: 12px;
  font-weight: 500;
  transition: background var(--transition);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.play-launch-btn:hover { background: var(--bg-hover); }
.play-launch-btn svg   { width: 13px; height: 13px; stroke: var(--accent); flex-shrink: 0; }

.play-arrow-btn {
  width: 34px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-raised);
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  transition: background var(--transition);
}
.play-arrow-btn:hover { background: var(--bg-hover); }

.play-arrow {
  width: 14px;
  height: 14px;
  stroke: currentColor;
  transition: transform var(--transition);
}
.play-arrow-btn.open .play-arrow { transform: rotate(180deg); }

/* Expandable play menu */
.play-menu {
  margin: 0 12px 10px;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  display: none;
}
.play-menu.open { display: flex; flex-direction: column; }

.play-menu-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 12px;
  cursor: pointer;
  font-size: 12px;
  color: var(--text-muted);
  transition: background var(--transition), color var(--transition);
  border: none;
  background: transparent;
  text-align: left;
  width: 100%;
}
.play-menu-item:hover      { background: var(--bg-hover); color: var(--text); }
.play-menu-item.active-mode { background: var(--accent-dim); color: var(--text); }
.play-menu-item:not(:last-child) { border-bottom: 1px solid var(--border); }
.play-menu-item svg { width: 14px; height: 14px; flex-shrink: 0; }

/* Grid row-break: forces a new row when a game name ends with = */
.grid-row-break { grid-column: 1 / -1; height: 0; }

/* ── In-tab game viewer (fullscreen iframe overlay) ─────────────────────── */
#game-viewer-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: var(--bg, #0e0f13);
  display: none;
  flex-direction: column;
}
#game-viewer-overlay.open { display: flex; }

#game-viewer-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

#game-viewer-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}

#game-viewer-pip {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  transition: background var(--transition), border-color var(--transition);
}
#game-viewer-pip:hover { background: var(--bg-hover); border-color: var(--border-hi); }
#game-viewer-pip svg { width: 14px; height: 14px; }

#game-viewer-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  cursor: pointer;
  font-size: 14px;
  transition: background var(--transition), border-color var(--transition);
}
#game-viewer-close:hover { background: var(--bg-hover); border-color: var(--border-hi); }

#game-viewer-frame {
  flex: 1;
  width: 100%;
  border: none;
  display: block;
  background: #000;
}

/* ── Empty / error state ──────────────────────────────────────────────────── */
.empty-state {
  grid-column: 1 / -1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  color: var(--text-dim);
  gap: 10px;
  text-align: center;
}

.empty-state svg { width: 40px; height: 40px; stroke: var(--text-dim); opacity: 0.5; }
.empty-state p { font-size: 13px; color: var(--text-muted); max-width: 280px; }

/* ── Settings page ────────────────────────────────────────────────────────── */
.settings-group {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  gap: 20px;
}

.settings-row:not(:last-child) { border-bottom: 1px solid var(--border); }

.settings-row-label h3 { font-size: 14px; font-weight: 500; color: var(--text); }
.settings-row-label p  { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

/* Toggle group (Left/Right buttons) */
.toggle-group {
  display: flex;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.toggle-btn {
  padding: 6px 16px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 13px;
  transition: background var(--transition), color var(--transition);
}

.toggle-btn:not(:last-child) { border-right: 1px solid var(--border); }
.toggle-btn.active { background: var(--accent-dim); color: var(--text); }
.toggle-btn:hover:not(.active) { background: var(--bg-hover); color: var(--text); }

/* Color-scheme selector (Settings) — wraps into pills, each with an accent swatch */
.toggle-group.scheme-group {
  flex-wrap: wrap;
  gap: 6px;
  border: none;
  background: none;
  overflow: visible;
  padding: 0;
}
.toggle-group.scheme-group .toggle-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.toggle-group.scheme-group .toggle-btn:not(:last-child) { border-right: 1px solid var(--border); }
.toggle-group.scheme-group .toggle-btn.active {
  background: var(--accent-dim);
  color: var(--text);
  border-color: var(--accent);
}
.scheme-swatch {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
  box-shadow: 0 0 0 1px rgba(0,0,0,0.25);
  flex-shrink: 0;
}

/* Cloak picker (Settings) — a native <select> restyled to match the theme */
.cloak-picker {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 10px;
  flex-shrink: 0;
}

.cloak-preview {
  width: 20px;
  height: 20px;
  border-radius: 4px;
  object-fit: contain;
  flex-shrink: 0;
}

.select-wrap { position: relative; display: inline-flex; align-items: center; }
.select-wrap::after {
  content: "";
  position: absolute;
  right: 13px;
  width: 0;
  height: 0;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-top: 5px solid var(--text-muted);
  pointer-events: none;
}

.cloak-select {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  min-width: 200px;
  padding: 7px 32px 7px 12px;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
  cursor: pointer;
  outline: none;
  transition: border-color var(--transition), background var(--transition);
}
.cloak-select:hover { background: var(--bg-hover); }
.cloak-select:focus { border-color: var(--border-hi); }
.cloak-select option { background: var(--bg-surface); color: var(--text); }

/* ── Login modal overlay ──────────────────────────────────────────────────── */
#login-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.75);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 500;
  backdrop-filter: blur(3px);
}

#login-overlay.open { display: flex; }

.login-modal {
  background: var(--bg-surface);
  border: 1px solid var(--border-hi);
  border-radius: 14px;
  padding: 32px 28px;
  width: 100%;
  max-width: 340px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  box-shadow: 0 24px 60px rgba(0,0,0,0.7);
}

.login-modal h2 {
  font-size: 17px;
  font-weight: 600;
  color: var(--text);
}

.login-modal p.login-sub {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: -10px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field label { font-size: 12px; color: var(--text-muted); font-weight: 500; }

.field input {
  padding: 9px 12px;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 13px;
  outline: none;
  transition: border-color var(--transition);
}

.field input:focus { border-color: var(--accent-dim); }

.btn-primary {
  padding: 10px;
  background: var(--accent);
  border: none;
  border-radius: var(--radius-sm);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity var(--transition);
}

.btn-primary:hover { opacity: 0.85; }
.btn-primary:disabled { opacity: 0.4; cursor: default; }

.btn-ghost {
  padding: 9px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 13px;
  cursor: pointer;
  transition: border-color var(--transition), color var(--transition);
}

.btn-ghost:hover { border-color: var(--border-hi); color: var(--text); }

.login-error {
  font-size: 12px;
  color: #e05555;
  display: none;
}

.login-error.show { display: block; }

/* Account panel (when logged in) */
.account-panel {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.account-badge {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.account-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--accent-dim);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
  color: var(--accent);
  flex-shrink: 0;
  text-transform: uppercase;
}

.account-info h3 { font-size: 14px; font-weight: 600; }
.account-info p  { font-size: 12px; color: var(--text-muted); }

/* PiP is handled entirely by the browser's Document Picture-in-Picture API */

/* ── Scrollbar ────────────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-hi); border-radius: 10px; }

/* ── Responsive ───────────────────────────────────────────────────────────── */
@media (max-width: 600px) {
  :root { --sidebar-w: 56px; }
  #main { padding: 20px 16px; }
  #games-grid { gap: 10px; }
  .games-toolbar { gap: 8px; }
  .search-wrap { max-width: 100%; }
  #pip-container { width: calc(100vw - 32px); bottom: 16px; right: 16px; }
}

@media (max-width: 400px) {
  #games-grid { gap: 8px; }
}

/* ── Home layout ──────────────────────────────────────────────────────────── */
.home-layout {
  display: flex;
  gap: 28px;
  align-items: flex-start;
  width: 100%;
}

.home-left {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.home-right {
  width: 300px;
  min-width: 260px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* ── Polls panel ──────────────────────────────────────────────────────────── */
.polls-panel {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.polls-empty {
  font-size: 12px;
  color: var(--text-dim);
  padding: 8px 0;
}

/* Create poll box */
.poll-create-box {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.poll-create-title {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-dim);
}

.poll-type-tabs {
  display: flex;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.poll-tab {
  flex: 1;
  padding: 6px 10px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 12px;
  transition: background var(--transition), color var(--transition);
}
.poll-tab:not(:last-child) { border-right: 1px solid var(--border); }
.poll-tab.active { background: var(--accent-dim); color: var(--text); }
.poll-tab:hover:not(.active) { background: var(--bg-hover); color: var(--text); }

.poll-input {
  width: 100%;
  padding: 8px 10px;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 13px;
  outline: none;
  transition: border-color var(--transition);
}
.poll-input:focus { border-color: var(--border-hi); }
.poll-input::placeholder { color: var(--text-dim); }

.poll-options-grid {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 6px 8px;
  align-items: center;
}

.poll-opt-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--accent);
  width: 16px;
}

.poll-form-err {
  font-size: 12px;
  color: #e05555;
  min-height: 16px;
}

.poll-form-hint {
  font-size: 11px;
  color: var(--text-dim);
  margin: 2px 0 2px;
}

.poll-submit-btn { margin-top: 2px; }

/* Poll card */
.poll-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.poll-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}

.poll-question {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  line-height: 1.4;
}

.poll-delete-btn {
  width: 22px;
  height: 22px;
  flex-shrink: 0;
  border: none;
  background: transparent;
  color: var(--text-dim);
  cursor: pointer;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--transition), color var(--transition);
}
.poll-delete-btn:hover { background: #3a1a1a; color: #e05555; }
.poll-delete-btn svg { width: 13px; height: 13px; }

/* Letter poll rows */
.poll-option-row {
  display: grid;
  grid-template-columns: 26px 1fr auto auto;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.poll-letter-btn {
  width: 26px;
  height: 26px;
  border-radius: 5px;
  border: 1px solid var(--border-hi);
  background: var(--bg-raised);
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: background var(--transition);
}
.poll-letter-btn:hover { background: var(--accent-dim); }

.poll-opt-text {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.poll-bar-wrap {
  height: 5px;
  background: var(--bg-raised);
  border-radius: 3px;
  overflow: hidden;
  min-width: 40px;
  flex: 1;
}
.poll-bar {
  height: 100%;
  background: var(--accent);
  border-radius: 3px;
  transition: width 0.4s ease;
  min-width: 2px;
}

.poll-stats {
  font-size: 11px;
  color: var(--text-dim);
  white-space: nowrap;
  min-width: 56px;
  text-align: right;
}

.poll-total {
  font-size: 11px;
  color: var(--text-dim);
  margin-top: 2px;
  text-align: right;
}

/* Custom answer poll */
.poll-custom-input-row {
  display: flex;
  gap: 6px;
}

.poll-custom-submit {
  padding: 8px 12px;
  flex-shrink: 0;
  font-size: 12px;
}

.poll-answers-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 140px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px 8px;
  background: var(--bg-raised);
}

.poll-answer-item {
  font-size: 12px;
  color: var(--text-muted);
  padding: 3px 0;
  border-bottom: 1px solid var(--border);
  word-break: break-word;
}
.poll-answer-item:last-child { border-bottom: none; }

/* ── Support inbox (admin) ────────────────────────────────────────────────── */
.support-inbox {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.support-inbox-title {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-dim);
}

.support-ticket {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.ticket-meta-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.ticket-meta {
  font-size: 11px;
  color: var(--text-dim);
}

.ticket-question {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  margin-top: 4px;
}

.ticket-answer {
  font-size: 12px;
  color: var(--text);
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px 8px;
  white-space: pre-wrap;
  word-break: break-word;
}

.ticket-replies {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 4px;
}

.ticket-reply {
  font-size: 12px;
  color: var(--accent);
  background: var(--accent-dim);
  border-radius: var(--radius-sm);
  padding: 6px 8px;
  word-break: break-word;
}

.ticket-reply-row {
  display: flex;
  gap: 6px;
  margin-top: 4px;
}

/* ── Support button (bottom-right, bright red) ────────────────────────────── */
#support-open-btn {
  position: fixed;
  bottom: 28px;
  right: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 22px;
  background: #e8162e;
  color: #fff;
  border: none;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  z-index: 300;
  box-shadow: 0 4px 20px rgba(232,22,46,0.45);
  letter-spacing: 0.02em;
  transition: background var(--transition), transform var(--transition), box-shadow var(--transition);
}
#support-open-btn:hover {
  background: #c2102a;
  transform: translateY(-2px);
  box-shadow: 0 6px 28px rgba(232,22,46,0.6);
}
/* When the sidebar is docked on the right, keep the button clear of it. */
body.sidebar-right #support-open-btn { right: calc(var(--sidebar-w) + 28px); }

/* ── Support popup ────────────────────────────────────────────────────────── */
#support-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.75);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 500;
  backdrop-filter: blur(3px);
}
#support-overlay.open { display: flex; }

#support-modal {
  background: var(--bg-surface);
  border: 1px solid var(--border-hi);
  border-radius: 14px;
  padding: 32px 28px;
  width: 100%;
  max-width: 520px;
  max-height: 88vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 18px;
  box-shadow: 0 24px 60px rgba(0,0,0,0.7);
}

.support-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
}

.support-sub {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: -10px;
}

.support-banned {
  margin: 8px 0;
}
.support-banned .support-sub {
  margin-top: 0;
  color: var(--danger, #e05555);
  font-weight: 600;
}
.support-ban-note {
  font-size: 12px;
  color: var(--text-dim);
  margin-top: 6px;
}

.support-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.support-field label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
}

.support-textarea {
  width: 100%;
  min-height: 90px;
  max-height: 90px;
  padding: 9px 12px;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 13px;
  font-family: inherit;
  line-height: 1.5;
  resize: none;
  overflow-y: auto;
  outline: none;
  transition: border-color var(--transition);
}
.support-textarea:focus { border-color: var(--border-hi); }
.support-textarea::placeholder { color: var(--text-dim); }

.support-btn-row {
  display: flex;
  gap: 8px;
  flex-direction: row-reverse;
}

/* ── Responsive home layout ───────────────────────────────────────────────── */
@media (max-width: 900px) {
  .home-layout { flex-direction: column; }
  .home-right  { width: 100%; min-width: unset; }
}

@media (max-width: 600px) {
  #support-open-btn { bottom: 16px; right: 16px; padding: 11px 20px; font-size: 14px; }
  body.sidebar-right #support-open-btn { right: calc(var(--sidebar-w) + 16px); }
  #support-modal    { padding: 24px 18px; }
  .poll-option-row  { grid-template-columns: 26px 1fr auto; }
  .poll-stats       { display: none; }
}

/* ── Statistics page ──────────────────────────────────────────────────────── */
.stats-top-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
}

.stat-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.stat-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -1px;
}

.stat-label {
  font-size: 12px;
  color: var(--text-muted);
}

.stats-section {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
}

.stats-charts-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}

.stats-chart-block {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
}

/* Line chart */
.line-chart-wrap { width: 100%; overflow-x: auto; }
.line-chart-svg  { width: 100%; max-width: 700px; display: block; }

.chart-grid { stroke: var(--border); stroke-width: 1; }
.chart-area { fill: var(--accent-dim); opacity: 0.4; }
.chart-line { stroke: var(--accent); stroke-width: 2; fill: none; }
.chart-dot  { fill: var(--accent); }
.chart-axis-label { fill: var(--text-dim); font-size: 9px; font-family: inherit; }

/* Horizontal bar chart */
.hbar-chart { display: flex; flex-direction: column; gap: 8px; }

.hbar-row {
  display: grid;
  grid-template-columns: 80px 1fr 70px;
  align-items: center;
  gap: 8px;
}

.hbar-label  { font-size: 12px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hbar-bar-wrap { height: 8px; background: var(--bg-raised); border-radius: 4px; overflow: hidden; }
.hbar-bar    { height: 100%; border-radius: 4px; transition: width 0.5s ease; min-width: 2px; }
.hbar-pct    { font-size: 11px; color: var(--text-dim); text-align: right; white-space: nowrap; }

/* Most played game */
.top-game-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 0;
}

.top-game-img {
  width: 64px;
  height: 64px;
  border-radius: 8px;
  object-fit: cover;
  background: var(--bg-raised);
  border: 1px solid var(--border);
}

.top-game-name  { font-size: 15px; font-weight: 600; color: var(--text); }
.top-game-count { font-size: 12px; color: var(--text-muted); margin-top: 3px; }

@media (max-width: 900px) {
  .stats-top-row    { grid-template-columns: repeat(2, 1fr); }
  .stats-charts-row { grid-template-columns: 1fr; }
}

@media (max-width: 500px) {
  .stats-top-row { grid-template-columns: 1fr 1fr; }
  .stat-value    { font-size: 22px; }
}

/* ── Editor page ──────────────────────────────────────────────────────────── */
#editor-ui {
  display: flex;
  gap: 12px;
  flex: 1;
  min-height: 0;
}

#editor-sidebar-panel {
  width: 220px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
  overflow-y: auto;
}

#editor-file-list { flex: 1; overflow-y: auto; }

/* ── File explorer tree (collapsible) ─────────────────────────────────────── */
.tree-folder { margin: 0; }

.tree-folder-header {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 6px;
  border-radius: 4px;
  cursor: pointer;
  user-select: none;
  color: var(--text);
  font-size: 12px;
  font-weight: 600;
  transition: background var(--transition);
}
.tree-folder-header:hover { background: var(--bg-hover); }

.tree-caret {
  display: inline-block;
  width: 12px;
  text-align: center;
  color: var(--text-dim);
  font-size: 10px;
  flex-shrink: 0;
}

.tree-label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.tree-children { padding-left: 14px; }
.tree-children.collapsed { display: none; }

.tree-file {
  display: block;
  width: 100%;
  text-align: left;
  padding: 4px 8px 4px 22px;
  background: transparent;
  border: none;
  border-radius: 4px;
  color: var(--text-muted);
  font-size: 12px;
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tree-file:hover { background: var(--bg-hover); color: var(--text); }
.tree-file.active { background: var(--accent-dim); color: var(--text); }

#editor-content-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}

#editor-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

#editor-textarea {
  flex: 1;
  width: 100%;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: 'Fira Code', 'Cascadia Code', 'Consolas', monospace;
  font-size: 13px;
  line-height: 1.6;
  padding: 12px 14px;
  resize: none;
  outline: none;
  transition: border-color var(--transition);
}

#editor-textarea:focus { border-color: var(--border-hi); }

/* ── User management in account panel ─────────────────────────────────────── */
.user-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 160px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 4px 6px;
  background: var(--bg-raised);
}

.user-row {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 4px 0;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
}
.user-row:last-child { border-bottom: none; }

.user-id   { color: var(--text-dim); min-width: 26px; }
.user-name { flex: 1; color: var(--text); font-weight: 500; }

.user-role {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 2px 6px;
  border-radius: 3px;
}
.role-owner  { background: #5e1a1a; color: #ff9a9a; }
.role-admin  { background: var(--accent-dim); color: var(--accent); }
.role-friend { background: #1a3a1a; color: #5fd35f; }

.user-create-form { display: flex; flex-direction: column; gap: 4px; }

.acct-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: center;
  width: 100%;
}

.acct-btn svg { width: 16px; height: 16px; flex-shrink: 0; }

/* Owner delete-account button (renders the "x" icon) */
.user-del-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 4px 7px;
}
.user-del-btn svg { width: 14px; height: 14px; flex-shrink: 0; }
.user-logout-btn { white-space: nowrap; }

/* ── Global overlays: site lock + owner broadcast ─────────────────────────────── */
.gp-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.78);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 600;
  backdrop-filter: blur(3px);
  padding: 20px;
}
.gp-overlay.open { display: flex; }

.gp-modal {
  background: var(--bg-surface);
  border: 1px solid var(--border-hi);
  border-radius: 14px;
  padding: 30px 28px;
  width: 100%;
  max-width: 420px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  box-shadow: 0 24px 60px rgba(0,0,0,0.7);
  text-align: center;
}
.gp-modal h2 { font-size: 18px; font-weight: 600; color: var(--text); margin: 0; }
.gp-lock-icon { font-size: 34px; line-height: 1; }
.gp-modal p  { font-size: 13px; color: var(--text-muted); line-height: 1.55; margin: 0; white-space: pre-wrap; word-break: break-word; }
.gp-ok-btn { align-self: center; margin-top: 6px; padding: 9px 28px; font-size: 14px; }

/* ── Admin panel subsections ──────────────────────────────────────────────────── */
.admin-subsection { margin-top: 4px; }

/* ── Textareas (broadcast / lock messages) ───────────────────────────────────── */
textarea.poll-input {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 13px;
  font-family: inherit;
  padding: 9px 12px;
  outline: none;
  transition: border-color var(--transition);
}
textarea.poll-input:focus { border-color: var(--border-hi); }

/* ── Account panel role colours ───────────────────────────────────────────── */
.role-badge-owner  { color: #ff9a9a; }
.role-badge-admin  { color: var(--accent); }
.role-badge-friend { color: #5fd35f; }

/* ── Voted state ──────────────────────────────────────────────────────────── */
.poll-letter-btn.voted { opacity: 0.45; cursor: default; }
.voted-note   { color: var(--accent); font-size: 11px; }
.voted-banner {
  font-size: 12px;
  color: var(--accent);
  padding: 6px 0;
  border-top: 1px solid var(--border);
}

/* ── Support ticket view ──────────────────────────────────────────────────── */
.ticket-reply-admin {
  background: var(--accent-dim);
  color: var(--accent);
}
.ticket-reply-user {
  background: var(--bg-hover);
  color: var(--text-muted);
}

.ban-badge {
  display: inline-block;
  margin-left: 8px;
  background: #3a1a1a;
  color: #e05555;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 3px;
  letter-spacing: 0.06em;
}
