/* Pinball — app styles */
:root {
  --bg: #0b0816;
  --bg2: #140f27;
  --card: #18122e;
  --card2: #201840;
  --line: #2d2452;
  --ink: #f1ecff;
  --dim: #9d95bf;
  --acc: #ff9a3c;
  --acc2: #ff3d8b;
  --cool: #35e0ff;
  --good: #3ddc97;
  --bad: #ff5d73;
  --r: 18px;
  --display: "Arial Black", "Impact", "Haettenschweiler", system-ui, sans-serif;
  --sans: system-ui, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.5 var(--sans); -webkit-tap-highlight-color: transparent; }
body { min-height: 100vh; background:
  radial-gradient(900px 500px at 15% -10%, rgba(255, 61, 139, .16), transparent 60%),
  radial-gradient(900px 600px at 95% 0%, rgba(53, 224, 255, .12), transparent 60%),
  var(--bg); }
a { color: var(--acc); text-decoration: none; }
button { font: inherit; color: inherit; }
[hidden] { display: none !important; }
#app { min-height: 100vh; display: flex; flex-direction: column; }

/* ---- top bar ---- */
.bar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 18px; padding: calc(10px + var(--safe-t)) 18px 10px; background: rgba(11, 8, 22, .78); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); border-bottom: 1px solid rgba(255,255,255,.06); }
.logo { display: flex; align-items: center; gap: 10px; color: var(--ink); font: 900 18px/1 var(--display); letter-spacing: 1px; white-space: nowrap; }
.logo-ball { width: 22px; height: 22px; border-radius: 50%; background: radial-gradient(circle at 35% 30%, #fff, #c9ced6 35%, #59606a 85%); box-shadow: 0 0 0 3px rgba(255,154,60,.35), 0 0 18px rgba(255,154,60,.5); }
.nav { display: flex; gap: 4px; margin-left: 8px; }
.nav a { color: var(--dim); padding: 8px 12px; border-radius: 999px; font-weight: 700; font-size: 14px; }
.nav a.on, .nav a:hover { color: var(--ink); background: rgba(255,255,255,.07); }
.who { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.chip { display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px 6px 6px; border-radius: 999px; background: var(--card); border: 1px solid var(--line); color: var(--ink); font-weight: 700; font-size: 14px; cursor: pointer; }
.avatar { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; font: 900 12px var(--display); color: #160b00; background: linear-gradient(135deg, var(--acc), var(--acc2)); }
@media (max-width: 720px) {
  .bar { flex-wrap: wrap; gap: 8px 12px; padding-bottom: 6px; }
  .logo-text { display: none; }
  .nav { order: 3; width: 100%; margin: 0; justify-content: space-between; }
  .nav a { flex: 1; text-align: center; }
}

/* ---- buttons ---- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 0; cursor: pointer; border-radius: 999px; padding: 12px 22px; font-weight: 800; font-size: 15px; background: var(--card2); color: var(--ink); border: 1px solid var(--line); transition: transform .12s, box-shadow .2s, background .2s; }
.btn:hover { background: #2a2052; }
.btn:active { transform: scale(.97); }
.btn.primary { background: linear-gradient(135deg, #ffb35c, var(--acc) 45%, #ff6a3d); color: #1a0d00; border: 0; box-shadow: 0 8px 30px -8px rgba(255,154,60,.7); }
.btn.primary:hover { box-shadow: 0 10px 38px -6px rgba(255,154,60,.9); }
.btn.big { padding: 16px 30px; font-size: 18px; }
.btn.ghost { background: transparent; }
.btn.small { padding: 7px 14px; font-size: 13px; }
.btn.danger { color: var(--bad); border-color: rgba(255,93,115,.4); }
.btn[disabled] { opacity: .5; cursor: default; }
.linkish { background: none; border: 0; color: var(--acc); cursor: pointer; padding: 0; font-weight: 700; }

/* ---- layout ---- */
.view { flex: 1; width: 100%; max-width: 1180px; margin: 0 auto; padding: 22px 18px 40px; }
h1, h2, h3 { font-family: var(--display); letter-spacing: .5px; margin: 0; line-height: 1.1; }
h1 { font-size: clamp(30px, 6vw, 56px); }
h2 { font-size: 24px; margin-bottom: 14px; }
.dim { color: var(--dim); }
.foot { text-align: center; color: var(--dim); font-size: 13px; padding: 18px 12px calc(18px + var(--safe-b)); border-top: 1px solid rgba(255,255,255,.05); }
.foot a { color: var(--dim); text-decoration: underline; }

/* ---- home ---- */
.hero { display: grid; grid-template-columns: 1.1fr 1fr; gap: 28px; align-items: center; min-height: 62vh; }
.hero-copy .kicker { color: var(--acc); font-weight: 900; letter-spacing: 3px; font-size: 13px; text-transform: uppercase; }
.hero-copy h1 { margin: 10px 0 14px; }
.hero-copy h1 em { font-style: normal; background: linear-gradient(90deg, var(--acc), var(--acc2), var(--cool)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.hero-copy p { color: var(--dim); font-size: 17px; max-width: 520px; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 12px; margin: 24px 0 18px; }
.hero-stage { position: relative; height: min(70vh, 640px); border-radius: 28px; overflow: hidden; border: 1px solid var(--line); box-shadow: 0 30px 80px -30px rgba(0,0,0,.8), 0 0 0 1px rgba(255,255,255,.03) inset; }
.hero-stage canvas { width: 100%; height: 100%; display: block; }
.hero-stage .stage-label { position: absolute; left: 14px; bottom: 14px; padding: 8px 14px; border-radius: 999px; background: rgba(0,0,0,.55); backdrop-filter: blur(6px); font-weight: 800; font-size: 13px; }
.stats { display: flex; gap: 22px; flex-wrap: wrap; color: var(--dim); font-size: 14px; }
.stats b { display: block; color: var(--ink); font: 900 24px var(--display); }
.controls-help { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; margin-top: 34px; }
.ch { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 16px 18px; }
.ch h3 { font-size: 15px; margin-bottom: 8px; color: var(--acc); }
.ch p { margin: 0; color: var(--dim); font-size: 14px; }
kbd { display: inline-block; min-width: 24px; padding: 1px 7px; border-radius: 6px; border: 1px solid var(--line); border-bottom-width: 3px; background: #0f0b1f; font: 700 12px var(--sans); color: var(--ink); text-align: center; }
@media (max-width: 860px) { .hero { grid-template-columns: 1fr; min-height: 0; } .hero-stage { height: 56vh; order: -1; } }

/* ---- tables gallery ---- */
.gal-head { display: flex; align-items: end; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; }
.tab { padding: 8px 14px; border-radius: 999px; background: var(--card); border: 1px solid var(--line); color: var(--dim); font-weight: 700; font-size: 13px; cursor: pointer; }
.tab.on { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 16px; }
.card { position: relative; background: var(--card); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; display: flex; flex-direction: column; transition: transform .18s, border-color .2s, box-shadow .2s; }
.card:hover { transform: translateY(-3px); border-color: #4a3d82; box-shadow: 0 20px 40px -20px rgba(0,0,0,.8); }
.thumb { position: relative; aspect-ratio: 600 / 820; background: #000; overflow: hidden; cursor: pointer; }
.thumb canvas { width: 100%; height: 100%; display: block; object-fit: cover; object-position: top; }
.thumb::after { content: ''; position: absolute; inset: 0; background: linear-gradient(180deg, transparent 55%, rgba(0,0,0,.75)); pointer-events: none; }
.thumb .play-ov { position: absolute; inset: 0; display: grid; place-items: center; opacity: 0; transition: opacity .2s; z-index: 2; }
.thumb:hover .play-ov { opacity: 1; }
.play-ov span { background: var(--acc); color: #1a0d00; font-weight: 900; padding: 10px 18px; border-radius: 999px; box-shadow: 0 8px 26px rgba(0,0,0,.5); }
.badge { position: absolute; z-index: 3; top: 10px; left: 10px; padding: 4px 10px; border-radius: 999px; font: 900 11px var(--sans); letter-spacing: 1px; background: var(--acc2); color: #fff; }
.badge.unplayed { background: var(--cool); color: #001a20; }
.fav { position: absolute; z-index: 3; top: 8px; right: 8px; width: 36px; height: 36px; border-radius: 50%; border: 0; background: rgba(0,0,0,.55); color: #fff; font-size: 18px; cursor: pointer; display: grid; place-items: center; }
.fav.on { color: #ffd23f; text-shadow: 0 0 10px rgba(255,210,63,.8); }
.card-body { padding: 12px 14px 14px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.card-title { font: 900 16px var(--display); letter-spacing: .3px; }
.card-line { display: flex; justify-content: space-between; gap: 8px; font-size: 13px; color: var(--dim); }
.card-line b { color: var(--ink); font-variant-numeric: tabular-nums; }
.crown { color: #ffd23f; }
.card-actions { display: flex; gap: 6px; margin-top: auto; padding-top: 6px; }
.card-actions .btn { flex: 1; }
.empty { text-align: center; color: var(--dim); padding: 50px 10px; background: var(--card); border-radius: var(--r); border: 1px dashed var(--line); }

/* ---- leaderboard ---- */
.lb-wrap { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
@media (max-width: 860px) { .lb-wrap { grid-template-columns: 1fr; } }
.panel { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 18px; }
table.lb { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.lb th { text-align: left; font-size: 11px; letter-spacing: 1.5px; color: var(--dim); text-transform: uppercase; padding: 6px 8px; }
.lb td { padding: 10px 8px; border-top: 1px solid rgba(255,255,255,.05); }
.lb td.n { text-align: right; font-weight: 800; }
.lb tr.me td { background: rgba(255,154,60,.09); }
.rank { width: 30px; height: 30px; border-radius: 50%; display: inline-grid; place-items: center; font: 900 13px var(--display); background: var(--card2); }
.rank.r1 { background: linear-gradient(135deg, #ffe58a, #e0a100); color: #2b1d00; }
.rank.r2 { background: linear-gradient(135deg, #f1f1f1, #9aa0a6); color: #222; }
.rank.r3 { background: linear-gradient(135deg, #f0b27a, #a0522d); color: #2b1100; }
select.sel, input.inp { width: 100%; padding: 11px 13px; border-radius: 12px; border: 1px solid var(--line); background: #0f0b1f; color: var(--ink); font: inherit; }
input.inp:focus, select.sel:focus { outline: 2px solid var(--acc); border-color: transparent; }
.champ { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-top: 1px solid rgba(255,255,255,.05); font-size: 14px; }
.champ .t { flex: 1; color: var(--dim); }
.champ b { font-variant-numeric: tabular-nums; }

/* ---- forms / modal ---- */
.modal-back { position: fixed; inset: 0; z-index: 100; background: rgba(5, 3, 12, .72); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); display: grid; place-items: center; padding: 18px; animation: fade .2s; }
.modal { position: relative; width: 100%; max-width: 440px; max-height: calc(100vh - 36px); overflow: auto; background: linear-gradient(180deg, #1d1638, #140f27); border: 1px solid var(--line); border-radius: 24px; padding: 26px 24px 22px; box-shadow: 0 40px 100px -20px rgba(0,0,0,.9); animation: pop .25s cubic-bezier(.2, 1.4, .4, 1); }
.modal.wide { max-width: 640px; }
.modal h2 { margin: 0 0 6px; }
.modal p { color: var(--dim); margin: 0 0 16px; }
.modal .x { position: absolute; top: 12px; right: 12px; width: 34px; height: 34px; border-radius: 50%; border: 0; background: rgba(255,255,255,.07); color: var(--dim); cursor: pointer; font-size: 18px; }
.field { margin-bottom: 12px; }
.field label { display: block; font-size: 12px; font-weight: 700; color: var(--dim); margin-bottom: 5px; letter-spacing: .5px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.row.end { justify-content: flex-end; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.msg { padding: 10px 14px; border-radius: 12px; font-size: 14px; margin-bottom: 12px; }
.msg.err { background: rgba(255,93,115,.12); border: 1px solid rgba(255,93,115,.4); color: #ffc2cb; }
.msg.ok { background: rgba(61,220,151,.1); border: 1px solid rgba(61,220,151,.4); color: #b8f5d9; }
.sep { text-align: center; color: var(--dim); font-size: 13px; margin: 6px 0; }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { transform: scale(.92) translateY(10px); opacity: 0; } }

/* news modal */
.news-burst { font: 900 64px/1 var(--display); background: linear-gradient(90deg, var(--acc), var(--acc2)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.news-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; margin: 16px 0; }
.news-item { border-radius: 14px; overflow: hidden; border: 1px solid var(--line); background: #000; cursor: pointer; position: relative; }
.news-item canvas { width: 100%; display: block; aspect-ratio: 600 / 820; }
.news-item span { position: absolute; left: 0; right: 0; bottom: 0; padding: 18px 8px 6px; font: 900 12px var(--display); background: linear-gradient(transparent, rgba(0,0,0,.85)); }

/* result modal */
.result-score { font: 900 46px/1 var(--display); font-variant-numeric: tabular-nums; margin: 6px 0 4px; }
.result-flags { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; margin: 10px 0 14px; }
.flag { padding: 6px 12px; border-radius: 999px; font-weight: 900; font-size: 12px; letter-spacing: 1px; background: var(--card2); }
.flag.gold { background: linear-gradient(135deg, #ffe58a, #e0a100); color: #2b1d00; }
.flag.pink { background: var(--acc2); color: #fff; }
.center { text-align: center; }

/* admin */
.adm-tabs { margin-bottom: 14px; }
.adm table { width: 100%; border-collapse: collapse; font-size: 14px; }
.adm td, .adm th { padding: 8px; border-top: 1px solid rgba(255,255,255,.05); text-align: left; }
.adm th { color: var(--dim); font-size: 11px; letter-spacing: 1px; text-transform: uppercase; border: 0; }
.scroll-x { overflow-x: auto; }
.switch { position: relative; width: 42px; height: 24px; border-radius: 999px; background: #3a3260; border: 0; cursor: pointer; }
.switch::after { content: ''; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: transform .2s; }
.switch.on { background: var(--good); }
.switch.on::after { transform: translateX(18px); }

/* ---- game layer ---- */
.game { position: fixed; inset: 0; z-index: 50; background: #000; touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; overscroll-behavior: none; }
.game canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.game-ui { position: absolute; top: calc(6px + var(--safe-t)); right: 6px; display: flex; gap: 8px; z-index: 3; }
.gbtn { width: 38px; height: 38px; border-radius: 50%; border: 1px solid rgba(255,255,255,.18); background: rgba(0,0,0,.5); color: #fff; font-size: 15px; cursor: pointer; backdrop-filter: blur(6px); }
.gbtn.off { opacity: .45; text-decoration: line-through; }
.gtouch { position: absolute; inset: 0; display: flex; z-index: 1; pointer-events: none; }
.gt { flex: 1; transition: background .08s; }
.gt.on { background: radial-gradient(circle at 50% 85%, rgba(255,255,255,.07), transparent 60%); }
.hint { position: absolute; left: 50%; bottom: calc(18px + var(--safe-b)); transform: translateX(-50%); z-index: 2; pointer-events: none; padding: 9px 16px; border-radius: 999px; background: rgba(0,0,0,.6); color: #fff; font-size: 13px; font-weight: 700; white-space: nowrap; opacity: 0; transition: opacity .4s; }
.hint.show { opacity: 1; }
body.playing { overflow: hidden; }

/* toast */
.toast { position: fixed; left: 50%; bottom: calc(24px + var(--safe-b)); transform: translate(-50%, 20px); z-index: 200; background: #241b47; border: 1px solid var(--line); padding: 12px 18px; border-radius: 14px; font-weight: 700; opacity: 0; pointer-events: none; transition: all .25s; max-width: 90vw; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

.prose { max-width: 720px; }
.prose p, .prose li { color: var(--dim); }
.prose h2 { margin-top: 24px; }
.spinner { width: 34px; height: 34px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--acc); animation: spin .8s linear infinite; margin: 50px auto; }
@keyframes spin { to { transform: rotate(360deg); } }
