/* TapNPlay portal. Dark ink background, coral accent, mint for multiplayer. */
:root {
  --bg: #0e0f1a;
  --bg2: #141628;
  --surface: #1b1e33;
  --surface2: #252943;
  --line: #2c3150;
  --text: #eef0ff;
  --muted: #9aa0c3;
  --accent: #ff5c8a;
  --accent2: #ff8a5c;
  --mint: #3ee6c4;
  --gold: #ffc94d;
  --radius: 14px;
  --top: 64px;
  --side: 232px;
  --side-mini: 76px;
  --gap: 14px;
  --font: 'Nunito', ui-rounded, system-ui, -apple-system, 'Segoe UI', sans-serif;
  color-scheme: dark;
}

/* light theme: chosen in the top bar (data-theme), otherwise follows the system */
:root[data-theme="light"] {
  --bg: #f6f7fc; --bg2: #ffffff; --surface: #ffffff; --surface2: #eceef8; --line: #dfe2f0;
  --text: #191b2e; --muted: #5d6385; --accent: #e8406f; --accent2: #f2703f; --mint: #0fa98b; --gold: #b7860b;
  color-scheme: light;
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #f6f7fc; --bg2: #ffffff; --surface: #ffffff; --surface2: #eceef8; --line: #dfe2f0;
    --text: #191b2e; --muted: #5d6385; --accent: #e8406f; --accent2: #f2703f; --mint: #0fa98b; --gold: #b7860b;
    color-scheme: light;
  }
}
.ic-light { display: none; }
:root[data-theme="light"] .ic-light { display: block; }
:root[data-theme="light"] .ic-dark { display: none; }
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) .ic-light { display: block; }
  :root:not([data-theme="dark"]) .ic-dark { display: none; }
}
.card { box-shadow: 0 1px 3px rgba(0,0,0,.12); }
.card-title { color: #fff; }
.stage-card h1 { color: #fff; }
.badge-mp { background: rgba(14, 15, 26, .8); }
.langs { position: relative; }
.langs summary { cursor: pointer; list-style: none; display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 999px; background: var(--surface); font-weight: 800; color: var(--text); }
.langs summary::-webkit-details-marker { display: none; }
.langs ul { position: absolute; bottom: 40px; right: 0; z-index: 5; list-style: none; margin: 0; padding: 6px; min-width: 190px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 18px 40px rgba(0,0,0,.35); }
.langs li a { display: block; padding: 6px 10px; border-radius: 8px; color: var(--text); }
.langs li a:hover, .langs li a[aria-current] { background: var(--surface2); }
.footer-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; }
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 600 15px/1.5 var(--font); }
a { color: inherit; text-decoration: none; }
img { display: block; max-width: 100%; }
button { font: inherit; color: inherit; }
h1, h2, h3 { font-weight: 900; line-height: 1.2; margin: 0; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--accent); color: #fff; padding: 8px 14px; border-radius: 10px; z-index: 100; }
.skip:focus { left: 8px; }
:focus-visible { outline: 3px solid var(--mint); outline-offset: 2px; }
.muted { color: var(--muted); }
.ic { width: 22px; height: 22px; flex: none; fill: currentColor; }
.ic-xs { width: 15px; height: 15px; }

