:root { --red: #ff3b4e; --blue: #33c8ff; --gold: #ffd34d; --ink: #f4f6ff; --glass: rgba(14, 16, 28, 0.72); --line: rgba(255, 255, 255, 0.12); }
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #05060a; color: var(--ink); font-family: Inter, system-ui, sans-serif; user-select: none; -webkit-user-select: none; }
canvas#view { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
.hidden { display: none !important; }
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; }

/* ---------- screens ---------- */
.screen { position: fixed; inset: 0; display: flex; flex-direction: column; align-items: center; padding: 28px 16px; overflow-y: auto; z-index: 10;
  background: radial-gradient(ellipse at 50% 120%, rgba(0,0,0,0) 30%, rgba(5,6,10,0.55) 80%); }
.screen.dim { background: rgba(4, 5, 10, 0.6); backdrop-filter: blur(6px); justify-content: center; }
.logo { font-family: 'Russo One', sans-serif; font-size: clamp(54px, 10vw, 112px); line-height: 0.9; letter-spacing: 2px; text-shadow: 0 6px 30px rgba(255, 59, 78, 0.45), 0 2px 0 #000; margin-top: 4vh; }
.logo span { color: var(--red); margin-left: 12px; }
.logo em { font-style: normal; font-size: 0.35em; color: var(--blue); vertical-align: top; margin-left: 8px; }
.tag { opacity: 0.85; margin: 10px 0 28px; font-weight: 600; letter-spacing: 1px; text-shadow: 0 2px 8px #000; }
.menu { display: flex; flex-direction: column; gap: 12px; width: min(420px, 100%); }
.menu .row { display: flex; gap: 12px; }
.menu .row button { flex: 1; padding: 14px; border-radius: 14px; background: var(--glass); border: 1px solid var(--line); font-weight: 800; letter-spacing: 1px; font-size: 14px; backdrop-filter: blur(10px); }
button.big { display: block; width: 100%; padding: 16px 20px; border-radius: 16px; background: var(--glass); border: 1px solid var(--line); font-family: 'Russo One', sans-serif; font-size: 22px; letter-spacing: 1.5px; text-align: left; backdrop-filter: blur(10px); transition: transform .12s, background .12s, border-color .12s; }
button.big small { display: block; font-family: Inter, sans-serif; font-size: 13px; opacity: 0.7; letter-spacing: 0; margin-top: 3px; font-weight: 600; }
button.big:hover, .menu .row button:hover { transform: translateY(-2px); border-color: rgba(255, 255, 255, 0.35); }
button.big.primary { background: linear-gradient(135deg, #ff3b4e, #ff7a3b); border-color: transparent; box-shadow: 0 10px 30px rgba(255, 59, 78, 0.35); }
button.big:disabled { opacity: 0.45; cursor: default; transform: none; }
button.ghost { margin-top: 18px; opacity: 0.6; text-decoration: underline; font-size: 13px; }
.wallet { margin-top: 22px; padding: 8px 16px; border-radius: 999px; background: var(--glass); border: 1px solid var(--line); font-weight: 600; backdrop-filter: blur(10px); }
.wallet b { color: var(--gold); font-size: 18px; }
.wallet.small { margin: 0; }
.stats { margin-top: 10px; font-size: 12px; opacity: 0.7; text-shadow: 0 1px 4px #000; }

.head { width: min(980px, 100%); display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; margin-bottom: 18px; }
.head h2 { margin: 0; font-family: 'Russo One', sans-serif; font-size: 30px; letter-spacing: 2px; text-shadow: 0 2px 10px #000; }
.head .back { justify-self: start; padding: 10px 16px; border-radius: 12px; background: var(--glass); border: 1px solid var(--line); font-weight: 800; }
.head > :last-child { justify-self: end; }

.panel { width: min(520px, 100%); background: var(--glass); border: 1px solid var(--line); border-radius: 22px; padding: 22px; backdrop-filter: blur(14px); display: flex; flex-direction: column; gap: 10px; }
.panel.narrow { width: min(400px, 100%); text-align: center; }
.panel h2 { margin: 0 0 8px; font-family: 'Russo One', sans-serif; letter-spacing: 3px; }
.panel label { font-weight: 800; font-size: 12px; letter-spacing: 1.5px; text-transform: uppercase; opacity: 0.75; margin-top: 6px; display: flex; justify-content: space-between; }
.panel input[type=range] { width: 100%; accent-color: var(--red); }
.seg { display: flex; flex-wrap: wrap; gap: 6px; }
.seg button { flex: 1 1 auto; padding: 10px 12px; border-radius: 10px; background: rgba(255, 255, 255, 0.06); border: 1px solid var(--line); font-weight: 700; font-size: 14px; }
.seg button.on { background: var(--red); border-color: var(--red); box-shadow: 0 4px 16px rgba(255, 59, 78, 0.4); }
.seg button:disabled { opacity: 0.35; cursor: default; }
.panel .big.primary { margin-top: 12px; text-align: center; }
.help p, .help li { line-height: 1.5; }
.help ul { padding-left: 18px; margin: 0; display: flex; flex-direction: column; gap: 8px; }
.pw { display: inline-block; padding: 1px 7px; border-radius: 6px; font-size: 11px; font-weight: 800; color: #000; }
.pw.big { background: #ffd34d; } .pw.multi { background: #b6ff3a; } .pw.freeze { background: #7fdcff; } .pw.shield { background: #c79bff; }

/* online */
.panel input[type=text], .panel input:not([type]) { width: 100%; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line); background: rgba(255,255,255,0.06); color: var(--ink); font: 700 16px Inter, sans-serif; outline: none; }
.panel input:focus { border-color: var(--red); }
.joinrow { display: flex; gap: 8px; }
.joinrow input { text-transform: uppercase; letter-spacing: 6px; font-family: 'Russo One', sans-serif !important; text-align: center; }
.joinrow button { padding: 0 22px; border-radius: 12px; background: var(--blue); color: #001; font-weight: 800; }
#oStatus { min-height: 22px; text-align: center; font-weight: 600; opacity: 0.9; }
#oStatus .code { display: block; font-family: 'Russo One', sans-serif; font-size: 52px; letter-spacing: 10px; color: var(--gold); margin: 6px 0; user-select: text; }
#oStatus .spin { display: inline-block; width: 14px; height: 14px; border: 2px solid rgba(255,255,255,0.3); border-top-color: #fff; border-radius: 50%; animation: spin .8s linear infinite; vertical-align: -2px; margin-right: 8px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* tour ladder */
#ladder { width: min(980px, 100%); display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.opp { position: relative; padding: 16px; border-radius: 18px; background: var(--glass); border: 1px solid var(--line); backdrop-filter: blur(12px); text-align: left; min-height: 150px; display: flex; flex-direction: column; gap: 4px; transition: transform .12s; }
.opp:not(:disabled):hover { transform: translateY(-3px); border-color: rgba(255, 255, 255, 0.4); }
.opp .n { font-size: 11px; opacity: 0.6; font-weight: 800; letter-spacing: 1.5px; }
.opp .name { font-family: 'Russo One', sans-serif; font-size: 22px; }
.opp .title { font-size: 13px; opacity: 0.75; }
.opp .meta { margin-top: auto; font-size: 12px; opacity: 0.85; display: flex; justify-content: space-between; }
.opp .chip { position: absolute; top: 12px; right: 12px; font-size: 11px; font-weight: 800; padding: 3px 8px; border-radius: 999px; }
.opp.beaten .chip { background: #2ecc71; color: #022; }
.opp.next { border-color: var(--red); box-shadow: 0 0 0 1px var(--red), 0 10px 30px rgba(255, 59, 78, 0.3); }
.opp.next .chip { background: var(--red); }
.opp.locked { opacity: 0.45; }
.opp .dot { width: 34px; height: 34px; border-radius: 50%; margin-bottom: 4px; box-shadow: inset 0 -4px 8px rgba(0,0,0,0.4), 0 2px 8px rgba(0,0,0,0.5); }

/* locker */
#locker { display: grid; grid-template-columns: minmax(0, 320px) 1fr minmax(0, 320px); grid-template-rows: auto auto 1fr; align-items: start; column-gap: 16px; background: none; }
#locker .head { grid-column: 1 / -1; justify-self: center; }
#lockTabs { grid-column: 1; display: flex; gap: 6px; margin-bottom: 10px; }
#lockTabs button { flex: 1; padding: 10px 6px; border-radius: 10px; background: var(--glass); border: 1px solid var(--line); font-weight: 800; font-size: 12px; letter-spacing: 1px; }
#lockTabs button.on { background: var(--red); border-color: var(--red); }
#lockList { grid-column: 1; grid-row: 3; display: flex; flex-direction: column; gap: 8px; max-height: calc(100vh - 190px); overflow-y: auto; padding-right: 4px; }
.item { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 14px; background: var(--glass); border: 1px solid var(--line); text-align: left; backdrop-filter: blur(10px); }
.item.sel { border-color: #fff; box-shadow: 0 0 0 1px #fff; }
.item .sw { width: 30px; height: 30px; border-radius: 50%; flex: none; box-shadow: inset 0 -4px 8px rgba(0,0,0,0.4); }
.item .t { flex: 1; font-weight: 800; }
.item .p { font-size: 12px; font-weight: 800; color: var(--gold); }
.item .p.own { color: #8fffb0; } .item .p.eq { color: #fff; background: var(--red); padding: 2px 7px; border-radius: 999px; } .item .p.lock { color: #aaa; }
#lockInfo { grid-column: 3; grid-row: 2 / 4; background: var(--glass); border: 1px solid var(--line); border-radius: 20px; padding: 18px; backdrop-filter: blur(14px); }
#lockInfo h3 { margin: 0; font-family: 'Russo One', sans-serif; font-size: 26px; }
#lockInfo p { opacity: 0.8; margin: 6px 0 14px; }
.stat { display: grid; grid-template-columns: 64px 1fr; align-items: center; gap: 8px; font-size: 12px; font-weight: 800; letter-spacing: 1px; margin-bottom: 8px; }
.stat .bar { height: 8px; border-radius: 4px; background: rgba(255, 255, 255, 0.1); overflow: hidden; }
.stat .bar i { display: block; height: 100%; background: linear-gradient(90deg, #ff3b4e, #ffd34d); border-radius: 4px; }
#liBtn { text-align: center; }

/* ---------- HUD ---------- */
#hud { position: fixed; inset: 0; pointer-events: none; z-index: 5; }
#scorebar { position: absolute; top: 14px; left: 50%; transform: translateX(-50%); display: flex; align-items: stretch; border-radius: 16px; overflow: hidden; box-shadow: 0 8px 30px rgba(0,0,0,0.45); font-family: 'Russo One', sans-serif; }
#scorebar .side { display: flex; align-items: center; gap: 12px; padding: 6px 14px; background: var(--glass); backdrop-filter: blur(10px); }
#scorebar .sc { font-size: 34px; min-width: 32px; text-align: center; }
#scorebar .you .sc { color: var(--red); } #scorebar .foe .sc { color: var(--blue); }
#scorebar .nm { font-size: 14px; letter-spacing: 1px; opacity: 0.9; }
#scorebar .mid { display: flex; align-items: center; padding: 0 12px; font-size: 11px; letter-spacing: 1.5px; background: rgba(0,0,0,0.55); color: var(--gold); }
#scorebar .sc.pop { animation: pop .5s; }
@keyframes pop { 0% { transform: scale(1); } 40% { transform: scale(1.7); } 100% { transform: scale(1); } }
#powers { position: absolute; top: 80px; left: 50%; transform: translateX(-50%); display: flex; gap: 8px; }
#powers .pw { font-size: 13px; padding: 4px 10px; border-radius: 999px; box-shadow: 0 4px 14px rgba(0,0,0,0.4); }
#powers .pw.foe { outline: 2px solid var(--blue); }
#speedo { position: absolute; right: 22px; bottom: 22px; font-family: 'Russo One', sans-serif; font-size: 44px; text-align: right; text-shadow: 0 3px 14px rgba(0,0,0,0.7); opacity: 0; transition: opacity .3s; }
#speedo small { display: block; font-size: 12px; letter-spacing: 2px; opacity: 0.7; }
#speedo.on { opacity: 1; }
#banner { position: absolute; top: 34%; left: 0; right: 0; text-align: center; font-family: 'Russo One', sans-serif; font-size: clamp(54px, 11vw, 140px); letter-spacing: 4px; opacity: 0; text-shadow: 0 6px 40px rgba(0,0,0,0.6); }
#banner.show { animation: banner 1.5s ease-out forwards; }
#banner.count { animation: count .8s ease-out forwards; }
#banner small { display: block; font-size: 0.24em; letter-spacing: 3px; opacity: 0.9; }
@keyframes banner { 0% { opacity: 0; transform: scale(2.2); } 15% { opacity: 1; transform: scale(1); } 80% { opacity: 1; } 100% { opacity: 0; transform: scale(0.95) translateY(-20px); } }
@keyframes count { 0% { opacity: 0; transform: scale(1.8); } 25% { opacity: 1; transform: scale(1); } 100% { opacity: 0; transform: scale(0.8); } }
#callout { position: absolute; top: 24%; left: 0; right: 0; text-align: center; font-family: 'Russo One', sans-serif; font-size: 34px; color: var(--gold); text-shadow: 0 3px 16px rgba(0,0,0,0.7); opacity: 0; }
#callout.show { animation: banner 1.1s ease-out forwards; }
#hint { position: absolute; bottom: 16px; left: 50%; transform: translateX(-50%); font-size: 13px; opacity: 0.75; text-shadow: 0 1px 4px #000; white-space: nowrap; transition: opacity 1s; }
#hint b { background: rgba(255,255,255,0.15); padding: 1px 6px; border-radius: 5px; }
#pauseBtn { position: absolute; top: 16px; right: 16px; width: 44px; height: 44px; border-radius: 12px; background: var(--glass); border: 1px solid var(--line); pointer-events: auto; font-weight: 800; }
#guardBtn { position: absolute; z-index: 2; left: 20px; bottom: 20px; width: 92px; height: 92px; border-radius: 50%; background: var(--glass); border: 2px solid rgba(255,255,255,0.25); pointer-events: auto; display: flex; flex-direction: column; align-items: center; justify-content: center; font-size: 26px; backdrop-filter: blur(10px); touch-action: none; }
#guardBtn span { font-family: 'Russo One', sans-serif; font-size: 13px; letter-spacing: 1px; margin-top: 2px; }
#guardBtn small { font-size: 9px; opacity: 0.6; font-weight: 800; letter-spacing: 1px; }
#guardBtn:active { background: var(--red); transform: scale(0.94); }
#clickToPlay { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; pointer-events: auto; cursor: pointer; }
#clickToPlay div { padding: 16px 28px; border-radius: 16px; background: var(--glass); border: 1px solid var(--line); font-family: 'Russo One', sans-serif; font-size: 22px; letter-spacing: 1px; backdrop-filter: blur(10px); animation: pulse 1.4s infinite; }
@keyframes pulse { 50% { transform: scale(1.05); } }
#arrow { position: absolute; font-size: 28px; color: var(--gold); text-shadow: 0 0 12px rgba(0,0,0,0.8); display: none; transform-origin: center; }

/* versus intro */
#versus { position: fixed; inset: 0; z-index: 6; display: flex; align-items: center; justify-content: center; gap: 4vw; pointer-events: none; font-family: 'Russo One', sans-serif; background: linear-gradient(90deg, rgba(255,59,78,0.25), rgba(0,0,0,0.35) 50%, rgba(51,200,255,0.25)); animation: vsfade 2.3s forwards; }
#versus .vs-you, #versus .vs-opp { font-size: clamp(30px, 5vw, 64px); text-shadow: 0 4px 20px rgba(0,0,0,0.6); }
#versus .vs-you { color: var(--red); animation: slideL .5s ease-out; } #versus .vs-opp { color: var(--blue); animation: slideR .5s ease-out; }
#versus .vs-x { font-size: clamp(40px, 7vw, 90px); color: var(--gold); }
#versus .vs-sub { position: absolute; top: 60%; width: 100%; text-align: center; font-family: Inter, sans-serif; font-weight: 600; opacity: 0.85; }
@keyframes slideL { from { transform: translateX(-60vw); } } @keyframes slideR { from { transform: translateX(60vw); } }
@keyframes vsfade { 0%, 80% { opacity: 1; } 100% { opacity: 0; } }

/* results */
#results h1 { font-family: 'Russo One', sans-serif; font-size: 52px; margin: 0; letter-spacing: 2px; }
#results h1.win { color: var(--gold); text-shadow: 0 4px 30px rgba(255, 211, 77, 0.5); } #results h1.lose { color: #aab; }
#rScore { font-family: 'Russo One', sans-serif; font-size: 34px; margin-bottom: 8px; }
#rRows .r { display: flex; justify-content: space-between; padding: 6px 4px; border-bottom: 1px solid var(--line); font-size: 14px; }
#rRows .r b { color: var(--gold); }
#rRows .r.total { font-size: 17px; font-weight: 800; border: 0; }
#rUnlock:not(:empty) { margin: 8px 0; padding: 12px; border-radius: 14px; background: linear-gradient(135deg, rgba(255,211,77,0.25), rgba(255,59,78,0.25)); border: 1px solid var(--gold); font-weight: 800; animation: pulse 1.4s infinite; }
#results .big { text-align: center; }

#toast { position: fixed; left: 50%; bottom: 40px; transform: translate(-50%, 30px); padding: 12px 20px; border-radius: 14px; background: var(--glass); border: 1px solid var(--gold); font-weight: 800; opacity: 0; transition: .3s; z-index: 30; pointer-events: none; backdrop-filter: blur(10px); }
#toast.on { opacity: 1; transform: translate(-50%, 0); }
#loading { position: fixed; inset: 0; z-index: 40; background: #05060a; display: flex; flex-direction: column; align-items: center; justify-content: center; transition: opacity .5s; }
#loading .bar { width: 220px; height: 4px; border-radius: 2px; background: rgba(255,255,255,0.1); margin-top: 30px; overflow: hidden; }
#loading .bar i { display: block; height: 100%; width: 40%; background: var(--red); animation: load 1s infinite ease-in-out; }
@keyframes load { 0% { transform: translateX(-100%); } 100% { transform: translateX(250%); } }
#loading.gone { opacity: 0; pointer-events: none; }

@media (max-width: 860px) {
  #locker { display: flex; flex-direction: column; align-items: stretch; }
  #locker .head { align-self: center; }
  #lockList { max-height: none; flex-direction: row; overflow-x: auto; padding-bottom: 6px; }
  .item { flex: none; }
  #lockInfo { margin-top: auto; }
  #hint { display: none; }
  #scorebar .nm { display: none; }
}
@media (max-height: 520px) {
  .logo { font-size: 50px; margin-top: 0; }
  .tag { margin: 4px 0 10px; }
  button.big { padding: 10px 16px; font-size: 18px; }
  .menu { gap: 8px; }
}
