* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; overflow: hidden; background: #10251c; font-family: 'Trebuchet MS', 'Segoe UI', sans-serif; }
#game-wrap { position: fixed; inset: 0; overflow: hidden; }
#game { display: block; width: 100%; height: 100%; touch-action: none; }

#hud { position: absolute; top: 0; left: 0; right: 0; padding: 14px 18px; display: flex; justify-content: space-between; align-items: flex-start; pointer-events: none; z-index: 5; }
#hud.hidden { display: none; }
.hud-left { text-shadow: 0 2px 6px rgba(0,0,0,.6); }
.hud-score { font-size: 30px; font-weight: bold; color: #fff; }
.hud-crystals { font-size: 20px; color: #8fe9ff; margin-top: 2px; font-weight: bold; }
#powerbar { display: flex; flex-direction: column; gap: 6px; align-items: flex-end; }
.pw { background: rgba(0,0,0,.4); color: #fff; padding: 5px 12px; border-radius: 20px; font-size: 14px; font-weight: bold; border: 2px solid rgba(255,255,255,.35); }
.pw.shield { border-color: #6fd3ff; color: #6fd3ff; }
.pw.magnet { border-color: #ffd166; color: #ffd166; }
.pw.boost { border-color: #ff8ad1; color: #ff8ad1; }
.pw.x2 { border-color: #b6ff8a; color: #b6ff8a; }

.overlay { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; z-index: 10; background: radial-gradient(circle at 50% 30%, rgba(255,150,200,.4), rgba(20,37,28,.85)); backdrop-filter: blur(3px); padding: 16px; }
.overlay.hidden { display: none; }
.panel { width: 100%; max-width: 460px; background: linear-gradient(160deg, rgba(40,74,50,.95), rgba(24,44,34,.97)); border: 2px solid rgba(255,150,200,.55); border-radius: 22px; padding: 26px 22px; text-align: center; box-shadow: 0 20px 60px rgba(0,0,0,.6); color: #fff; }
.panel h1 { font-size: 32px; margin-bottom: 8px; background: linear-gradient(90deg,#ffd166,#ff8ad1,#8fe9ff); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }
.tag { font-size: 15px; color: #e6ffe9; margin-bottom: 14px; line-height: 1.4; }

.char-select { text-align: left; margin: 10px 0 14px; background: rgba(0,0,0,.22); border: 1px solid rgba(255,255,255,.18); border-radius: 14px; padding: 12px; }
.char-title { font-size: 13px; color: #dff7e6; margin-bottom: 10px; letter-spacing: .2px; }
.char-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.char-card { appearance: none; border: 2px solid rgba(255,255,255,.18); background: rgba(255,255,255,.08); border-radius: 14px; padding: 10px; cursor: pointer; color: #fff; display: flex; flex-direction: column; align-items: center; gap: 8px; transition: transform .08s, border-color .12s, background .12s; }
.char-card:active { transform: scale(.98); }
.char-card.selected { border-color: rgba(255,209,102,.9); background: rgba(255,209,102,.14); }
.char-ava { width: 72px; height: 72px; border-radius: 16px; background: rgba(0,0,0,.22); border: 1px solid rgba(255,255,255,.14); display: grid; place-items: center; }
.char-name { font-weight: 900; font-size: 14px; }
.char-desc { font-size: 11px; color: rgba(230,255,233,.85); line-height: 1.25; text-align: center; min-height: 28px; }

.controls-hint { text-align: left; font-size: 13px; color: #d3f0d8; background: rgba(0,0,0,.25); border-radius: 12px; padding: 12px 14px; margin-bottom: 14px; display: flex; flex-direction: column; gap: 6px; }
input#player-name { width: 100%; padding: 12px 14px; border-radius: 12px; border: 2px solid rgba(255,150,200,.5); background: rgba(0,0,0,.3); color: #fff; font-size: 16px; margin-bottom: 14px; outline: none; }
input#player-name::placeholder { color: #bfe0c8; }
button { width: 100%; padding: 14px; font-size: 18px; font-weight: bold; border: none; border-radius: 14px; cursor: pointer; margin-top: 8px; color: #1a0b3a; background: linear-gradient(90deg,#ffd166,#ff8ad1); transition: transform .08s; }
button:active { transform: scale(.97); }
button.secondary { background: rgba(255,255,255,.12); color: #fff; border: 2px solid rgba(255,255,255,.25); }
.result { font-size: 26px; font-weight: bold; margin: 12px 0 4px; line-height: 1.5; }
.crystals-final { font-size: 20px; color: #8fe9ff; }
.rank-line { font-size: 16px; color: #ffd166; margin-top: 8px; }
.lb-list { list-style: none; text-align: left; margin: 10px 0 16px; max-height: 46vh; overflow-y: auto; }
.lb-list li { display: flex; justify-content: space-between; padding: 9px 12px; border-radius: 10px; margin-bottom: 5px; background: rgba(0,0,0,.25); font-size: 15px; }
.lb-list li .rk { color: #ffd166; font-weight: bold; margin-right: 10px; }
.lb-list li .nm { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-list li .sc { color: #8fe9ff; font-weight: bold; }
.lb-list li.me { background: rgba(255,209,102,.2); border: 1px solid rgba(255,209,102,.5); }
.lb-list li.loading { justify-content: center; color: #bfe0c8; }

@media (max-width: 380px) {
  .char-grid { grid-template-columns: 1fr; }
  .char-card { flex-direction: row; justify-content: flex-start; align-items: center; }
  .char-desc { text-align: left; min-height: 0; }
  .char-ava { width: 58px; height: 58px; }
}
