/* =============================================================================================
   FINISH — one look for every popup, side sheet, tab bar, list, field and button in the game:
   deep violet glass with gold trim (the family of the home screen and the daily reward), a single
   segmented-tab style, clear headings, and matching inputs and switches.
   Only colors, borders, type and motion are set here; each panel keeps its own layout.
   ============================================================================================= */
:root {
  --fin-bg-1: #3a1e7c;
  --fin-bg-2: #24104f;
  --fin-bg-3: #160a35;
  --fin-trim: rgba(255, 214, 120, 0.55);
  --fin-trim-soft: rgba(255, 214, 120, 0.22);
  --fin-line: rgba(255, 255, 255, 0.09);
  --fin-card: rgba(255, 255, 255, 0.055);
  --fin-card-hover: rgba(255, 255, 255, 0.1);
  --fin-ink: #f6f2ff;
  --fin-ink-2: #d6ccf5;
  --fin-ink-3: #a99fd0;
  --fin-gold-1: #ffe27a;
  --fin-gold-2: #f2a900;
  --fin-gold-ink: #3a2400;
  --fin-panel: radial-gradient(ellipse 90% 45% at 50% 0%, rgba(255, 214, 90, 0.14), rgba(255, 214, 90, 0) 70%), linear-gradient(170deg, var(--fin-bg-1), var(--fin-bg-2) 55%, var(--fin-bg-3));
}

/* ---------------------------------------------------------------- popups ------------------- */
.modal > .modal-box {
  color: var(--fin-ink);
  background: var(--fin-panel);
  border: 1.5px solid var(--fin-trim);
  border-radius: 22px;
  box-shadow: 0 0 0 4px rgba(90, 50, 170, 0.32), 0 28px 70px rgba(0, 0, 0, 0.65), inset 0 1px 0 rgba(255, 255, 255, 0.18);
  scrollbar-width: thin; scrollbar-color: rgba(214, 204, 245, 0.35) transparent;
}
.modal > .modal-box h2 {
  font-family: 'Arial Black', Roboto, sans-serif; font-weight: 900; letter-spacing: 0.01em; color: #fff;
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.35);
}
.modal > .modal-box .muted, .drawer .muted { color: var(--fin-ink-3); }
.modal { background: rgba(10, 4, 28, 0.62); }

/* ---------------------------------------------------------------- side sheets --------------- */
aside.drawer {
  color: var(--fin-ink);
  background: radial-gradient(ellipse 120% 35% at 100% 0%, rgba(255, 214, 90, 0.12), rgba(255, 214, 90, 0) 60%), linear-gradient(175deg, var(--fin-bg-1) 0%, var(--fin-bg-2) 45%, var(--fin-bg-3) 100%);
  border-left: 1.5px solid var(--fin-trim);
  box-shadow: -18px 0 50px rgba(0, 0, 0, 0.6), inset 1px 0 0 rgba(255, 255, 255, 0.08);
  scrollbar-width: thin; scrollbar-color: rgba(214, 204, 245, 0.35) transparent;
}
@media (orientation: portrait) and (max-width: 700px) {
  aside.drawer { border-left: 0; border-top: 1.5px solid var(--fin-trim); }
}
.sheet-head, aside.drawer > .row.between:first-child { padding-bottom: 10px; margin-bottom: 6px; border-bottom: 1px solid var(--fin-line); }
.sheet-head h2, aside.drawer > .row h2 { font-family: 'Arial Black', Roboto, sans-serif; font-size: 1.12rem; font-weight: 900; color: #fff; letter-spacing: 0.01em; text-shadow: 0 2px 0 rgba(0, 0, 0, 0.35); }
.sheet-section { border-top: 1px solid var(--fin-line); }
.sheet-section h3, aside.drawer h3 { color: var(--fin-gold-1); font-size: 0.7rem; font-weight: 900; letter-spacing: 0.14em; text-transform: uppercase; }

/* Round close / refresh buttons on sheets and popups. */
.sheet-head .icon-btn, .modal .icon-btn, aside.drawer .icon-btn {
  display: grid; place-items: center; border-radius: 50%; color: #fff; cursor: pointer;
  background: rgba(255, 255, 255, 0.08); border: 1px solid rgba(255, 255, 255, 0.18);
  transition: rotate 0.35s var(--spring, ease-out), background 0.2s, border-color 0.2s;
}
.sheet-head .icon-btn:hover, .modal .icon-btn:hover, aside.drawer .icon-btn:hover { rotate: 90deg; background: rgba(255, 255, 255, 0.16); border-color: var(--fin-trim); }

/* ---------------------------------------------------------------- tabs (one style everywhere) */
.stat-tabs, .store-tabs, .auth-tabs, .sp-tabs {
  padding: 4px; gap: 4px; border-radius: 14px; background: rgba(8, 4, 24, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.07); box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.5);
}
.stat-tab, .store-tab, .auth-tab, .sp-tab {
  border: 0; border-radius: 10px; background: transparent; color: var(--fin-ink-3); font-weight: 800; cursor: pointer;
  box-shadow: none; transition: background 0.25s, color 0.25s, box-shadow 0.25s, scale 0.2s var(--spring, ease-out);
}
.stat-tab:hover:not(.on), .store-tab:hover:not(.on), .auth-tab:hover:not(.on), .sp-tab:hover:not(.on) { color: var(--fin-ink); background: rgba(255, 255, 255, 0.06); }
.stat-tab.on, .store-tab.on, .auth-tab.on, .sp-tab.on {
  background: linear-gradient(180deg, var(--fin-gold-1), var(--fin-gold-2)); color: var(--fin-gold-ink);
  box-shadow: 0 2px 0 #a35a00, 0 5px 12px rgba(242, 169, 0, 0.28);
}
/* Leaderboard tabs: the icon above its label, so five tabs fit side by side. */
.stat-tab { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; padding: 7px 2px; line-height: 1.1; font-size: 0.7rem; }
.stat-tab i { font-style: normal; font-size: 1.05rem; line-height: 1; }
.sp-tab b { color: inherit; }

