* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { width: 100%; height: 100%; overflow: hidden; background: #0b0620; font-family: "Trebuchet MS", "Segoe UI", system-ui, sans-serif; user-select: none; -webkit-user-select: none; touch-action: none; }
canvas#game { display: block; width: 100vw; height: 100vh; }
.hidden { display: none !important; }

.overlay { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; background: radial-gradient(circle at 50% 30%, rgba(255,255,255,.25), rgba(40,20,90,.55)); z-index: 10; }
.panel { background: #fff; border-radius: 28px; padding: 28px 34px; width: min(440px, 92vw); text-align: center; box-shadow: 0 10px 0 #5b2bb5, 0 20px 50px rgba(0,0,0,.35); max-height: 92vh; overflow: auto; }
.tag { margin: 14px 0 18px; color: #5b2bb5; font-weight: 700; }
label, .label { display: block; font-weight: 800; color: #333; margin: 10px 0 6px; text-align: left; }
input { width: 100%; padding: 10px 14px; border-radius: 14px; border: 3px solid #d9cdf3; font-size: 18px; font-weight: 700; outline: none; margin-top: 6px; }
input:focus { border-color: #8a5cf5; }
.colors { display: grid; grid-template-columns: repeat(8, 1fr); gap: 8px; margin-bottom: 18px; }
.colors div { aspect-ratio: 1; border-radius: 50%; cursor: pointer; border: 4px solid transparent; box-shadow: inset 0 -4px 0 rgba(0,0,0,.2); }
.colors div.sel { border-color: #222; transform: scale(1.12); }
button.big { width: 100%; padding: 14px; font-size: 26px; font-weight: 900; color: #fff; background: #3ed36b; border: none; border-radius: 18px; box-shadow: 0 6px 0 #1f8f42; cursor: pointer; letter-spacing: 2px; }
button.big:active { transform: translateY(4px); box-shadow: 0 2px 0 #1f8f42; }
.help { margin-top: 16px; font-size: 13px; color: #666; line-height: 1.6; }

#hud { position: fixed; top: 12px; left: 0; right: 0; display: flex; justify-content: center; gap: 12px; pointer-events: none; z-index: 5; flex-wrap: wrap; }
#hud > div { background: rgba(30,10,70,.7); color: #fff; padding: 8px 16px; border-radius: 14px; font-weight: 900; font-size: 18px; }
#qualified { color: #7dffa0 !important; }
#banner { position: fixed; top: 32%; left: 0; right: 0; text-align: center; font-size: 96px; font-weight: 900; color: #ffc928; text-shadow: 0 6px 0 #c27b00, 0 0 30px rgba(0,0,0,.35); pointer-events: none; z-index: 6; animation: pop .35s ease-out; }
#sub { position: fixed; top: calc(32% + 120px); left: 0; right: 0; text-align: center; font-size: 26px; font-weight: 900; color: #fff; text-shadow: 0 3px 0 rgba(0,0,0,.4); pointer-events: none; z-index: 6; }
@keyframes pop { from { transform: scale(2.2); opacity: 0; } to { transform: scale(1); opacity: 1; } }

#results h2 { font-size: 40px; color: #ff4fa3; text-shadow: 0 4px 0 #b3166a; margin-bottom: 8px; }
#results p { font-weight: 700; color: #444; margin-bottom: 12px; }
#resList { text-align: left; margin: 0 0 18px 0; padding-left: 28px; max-height: 40vh; overflow: auto; font-weight: 700; }
#resList li { padding: 3px 0; }
#resList li.me { color: #8a5cf5; }
#resList .dot { display: inline-block; width: 12px; height: 12px; border-radius: 50%; margin-right: 6px; vertical-align: middle; }

#touch { position: fixed; inset: 0; pointer-events: none; z-index: 4; }
#stick { position: absolute; left: 30px; bottom: 30px; width: 130px; height: 130px; border-radius: 50%; background: rgba(255,255,255,.25); border: 3px solid rgba(255,255,255,.6); pointer-events: auto; }
#knob { position: absolute; left: 40px; top: 40px; width: 50px; height: 50px; border-radius: 50%; background: rgba(255,255,255,.85); }
#tJump, #tDive { position: absolute; pointer-events: auto; border: none; border-radius: 50%; font-weight: 900; color: #fff; font-size: 16px; }
#tJump { right: 30px; bottom: 40px; width: 96px; height: 96px; background: #3ed36b; box-shadow: 0 5px 0 #1f8f42; }
#tDive { right: 140px; bottom: 30px; width: 70px; height: 70px; background: #ff8a3d; box-shadow: 0 5px 0 #c25510; }

/* ---------- Intro ---------- */
body { font-family: "Lilita One", "Trebuchet MS", system-ui, sans-serif; }
input, .help, .wallet-note, .pot-note { font-family: "Trebuchet MS", system-ui, sans-serif; }
.overlay.intro { background: radial-gradient(ellipse at 50% 120%, rgba(8,3,26,0) 40%, rgba(8,3,26,.6) 100%); justify-content: space-between; align-items: center; padding: 3vh 5vw; gap: 3vw; transition: opacity .5s; }
.overlay.intro.fade { opacity: 0; pointer-events: none; }
.intro-left { display: flex; flex-direction: column; align-items: flex-start; max-width: 56vw; animation: slideIn .8s cubic-bezier(.2,1.4,.4,1) both; }
#logo { width: min(620px, 52vw); height: auto; overflow: visible; filter: drop-shadow(0 12px 18px rgba(10,0,40,.55)) drop-shadow(0 0 24px rgba(153,69,255,.45)); }
#logo .logo-word { animation: logoBob 3.2s ease-in-out infinite; transform-origin: 330px 160px; }
#logo .sun { animation: none; }
#logo .rays { animation: spin 14s linear infinite; transform-box: fill-box; transform-origin: center; }
#logo .crown { animation: crownWiggle 2.4s ease-in-out infinite; transform-box: fill-box; transform-origin: center bottom; }
#logo .sparkles path { animation: twinkle 1.6s ease-in-out infinite; transform-box: fill-box; transform-origin: center; }
#logo .sparkles path:nth-child(2) { animation-delay: .8s; }
@keyframes logoBob { 0%,100% { transform: translateY(0) rotate(-2deg); } 50% { transform: translateY(-8px) rotate(-1deg); } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes crownWiggle { 0%,100% { transform: rotate(-6deg); } 50% { transform: rotate(6deg) translateY(-6px); } }
@keyframes twinkle { 0%,100% { transform: scale(.4); opacity: .3; } 50% { transform: scale(1.1); opacity: 1; } }
@keyframes slideIn { from { transform: translateX(-60px) scale(.9); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes slideUp { from { transform: translateY(60px); opacity: 0; } to { transform: none; opacity: 1; } }

.intro .tag { color: #fff; font-size: clamp(18px, 2.2vw, 28px); margin: 6px 0 12px 12px; text-shadow: 0 3px 0 #0e0726; letter-spacing: .5px; }
.chips { display: flex; gap: 10px; flex-wrap: wrap; margin-left: 12px; }
.chips span { background: rgba(255,255,255,.16); border: 2px solid rgba(255,255,255,.35); color: #fff; padding: 6px 14px; border-radius: 999px; font-size: 16px; backdrop-filter: blur(6px); }
.pot { margin: 22px 0 0 12px; padding: 12px 22px; border-radius: 20px; background: linear-gradient(120deg, #9945ff, #3fb6f5 60%, #14f195); border: 4px solid #0e0726; box-shadow: 0 6px 0 #0e0726, 0 0 30px rgba(20,241,149,.35); color: #fff; text-shadow: 0 3px 0 #0e0726; min-width: 240px; }
.pot-label { font-size: 15px; letter-spacing: 3px; opacity: .8; }
.pot-value { font-size: 40px; line-height: 1.05; }
.pot-note { font-size: 12px; font-weight: 700; opacity: .75; }

.panel.card { background: rgba(255,255,255,.92); backdrop-filter: blur(10px); border: 4px solid #0e0726; box-shadow: 0 10px 0 #0e0726, 0 24px 60px rgba(30,0,40,.5); width: min(380px, 90vw); animation: slideUp .8s .15s cubic-bezier(.2,1.3,.4,1) both; text-align: left; }
.panel.card label, .panel.card .label { font-weight: 400; color: #0e0726; font-size: 17px; }
.panel.card input { font-family: "Lilita One", sans-serif; font-weight: 400; border-color: #dccbff; color: #0e0726; }
.wallet { width: 100%; padding: 12px; font-family: inherit; font-size: 20px; color: #fff; border: 3px solid #0e0726; border-radius: 16px; cursor: pointer; background: linear-gradient(90deg, #9945ff, #3fb6f5); box-shadow: 0 5px 0 #0e0726; letter-spacing: 1px; }
.wallet:active { transform: translateY(3px); box-shadow: 0 2px 0 #0e0726; }
.wallet.connected { background: linear-gradient(90deg, #14f195, #0fb87a); color: #0e0726; }
.wallet-note { font-size: 13px; color: #5a4a7a; margin: 8px 2px 4px; font-weight: 700; }
.panel.card button.big { font-family: inherit; font-weight: 400; background: linear-gradient(180deg, #5dffc0, #14f195 55%, #0ec27a); color: #0e0726; border: 3px solid #0e0726; box-shadow: 0 6px 0 #0e0726; font-size: 32px; animation: pulse 1.6s ease-in-out infinite; }
.panel.card button.big:disabled { filter: grayscale(.8) brightness(.95); animation: none; cursor: not-allowed; }
@keyframes pulse { 0%,100% { transform: scale(1); } 50% { transform: scale(1.04); } }
.panel.card .help { text-align: center; }
.colors div { border-color: transparent; }
.colors div.sel { border-color: #0e0726; }

#muteBtn { position: fixed; right: 16px; top: 14px; z-index: 20; width: 46px; height: 46px; border-radius: 50%; border: 3px solid #0e0726; background: #fff; color: #0e0726; font-size: 24px; cursor: pointer; box-shadow: 0 4px 0 #0e0726; }
#muteBtn.muted { opacity: .55; text-decoration: line-through; }

@media (max-width: 820px) {
  .overlay.intro { flex-direction: column; justify-content: flex-start; padding-top: 2vh; overflow-y: auto; }
  .intro-left { max-width: 100%; align-items: center; text-align: center; }
  #logo { width: min(440px, 88vw); }
  .chips { justify-content: center; margin: 0; }
  .pot { margin: 14px 0 8px; }
  .intro .tag { margin: 4px 0 10px; }
}
.lobbies { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.lobby { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 10px 6px; border-radius: 16px; border: 3px solid #dccbff; background: #f6f1ff; cursor: pointer; font-family: inherit; color: #0e0726; }
.lobby.sel { border-color: #0e0726; background: linear-gradient(135deg, #e9dcff, #d4fff0); box-shadow: 0 4px 0 #0e0726; }
.lobby-name { font-size: 20px; }
.lobby-share { font-size: 15px; color: #7a2fff; }
.lobby.sel .lobby-share { color: #0a8a55; }
.lobby-slots { font-family: "Trebuchet MS", sans-serif; font-size: 11px; font-weight: 700; opacity: .6; }
button.link { display: block; margin: 10px auto 0; background: none; border: none; color: #7a2fff; font-family: inherit; font-size: 16px; cursor: pointer; text-decoration: underline; }
#waiting h2 { font-size: 34px; color: #0e0726; text-align: center; }
#waiting p { text-align: center; color: #5a4a7a; font-family: "Trebuchet MS", sans-serif; font-weight: 700; margin: 6px 0 10px; }
.wait-count { text-align: center; font-size: 44px; color: #7a2fff; }
.wait-list { list-style: none; display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; max-height: 30vh; overflow: auto; margin: 10px 0; }
.wait-list li { background: #f1eaff; border-radius: 999px; padding: 4px 10px; font-size: 14px; color: #0e0726; }
.wait-list .dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 5px; }
#results .panel { font-family: "Lilita One", sans-serif; }
