:root {
  color-scheme: dark;
  --bg: #0b0e1d;
  --surface: rgba(24, 29, 56, .86);
  --surface-2: #202746;
  --surface-3: #2a3154;
  --text: #f8f8ff;
  --muted: #aeb5d3;
  --primary: #8d7cff;
  --primary-2: #c57dff;
  --accent: #ff7ba7;
  --good: #65d5a0;
  --warn: #ffca70;
  --danger: #ff6f78;
  --border: rgba(255,255,255,.1);
  --shadow: 0 20px 70px rgba(0,0,0,.28);
  --radius: 24px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; }
html, body { margin:0; min-height:100%; background: radial-gradient(circle at 10% -10%, #30265a 0, transparent 38%), radial-gradient(circle at 100% 0, #391f46 0, transparent 32%), var(--bg); color:var(--text); font: 16px/1.45 system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif; }
body { padding-bottom: calc(82px + var(--safe-bottom)); }
button, input, select { font:inherit; }
button { color:inherit; }
button:focus-visible, input:focus-visible { outline:3px solid rgba(141,124,255,.35); outline-offset:2px; }
.offline-bar { position:sticky; top:0; z-index:50; padding:8px 16px; text-align:center; background:#7a5d1d; font-size:.82rem; }
.topbar { position:sticky; top:0; z-index:30; min-height:76px; display:flex; align-items:center; justify-content:space-between; padding:14px max(18px, env(safe-area-inset-right)) 12px max(18px, env(safe-area-inset-left)); backdrop-filter: blur(18px); background:linear-gradient(to bottom, rgba(11,14,29,.94), rgba(11,14,29,.64)); }
.brand { border:0; background:none; display:flex; align-items:center; gap:11px; padding:0; text-align:left; cursor:pointer; }
.brand-mark { width:42px; height:42px; display:grid; place-items:center; border-radius:15px; background:linear-gradient(135deg,var(--accent),var(--primary)); box-shadow:0 8px 26px rgba(141,124,255,.3); }
.brand strong, .brand small { display:block; }
.brand strong { font-size:1.02rem; letter-spacing:-.02em; }
.brand small { color:var(--muted); font-size:.72rem; }
.top-actions { display:flex; align-items:center; gap:10px; }
.pill { display:inline-flex; align-items:center; gap:7px; border:1px solid var(--border); border-radius:999px; padding:7px 10px; color:var(--muted); font-size:.75rem; background:rgba(255,255,255,.04); }
.pill i { width:7px; height:7px; border-radius:50%; background:var(--good); box-shadow:0 0 0 4px rgba(101,213,160,.1); }
.pill.offline i { background:var(--warn); }
.icon-btn { width:42px; height:42px; border:1px solid var(--border); background:var(--surface); border-radius:15px; cursor:pointer; }
.app-shell { width:min(1100px,100%); margin:0 auto; padding:8px 18px 34px; }
.hero { overflow:hidden; position:relative; border:1px solid var(--border); border-radius:32px; padding:28px; background:linear-gradient(135deg,rgba(141,124,255,.25),rgba(255,123,167,.13)),var(--surface); box-shadow:var(--shadow); }
.hero::after { content:""; position:absolute; width:240px; height:240px; right:-90px; top:-100px; border-radius:50%; background:radial-gradient(circle,rgba(255,255,255,.16),transparent 65%); }
.hero-kicker { color:#d6d1ff; text-transform:uppercase; letter-spacing:.13em; font-size:.7rem; font-weight:800; }
.hero h1 { max-width:650px; margin:8px 0 10px; font-size:clamp(2rem,6vw,3.6rem); line-height:1.02; letter-spacing:-.055em; }
.hero p { max-width:620px; margin:0; color:#d0d4e7; }
.hero-actions { display:flex; flex-wrap:wrap; gap:10px; margin-top:22px; }
.btn { min-height:46px; border:0; border-radius:15px; padding:11px 17px; font-weight:750; cursor:pointer; background:var(--surface-3); }
.btn.primary { background:linear-gradient(135deg,var(--primary),var(--primary-2)); box-shadow:0 10px 28px rgba(141,124,255,.24); }
.btn.secondary { border:1px solid var(--border); background:rgba(255,255,255,.06); }
.btn.ghost { background:transparent; color:var(--muted); }
.btn.danger { background:rgba(255,111,120,.14); color:#ffd5d8; }
.btn:disabled { opacity:.45; cursor:not-allowed; }
.section-head { display:flex; justify-content:space-between; align-items:end; gap:16px; margin:28px 2px 14px; }
.section-head h2 { margin:0; font-size:1.25rem; letter-spacing:-.025em; }
.section-head p { margin:3px 0 0; color:var(--muted); font-size:.88rem; }
.text-btn { border:0; background:none; color:#c9c2ff; cursor:pointer; }
.game-grid { display:grid; grid-template-columns:repeat(4,1fr); gap:14px; }
.game-card { min-height:210px; position:relative; overflow:hidden; border:1px solid var(--border); border-radius:24px; padding:18px; background:var(--surface); box-shadow:0 12px 36px rgba(0,0,0,.16); display:flex; flex-direction:column; cursor:pointer; transition:.18s ease; }
.game-card:hover { transform:translateY(-3px); border-color:rgba(141,124,255,.42); }
.game-card .game-icon { width:58px; height:58px; display:grid; place-items:center; font-size:1.65rem; border-radius:19px; background:linear-gradient(135deg,rgba(141,124,255,.28),rgba(255,123,167,.16)); }
.game-card h3 { margin:18px 0 5px; font-size:1.15rem; }
.game-card p { margin:0; color:var(--muted); font-size:.85rem; }
.game-card footer { margin-top:auto; display:flex; justify-content:space-between; align-items:center; color:#d8d3ff; font-size:.82rem; }
.badge { display:inline-flex; align-items:center; gap:6px; border:1px solid var(--border); border-radius:999px; padding:5px 8px; color:var(--muted); font-size:.72rem; }
.mode-grid { display:grid; grid-template-columns:repeat(3,1fr); gap:12px; }
.mode-card { border:1px solid var(--border); border-radius:20px; padding:17px; background:rgba(255,255,255,.04); cursor:pointer; text-align:left; }
.mode-card strong { display:block; margin:8px 0 4px; }
.mode-card small { color:var(--muted); }
.panel { border:1px solid var(--border); border-radius:24px; padding:20px; background:var(--surface); box-shadow:0 12px 40px rgba(0,0,0,.14); }
.panel + .panel { margin-top:14px; }
.panel h2,.panel h3 { margin-top:0; }
.form-grid { display:grid; gap:12px; }
.field label { display:block; margin:0 0 6px 2px; color:var(--muted); font-size:.8rem; }
.input { width:100%; min-height:48px; border:1px solid var(--border); border-radius:14px; padding:10px 13px; background:#10152b; color:var(--text); }
.two-col { display:grid; grid-template-columns:1fr 1fr; gap:14px; }
.auth-wrap { width:min(520px,100%); margin:26px auto; }
.notice { border-left:3px solid var(--primary); padding:12px 14px; border-radius:12px; background:rgba(141,124,255,.1); color:#dedaff; }
.list { display:grid; gap:10px; }
.list-item { display:flex; align-items:center; gap:13px; border:1px solid var(--border); border-radius:17px; padding:13px; background:rgba(255,255,255,.035); cursor:pointer; }
.list-item .grow { flex:1; min-width:0; }
.list-item strong,.list-item small { display:block; }
.list-item small { color:var(--muted); white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.status-dot { width:11px; height:11px; border-radius:50%; background:var(--warn); }
.status-dot.active { background:var(--good); }
.status-dot.finished { background:var(--muted); }
.game-screen { display:grid; gap:14px; }
.game-toolbar { display:flex; justify-content:space-between; align-items:center; gap:12px; }
.turn { display:flex; align-items:center; gap:9px; color:var(--muted); }
.turn b { color:var(--text); }
.board-wrap { display:grid; place-items:center; min-height:360px; border:1px solid var(--border); border-radius:28px; padding:20px; background:linear-gradient(180deg,rgba(255,255,255,.04),rgba(255,255,255,.01)); }
.ttt-info { margin-bottom:12px; color:var(--muted); font-size:.82rem; text-align:center; }
.ttt-board { width:min(92vw,var(--ttt-max,360px)); aspect-ratio:1; display:grid; grid-template-columns:repeat(var(--ttt-size,3),1fr); gap:clamp(3px,.9vw,9px); }
.ttt-cell { min-width:0; padding:0; border:1px solid var(--border); border-radius:clamp(6px,2.5vw,20px); background:var(--surface-2); font-size:var(--ttt-font,4rem); font-weight:850; cursor:pointer; }
.ttt-cell.x { color:#b8adff; } .ttt-cell.o { color:#ff9abc; }
.c4-board { width:min(92vw,520px); aspect-ratio:7/6; display:grid; grid-template-columns:repeat(7,1fr); gap:6px; padding:10px; border-radius:22px; background:#3b4380; }
.c4-cell { border:0; border-radius:50%; background:#11162d; cursor:pointer; box-shadow:inset 0 5px 10px rgba(0,0,0,.35); }
.c4-cell.p1 { background:#a69bff; } .c4-cell.p2 { background:#ff87ad; }
.hangman-word { font-size:clamp(1.7rem,8vw,3.2rem); letter-spacing:.16em; text-align:center; overflow-wrap:anywhere; }
.keyboard { display:grid; grid-template-columns:repeat(auto-fit,minmax(42px,1fr)); gap:7px; width:min(720px,100%); margin:20px auto 0; }
.keyboard button { min-height:44px; border:1px solid var(--border); border-radius:12px; background:var(--surface-2); }
.keyboard button:disabled { opacity:.25; }
.sea-layout { display:grid; grid-template-columns:1fr 1fr; gap:16px; width:100%; }
.sea h4 { text-align:center; margin:0 0 8px; color:var(--muted); }
.sea-grid { display:grid; grid-template-columns:repeat(var(--sea-size,8),1fr); gap:3px; aspect-ratio:1; }
.sea-cell { min-width:0; border:1px solid rgba(255,255,255,.08); border-radius:5px; padding:0; background:#17284a; }
.sea-cell.ship { background:#77809a; }.sea-cell.hit{background:#ff6f78}.sea-cell.miss{background:#496383}.sea-cell.target{cursor:crosshair}

.game-settings { margin-top:20px; padding:16px; border:1px solid var(--border); border-radius:20px; background:rgba(255,255,255,.025); }
.game-settings h3 { margin:0 0 4px; }
.settings-row { display:grid; grid-template-columns:1fr 1fr; gap:12px; margin-top:14px; }
.input-help { display:flex; justify-content:space-between; gap:12px; margin:6px 2px 0; color:var(--muted); font-size:.75rem; }
.fleet-setup { width:min(780px,100%); display:grid; grid-template-columns:minmax(220px,.85fr) minmax(280px,1.15fr); gap:18px; align-items:center; }
.fleet-copy { align-self:stretch; padding:4px; }
.fleet-progress { display:flex; flex-wrap:wrap; gap:7px; margin:16px 0; }
.ship-chip { border:1px solid var(--border); border-radius:999px; padding:6px 10px; color:var(--muted); font-size:.78rem; }
.ship-chip.current { color:#fff; border-color:rgba(141,124,255,.65); background:rgba(141,124,255,.18); }
.ship-chip.done { color:#bff2d8; border-color:rgba(101,213,160,.45); background:rgba(101,213,160,.1); }
.fleet-tools { display:flex; flex-wrap:wrap; gap:8px; }
.placement-hint { margin-top:15px; color:#dedaff; }
.placement-hint.ready { color:#bff2d8; }
.placement-sea { width:100%; }
.sea-cell.placement { cursor:pointer; transition:.12s ease; }
.sea-cell.placement:hover { transform:scale(.96); border-color:rgba(255,255,255,.3); }
.sea-cell.placement.ship { background:linear-gradient(135deg,#8c96b3,#68728e); box-shadow:inset 0 0 0 1px rgba(255,255,255,.12); }
.confirm-fleet { grid-column:1/-1; width:100%; }
.qr-layout { display:grid; grid-template-columns:1fr 1fr; gap:16px; }
.qr-box { min-height:280px; display:grid; place-items:center; padding:16px; border-radius:20px; background:white; color:#111; }
.qr-box canvas,.qr-box img { max-width:100%; height:auto!important; }
.video-wrap { position:relative; overflow:hidden; border-radius:20px; background:#05060b; aspect-ratio:4/3; }
.video-wrap video { width:100%; height:100%; object-fit:cover; }
.pass-screen { min-height:420px; display:grid; place-items:center; text-align:center; }
.pass-screen .big { font-size:4rem; }
.modal { width:min(620px,calc(100% - 28px)); border:1px solid var(--border); border-radius:25px; padding:0; color:var(--text); background:#13172c; box-shadow:var(--shadow); }
.modal::backdrop { background:rgba(0,0,0,.72); backdrop-filter:blur(5px); }
#modalBody { padding:22px; }
.modal-actions { display:flex; justify-content:flex-end; flex-wrap:wrap; gap:9px; margin-top:18px; }
.toast { position:fixed; left:50%; bottom:calc(92px + var(--safe-bottom)); z-index:80; transform:translateX(-50%); max-width:calc(100% - 30px); padding:11px 15px; border:1px solid var(--border); border-radius:14px; background:#272d4d; box-shadow:var(--shadow); }
.bottom-nav { position:fixed; left:50%; bottom:0; z-index:40; transform:translateX(-50%); width:min(760px,100%); display:grid; grid-template-columns:repeat(4,1fr); padding:8px 10px calc(8px + var(--safe-bottom)); border:1px solid var(--border); border-bottom:0; border-radius:24px 24px 0 0; background:rgba(17,20,42,.92); backdrop-filter:blur(22px); }
.bottom-nav button { border:0; background:none; color:var(--muted); padding:5px; font-size:.72rem; cursor:pointer; }
.bottom-nav span { display:block; font-size:1.25rem; line-height:1.15; }
.bottom-nav button.active { color:#e3dfff; }
.empty { padding:38px 20px; text-align:center; color:var(--muted); }
hr { border:0; border-top:1px solid var(--border); margin:18px 0; }
code { background:rgba(255,255,255,.08); padding:.15em .35em; border-radius:6px; }
.light { color:var(--muted); }
@media (max-width:820px){.game-grid{grid-template-columns:1fr 1fr}.sea-layout,.qr-layout{grid-template-columns:1fr}.mode-grid{grid-template-columns:1fr}.hero{padding:24px}.two-col{grid-template-columns:1fr}.sea-layout{width:min(560px,100%)}.fleet-setup{grid-template-columns:1fr}.placement-sea{width:min(560px,100%);margin:auto}.settings-row{grid-template-columns:1fr 1fr}}
@media (max-width:470px){.game-grid{grid-template-columns:1fr}.game-card{min-height:170px}.pill span{display:none}.topbar{min-height:68px}.app-shell{padding-left:14px;padding-right:14px}.hero h1{font-size:2.2rem}.board-wrap{padding:12px;min-height:330px}.ttt-cell{border-radius:8px}.game-toolbar{align-items:flex-start;flex-direction:column}.brand small{display:none}.settings-row{grid-template-columns:1fr}.fleet-tools .btn{flex:1 1 calc(50% - 8px);padding-left:10px;padding-right:10px}}