/* ---------------------------------------------------------------- lists --------------------- */
.stats-list li, .friend-list li, .room-list li, .sp-list li, .swap-list li, .request-list li, #requestList li, .results li, .help-row {
  background: var(--fin-card); border: 1px solid var(--fin-line); border-radius: 14px;
  transition: background 0.2s, border-color 0.2s, translate 0.2s var(--ease-out, ease-out);
}
.stats-list li:not(.empty):hover, .friend-list li:not(.empty):hover, .room-list li:not(.empty):hover { background: var(--fin-card-hover); border-color: var(--fin-trim-soft); }
.stats-list li.empty, .friend-list li.empty, .room-list li.empty, .sp-list .sp-empty { background: none; border: 0; color: var(--fin-ink-3); }
.stats-list li.top { background: linear-gradient(90deg, rgba(255, 200, 61, 0.2), var(--fin-card)); border-color: var(--fin-trim-soft); }
.stats-list li.won { background: linear-gradient(90deg, rgba(74, 222, 128, 0.16), var(--fin-card)); }
.stats-list li.me { outline: 0; border-color: var(--fin-trim); box-shadow: 0 0 0 1px var(--fin-trim) inset; }
.stats-list .pts { color: var(--fin-gold-1); }
.results li.me { border-color: var(--fin-trim); background: linear-gradient(90deg, rgba(255, 200, 61, 0.16), var(--fin-card)); }

