:root {
  --bg: #0b0720; --panel: #17103a; --panel2: #221752; --ink: #f6f2ff; --dim: #b3a8d8;
  --pink: #ff5d8f; --gold: #ffd166; --teal: #3ee6c4; --orange: #ff9f5a;
  --font: "Fredoka", "Baloo 2", "Trebuchet MS", "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: radial-gradient(1200px 800px at 50% 0%, #2a1a66 0%, #120a30 55%, #070414 100%);
  color: var(--ink); font-family: var(--font); overflow: hidden;
  -webkit-user-select: none; user-select: none; -webkit-tap-highlight-color: transparent; touch-action: none;
}
#app { display: flex; height: 100%; justify-content: center; align-items: stretch; gap: 18px; padding: 10px 14px; }
.panel { width: 270px; flex: 0 0 270px; display: flex; flex-direction: column; gap: 12px; padding: 14px; align-self: center; max-height: 100%; overflow: auto;
  background: linear-gradient(180deg, rgba(40,26,96,.85), rgba(20,13,52,.85)); border: 1px solid rgba(255,255,255,.12); border-radius: 18px; box-shadow: 0 14px 40px rgba(0,0,0,.45); }
#stage { position: relative; flex: 0 0 auto; display: flex; flex-direction: column; align-items: center; justify-content: center; min-width: 0; height: 100%; }
#tableWrap { position: relative; flex: 1 1 0; min-height: 0; display: flex; align-items: center; justify-content: center; }
#table { position: absolute; left: 0; bottom: 0; transform-origin: 50% 100%; display: block; border-radius: 14px; box-shadow: 0 18px 60px rgba(0,0,0,.65), 0 0 0 2px rgba(255,255,255,.08); touch-action: none; }

