/* ===== Base tokens ===== */
:root {
  color-scheme: dark;
  /* OLED: pure black background (pixels off), dark surfaces and a red accent */
  --bg: #000000;
  --bg-2: #0a0a0c;
  --surface: rgba(255, 255, 255, 0.04);
  --surface-2: rgba(255, 255, 255, 0.075);
  --surface-3: rgba(255, 255, 255, 0.12);
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.16);
  --text: #f4f4f6;
  --muted: #8d8d99;
  --accent: #ff3358;
  --accent-2: #c3112f;
  --accent-ink: #ffffff;
  --accent-soft: rgba(255, 51, 88, 0.14);
  --good: #3ee08f;
  --bad: #ff5d6c;
  --info: #6aa8ff;
  --radius: 18px;
  --radius-sm: 11px;
  --shadow: 0 18px 40px -12px rgba(0, 0, 0, 0.55);
  --font: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --font-display: 'Unbounded', 'Inter', system-ui, sans-serif;
  --font-card: 'Playfair Display', Georgia, 'Times New Roman', serif;
  --header-h: 64px;
  --tabbar-h: 0px;
  --gutter: clamp(16px, 4vw, 32px);
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100dvh;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
  background:
    radial-gradient(900px 420px at 50% -220px, rgba(255, 30, 70, 0.16), transparent 70%),
    var(--bg);
  background-attachment: fixed;
  -webkit-tap-highlight-color: transparent;
}
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; }
h1, h2, h3 { line-height: 1.15; margin: 0; }
img, svg { display: block; }
.muted { color: var(--muted); }
.ico { display: inline-flex; }
::selection { background: rgba(255, 51, 88, 0.4); }

.glass {
  background: linear-gradient(180deg, rgba(255,255,255,0.06), rgba(255,255,255,0.025));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  box-shadow: var(--shadow);
}