/* Number tiles (leaderboard summary, store wallet). */
.stat, .stats-summary .stat { background: var(--fin-card); border: 1px solid var(--fin-line); border-radius: 14px; }
.stat b { color: #fff; font-size: 1.15rem; }
.stat span { color: var(--fin-ink-3); font-size: 0.66rem; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; }

/* ---------------------------------------------------------------- fields & switches -------- */
.modal input:not([type=checkbox]):not([type=range]):not([type=file]), aside.drawer input:not([type=checkbox]):not([type=range]):not([type=file]), .modal textarea {
  color: #fff; background: rgba(8, 4, 24, 0.55); border: 1px solid rgba(214, 204, 245, 0.22); border-radius: 12px;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.modal input::placeholder, aside.drawer input::placeholder { color: rgba(214, 204, 245, 0.5); }
.modal input:focus, aside.drawer input:focus, .modal textarea:focus { outline: none; border-color: var(--fin-gold-1); box-shadow: 0 0 0 3px rgba(255, 214, 90, 0.2); }
.switch-row input { background: rgba(8, 4, 24, 0.6); box-shadow: inset 0 0 0 1px rgba(214, 204, 245, 0.25); transition: background 0.25s; }
.switch-row input:checked { background: linear-gradient(180deg, var(--fin-gold-1), var(--fin-gold-2)); box-shadow: none; }
.switch-row input::after { box-shadow: 0 2px 4px rgba(0, 0, 0, 0.4); transition: transform 0.25s var(--spring, ease-out); }
.switch-row span { color: var(--fin-ink); }
input[type=range] { accent-color: var(--fin-gold-2); }

/* ---------------------------------------------------------------- buttons inside panels ---- */
.modal .btn:not(.primary):not(.ghost):not(.danger):not(.google-btn):not(.wa-btn),
aside.drawer .btn:not(.primary):not(.ghost):not(.danger):not(.google-btn) {
  color: #fff; background: rgba(255, 255, 255, 0.08); border: 1px solid rgba(255, 255, 255, 0.16);
}
.modal .btn:not(.primary):not(.ghost):not(.danger):not(.google-btn):not(.wa-btn):hover,
aside.drawer .btn:not(.primary):not(.ghost):not(.danger):not(.google-btn):hover { background: rgba(255, 255, 255, 0.14); border-color: var(--fin-trim-soft); }
.modal .btn.primary, aside.drawer .btn.primary {
  background: linear-gradient(180deg, #ffe58a, var(--fin-gold-2)); color: var(--fin-gold-ink); border: 0;
  box-shadow: 0 3px 0 #a35a00, 0 8px 18px rgba(242, 169, 0, 0.25); text-shadow: 0 1px 0 rgba(255, 255, 255, 0.35);
}
.modal .btn.danger, aside.drawer .btn.danger { background: linear-gradient(180deg, #ff6b5e, #c4271f); color: #fff; border: 0; box-shadow: 0 3px 0 #7c1512; }
.modal .btn.ghost, aside.drawer .btn.ghost { color: var(--fin-ink-2); }
.modal .btn.ghost:hover, aside.drawer .btn.ghost:hover { color: #fff; background: rgba(255, 255, 255, 0.06); }

/* ---------------------------------------------------------------- the in-game menu --------- */
#menu .modal-box { gap: 10px; width: min(360px, 100%); }
#menu .modal-box > .btn { width: 100%; padding: 12px 14px; border-radius: 14px; font-weight: 800; }
#menu .volume-row { padding: 10px 12px; border-radius: 14px; background: var(--fin-card); border: 1px solid var(--fin-line); }

/* ---------------------------------------------------------------- create room / options ---- */
.room-box .rm-head h2 { background: linear-gradient(180deg, var(--fin-gold-1), var(--fin-gold-2)); color: var(--fin-gold-ink); box-shadow: 0 3px 0 #a35a00; text-shadow: 0 1px 0 rgba(255, 255, 255, 0.35); }
.room-box .chip { color: var(--fin-ink); background: rgba(8, 4, 24, 0.5); border-color: rgba(255, 255, 255, 0.16); }
.room-box .chip.on { background: linear-gradient(180deg, var(--fin-gold-1), #f4af2e); color: var(--fin-gold-ink); border-color: #fff0b3; }
.room-box .tile { background: linear-gradient(160deg, rgba(255, 255, 255, 0.14), rgba(255, 255, 255, 0.05)); border-color: rgba(255, 255, 255, 0.22); box-shadow: 0 3px 0 rgba(0, 0, 0, 0.35); color: var(--fin-ink); }
.room-box .tile .tile-name { color: var(--fin-ink); }
.room-box .tile.on { background: linear-gradient(160deg, #fff3be, #f9c95a); box-shadow: 0 3px 0 #b47c11, 0 0 14px rgba(255, 214, 90, 0.4); }
.room-box .tile.on .tile-name { color: var(--fin-gold-ink); }
.room-box > .btn.big { background: linear-gradient(180deg, #ffe58a, var(--fin-gold-2)); color: var(--fin-gold-ink); box-shadow: 0 4px 0 #a35a00, 0 10px 22px rgba(242, 169, 0, 0.28); text-shadow: 0 1px 0 rgba(255, 255, 255, 0.35); }

/* ---------------------------------------------------------------- quick match -------------- */
.match-box .match-count { background: rgba(8, 4, 24, 0.45); border-color: rgba(255, 255, 255, 0.14); color: var(--fin-ink); }
.match-box .match-count.on { background: linear-gradient(180deg, var(--fin-gold-1), var(--fin-gold-2)); color: var(--fin-gold-ink); border-color: #fff0b3; }

/* ---------------------------------------------------------------- lobby side panel & menus -- */
.side-panel { background: linear-gradient(175deg, rgba(58, 30, 124, 0.85), rgba(22, 10, 53, 0.9)); border: 1px solid var(--fin-trim-soft); }
.seat-menu { background: var(--fin-panel); border: 1.5px solid var(--fin-trim); color: var(--fin-ink); box-shadow: 0 16px 40px rgba(0, 0, 0, 0.55); }
.seat-menu .sm-item { color: var(--fin-ink); }
.seat-menu .sm-item:hover { background: rgba(255, 255, 255, 0.1); }
.seat-menu .sm-item.danger { color: #ffb3ad; }

/* ---------------------------------------------------------------- toasts & connection bar -- */
.toast { background: linear-gradient(180deg, rgba(48, 26, 104, 0.96), rgba(28, 13, 64, 0.96)); border: 1px solid var(--fin-trim-soft); color: var(--fin-ink); border-radius: 14px; box-shadow: 0 12px 30px rgba(0, 0, 0, 0.5); }

/* ---------------------------------------------------------------- chat -------------------- */
.chat-list li { border-radius: 12px; }
.chat-list li.mine { background: rgba(255, 214, 90, 0.12); }
.chat-list li.system { color: var(--fin-ink-3); }

/* ---------------------------------------------------------------- pages over the screen ---- */
/* Settings, Friends & Chat, Live tables, Leaderboard and Store open as a page over the screen (zooming
   in from the middle, over a dimmed backdrop) instead of a panel sliding in from the side. At a table,
   Friends & Chat sits at the side instead so it never covers the game (social.css). */
aside.drawer.tall {
  z-index: 35; top: 50%; left: 50%; right: auto; bottom: auto; margin: 0; max-width: none;
  width: min(980px, calc(100vw - 28px)); height: min(calc(100vh - 24px), 720px); height: min(calc(100dvh - 24px), 720px);
  translate: -50% -50%; padding: 16px 20px; border: 1.5px solid var(--fin-trim); border-radius: 24px;
  background: var(--fin-panel);
  box-shadow: 0 0 0 4px rgba(90, 50, 170, 0.32), 0 30px 80px rgba(0, 0, 0, 0.7), inset 0 1px 0 rgba(255, 255, 255, 0.16);
  animation: pageIn 0.42s var(--spring-soft, ease-out) both;
  transition: opacity 0.22s var(--ease-out, ease-out), scale 0.22s var(--ease-in, ease-in), display 0.22s allow-discrete;
}
aside.drawer.tall.hidden { translate: -50% -50%; scale: 0.94; opacity: 0; }
@keyframes pageIn { from { opacity: 0; scale: 0.9; } }
@media (orientation: portrait) and (max-width: 700px) {
  aside.drawer.tall { width: calc(100vw - 20px); height: calc(100vh - 20px); height: calc(100dvh - 20px); border-radius: 22px; border: 1.5px solid var(--fin-trim); }
}
.page-shade {
  position: fixed; inset: 0; z-index: 34; background: rgba(10, 4, 28, 0.6); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
  transition: opacity 0.22s var(--ease-out, ease-out), display 0.22s allow-discrete;
}
.page-shade.hidden { opacity: 0; }
@starting-style { .page-shade:not(.hidden) { opacity: 0; } }
/* The content of a page uses its width: two columns where there's room. */
@media (min-width: 760px) {
  #settingsSheet .sheet-scroll { grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 16px; row-gap: 10px; }
  #settingsSheet .profile-row, #settingsSheet #changePhotoLink, #settingsSheet #serverSection { grid-column: 1 / -1; }
  #settingsSheet .sheet-section { margin-top: 0; padding: 12px 14px; border: 1px solid var(--fin-line); border-radius: 16px; background: var(--fin-card); }
  #liveSheet .room-list, #statsSheet .stats-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .store-sheet .store-offers { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
  .stats-summary { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