.logo { display: flex; align-items: center; gap: 10px; font-size: 30px; font-weight: 700; color: var(--gold); line-height: 1; }
.logo img { width: 58px; height: 58px; }
.logo span, h1 span { color: var(--pink); }
.logo small { display: block; font-size: 12px; font-weight: 500; color: var(--dim); margin-top: 5px; letter-spacing: .5px; }
.lbl { font-size: 11px; letter-spacing: 2px; color: var(--dim); }
.display { background: #07040f; border: 2px solid #3a2a78; border-radius: 12px; padding: 10px 12px; box-shadow: inset 0 0 22px rgba(255,93,143,.18); }
.score { font-size: 38px; font-weight: 700; color: var(--gold); text-shadow: 0 0 14px rgba(255,209,102,.55); font-variant-numeric: tabular-nums; text-align: right; line-height: 1.15; white-space: nowrap; }
.display .row { display: flex; justify-content: space-between; font-size: 13px; color: var(--teal); margin-top: 2px; font-weight: 600; }
.msg { min-height: 62px; background: var(--panel2); border-radius: 12px; padding: 10px 12px; }
#msg { font-size: 18px; font-weight: 700; color: var(--pink); }
#msgSub { font-size: 13px; color: var(--ink); opacity: .9; margin-top: 2px; }
.goal { background: rgba(0,0,0,.25); border-radius: 12px; padding: 10px 12px; }
#hint { font-size: 14px; margin-top: 3px; color: var(--gold); font-weight: 600; }
.chips { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.chip { background: rgba(0,0,0,.28); border: 1px solid rgba(255,255,255,.1); border-radius: 10px; padding: 7px 9px; font-size: 12px; display: flex; flex-direction: column; gap: 2px; }
.chip b { color: var(--dim); font-weight: 600; letter-spacing: .5px; }
.chip span { font-size: 16px; font-weight: 700; color: var(--ink); }
.chip.on { border-color: var(--teal); box-shadow: 0 0 12px rgba(62,230,196,.35); }
.chip.on span { color: var(--teal); }

h1 { font-size: 46px; margin: 0; color: var(--gold); text-shadow: 0 4px 0 rgba(0,0,0,.35), 0 0 26px rgba(255,209,102,.4); }
h2 { margin: 0 0 6px; font-size: 26px; color: var(--gold); }
h3 { margin: 4px 0 6px; font-size: 13px; letter-spacing: 2px; text-transform: uppercase; color: var(--teal); }
.tag { margin: 2px 0 12px; color: var(--dim); }
.scores { list-style: none; margin: 0; padding: 0; counter-reset: r; font-size: 14px; }
.scores li { counter-increment: r; display: flex; gap: 8px; padding: 3px 6px; border-radius: 6px; font-variant-numeric: tabular-nums; }
.scores li::before { content: counter(r) "."; width: 20px; color: var(--dim); text-align: right; }
.scores li .n { flex: 1; text-align: left; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.scores li .s { color: var(--gold); font-weight: 600; }
.scores li.me { background: rgba(255,93,143,.25); outline: 1px solid var(--pink); }
.keys { list-style: none; margin: 0; padding: 0; font-size: 13px; color: var(--ink); display: flex; flex-direction: column; gap: 6px; text-align: left; }
kbd { display: inline-block; min-width: 22px; padding: 1px 6px; text-align: center; background: #2c1f66; border: 1px solid #5a47b0; border-bottom-width: 3px; border-radius: 6px; font-family: inherit; font-size: 12px; color: #fff; }
.btns { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 4px; }

button { font-family: inherit; cursor: pointer; border: 0; border-radius: 12px; color: #2a0f30; }
button.big { background: linear-gradient(180deg, #ffe08a, #ffb347); font-size: 22px; font-weight: 700; padding: 12px 34px; box-shadow: 0 5px 0 #b86a1c, 0 10px 24px rgba(0,0,0,.4); letter-spacing: 1px; }
button.big:active { transform: translateY(3px); box-shadow: 0 2px 0 #b86a1c; }
button.ghost { background: rgba(255,255,255,.08); color: var(--ink); border: 1px solid rgba(255,255,255,.2); padding: 8px 10px; font-size: 13px; font-weight: 600; }
button.ghost:hover { background: rgba(255,255,255,.16); }
button:focus-visible, input:focus-visible, select:focus-visible { outline: 3px solid var(--teal); outline-offset: 2px; }

.overlay { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; background: rgba(6,3,18,.72); backdrop-filter: blur(3px); z-index: 5; padding: 12px; }
.overlay[hidden] { display: none; }
.card { width: min(560px, 100%); max-height: 100%; overflow: auto; text-align: center; padding: 22px 22px 20px; border-radius: 20px;
  background: linear-gradient(180deg, #2c1c6c, #170f3c); border: 2px solid rgba(255,209,102,.45); box-shadow: 0 20px 60px rgba(0,0,0,.6); }
.card.small { width: min(400px, 100%); display: flex; flex-direction: column; gap: 12px; align-items: stretch; }
.cols { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; margin-top: 18px; text-align: left; }
.cols .ghost { margin-top: 12px; width: 100%; }
label { display: flex; flex-direction: column; gap: 5px; text-align: left; font-size: 14px; font-weight: 600; }
label small { font-weight: 500; color: var(--dim); font-size: 12px; }
label b { color: var(--gold); float: right; }
label.check { flex-direction: row; align-items: center; gap: 8px; }
input[type=range] { width: 100%; accent-color: var(--pink); }
select, input[type=text] { font-family: inherit; font-size: 16px; padding: 8px 10px; border-radius: 10px; border: 2px solid #5a47b0; background: #0d0826; color: #fff; }
#pseudo { text-transform: uppercase; text-align: center; font-size: 22px; font-weight: 700; letter-spacing: 2px; -webkit-user-select: text; user-select: text; }
#hsForm { display: flex; flex-direction: column; gap: 12px; }
#hsForm[hidden] { display: none; }
#final { text-align: center; font-size: 44px; }

#topbar { display: none; width: 100%; align-items: center; gap: 8px; padding: 4px 6px 6px; }
.tb-score { display: flex; flex-direction: column; line-height: 1.05; }
#tbScore { font-size: 22px; font-weight: 700; color: var(--gold); font-variant-numeric: tabular-nums; }
#tbInfo { font-size: 10px; color: var(--teal); font-weight: 600; }
#tbMsg { flex: 1; text-align: center; font-size: 13px; font-weight: 700; color: var(--pink); overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.tb-btns { display: flex; gap: 6px; }
.tb-btns button.on { background: rgba(62,230,196,.3); border-color: var(--teal); }
.tb-btns button { width: 38px; height: 38px; background: rgba(255,255,255,.1); color: #fff; font-size: 17px; border: 1px solid rgba(255,255,255,.2); }

@media (max-width: 1150px) { #right { display: none; } }
@media (max-width: 860px), (max-aspect-ratio: 3/4) {
  #left, #right { display: none; }
  #app { padding: 4px; gap: 0; }
  #topbar { display: flex; }
  #stage { width: 100%; }
  .cols { grid-template-columns: 1fr; }
  h1 { font-size: 36px; }
}
@media (max-height: 620px) { .panel { gap: 7px; padding: 10px; } .score { font-size: 30px; } .logo img { width: 42px; height: 42px; } }