/* ===== Buttons ===== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 42px; padding: 0 18px;
  border-radius: 3px; border: 1px solid var(--border-strong);
  background: var(--surface-2);
  font-weight: 600; cursor: pointer; white-space: nowrap;
  transition: transform .15s var(--ease), background .2s, border-color .2s, box-shadow .2s, opacity .2s;
  user-select: none;
}
.btn:hover { background: var(--surface-3); }
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.btn:focus-visible, .icon-btn:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn-primary {
  background: linear-gradient(180deg, #ff4f70, var(--accent-2));
  color: var(--accent-ink); border-color: transparent;
  box-shadow: 0 8px 26px -10px rgba(255, 40, 80, 0.75), inset 0 1px 0 rgba(255,255,255,.35);
  text-shadow: 0 1px 1px rgba(0,0,0,.25);
}
.btn-primary:hover { background: linear-gradient(180deg, #ff6783, #d8183a); }
.btn-danger { background: rgba(241, 109, 109, 0.15); border-color: rgba(241, 109, 109, 0.4); color: #ffb3b3; }
.btn-ghost { background: transparent; }
.btn-sm { height: 36px; padding: 0 14px; font-size: 14px; border-radius: 3px; }
.btn-lg { height: 50px; padding: 0 26px; font-size: 16px; border-radius: 3px; }
.btn-block { width: 100%; }
.icon-btn {
  display: inline-grid; place-items: center;
  width: 40px; height: 40px; border-radius: 3px;
  border: 1px solid transparent; background: transparent; cursor: pointer;
  color: var(--muted); transition: background .2s, color .2s;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }

/* ===== Header and navigation ===== */
.app-header {
  position: sticky; top: 0; z-index: 50;
  height: var(--header-h);
  display: flex; align-items: center; gap: 24px;
  padding: 0 var(--gutter);
  background: rgba(0, 0, 0, 0.78);
  backdrop-filter: saturate(160%) blur(16px);
  -webkit-backdrop-filter: saturate(160%) blur(16px);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark svg { width: 34px; height: 34px; filter: drop-shadow(0 0 10px rgba(255, 40, 80, .35)); }
.brand-name { font-family: var(--font-display); font-size: 19px; font-weight: 700; letter-spacing: -.01em; white-space: nowrap; }
.brand-name b { font-weight: 800; background: linear-gradient(180deg, #ff6b86, #e0103a); -webkit-background-clip: text; background-clip: text; color: transparent; }
.top-nav { display: flex; gap: 4px; }
.nav-link {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 8px 14px; border-radius: 3px; color: var(--muted); font-weight: 600;
  transition: color .2s, background .2s;
}
.nav-link:hover { color: var(--text); background: var(--surface); }
.nav-link.active { color: var(--text); background: var(--surface-2); }
.header-right { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.lang-switch { display: flex; gap: 2px; padding: 3px; border-radius: 999px; background: rgba(255, 255, 255, 0.05); border: 1px solid var(--border, #2a2a33); }
.lang-switch button { display: grid; place-items: center; width: 34px; height: 26px; padding: 0; border: 0; border-radius: 999px; background: none; cursor: pointer; opacity: .45; filter: grayscale(.6); transition: opacity .15s, filter .15s, background .15s; }
.lang-switch button:hover { opacity: .85; filter: none; }
.lang-switch svg { width: 20px; height: 14px; border-radius: 2px; box-shadow: 0 0 0 1px rgba(255,255,255,.18); }
.lang-switch button.on { opacity: 1; filter: none; background: rgba(255, 255, 255, 0.12); }
.user-chip { display: flex; align-items: center; gap: 10px; padding: 4px 12px 4px 4px; border-radius: 999px; font-weight: 600; }
.user-chip:hover { background: var(--surface-2); }

.avatar {
  display: inline-grid; place-items: center; flex: none;
  border-radius: 50%; font-weight: 800; color: #10131c;
  background: radial-gradient(circle at 30% 25%, color-mix(in srgb, var(--av) 60%, white), var(--av));
  box-shadow: 0 0 0 2px rgba(255,255,255,.08), 0 4px 12px -4px var(--av);
}

.tabbar { display: none; }

.view {
  width: min(1180px, 100%);
  margin: 0 auto;
  padding: 28px var(--gutter) calc(48px + var(--tabbar-h));
  view-transition-name: main-view;
}

@media (max-width: 720px) {
  :root { --header-h: 56px; --tabbar-h: calc(64px + env(safe-area-inset-bottom)); }
  .top-nav, .user-chip span, .header-right .icon-btn { display: none; }
  .brand-name { font-size: 17px; }
  .tabbar {
    display: flex; position: fixed; z-index: 60; left: 0; right: 0; bottom: 0;
    height: var(--tabbar-h); padding: 6px 8px env(safe-area-inset-bottom);
    background: rgba(0, 0, 0, 0.9);
    backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px);
    border-top: 1px solid var(--border);
  }
  .tabbar .nav-link { flex: 1; flex-direction: column; gap: 2px; font-size: 11px; padding: 6px 4px; justify-content: center; }
  .tabbar .nav-link.active { background: transparent; color: var(--accent); }
  .view { padding-top: 20px; }
}

/* In a game: maximum room for the board */
body.in-game .tabbar { display: none; }
body.in-game { --tabbar-h: 0px; }
body.in-game .view { width: 100%; max-width: none; padding: 0; }
@media (max-width: 720px) { body.in-game .app-header { display: none; } }

::view-transition-old(main-view) { animation: vt-out .18s ease both; }
::view-transition-new(main-view) { animation: vt-in .28s var(--ease) both; }
@keyframes vt-out { to { opacity: 0; transform: translateY(-6px); } }
@keyframes vt-in { from { opacity: 0; transform: translateY(10px); } }

/* ===== Home ===== */
.hero { display: grid; grid-template-columns: 1.3fr 1fr; gap: 28px; align-items: center; margin-bottom: 34px; }
.eyebrow { text-transform: uppercase; letter-spacing: .18em; font-size: 12px; font-weight: 700; color: var(--accent); margin: 0 0 10px; }
.hero h1 { font-family: var(--font-display); font-size: clamp(28px, 4.4vw, 48px); font-weight: 700; letter-spacing: -.02em; }
.hero h1 em { font-style: normal; background: linear-gradient(180deg, #ff6b86, #e0103a); -webkit-background-clip: text; background-clip: text; color: transparent; }
.lead { color: var(--muted); font-size: 17px; max-width: 56ch; margin: 14px 0 0; }
.hero-cta { display: flex; gap: 12px; margin-top: 24px; flex-wrap: wrap; }
.hero-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.stat {
  display: flex; flex-direction: column; gap: 2px; padding: 16px 18px;
  border-radius: var(--radius); background: var(--surface); border: 1px solid var(--border);
}
.stat-value { font-size: 26px; font-weight: 800; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.stat-label { color: var(--muted); font-size: 13px; }

.games-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 20px; }
.game-card {
  --accent-g: var(--accent);
  position: relative; display: flex; flex-direction: column;
  border-radius: 3px; overflow: hidden;
  background: var(--bg-2); border: 1px solid var(--border);
  box-shadow: var(--shadow);
  transition: transform .3s var(--ease), border-color .3s, box-shadow .3s;
  animation: rise .5s var(--ease) both;
}
.game-card:not(.soon):hover {
  transform: translateY(-6px);
  border-color: color-mix(in srgb, var(--accent-g) 55%, transparent);
  box-shadow: 0 26px 50px -18px color-mix(in srgb, var(--accent-g) 45%, transparent);
}
.game-art { aspect-ratio: 16 / 9; overflow: hidden; }
.game-art svg { width: 100%; height: 100%; transition: transform .6s var(--ease); }
.game-card:hover .game-art svg { transform: scale(1.05); }
.game-info { padding: 16px 18px 18px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.game-title-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.game-info h3 { font-family: var(--font-display); font-size: 21px; font-weight: 600; min-width: 0; overflow-wrap: anywhere; }
.game-info p { margin: 0; color: var(--muted); font-size: 14px; }
.play-pill {
  display: inline-flex; align-items: center; gap: 5px; padding: 5px 12px 5px 10px;
  border-radius: 999px; font-size: 13px; font-weight: 700; flex: none;
  background: color-mix(in srgb, var(--accent-g) 18%, transparent);
  color: color-mix(in srgb, var(--accent-g) 80%, white);
}
.play-pill svg { fill: currentColor; }
.game-meta { display: flex; flex-direction: column; gap: 2px; margin-top: auto; padding-top: 8px; font-size: 12.5px; color: var(--muted); }
.mini-stats { color: color-mix(in srgb, var(--accent-g) 70%, white); font-weight: 600; }
.game-card.soon { border-style: dashed; background: transparent; box-shadow: none; }
.soon-art { display: grid; place-items: center; font-size: 56px; color: var(--muted); font-weight: 200; background: repeating-linear-gradient(45deg, transparent 0 12px, rgba(255,255,255,.02) 12px 24px); }

@keyframes rise { from { opacity: 0; transform: translateY(14px); } }

@media (max-width: 820px) {
  .hero { grid-template-columns: 1fr; }
}

/* ===== Log in / sign up ===== */
.auth-wrap { display: grid; place-items: center; min-height: calc(100dvh - var(--header-h) - 120px); }
.auth-card { width: min(440px, 100%); padding: 32px 28px; }
.auth-card h1 { font-family: var(--font-display); font-size: 30px; margin-bottom: 6px; }
.auth-form { display: flex; flex-direction: column; gap: 14px; margin-top: 22px; }
.auth-form label, .field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 600; color: var(--muted); }
input, select {
  height: 46px; padding: 0 14px; border-radius: 3px;
  border: 1px solid var(--border-strong); background: rgba(0,0,0,.25);
  color: var(--text); font: inherit; font-size: 16px; outline: none;
  transition: border-color .2s, box-shadow .2s;
}
input:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.form-error { color: var(--bad); min-height: 1.2em; margin: 0; font-size: 14px; }
.form-error:empty { display: none; }
.auth-switch { text-align: center; margin: 18px 0 0; color: var(--muted); }
.auth-switch a { color: var(--accent); font-weight: 600; }
.swatches { display: flex; gap: 10px; flex-wrap: wrap; }
.swatch { width: 32px; height: 32px; border-radius: 50%; border: 2px solid transparent; cursor: pointer; transition: transform .15s; box-shadow: inset 0 -3px 0 rgba(0,0,0,.2); }
.swatch:hover { transform: scale(1.1); }
.swatch.on { border-color: #fff; box-shadow: 0 0 0 3px rgba(255,255,255,.2); }

/* ===== Profile ===== */
.profile-head { display: flex; align-items: center; gap: 20px; padding: 24px; flex-wrap: wrap; }
.profile-head h1 { font-family: var(--font-display); font-size: 28px; }
.profile-head p { margin: 4px 0 0; }
.profile-id { flex: 1; min-width: 200px; }
.kpis { display: grid; grid-template-columns: repeat(5, 1fr); gap: 14px; margin: 18px 0; }
.kpi { display: flex; flex-direction: column; padding: 18px; gap: 4px; box-shadow: none; }
.kpi-value { font-size: 28px; font-weight: 800; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.kpi-label { font-size: 13px; color: var(--muted); }
.kpi.good .kpi-value { color: var(--good); }
.kpi.bad .kpi-value { color: var(--bad); }
@media (max-width: 820px) { .kpis { grid-template-columns: repeat(2, 1fr); } .kpis .kpi:last-child { grid-column: span 2; } }

.panel { padding: 22px; margin-bottom: 18px; }
.panel h2 { font-size: 18px; margin-bottom: 16px; }
.game-stats { display: flex; flex-direction: column; gap: 16px; }
.gs-row { display: grid; grid-template-columns: 140px 1fr 1fr; gap: 16px; align-items: center; }
.gs-name { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 16px; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--accent-g); box-shadow: 0 0 10px var(--accent-g); }
.gs-nums { display: flex; gap: 14px; flex-wrap: wrap; color: var(--muted); font-size: 13px; }
.gs-nums b { color: var(--text); font-size: 15px; font-variant-numeric: tabular-nums; }
.gs-bar { position: relative; height: 28px; border-radius: 3px; background: var(--surface); overflow: hidden; }
.gs-fill { position: absolute; inset: 0 auto 0 0; background: linear-gradient(90deg, color-mix(in srgb, var(--accent-g) 35%, transparent), color-mix(in srgb, var(--accent-g) 75%, transparent)); border-radius: 3px; transition: width .8s var(--ease); }
.gs-bar span { position: relative; z-index: 1; line-height: 28px; padding-left: 10px; font-size: 13px; font-weight: 600; }
@media (max-width: 720px) { .gs-row { grid-template-columns: 1fr; gap: 8px; } }

.history { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.history li { display: grid; grid-template-columns: 76px 90px 1fr auto; gap: 12px; align-items: center; padding: 10px 4px; border-bottom: 1px solid var(--border); font-size: 14px; }
.history li:last-child { border-bottom: 0; }
.res { font-size: 12px; font-weight: 700; padding: 3px 9px; border-radius: 999px; text-align: center; }
.res-win { background: rgba(62, 207, 142, .15); color: var(--good); }
.res-loss { background: rgba(241, 109, 109, .15); color: var(--bad); }
.res-draw { background: var(--surface-2); color: var(--muted); }
.h-game { font-weight: 600; }
.h-detail { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 560px) { .history li { grid-template-columns: 70px 1fr auto; } .h-detail { display: none; } }
.empty { color: var(--muted); text-align: center; padding: 28px 0; }

/* ===== Ranking ===== */
.page-head { margin-bottom: 18px; }
.page-head h1 { font-family: var(--font-display); font-size: clamp(26px, 3.6vw, 38px); }
.page-head p { margin: 6px 0 0; }
.tabs { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; margin-bottom: 14px; scrollbar-width: none; }
.tab { padding: 9px 16px; border-radius: 999px; border: 1px solid var(--border); color: var(--muted); font-weight: 600; white-space: nowrap; transition: all .2s; }
.tab:hover { color: var(--text); }
.tab.active { background: var(--text); color: var(--bg); border-color: var(--text); }
.sort-row { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; font-size: 14px; }
.seg { display: inline-flex; padding: 3px; border-radius: 3px; background: var(--surface); border: 1px solid var(--border); }
.seg button { border: 0; background: transparent; padding: 7px 12px; border-radius: 3px; cursor: pointer; color: var(--muted); font-weight: 600; font-size: 13px; }
.seg button.on { background: var(--surface-3); color: var(--text); }
.lb-table { display: flex; flex-direction: column; }
.lb-row {
  display: grid; grid-template-columns: 48px 1fr 80px 70px 70px 110px; gap: 8px; align-items: center;
  padding: 10px 10px; border-radius: 3px; cursor: pointer;
  animation: rise .4s var(--ease) both; transition: background .2s;
}
.lb-row:hover:not(.lb-headrow) { background: var(--surface); }
.lb-headrow { cursor: default; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .08em; font-weight: 700; animation: none; }
.lb-row .num { text-align: right; font-variant-numeric: tabular-nums; }
.lb-row .strong { font-weight: 800; font-size: 16px; }
.rank { font-weight: 800; color: var(--muted); text-align: center; font-size: 15px; }
.top .rank { font-size: 22px; }
.lb-player { display: flex; align-items: center; gap: 10px; font-weight: 600; min-width: 0; }
.lb-player span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-row.me { background: var(--accent-soft); box-shadow: inset 0 0 0 1px rgba(255, 51, 88, 0.4); }
@media (max-width: 600px) {
  .lb-row { grid-template-columns: 36px 1fr 64px 52px; }
  .hide-sm { display: none; }
  .panel { padding: 12px; }
}

/* ===== Modal dialog and toasts ===== */
.modal {
  border: 0; padding: 0; background: transparent; color: var(--text);
  max-width: min(480px, calc(100vw - 32px)); width: 100%;
}
.modal-wide { max-width: min(640px, calc(100vw - 32px)); }
.modal::backdrop { background: rgba(0, 0, 0, 0.7); backdrop-filter: blur(4px); animation: fade .2s ease; }
.modal[open] .modal-card { animation: pop .28s var(--ease); }
.modal.closing .modal-card { animation: pop-out .18s ease forwards; }
.modal-card {
  background: linear-gradient(180deg, #121215, #08080a);
  border: 1px solid var(--border-strong); border-radius: 3px; padding: 24px;
  box-shadow: 0 40px 80px -20px rgba(0,0,0,.7);
  max-height: calc(100dvh - 48px); overflow: auto;
}
.modal-title { font-family: var(--font-display); font-size: 22px; margin-bottom: 12px; }
.modal-body { color: #d2d2da; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 22px; flex-wrap: wrap; }
.rules ul { padding-left: 20px; }
.rules li { margin: 6px 0; }
@keyframes pop { from { opacity: 0; transform: translateY(12px) scale(.97); } }
@keyframes pop-out { to { opacity: 0; transform: scale(.97); } }
@keyframes fade { from { opacity: 0; } }

.toast-host { position: fixed; z-index: 1000; left: 50%; top: 16px; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast {
  padding: 11px 18px; border-radius: 3px; font-weight: 600; font-size: 14px;
  background: #111114; border: 1px solid var(--border-strong); box-shadow: var(--shadow);
  animation: toast-in .3s var(--ease);
}
.toast-success { border-color: rgba(62, 207, 142, .5); }
.toast-error { border-color: rgba(241, 109, 109, .6); color: #ffc4c4; }
.toast.out { opacity: 0; transform: translateY(-8px); transition: all .3s; }
@keyframes toast-in { from { opacity: 0; transform: translateY(-10px); } }

/* ===== Game page ===== */
.play {
  --accent-g: var(--accent);
  display: flex; flex-direction: column;
  height: calc(100dvh - var(--header-h));
}
@media (max-width: 720px) { .play { height: 100dvh; } }
.play-bar {
  display: flex; align-items: center; gap: 8px;
  padding: 8px max(12px, env(safe-area-inset-left)) 8px max(12px, env(safe-area-inset-right));
  border-bottom: 1px solid var(--border);
  background: #000;
}
.play-title { font-family: var(--font-display); font-size: 19px; font-weight: 600; flex: 1; }
.clock { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-variant-numeric: tabular-nums; font-size: 14px; font-weight: 600; padding: 0 6px; }
.game-root { flex: 1; min-height: 0; position: relative; display: flex; flex-direction: column; overflow: hidden; }

/* Shared control panel in the games */
.g-toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; justify-content: center; padding: 10px 12px; }
.g-toolbar .btn { height: 38px; padding: 0 14px; font-size: 14px; }
.g-status { text-align: center; font-weight: 600; min-height: 24px; padding: 2px 12px; color: #e2e2e8; }
.g-setup { display: grid; place-items: center; flex: 1; padding: 20px; overflow: auto; }
.g-setup-card { width: min(460px, 100%); padding: 26px; display: flex; flex-direction: column; gap: 18px; }
.g-setup-card h2 { font-family: var(--font-display); font-size: 24px; }
.opt-group { display: flex; flex-direction: column; gap: 8px; }
.opt-group > span { font-size: 13px; color: var(--muted); font-weight: 600; }
.opt-group .seg { display: flex; }
.opt-group .seg button { flex: 1; padding: 10px 8px; font-size: 14px; }
.result-banner { text-align: center; }
.result-banner .big { font-family: var(--font-display); font-size: 34px; margin: 4px 0; }
.result-banner.win .big { color: var(--accent); }
.result-banner.loss .big { color: #c9c9d3; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* ===== Online play ===== */
.game-card-link { position: absolute; inset: 0; z-index: 1; border-radius: inherit; }
.game-card:not(.soon) { cursor: pointer; }
.game-modes { position: relative; z-index: 2; display: flex; gap: 8px; margin-top: 12px; }
.game-modes .btn { flex: 1 1 0; min-width: 0; padding: 0 8px; gap: 6px; font-size: 13px; }
.btn-online { border-color: color-mix(in srgb, var(--accent) 55%, transparent); background: var(--accent-soft); color: #ffd0d9; }
.btn-online:hover { background: color-mix(in srgb, var(--accent) 26%, transparent); }
.small { font-size: 13px; }
.center { text-align: center; }

.net-notice {
  display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; margin: 0 0 18px;
  border-radius: 3px; border: 1px solid rgba(255, 196, 80, .35); background: rgba(255, 196, 80, .07);
  color: #f3dfb5; font-size: 13.5px; line-height: 1.45;
}
.net-notice .ico { flex: none; color: #ffc450; margin-top: 1px; }
.room-card .net-notice { margin: 0; }

.online-grid { display: grid; grid-template-columns: minmax(0, 380px) 1fr; gap: 18px; align-items: start; }
@media (max-width: 820px) { .online-grid { grid-template-columns: 1fr; } }
.online-create { display: flex; flex-direction: column; gap: 14px; }
.online-create h2, .panel-head h2 { font-size: 18px; margin: 0; }
.online-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.online-actions .btn { padding: 0 12px; font-size: 15px; }
.join-code { display: flex; gap: 8px; }
.join-code input { flex: 1; min-width: 0; height: 42px; text-transform: lowercase; }
.panel-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.panel-head .muted { font-size: 13px; }
.room-list { display: flex; flex-direction: column; gap: 6px; }
.room-row { display: flex; align-items: center; gap: 12px; padding: 10px; border-radius: 3px; background: var(--surface); border: 1px solid var(--border); animation: rise .35s var(--ease) both; }
.room-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.room-main span { font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.room-seats { display: inline-flex; align-items: center; gap: 4px; color: var(--muted); font-weight: 700; font-variant-numeric: tabular-nums; font-size: 13px; }

.room-card { width: min(560px, 100%); }
.invite { display: flex; gap: 8px; }
.invite input { flex: 1; min-width: 0; height: 42px; font-size: 13px; color: var(--muted); }
.seat-grid { display: grid; gap: 10px; }
.seat-grid.n2 { grid-template-columns: 1fr 1fr; }
.seat-grid.n4 { grid-template-columns: 1fr 1fr; }
.seat-card { display: flex; flex-direction: column; gap: 8px; padding: 12px; border-radius: 3px; border: 1px dashed var(--border-strong); min-height: 96px; }
.seat-card.taken { border-style: solid; background: var(--surface); }
.seat-card.me { border-color: color-mix(in srgb, var(--accent) 60%, transparent); background: var(--accent-soft); }
.seat-label { font-size: 11px; text-transform: uppercase; letter-spacing: .1em; font-weight: 700; color: var(--muted); }
.seat-who { display: flex; align-items: center; gap: 8px; font-size: 14px; min-width: 0; }
.seat-who b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.seat-card .btn { align-self: flex-start; }

.online-badge { margin-left: 10px; vertical-align: middle; font-family: var(--font); font-size: 11px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; padding: 3px 8px; border-radius: 999px; background: var(--accent-soft); color: #ff9fb2; }
.net-chip { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 700; color: var(--muted); white-space: nowrap; }
.net-dot { width: 8px; height: 8px; border-radius: 50%; background: #666; flex: none; }
.net-dot.ok { background: var(--good); box-shadow: 0 0 8px var(--good); }
.net-dot.warn { background: #ffb020; box-shadow: 0 0 8px #ffb020; animation: blink 1s ease-in-out infinite; }
@keyframes blink { 50% { opacity: .35; } }
.net-banner {
  display: flex; align-items: center; justify-content: center; gap: 12px; flex-wrap: wrap;
  padding: 8px 14px; font-size: 13.5px; text-align: center;
  background: rgba(255, 176, 32, .1); border-bottom: 1px solid rgba(255, 176, 32, .35); color: #ffe2a8;
}
.net-banner[hidden] { display: none; }
.play-bar { position: relative; }
.emote-pop {
  position: absolute; z-index: 80; top: calc(100% + 6px); right: 12px; display: flex; flex-wrap: wrap; gap: 6px; max-width: 260px;
  padding: 8px; border-radius: 3px; background: #111114; border: 1px solid var(--border-strong); box-shadow: var(--shadow);
  animation: pop .2s var(--ease);
}
.emote-pop button { border: 0; background: var(--surface-2); color: var(--text); border-radius: 3px; padding: 6px 10px; font-size: 16px; cursor: pointer; }
.emote-pop button:hover { background: var(--surface-3); }
@media (max-width: 720px) {
  .net-chip span:last-child { display: none; }
  .online-badge { display: none; }
}

/* ===== Friends ===== */
.nav-link { position: relative; }
.nav-badge { position: absolute; top: 2px; right: 4px; min-width: 17px; height: 17px; padding: 0 5px; border-radius: 3px; background: var(--accent); color: #fff; font-size: 11px; font-style: normal; font-weight: 800; line-height: 17px; text-align: center; }
.tabbar .nav-badge { right: calc(50% - 26px); }
.friend-list { display: flex; flex-direction: column; gap: 6px; margin-top: 6px; }
.friend-row { display: flex; align-items: center; gap: 12px; padding: 10px; border-radius: 3px; background: var(--surface); border: 1px solid var(--border); }
.friend-who { flex: 1; min-width: 0; display: flex; align-items: center; gap: 12px; }
.friend-who > div { min-width: 0; display: flex; flex-direction: column; }
.friend-who b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.friend-who .muted { font-size: 12.5px; }
.av-wrap { position: relative; flex: none; }
.av-wrap .net-dot { position: absolute; right: -1px; bottom: -1px; width: 12px; height: 12px; border: 2px solid #000; }
.friend-actions { display: flex; align-items: center; gap: 6px; flex: none; }
.friend-search { display: flex; align-items: center; gap: 10px; margin: 8px 0; color: var(--muted); }
.friend-search input { flex: 1; }
h3.sub { font-size: 13px; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); margin: 16px 0 6px; }
.invite { flex-wrap: wrap; }
.lb-table.with-rating .lb-row { grid-template-columns: 48px 1fr 80px 80px 70px 70px 110px; }
.lb-row .rating { color: #ffd0d9; }
@media (max-width: 600px) {
  .lb-table.with-rating .lb-row { grid-template-columns: 36px 1fr 60px 56px 48px; }
}
button.tab { background: transparent; cursor: pointer; font: inherit; font-weight: 600; }
button.tab.active { background: var(--text); }

/* ===== Lobby ===== */
.lobby-grid { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.lobby-chat { display: flex; flex-direction: column; gap: 10px; min-height: 460px; }
.lobby-chat h3, .lobby-side h3 { display: flex; align-items: center; gap: 6px; font-size: 15px; margin: 0 0 4px; }
.lobby-msgs { flex: 1; display: flex; flex-direction: column; gap: 10px; height: 52dvh; min-height: 300px; overflow-y: auto; padding: 4px 2px; }
.lobby-msg { display: grid; grid-template-columns: 28px 1fr auto; gap: 8px; align-items: start; }
.lobby-msg p { margin: 2px 0 0; overflow-wrap: anywhere; }
.lobby-msg.me b { color: var(--accent); }
.lobby-empty { text-align: center; margin: auto; }
.lobby-form { display: flex; gap: 8px; }
.lobby-input { flex: 1; min-width: 0; height: 42px; padding: 0 14px; border-radius: 3px; border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); font: inherit; }
.lobby-note { margin: 0; color: #ffc861; font-size: 13px; }
.lobby-side { display: flex; flex-direction: column; gap: 16px; }
.lobby-games { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.lobby-game { --accent-g: var(--accent); display: flex; flex-direction: column; gap: 2px; padding: 10px 12px; border-radius: 3px; border: 1px solid var(--border); background: var(--surface); cursor: pointer; text-align: left; transition: border-color .2s, box-shadow .2s; }
.lobby-game:hover { border-color: var(--accent-g); }
.lobby-game small { color: var(--muted); font-size: 12px; }
.lobby-game.on { border-color: var(--accent-g); box-shadow: 0 0 0 1px var(--accent-g), 0 0 24px -8px var(--accent-g); animation: ee-blink 1.4s ease-in-out infinite; }
.lobby-online { display: flex; flex-direction: column; gap: 8px; max-height: 40dvh; overflow-y: auto; }
.lobby-user { display: flex; align-items: center; gap: 8px; font-size: 14px; flex-wrap: wrap; }
.lobby-tag { color: var(--good); font-size: 12px; }
@keyframes ee-blink { 50% { opacity: .65; } }
@media (max-width: 820px) { .lobby-grid { grid-template-columns: 1fr; } .lobby-msgs { height: 45dvh; } }

/* ===== Install as an app ===== */
.install-banner { display: flex; align-items: center; gap: 12px; padding: 12px 14px; margin: 0 0 18px; border-radius: 3px; background: linear-gradient(90deg, rgba(255,77,94,.14), rgba(255,77,94,.04)); border: 1px solid rgba(255,77,94,.35); }
.install-banner[hidden] { display: none; }
.install-banner img { border-radius: 3px; flex: none; }
.install-banner div { flex: 1; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.install-steps { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 8px; line-height: 1.45; }
.install-ico { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 6px; background: #2a2a33; font-size: 13px; }

/* ===== Administration ===== */
.adm-stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px; margin-bottom: 18px; }
.adm-card { display: flex; flex-direction: column; gap: 2px; padding: 14px 16px; border-radius: 3px; background: var(--surface, #141418); border: 1px solid var(--border, #2a2a33); }
.adm-card b { font-size: 26px; font-family: var(--font-display); }
.adm-card span { font-size: 13px; color: var(--muted, #9a9aa6); }
.adm-grid { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 18px; align-items: start; }
.adm-side .panel { margin-bottom: 18px; }
.adm-table { overflow-x: auto; margin-top: 12px; }
.adm-table table { width: 100%; border-collapse: collapse; font-size: 14px; }
.adm-table th { text-align: left; font-weight: 600; color: var(--muted, #9a9aa6); font-size: 12px; padding: 6px 8px; }
.adm-table td { padding: 8px; border-top: 1px solid var(--border, #2a2a33); white-space: nowrap; }
.adm-table tr.banned td { opacity: .6; }
.adm-dot { color: #3ecf8e; margin-left: 6px; }
.adm-report { padding: 12px 0; border-top: 1px solid var(--border, #2a2a33); display: flex; flex-direction: column; gap: 6px; }
.adm-report:first-child { border-top: 0; padding-top: 0; }
.adm-report blockquote, .lobby-quote { margin: 0; padding: 8px 12px; border-left: 3px solid #ff4d5e; background: rgba(255,255,255,.04); border-radius: 0 8px 8px 0; }
.adm-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.adm-form { display: flex; flex-direction: column; gap: 10px; }
.adm-online { display: flex; flex-direction: column; gap: 6px; max-height: 260px; overflow-y: auto; }
.lobby-report { margin-left: auto; align-self: flex-start; background: none; border: 0; color: var(--muted, #9a9aa6); cursor: pointer; opacity: 0; font-size: 14px; padding: 2px 6px; }
.lobby-msg:hover .lobby-report, .lobby-report:focus { opacity: .8; }
@media (hover: none) { .lobby-report { opacity: .5; } }
@media (max-width: 860px) { .adm-grid { grid-template-columns: 1fr; } }

/* ===== Full screen (focus mode): only the game; the bar slides in from the handle ===== */
.fs-grab { display: none; }
body.focus-mode .app-header { display: none; }
body.focus-mode .play { position: relative; height: 100dvh; padding-top: max(14px, env(safe-area-inset-top)); background: #000; }
body.focus-mode .play-bar {
  position: absolute; z-index: 120; top: 0; left: 0; right: 0;
  padding-top: max(8px, env(safe-area-inset-top));
  transform: translateY(-100%); transition: transform .25s var(--ease);
  box-shadow: 0 10px 30px rgba(0,0,0,.6);
}
body.focus-mode .play.bar-open .play-bar { transform: none; }
body.focus-mode .fs-grab {
  display: grid; place-items: center; position: absolute; z-index: 110; top: max(0px, calc(env(safe-area-inset-top) - 14px)); left: 50%; transform: translateX(-50%);
  width: 76px; height: 14px; padding: 0; border: 0; background: none; cursor: pointer;
}
.fs-grab i { display: block; width: 44px; height: 5px; border-radius: 3px; background: rgba(255,255,255,.35); transition: background .2s; }
.fs-grab:hover i, .fs-grab:focus-visible i { background: rgba(255,255,255,.7); }
/* long game names stay on one line in the game bar */
.play-title { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 720px) { .play-title { font-size: 17px; } .play-bar { gap: 4px; } .clock { padding: 0 2px; } }
