/* Arcade theme for Tumder — light / dark, no frameworks */
:root {
  --bg: #F4F3EE; --surf: #FFFFFF; --surf2: #ECEAE3; --ink: #15151C; --mute: #5C5C68; --line: #E2E0D8;
  --acc: #2F55F0; --acc-ink: #FFFFFF; --acc-soft: #E4EAFF; --acc-text: #2447D6;
  --ok: #0E6E4F; --ok-soft: #DDF3EA; --bad: #B42318; --bad-soft: #FDE7E4; --warn: #9A5B00; --warn-soft: #FFF1D6;
  --off: #C9C7BF; --star: #E8A200; --shadow: 0 1px 2px rgba(20,20,30,.06), 0 4px 16px rgba(20,20,30,.06);
  --r-sm: 10px; --r: 14px; --r-lg: 20px; --r-xl: 24px;
  --f-display: 'Unbounded', 'Onest', system-ui, sans-serif;
  --f-body: 'Onest', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --header-h: 72px; --gutter: 24px;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #0E0F14; --surf: #171922; --surf2: #20232F; --ink: #F1F0EB; --mute: #9B9DAC; --line: #2A2D3B;
  --acc: #7C95FF; --acc-ink: #0B0D14; --acc-soft: #1E2644; --acc-text: #9DB0FF;
  --ok: #4ADE9B; --ok-soft: #133222; --bad: #FF8A7A; --bad-soft: #3A1B18; --warn: #FFB45C; --warn-soft: #3A2A12;
  --off: #3A3E4F; --star: #FFC83D; --shadow: 0 1px 2px rgba(0,0,0,.3), 0 6px 20px rgba(0,0,0,.25);
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0E0F14; --surf: #171922; --surf2: #20232F; --ink: #F1F0EB; --mute: #9B9DAC; --line: #2A2D3B;
    --acc: #7C95FF; --acc-ink: #0B0D14; --acc-soft: #1E2644; --acc-text: #9DB0FF;
    --ok: #4ADE9B; --ok-soft: #133222; --bad: #FF8A7A; --bad-soft: #3A1B18; --warn: #FFB45C; --warn-soft: #3A2A12;
    --off: #3A3E4F; --star: #FFC83D; color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 400 15px/1.5 var(--f-body); min-height: 100vh; display: flex; flex-direction: column; }
img { max-width: 100%; display: block; }
a { color: inherit; text-decoration: none; }
a:hover { color: var(--acc-text); }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3 { margin: 0; line-height: 1.15; }
:focus-visible { outline: 2px solid var(--acc); outline-offset: 2px; border-radius: 6px; }
.sr-only { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.hidden, [hidden] { display: none !important; }
.muted { color: var(--mute); }
.i { width: 20px; height: 20px; flex-shrink: 0; }
.i-sm { width: 16px; height: 16px; }
.i-lg { width: 24px; height: 24px; }
.container { width: 100%; max-width: 1400px; margin: 0 auto; padding: 0 var(--gutter); }
.page { flex: 1 0 auto; padding-bottom: 56px; }
.display { font-family: var(--f-display); font-weight: 600; letter-spacing: -0.02em; }

/* ---------- buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 44px; padding: 0 18px; border-radius: 12px; border: 1px solid transparent; background: var(--surf2); color: var(--ink); font-weight: 600; font-size: 15px; white-space: nowrap; transition: filter .15s, background .15s; text-decoration: none; }
.btn:hover { filter: brightness(.97); color: inherit; }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--acc); color: var(--acc-ink); }
.btn-primary:hover { color: var(--acc-ink); filter: brightness(1.06); }
.btn-outline { background: transparent; border-color: var(--line); }
.btn-ghost { background: transparent; }
.btn-danger { background: transparent; border-color: var(--line); color: var(--bad); }
.btn-danger:hover { color: var(--bad); background: var(--bad-soft); }
.btn-sm { height: 36px; padding: 0 12px; font-size: 14px; border-radius: 10px; }
.btn-lg { height: 52px; padding: 0 26px; font-size: 16px; border-radius: 14px; }
.btn-icon { width: 44px; padding: 0; }
.btn-icon.btn-sm { width: 36px; }
.btn-block { width: 100%; }
.btn.is-active { background: var(--acc-soft); color: var(--acc-text); }
.btn .spinner { width: 16px; height: 16px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.chip { display: inline-flex; align-items: center; gap: 6px; height: 38px; padding: 0 15px; border-radius: 999px; border: 1px solid var(--line); background: var(--surf); font-size: 14px; font-weight: 500; white-space: nowrap; }
.chip:hover { border-color: var(--ink); color: var(--ink); }
.chip.is-active { background: var(--ink); border-color: var(--ink); color: var(--bg); }
.chip .count { opacity: .7; font-weight: 500; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chips-scroll { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin: 0 calc(var(--gutter) * -1); padding: 0 var(--gutter); }
.chips-scroll::-webkit-scrollbar { display: none; }

.badge { display: inline-flex; align-items: center; gap: 4px; padding: 4px 10px; border-radius: 999px; font-size: 13px; font-weight: 600; background: var(--surf2); color: var(--mute); white-space: nowrap; }
.badge-ok { background: var(--ok-soft); color: var(--ok); }
.badge-bad { background: var(--bad-soft); color: var(--bad); }
.badge-warn { background: var(--warn-soft); color: var(--warn); }
.badge-acc { background: var(--acc-soft); color: var(--acc-text); }

.panel { background: var(--surf); border: 1px solid var(--line); border-radius: var(--r-lg); }
.panel-pad { padding: 24px; }
.panel h2 { font-size: 17px; font-weight: 700; margin-bottom: 12px; font-family: var(--f-body); letter-spacing: 0; }

/* ---------- header ---------- */
.site-header { position: sticky; top: 0; z-index: 50; background: var(--surf); border-bottom: 1px solid var(--line); }
.header-row { height: var(--header-h); display: flex; align-items: center; gap: 28px; }
.logo { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.logo:hover { color: inherit; }
.logo-mark { width: 36px; height: 36px; border-radius: 11px; background: var(--acc); color: var(--acc-ink); display: grid; place-items: center; }
.logo-text { font-family: var(--f-display); font-weight: 700; font-size: 20px; letter-spacing: -0.02em; }
.main-nav { display: flex; gap: 4px; font-weight: 500; }
.main-nav a { padding: 10px 14px; border-radius: 10px; color: var(--mute); }
.main-nav a:hover { color: var(--ink); background: var(--surf2); }
.main-nav a.is-active { color: var(--ink); background: var(--surf2); }
.search { flex: 1; max-width: 520px; height: 44px; display: flex; align-items: center; gap: 10px; padding: 0 16px; border-radius: 12px; background: var(--surf2); color: var(--mute); border: 1px solid transparent; }
.search:focus-within { border-color: var(--acc); background: var(--surf); }
.search input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; font-size: 15px; color: var(--ink); }
.search input::placeholder { color: var(--mute); }
.header-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.auth-links { display: flex; gap: 8px; }
.theme-toggle .i-moon { display: none; }
:root[data-theme="dark"] .theme-toggle .i-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .i-moon { display: block; }
.theme-toggle .i-sun { display: block; }

.user-menu { position: relative; }
.user-menu > summary { list-style: none; display: flex; align-items: center; gap: 10px; padding: 4px 14px 4px 4px; border-radius: 999px; background: var(--surf2); cursor: pointer; }
.user-menu > summary::-webkit-details-marker { display: none; }
.avatar { border-radius: 50%; object-fit: cover; background: var(--surf2); flex-shrink: 0; }
.user-menu .who { display: flex; flex-direction: column; line-height: 1.2; }
.user-menu .who b { font-size: 14px; font-weight: 600; }
.user-menu .who span { font-size: 12px; color: var(--mute); }
.dropdown { position: absolute; right: 0; top: calc(100% + 8px); min-width: 240px; background: var(--surf); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow); padding: 8px; display: flex; flex-direction: column; z-index: 60; }
.dropdown a { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px; font-weight: 500; }
.dropdown a:hover { background: var(--surf2); color: var(--ink); }
.dropdown hr { border: 0; border-top: 1px solid var(--line); margin: 6px 4px; width: auto; }
.dropdown .langs { display: flex; gap: 4px; padding: 6px 8px 2px; flex-wrap: wrap; }
.dropdown .langs a { padding: 6px 10px; font-size: 13px; color: var(--mute); }

.mobile-tabs { display: none; }

/* ---------- sections ---------- */
.section { margin-top: 44px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.section-head h2 { font-family: var(--f-display); font-weight: 600; font-size: 24px; letter-spacing: -0.02em; }
.section-head a { font-weight: 500; color: var(--acc-text); }
.page-title { font-family: var(--f-display); font-weight: 600; font-size: 32px; letter-spacing: -0.02em; }
.page-head { padding-top: 32px; display: flex; flex-direction: column; gap: 8px; }
.crumbs { display: flex; flex-wrap: wrap; gap: 8px; font-size: 14px; color: var(--mute); padding-top: 20px; }
.crumbs a:hover { color: var(--ink); }
.crumbs span[aria-current] { color: var(--ink); }

/* ---------- game cards ---------- */
.game-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 24px 20px; margin: 0; padding: 0; list-style: none; }
.game-card { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.game-card:hover { color: inherit; }
.game-thumb { position: relative; display: block; aspect-ratio: 4 / 3; border-radius: 16px; overflow: hidden; background: var(--surf2); }
.game-thumb img { width: 100%; height: 100%; object-fit: cover; transition: transform .25s ease; }
.game-card:hover .game-thumb img { transform: scale(1.04); }
.game-thumb .flag { position: absolute; top: 10px; right: 10px; padding: 4px 9px; border-radius: 999px; background: #fff; color: #15151C; font-size: 12px; font-weight: 700; }
.game-thumb .flag-star { left: 10px; right: auto; background: var(--star); color: #15151C; display: inline-flex; }
.game-title { font-weight: 600; font-size: 15px; line-height: 1.3; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.game-meta { font-size: 13px; color: var(--mute); margin-top: -4px; display: flex; gap: 6px; flex-wrap: wrap; }
.game-meta .rate { color: var(--ink); font-weight: 500; }
.game-meta .rate::before { content: '★ '; color: var(--star); }

/* ---------- home hero ---------- */
.home-top { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 24px; margin-top: 24px; }
.hero { position: relative; overflow: hidden; min-height: 380px; border-radius: var(--r-xl); background: #2B3A8F; color: #fff; display: flex; flex-direction: column; justify-content: flex-end; gap: 14px; padding: 44px; isolation: isolate; }
.hero-bg { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; z-index: -2; }
.hero::after { content: ''; position: absolute; inset: 0; z-index: -1; background: linear-gradient(0deg, rgba(8,10,20,.85) 0%, rgba(8,10,20,.45) 50%, rgba(8,10,20,.05) 100%); }
.hero .kicker { align-self: flex-start; padding: 6px 12px; border-radius: 999px; background: rgba(255,255,255,.18); backdrop-filter: blur(6px); font-size: 13px; font-weight: 600; }
.hero h1 { font-family: var(--f-display); font-weight: 700; font-size: clamp(30px, 4vw, 48px); letter-spacing: -0.03em; }
.hero p { margin: 0; max-width: 560px; font-size: 16px; opacity: .92; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.hero-actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding-top: 6px; }
.hero .btn-white { background: #fff; color: #15151C; }
.hero .btn-white:hover { color: #15151C; }
.hero .meta { font-weight: 500; font-size: 15px; }
.side-stack { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.mini-game { display: flex; gap: 14px; align-items: center; padding: 18px; }
.mini-game .thumb { width: 96px; height: 72px; border-radius: 12px; overflow: hidden; flex-shrink: 0; background: var(--surf2); }
.mini-game .thumb img { width: 100%; height: 100%; object-fit: cover; }
.mini-game .body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.eyebrow { font-size: 12px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--mute); }
.leader-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.leader-list li { display: flex; align-items: center; gap: 12px; }
.leader-list .pos { width: 22px; font-weight: 600; font-size: 14px; color: var(--mute); text-align: center; }
.leader-list .pos.top { color: var(--star); }
.leader-list .name { flex: 1; min-width: 0; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.leader-list .xp { font-size: 14px; color: var(--mute); white-space: nowrap; }
.panel-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.panel-head h2 { margin: 0; font-family: var(--f-display); font-weight: 600; font-size: 16px; }
.panel-head a { font-size: 14px; font-weight: 500; color: var(--acc-text); }

/* ---------- ads ---------- */
.ad-slot { margin: 24px auto 0; text-align: center; overflow: hidden; }
.ad-slot:empty { display: none; }

/* ---------- play page ---------- */
.play-layout { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 24px; margin-top: 16px; align-items: start; }
.play-main { display: flex; flex-direction: column; gap: 20px; min-width: 0; }
.player { position: relative; width: 100%; aspect-ratio: 16 / 9; max-height: calc(100vh - 140px); border-radius: var(--r-lg); overflow: hidden; background: #0B0C12; }
.player iframe { position: absolute; inset: 0; width: 100% !important; height: 100% !important; border: 0; }
.player-cover { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px; color: #fff; z-index: 2; isolation: isolate; text-align: center; padding: 20px; }
.player-cover img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; z-index: -2; filter: blur(2px) saturate(1.1); transform: scale(1.04); }
.player-cover::after { content: ''; position: absolute; inset: 0; background: rgba(8,10,20,.55); z-index: -1; }
.player-cover .title { font-family: var(--f-display); font-weight: 700; font-size: clamp(22px, 3.2vw, 40px); letter-spacing: -0.03em; }
.play-btn { height: 60px; padding: 0 34px; border-radius: 999px; border: 0; background: #fff; color: #15151C; font-weight: 700; font-size: 17px; display: inline-flex; align-items: center; gap: 10px; }
.play-btn:hover { transform: scale(1.03); }
.player-ad { position: absolute; inset: 0; z-index: 3; background: var(--surf); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px; padding: 20px; }
.player-ad .count { font-family: var(--f-display); font-size: 40px; font-weight: 700; }
.player:fullscreen { max-height: none; border-radius: 0; }
.game-bar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.game-bar .info { flex: 1; min-width: 240px; display: flex; flex-direction: column; gap: 6px; }
.game-bar h1 { font-family: var(--f-display); font-weight: 600; font-size: 28px; letter-spacing: -0.02em; }
.game-bar .meta { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; font-size: 14px; color: var(--mute); }
.stars { position: relative; display: inline-block; font-size: 18px; line-height: 1; letter-spacing: 2px; color: var(--line); }
.stars::before { content: '★★★★★'; }
.stars > span { position: absolute; inset: 0 auto 0 0; overflow: hidden; color: var(--star); white-space: nowrap; }
.stars > span::before { content: '★★★★★'; }
.fav-btn.is-on { color: #E0447A; border-color: #E0447A; }
.fav-btn.is-on .i { fill: currentColor; }
.two-col { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
.two-col:has(> [hidden]) { grid-template-columns: minmax(0, 1fr); }
.two-col > [hidden] { display: none; }
.prose { font-size: 15px; line-height: 1.65; color: var(--mute); white-space: pre-line; overflow-wrap: anywhere; }
.xp-card { display: flex; align-items: center; gap: 14px; padding: 18px 20px; border-radius: var(--r-lg); background: var(--acc-soft); }
.xp-card .mark { width: 44px; height: 44px; border-radius: 12px; background: var(--acc); color: var(--acc-ink); display: grid; place-items: center; font-weight: 700; font-size: 14px; flex-shrink: 0; }
.row-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.row-game { display: flex; align-items: center; gap: 14px; }
.row-game .thumb { width: 96px; height: 72px; flex-shrink: 0; border-radius: 12px; overflow: hidden; background: var(--surf2); }
.row-game .thumb img { width: 100%; height: 100%; object-fit: cover; }
.row-game .body { min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.row-game .title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-game .meta { font-size: 13px; color: var(--mute); }
.share-row { display: flex; gap: 8px; flex-wrap: wrap; }
.admin-chart { height: 220px; }

/* ---------- categories ---------- */
.cat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; list-style: none; margin: 24px 0 0; padding: 0; }
.cat-tile { position: relative; display: flex; flex-direction: column; justify-content: flex-end; gap: 4px; height: 120px; padding: 18px; border-radius: var(--r-lg); color: #fff; overflow: hidden; isolation: isolate; }
.cat-tile:hover { color: #fff; transform: translateY(-2px); }
.cat-tile b { font-family: var(--f-display); font-weight: 600; font-size: 18px; letter-spacing: -0.01em; }
.cat-tile span { font-size: 14px; opacity: .9; }
.cat-tile::before { content: ''; position: absolute; width: 140px; height: 140px; right: -30px; top: -40px; border-radius: 50%; background: rgba(255,255,255,.18); z-index: -1; }
.cat-tile::after { content: ''; position: absolute; width: 70px; height: 70px; right: 60px; bottom: -30px; border-radius: 18px; transform: rotate(18deg); background: rgba(0,0,0,.14); z-index: -1; }
.cat-c0 { background: #3D63F0; } .cat-c1 { background: #E0533D; } .cat-c2 { background: #1E9E78; } .cat-c3 { background: #8052F0; }
.cat-c4 { background: #D13D72; } .cat-c5 { background: #1580A6; } .cat-c6 { background: #B8660F; } .cat-c7 { background: #4F5D7A; }

/* ---------- empty / error ---------- */
.empty { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; padding: 64px 20px; text-align: center; color: var(--mute); }
.empty .i { width: 40px; height: 40px; color: var(--mute); }
.empty h2, .empty h3 { color: var(--ink); font-size: 20px; }
.empty-inline { padding: 20px; color: var(--mute); text-align: center; }

/* ---------- leaderboard ---------- */
.board { margin-top: 24px; }
.board-row { display: grid; grid-template-columns: 48px minmax(0, 1fr) auto auto; gap: 16px; align-items: center; padding: 14px 20px; border-bottom: 1px solid var(--line); }
.board-row:last-child { border-bottom: 0; }
.board-row .pos { font-family: var(--f-display); font-weight: 600; font-size: 18px; text-align: center; color: var(--mute); }
.board-row .pos.p1 { color: #E8A200; } .board-row .pos.p2 { color: #8E9AAF; } .board-row .pos.p3 { color: #C0773C; }
.board-row .who { display: flex; align-items: center; gap: 12px; min-width: 0; font-weight: 600; }
.board-row .who span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.board-row .xp { font-weight: 600; }

/* ---------- profile ---------- */
.profile-cover { position: relative; height: 200px; border-radius: var(--r-xl); margin-top: 24px; overflow: hidden; background: #3D63F0; }
.profile-cover::before { content: ''; position: absolute; width: 360px; height: 360px; right: -60px; top: -120px; border-radius: 50%; background: rgba(255,255,255,.16); }
.profile-cover::after { content: ''; position: absolute; width: 160px; height: 160px; right: 300px; bottom: -70px; border-radius: 36px; transform: rotate(18deg); background: rgba(0,0,0,.14); }
.style-1, .style-1-image { background: #3D63F0; } .style-2, .style-2-image { background: #E0533D; } .style-3, .style-3-image { background: #1E9E78; }
.style-4 { background: #8052F0; } .style-5 { background: #D13D72; } .style-6 { background: #1580A6; } .style-7 { background: #4F5D7A; }
.profile-head { display: flex; align-items: flex-end; gap: 20px; margin-top: -56px; padding: 0 28px; position: relative; flex-wrap: wrap; }
.profile-head .avatar { width: 112px; height: 112px; border: 5px solid var(--bg); }
.profile-head h1 { font-family: var(--f-display); font-weight: 600; font-size: 28px; padding-bottom: 10px; }
.profile-layout { display: grid; grid-template-columns: 320px minmax(0, 1fr); gap: 24px; margin-top: 28px; align-items: start; }
.facts { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; font-size: 15px; }
.facts li { display: flex; gap: 10px; align-items: flex-start; }
.facts .i { color: var(--mute); margin-top: 2px; }

/* ---------- forms ---------- */
.field { display: flex; flex-direction: column; gap: 6px; }
.field > label, .field-label { font-size: 14px; font-weight: 600; }
.field .hint { font-size: 13px; color: var(--mute); }
.input, .select, .textarea { width: 100%; height: 46px; padding: 0 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--surf); color: var(--ink); font-size: 15px; outline: none; transition: border-color .15s, box-shadow .15s; }
.textarea { height: auto; min-height: 110px; padding: 12px 14px; resize: vertical; line-height: 1.5; }
.select { appearance: none; padding-right: 40px; background-image: linear-gradient(45deg, transparent 50%, var(--mute) 50%), linear-gradient(135deg, var(--mute) 50%, transparent 50%); background-position: calc(100% - 20px) 20px, calc(100% - 15px) 20px; background-size: 5px 5px; background-repeat: no-repeat; }
.input:focus, .select:focus, .textarea:focus { border-color: var(--acc); box-shadow: 0 0 0 3px var(--acc-soft); }
.input:disabled { background: var(--surf2); color: var(--mute); }
.input-icon { position: relative; }
.input-icon .i { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--mute); pointer-events: none; }
.input-icon .input { padding-left: 42px; }
.form-stack { display: flex; flex-direction: column; gap: 18px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px 20px; }
.form-grid .full { grid-column: 1 / -1; }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; flex-wrap: wrap; }
.check { display: inline-flex; align-items: center; gap: 10px; font-weight: 500; cursor: pointer; }
.check input, input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--acc); cursor: pointer; margin: 0; }
.switch { position: relative; width: 44px; height: 26px; border-radius: 999px; border: 0; padding: 3px; background: var(--off); display: inline-flex; transition: background .15s; flex-shrink: 0; }
.switch::after { content: ''; width: 20px; height: 20px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.25); transition: transform .15s; }
.switch[aria-checked="true"] { background: var(--ok); }
.switch[aria-checked="true"]::after { transform: translateX(18px); }
.seg { display: inline-flex; padding: 3px; border-radius: 12px; background: var(--surf2); gap: 2px; flex-wrap: wrap; }
.seg a, .seg button { height: 36px; padding: 0 14px; border-radius: 9px; border: 0; background: transparent; color: var(--mute); font-weight: 600; font-size: 14px; display: inline-flex; align-items: center; gap: 8px; }
.seg a:hover, .seg button:hover { color: var(--ink); }
.seg .is-active { background: var(--surf); color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,.12); }
.seg .count { font-weight: 500; opacity: .75; }

/* auth */
.auth-wrap { display: flex; justify-content: center; padding: 56px 0; }
.auth-card { width: 100%; max-width: 440px; padding: 36px; display: flex; flex-direction: column; gap: 22px; }
.auth-card h1 { font-family: var(--f-display); font-weight: 600; font-size: 26px; letter-spacing: -0.02em; }
.auth-card .alt { text-align: center; font-size: 14px; color: var(--mute); }
.auth-card .alt a { color: var(--acc-text); font-weight: 600; }

/* settings */
.settings-layout { display: grid; grid-template-columns: 260px minmax(0, 1fr); gap: 24px; margin-top: 28px; align-items: start; }
.side-nav { display: flex; flex-direction: column; gap: 4px; padding: 10px; }
.side-nav a { display: flex; align-items: center; gap: 12px; height: 44px; padding: 0 12px; border-radius: 10px; font-weight: 500; }
.side-nav a:hover { background: var(--surf2); color: var(--ink); }
.side-nav a.active, .side-nav a.is-active { background: var(--acc-soft); color: var(--acc-text); font-weight: 600; }
.avatar-edit { display: flex; align-items: center; gap: 24px; flex-wrap: wrap; }
.avatar-edit .avatar { width: 120px; height: 120px; }
.theme-options { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 12px; list-style: none; padding: 0; margin: 0; }
.theme-options label { cursor: pointer; }
.theme-options input { position: absolute; opacity: 0; }
.theme-swatch { height: 76px; border-radius: 14px; display: grid; place-items: center; color: #fff; font-weight: 700; border: 3px solid transparent; }
.theme-options input:checked + .theme-swatch { border-color: var(--ink); box-shadow: 0 0 0 3px var(--bg) inset; }
.theme-options input:focus-visible + .theme-swatch { outline: 2px solid var(--acc); outline-offset: 2px; }

/* ---------- footer ---------- */
.site-footer { border-top: 1px solid var(--line); background: var(--surf); }
.footer-row { display: flex; align-items: center; gap: 24px; padding-top: 26px; padding-bottom: 26px; font-size: 14px; color: var(--mute); flex-wrap: wrap; }
.footer-row .brand { font-family: var(--f-display); font-weight: 700; font-size: 16px; color: var(--ink); }
.footer-row nav { margin-left: auto; display: flex; gap: 18px; flex-wrap: wrap; }
.footer-row a:hover { color: var(--ink); }
.footer-row .langs a.is-active { color: var(--ink); font-weight: 600; }

/* ---------- toast & dialog ---------- */
.toasts { position: fixed; right: 20px; bottom: 20px; z-index: 200; display: flex; flex-direction: column; gap: 10px; max-width: min(420px, calc(100vw - 40px)); }
.toast { display: flex; align-items: flex-start; gap: 12px; padding: 14px 16px; border-radius: 14px; background: var(--ink); color: var(--bg); box-shadow: var(--shadow); font-size: 14px; font-weight: 500; animation: toast-in .2s ease; }
.toast.is-error { background: var(--bad); color: #fff; }
.toast.is-ok .i { color: var(--ok); }
:root[data-theme="dark"] .toast.is-error { color: #1a0a08; }
@keyframes toast-in { from { transform: translateY(8px); opacity: 0; } }
dialog.modal { border: 0; padding: 0; border-radius: var(--r-lg); background: var(--surf); color: var(--ink); width: min(480px, calc(100vw - 32px)); box-shadow: var(--shadow); }
dialog.modal::backdrop { background: rgba(8,10,20,.55); }
.modal-body { padding: 24px; display: flex; flex-direction: column; gap: 16px; }
.modal-body h2 { font-family: var(--f-display); font-weight: 600; font-size: 20px; }

/* ---------- responsive ---------- */
@media (max-width: 1100px) {
  .home-top, .play-layout { grid-template-columns: minmax(0, 1fr); }
  .side-stack { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .profile-layout, .settings-layout { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 860px) {
  :root { --gutter: 16px; --header-h: 60px; }
  .main-nav, .header-actions .auth-links { display: none; }
  .header-row { gap: 12px; }
  .search { order: 3; }
  .site-header .search { display: none; }
  .mobile-search { display: flex !important; margin-top: 16px; max-width: none; }
  .user-menu .who { display: none; }
  .user-menu > summary { padding: 3px; }
  .mobile-tabs { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); position: sticky; bottom: 0; z-index: 50; height: 64px; background: var(--surf); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
  .mobile-tabs a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; font-size: 12px; font-weight: 500; color: var(--mute); }
  .mobile-tabs a.is-active { color: var(--acc-text); font-weight: 600; }
  .site-footer { padding-bottom: 0; }
  .side-stack { grid-template-columns: minmax(0, 1fr); }
  .hero { min-height: 260px; padding: 22px; border-radius: 22px; }
  .game-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px 12px; }
  .game-thumb { border-radius: 14px; }
  .section { margin-top: 32px; }
  .section-head h2 { font-size: 19px; }
  .page-title { font-size: 24px; }
  .two-col, .form-grid { grid-template-columns: minmax(0, 1fr); }
  .game-bar h1 { font-size: 22px; }
  .game-bar .actions { width: 100%; }
  .game-bar .actions .grow { flex: 1; }
  .player { border-radius: 14px; }
  .board-row { grid-template-columns: 36px minmax(0, 1fr) auto; padding: 12px 14px; }
  .board-row .extra { display: none; }
  .auth-card { padding: 24px; }
  .toasts { left: 16px; right: 16px; bottom: 80px; max-width: none; }
  .footer-row nav { margin-left: 0; }
}
.mobile-search { display: none !important; }
@media (max-width: 860px) { .mobile-search { display: flex !important; } }
.section:has(> .game-grid:empty), .section:has(.game-grid:empty) { display: none; }
.profile-head > div { padding-top: 60px; }
.home-h1 { font-family: var(--f-display); font-weight: 600; font-size: 22px; letter-spacing: -0.02em; margin-top: 28px; }
.hero .hero-title { font-family: var(--f-display); font-weight: 700; font-size: clamp(30px, 4vw, 48px); letter-spacing: -0.03em; }
.cat-intro { margin: 6px 0 0; max-width: 760px; color: var(--mute); line-height: 1.6; }

/* auth: notices, resend, e-mail confirmation, reCAPTCHA note */
.auth-stack { width: 100%; max-width: 440px; display: flex; flex-direction: column; gap: 16px; }
.auth-card[hidden] { display: none; }
.auth-card h2 { font-family: var(--f-display); font-weight: 600; font-size: 19px; }
.notice { display: flex; gap: 10px; align-items: flex-start; padding: 14px 16px; border-radius: 12px; background: var(--surf2); font-size: 14px; line-height: 1.5; }
.notice-ok { background: var(--ok-soft); color: var(--ok); }
.notice-warn { background: var(--warn-soft); color: var(--warn); }
.verify-ok { width: 64px; height: 64px; margin: 0 auto; border-radius: 50%; background: var(--ok-soft); color: var(--ok); display: grid; place-items: center; }
.verify-ok .i { width: 30px; height: 30px; }
.recaptcha-note { margin: 0; font-size: 12px; line-height: 1.5; color: var(--mute); }
.recaptcha-note a { color: inherit; text-decoration: underline; }
.grecaptcha-badge { visibility: hidden !important; }

/* cookie consent */
.cookie-bar { position: fixed; left: 20px; bottom: 20px; z-index: 150; max-width: 600px; display: flex; flex-direction: column; gap: 14px; padding: 18px 20px; border-radius: 16px; background: var(--surf); border: 1px solid var(--line); box-shadow: 0 10px 30px rgba(0,0,0,.14); }
.cookie-bar[hidden] { display: none; }
.cookie-bar p { margin: 0; font-size: 14px; line-height: 1.5; color: var(--ink); }
.cookie-bar a { color: var(--acc-text); font-weight: 600; white-space: nowrap; }
.cookie-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.cookie-bar.is-hiding { opacity: 0; transform: translateY(10px); transition: opacity .2s, transform .2s; }
.cookie-modal .modal-body a { color: var(--acc-text); font-weight: 600; }
.ck-row { display: flex; align-items: center; gap: 14px; padding: 14px 0; border-top: 1px solid var(--line); cursor: pointer; }
.ck-row > span:first-child { flex: 1; display: flex; flex-direction: column; gap: 3px; font-size: 15px; }
.ck-row small { color: var(--mute); font-size: 13px; line-height: 1.45; }
.ck-row input[disabled] { display: none; }
input.ck-toggle[type="checkbox"] { appearance: none; -webkit-appearance: none; position: relative; width: 44px; height: 26px; flex: none; border-radius: 999px; background: var(--off, #c9ccd6); cursor: pointer; transition: background .15s; margin: 0; }
input.ck-toggle::after { content: ''; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.25); transition: transform .15s; }
input.ck-toggle:checked { background: var(--ok); }
input.ck-toggle:checked::after { transform: translateX(18px); }
.ck-toggle:focus-visible { outline: 2px solid var(--acc); outline-offset: 2px; }
.linklike { border: 0; background: none; padding: 0; font: inherit; color: inherit; cursor: pointer; }
.linklike:hover { color: var(--ink); }
.page-narrow { max-width: 860px; padding-top: 24px; padding-bottom: 48px; }
.cookie-prose h2 { font-family: var(--f-display); font-weight: 600; font-size: 20px; margin: 24px 0 8px; }
.cookie-table .tr { grid-template-columns: 180px minmax(0, 1fr) 150px; padding-top: 14px; padding-bottom: 14px; }
@media (max-width: 860px) {
  .cookie-bar { left: 12px; right: 12px; bottom: calc(76px + env(safe-area-inset-bottom)); max-width: none; padding: 16px; }
  .cookie-actions .btn { flex: 1 1 auto; }
  .cookie-table .tr { grid-template-columns: minmax(0, 1fr); gap: 4px; }
  .cookie-table .tr.th { display: none; }
}
.cookie-prose .btn { white-space: normal; height: auto; min-height: 44px; text-align: center; max-width: 100%; }
dialog.cookie-modal { max-height: calc(100dvh - 24px); overflow: auto; }
@media (max-width: 860px) {
  .cookie-modal .modal-body { padding: 20px; gap: 12px; }
  .cookie-modal .form-actions .btn { flex: 1 1 100%; }
  .ck-row { padding: 10px 0; }
}

/* Script fonts: Unbounded/Onest have no CJK, Arabic or full Vietnamese glyphs */
html[lang="ja"] { --f-display: 'Noto Sans JP', system-ui, sans-serif; --f-body: 'Noto Sans JP', system-ui, sans-serif; }
html[lang="ko"] { --f-display: 'Noto Sans KR', system-ui, sans-serif; --f-body: 'Noto Sans KR', system-ui, sans-serif; }
html[lang="vi"] { --f-display: 'Be Vietnam Pro', system-ui, sans-serif; --f-body: 'Be Vietnam Pro', system-ui, sans-serif; }
html[lang="ar"] { --f-display: 'Noto Sans Arabic', system-ui, sans-serif; --f-body: 'Noto Sans Arabic', system-ui, sans-serif; }
html[lang="ja"] body, html[lang="ko"] body { word-break: keep-all; overflow-wrap: anywhere; }
html[lang="ar"] .display, html[lang="ar"] h1, html[lang="ar"] h2 { letter-spacing: 0; }

/* Right-to-left (Arabic). Flex/grid mirror by themselves; fix the absolute bits. */
[dir="rtl"] .header-actions { margin-left: 0; margin-right: auto; }
[dir="rtl"] .dropdown { right: auto; left: 0; }
[dir="rtl"] .game-thumb .flag { right: auto; left: 10px; }
[dir="rtl"] .game-thumb .flag-star { left: auto; right: 10px; }
[dir="rtl"] .select { padding-right: 14px; padding-left: 40px; background-position: 20px 20px, 15px 20px; }
[dir="rtl"] .input-icon .i { left: auto; right: 14px; }
[dir="rtl"] .input-icon .input { padding-left: 14px; padding-right: 42px; }
[dir="rtl"] .footer-row nav { margin-left: 0; margin-right: auto; }
[dir="rtl"] .toasts { right: auto; left: 20px; }
[dir="rtl"] .cookie-bar { left: auto; right: 20px; }
[dir="rtl"] input.ck-toggle:checked::after { transform: translateX(18px); }
[dir="rtl"] .i-flip, [dir="rtl"] .pager .btn-icon, [dir="rtl"] use[href$="#chevron-right"], [dir="rtl"] use[href$="#chevron-left"] { transform: scaleX(-1); transform-origin: center; }
[dir="rtl"] .cat-tile::before, [dir="rtl"] .cat-tile::after, [dir="rtl"] .profile-cover::before, [dir="rtl"] .profile-cover::after { transform: scaleX(-1); }
@media (max-width: 860px) {
  [dir="rtl"] .toasts { left: 16px; right: 16px; }
  [dir="rtl"] .cookie-bar { left: 12px; right: 12px; }
}

/* real ratings */
.rate-box { display: flex; align-items: center; gap: 10px; margin-top: 10px; font-size: 14px; }
.rate-pick { display: inline-flex; gap: 2px; }
.rate-pick .js-rate { background: none; border: 0; padding: 0 2px; font-size: 24px; line-height: 1; cursor: pointer; color: var(--line); }
.rate-pick .js-rate.is-on { color: var(--star); }
.rate-pick:hover .js-rate { color: var(--star); }
.rate-pick .js-rate:hover ~ .js-rate { color: var(--line); }

/* description image */
.desc-cover { float: left; width: 200px; max-width: 40%; height: auto; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 12px; margin: 0 16px 8px 0; background: var(--surf2); }
[dir="rtl"] .desc-cover { float: right; margin: 0 0 8px 16px; }

/* soft language banner */
.lang-banner { position: fixed; top: 78px; left: 50%; transform: translateX(-50%); z-index: 55; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: center; padding: 10px 14px; background: var(--surf); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow); max-width: min(620px, calc(100% - 24px)); font-size: 14px; }

/* brand mark: the "F" icon (same as favicon) */
.logo-mark.logo-f { display: block; width: 36px; height: 36px; background: none; border-radius: 0; flex-shrink: 0; }
.az-nav { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 18px; }
.az-nav .is-off { opacity: .35; pointer-events: none; }
.az-nav .is-current { background: var(--ink); color: var(--bg); }
.lp-more { margin-top: 32px; }
.lp-more h2 { font-size: 18px; margin: 0 0 10px; }
.lp-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.js-pwa-install[hidden] { display: none; }
.js-pwa-install { font-weight: 600; color: var(--brand, inherit); }