/* ---------------------------------------------------------------- top bar */
.topbar {
  position: fixed; inset: 0 0 auto 0; height: var(--top); z-index: 30;
  display: flex; align-items: center; gap: 14px; padding: 0 16px;
  background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(12px); border-bottom: 1px solid var(--line);
}
.logo { display: inline-flex; color: var(--text); }
.logo svg { height: 32px; width: auto; }
.iconbtn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-width: 40px; height: 40px; padding: 0 10px; border: 0; border-radius: 12px;
  background: transparent; cursor: pointer; color: var(--text);
}
.iconbtn:hover { background: var(--surface2); }
.search { position: relative; flex: 1; max-width: 560px; margin: 0 auto; }
.search input {
  width: 100%; height: 42px; padding: 0 16px 0 44px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--surface); color: var(--text); font: inherit;
}
.search input:focus { outline: none; border-color: var(--accent); background: var(--bg2); }
.search-ic { position: absolute; left: 14px; top: 10px; color: var(--muted); }
.suggest {
  position: absolute; left: 0; right: 0; top: 48px; padding: 6px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--line); box-shadow: 0 18px 40px rgba(0,0,0,.5);
}
.suggest a { display: flex; align-items: center; gap: 12px; padding: 6px 8px; border-radius: 10px; }
.suggest a:hover, .suggest a.on { background: var(--surface2); }
.suggest img { width: 64px; height: 36px; object-fit: cover; border-radius: 6px; }
.me { display: flex; align-items: center; gap: 8px; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 42px; padding: 0 20px; border-radius: 999px; border: 0; cursor: pointer; font-weight: 900; white-space: nowrap;
  background: linear-gradient(135deg, var(--accent), var(--accent2)); color: #fff;
  box-shadow: 0 6px 18px rgba(255, 92, 138, .3);
}
.btn:hover { filter: brightness(1.08); }
.btn-ghost { background: var(--surface2); box-shadow: none; }
.btn-sm { height: 34px; padding: 0 14px; font-size: 14px; }
.avatar {
  --c1: #ff5c8a; --c2: #ffc94d;
  width: 36px; height: 36px; border-radius: 50%; display: inline-grid; place-items: center; flex: none;
  background: linear-gradient(135deg, var(--c1), var(--c2)); color: #14121f; font-weight: 900; font-size: 15px;
}
.me-chip { display: flex; align-items: center; gap: 10px; padding: 3px 12px 3px 3px; border-radius: 999px; background: var(--surface2); }
.me-chip span { max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------------------------------------------------------------- shell + sidebar */
.shell { padding-top: var(--top); }
.sidebar {
  position: fixed; top: var(--top); bottom: 0; left: 0; width: var(--side); z-index: 20;
  overflow-y: auto; padding: 10px 10px 24px; background: var(--bg); border-right: 1px solid var(--line);
  scrollbar-width: thin;
}
.sidebar ul { list-style: none; margin: 0; padding: 0; }
.sidebar a { display: flex; align-items: center; gap: 14px; padding: 9px 12px; border-radius: 12px; color: var(--muted); font-weight: 800; }
.sidebar a:hover { background: var(--surface); color: var(--text); }
.sidebar a[aria-current] { background: var(--surface2); color: var(--text); }
.sidebar a[aria-current] .ic { color: var(--accent); }
.sidebar hr { border: 0; border-top: 1px solid var(--line); margin: 10px 6px; }
.sidebar .small a { padding: 5px 12px; font-size: 13px; }
.main { margin-left: var(--side); padding: 22px 26px 0; min-width: 0; }
.scrim { position: fixed; inset: var(--top) 0 0 0; background: rgba(0,0,0,.55); z-index: 19; }

/* collapsed sidebar (desktop, toggled) */
body.mini .sidebar { width: var(--side-mini); }
body.mini .sidebar span, body.mini .sidebar hr, body.mini .sidebar .small { display: none; }
body.mini .sidebar a { justify-content: center; }
body.mini .main { margin-left: var(--side-mini); }

/* ---------------------------------------------------------------- cards */
.card {
  position: relative; display: block; border-radius: var(--radius); overflow: hidden; background: var(--surface);
  aspect-ratio: 16 / 9; transform: translateZ(0); transition: transform .18s ease, box-shadow .18s ease;
}
.card img { width: 100%; height: 100%; object-fit: cover; }
.card:hover { transform: translateY(-3px) scale(1.03); box-shadow: 0 14px 32px rgba(0,0,0,.55), 0 0 0 2px var(--accent); z-index: 2; }
.card-title {
  position: absolute; inset: auto 0 0 0; padding: 26px 12px 9px; font-weight: 900; font-size: 15px;
  background: linear-gradient(transparent, rgba(8, 8, 18, .92)); opacity: 0; transform: translateY(6px); transition: .18s;
}
.card:hover .card-title, .card:focus-visible .card-title { opacity: 1; transform: none; }
.badges { position: absolute; top: 8px; left: 8px; display: flex; gap: 6px; }
.badge { display: inline-flex; align-items: center; height: 22px; padding: 0 8px; border-radius: 8px; font-size: 12px; font-weight: 900; text-transform: uppercase; letter-spacing: .3px; }
.badge-new { background: var(--mint); color: #062a23; }
.badge-hot { background: var(--accent); color: #fff; }
.badge-mp { background: rgba(14, 15, 26, .8); color: var(--mint); padding: 0 6px; }

/* hero: one big tile and four small ones */
.hero { display: grid; grid-template-columns: 2fr 1fr 1fr; grid-template-rows: 1fr 1fr; gap: var(--gap); margin-bottom: 30px; }
.hero .card-big { grid-row: span 2; aspect-ratio: auto; min-height: 100%; }
.hero .card-big .card-title { opacity: 1; transform: none; font-size: 22px; padding: 40px 18px 14px; }

/* rows */
.row { margin-bottom: 30px; }
.row-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.row-head h2 { font-size: 20px; }
.row-head h2 a { display: inline-flex; align-items: center; gap: 6px; }
.row-head h2 a:hover { color: var(--accent); }
.row-nav { display: flex; gap: 4px; }
.row-nav .iconbtn { background: var(--surface); }
.row-nav .iconbtn:hover { background: var(--surface2); }
.row-track {
  display: grid; grid-auto-flow: column; grid-auto-columns: calc((100% - 5 * var(--gap)) / 6); gap: var(--gap);
  overflow-x: auto; scroll-snap-type: x mandatory; scroll-behavior: smooth; scrollbar-width: none;
  padding: 6px 4px 10px; margin: -6px -4px -10px;
}
.row-track::-webkit-scrollbar { display: none; }
.row-track > * { scroll-snap-align: start; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: var(--gap); margin-bottom: 30px; }

/* ---------------------------------------------------------------- text */
.crumbs { display: flex; flex-wrap: wrap; gap: 8px; color: var(--muted); font-size: 14px; margin-bottom: 14px; }
.crumbs a:hover { color: var(--text); }
.list-head { margin: 6px 0 20px; }
.list-head h1 { font-size: 30px; margin-bottom: 6px; }
.list-head p { color: var(--muted); margin: 0; max-width: 720px; }
.prose { max-width: 860px; color: color-mix(in srgb, var(--text) 86%, var(--muted)); }
.prose h1 { font-size: 26px; margin: 10px 0 12px; color: var(--text); }
.prose h2 { font-size: 20px; margin: 26px 0 10px; color: var(--text); }
.prose p, .prose li { line-height: 1.7; }
.prose a { color: var(--accent); }
.prose code { background: var(--surface2); padding: 1px 6px; border-radius: 6px; }
.intro, .faq { margin: 10px 0 34px; }
.faq details { background: var(--surface); border-radius: 12px; margin-bottom: 8px; padding: 0 16px; }
.faq summary { cursor: pointer; padding: 13px 0; font-weight: 800; color: var(--text); }
.faq details p { margin: 0 0 14px; }
.page-text { padding: 10px 0 40px; }
.empty { color: var(--muted); padding: 30px 0; }

/* ---------------------------------------------------------------- game page */
.game-layout { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 24px; align-items: start; }
.stage {
  position: relative; width: 100%; aspect-ratio: var(--aspect); max-height: calc(100vh - var(--top) - 130px);
  border-radius: var(--radius) var(--radius) 0 0; overflow: hidden; background: #000;
}
.stage-portrait { max-width: calc((100vh - var(--top) - 130px) * var(--aspect)); margin: 0 auto; }
.stage iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.stage-cover { position: absolute; inset: 0; display: grid; place-items: center; }
.stage-bg { position: absolute; inset: -20px; width: calc(100% + 40px); height: calc(100% + 40px); object-fit: cover; filter: blur(22px) brightness(.45); }
.stage-card { position: relative; display: flex; flex-direction: column; align-items: center; gap: 14px; text-align: center; padding: 20px; }
.stage-card img { width: min(320px, 56vw); aspect-ratio: 16/9; object-fit: cover; border-radius: var(--radius); box-shadow: 0 16px 40px rgba(0,0,0,.6); }
.stage-card h1 { font-size: 28px; text-shadow: 0 2px 12px rgba(0,0,0,.6); }
.btn-play { height: 54px; padding: 0 34px; font-size: 19px; }
.btn-play .ic { width: 20px; height: 20px; }
.gamebar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding: 10px 14px; background: var(--surface); border-radius: 0 0 var(--radius) var(--radius); margin-bottom: 22px;
}
.gamebar-title { display: flex; flex-direction: column; line-height: 1.25; }
.gamebar-title span { color: var(--muted); font-size: 13px; }
.gamebar-actions { display: flex; gap: 4px; }
.gamebar-actions .iconbtn span { font-size: 14px; color: var(--muted); }
.rate[aria-pressed="true"] { color: var(--mint); background: var(--surface2); }
.rate[data-v="-1"][aria-pressed="true"] { color: var(--accent); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0 6px; }
.chip { padding: 5px 12px; border-radius: 999px; background: var(--surface2); font-size: 13px; font-weight: 800; color: var(--text) !important; }
.chip:hover { background: var(--line); }
.chip-plain { background: transparent; border: 1px solid var(--line); color: var(--muted) !important; }
.controls { border-collapse: collapse; }
.credits { font-size: 13px; color: var(--muted); }
.controls th, .controls td { text-align: left; padding: 6px 18px 6px 0; border-bottom: 1px solid var(--line); }
.controls th { color: var(--text); white-space: nowrap; }
.facts { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; margin: 24px 0; }
.facts div { background: var(--surface); padding: 10px 14px; border-radius: 12px; }
.facts dt { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .4px; }
.facts dd { margin: 2px 0 0; color: var(--text); font-weight: 800; }
.side-col { position: sticky; top: calc(var(--top) + 16px); }
.side-h { font-size: 17px; margin: 0 0 10px; }
.side-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.board { background: var(--surface); border-radius: var(--radius); padding: 14px 16px; margin-bottom: 20px; }
.board h2 { font-size: 16px; display: flex; align-items: center; gap: 8px; margin-bottom: 8px; color: var(--gold); }
.board-list { list-style: none; margin: 0; padding: 0; counter-reset: r; }
.board-list li { display: flex; align-items: center; gap: 10px; padding: 5px 0; font-size: 14px; }
.board-list li .avatar { width: 26px; height: 26px; font-size: 12px; }
.board-list li .n { width: 20px; color: var(--muted); text-align: right; }
.board-list li .who { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.board-list li .sc { font-weight: 900; color: var(--gold); }
.board-list li.me .who { color: var(--mint); }

/* playing on a phone: the game takes the whole screen */
body.playing-full { overflow: hidden; }
.stage.full { position: fixed; inset: 0; z-index: 50; max-height: none; max-width: none; border-radius: 0; aspect-ratio: auto; }
.stage-close { position: absolute; top: max(8px, env(safe-area-inset-top)); right: 8px; z-index: 2; background: rgba(0,0,0,.55); border-radius: 50%; }

/* ---------------------------------------------------------------- profile + modal */
.profile { display: grid; gap: 18px; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); max-width: 980px; margin-bottom: 30px; }
.panel { background: var(--surface); border-radius: var(--radius); padding: 20px; }
.panel h2 { font-size: 18px; margin-bottom: 14px; }
.field { display: grid; gap: 6px; margin-bottom: 12px; }
.field span { color: var(--muted); font-size: 13px; }
.field input { height: 42px; padding: 0 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--bg2); color: var(--text); font: inherit; }
.field input:focus { outline: none; border-color: var(--accent); }
.err { color: var(--accent); min-height: 1.4em; margin: 0 0 8px; font-size: 14px; }
.avatars { display: grid; grid-template-columns: repeat(8, 1fr); gap: 8px; margin: 6px 0 14px; }
.avatars button { border: 2px solid transparent; border-radius: 50%; padding: 2px; background: none; cursor: pointer; }
.avatars button[aria-pressed="true"] { border-color: var(--mint); }
.avatars .avatar { width: 100%; height: auto; aspect-ratio: 1; }
.tabs { display: flex; gap: 6px; margin-bottom: 16px; }
.tabs button { flex: 1; height: 38px; border-radius: 10px; border: 0; background: var(--bg2); cursor: pointer; font-weight: 800; color: var(--muted); }
.tabs button[aria-selected="true"] { background: var(--surface2); color: var(--text); }
.modal { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; background: rgba(5, 5, 12, .7); padding: 16px; }
.modal[hidden] { display: none; }
.modal .panel { width: min(420px, 100%); position: relative; }
.modal .close { position: absolute; top: 8px; right: 8px; }
.menu-pop { position: absolute; top: 56px; right: 12px; min-width: 200px; padding: 6px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 18px 40px rgba(0,0,0,.5); }
.menu-pop a, .menu-pop button { display: block; width: 100%; text-align: left; padding: 9px 12px; border: 0; border-radius: 10px; background: none; cursor: pointer; }
.menu-pop a:hover, .menu-pop button:hover { background: var(--surface2); }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--surface2); padding: 10px 18px; border-radius: 999px; z-index: 70; box-shadow: 0 10px 30px rgba(0,0,0,.5); }

/* ---------------------------------------------------------------- footer */
.footer { margin: 40px -26px 0; padding: 26px; border-top: 1px solid var(--line); color: var(--muted); font-size: 14px; }
.footer nav { display: flex; flex-wrap: wrap; gap: 6px 18px; margin-bottom: 12px; }
.footer a:hover { color: var(--text); }
.footer p { margin: 0; }

/* ---------------------------------------------------------------- responsive */
@media (max-width: 1500px) { .row-track { grid-auto-columns: calc((100% - 4 * var(--gap)) / 5); } }
@media (max-width: 1240px) {
  .row-track { grid-auto-columns: calc((100% - 3 * var(--gap)) / 4); }
  .game-layout { grid-template-columns: 1fr; }
  .side-col { position: static; }
  .side-grid { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }
}
@media (max-width: 1000px) {
  .main { margin-left: 0 !important; padding: 18px 16px 0; }
  .footer { margin: 40px -16px 0; padding: 22px 16px; }
  .sidebar { transform: translateX(-100%); transition: transform .2s ease; width: var(--side) !important; }
  .sidebar span, .sidebar hr, .sidebar .small { display: revert !important; }
  .sidebar a { justify-content: flex-start !important; }
  body.nav-open .sidebar { transform: none; }
  .row-track { grid-auto-columns: calc((100% - 2 * var(--gap)) / 3); }
  .hero { grid-template-columns: 1fr 1fr; grid-template-rows: auto; }
  .hero .card-big { grid-column: span 2; grid-row: auto; aspect-ratio: 16 / 9; }
}
@media (max-width: 640px) {
  :root { --gap: 10px; }
  .topbar { gap: 6px; padding: 0 8px; }
  .logo svg { height: 26px; }
  .search input { height: 38px; padding-left: 38px; }
  .search-ic { left: 11px; top: 8px; }
  .me-chip span { display: none; }
  .me-chip { padding: 3px; }
  .btn.me-login { padding: 0 14px; height: 36px; }
  .row-track { grid-auto-columns: 44%; }
  .row-head h2 { font-size: 18px; }
  .row-nav { display: none; }
  .grid { grid-template-columns: 1fr 1fr; }
  .card-title { opacity: 1; transform: none; font-size: 13px; padding: 20px 8px 6px; }
  .list-head h1 { font-size: 24px; }
  .stage { aspect-ratio: 16 / 11; max-height: none; }
  .stage-portrait { aspect-ratio: 3 / 4; max-width: none; }
  .stage-card h1 { font-size: 22px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; scroll-behavior: auto !important; } }
