:root {
  --ink: #2b1b4d; --white: #fff; --glass: rgba(255,255,255,.14); --glass-b: rgba(255,255,255,.28);
  --pink: #ff4fa3; --yellow: #ffd23f; --green: #2ed573; --red: #ff4d4d; --blue: #3b82f6; --violet: #7c4dff; --orange: #ff9f1a;
  --font: 'Fredoka', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; margin: 0; overflow: hidden; }
body {
  font-family: var(--font); color: var(--white);
  background: linear-gradient(135deg, #2a1458, #5b21b6, #c026d3, #ff6b6b, #5b21b6, #2a1458);
  background-size: 400% 400%; animation: bgmove 28s ease-in-out infinite;
}
@keyframes bgmove { 0% { background-position: 0% 50% } 50% { background-position: 100% 50% } 100% { background-position: 0% 50% } }
#game { position: fixed; inset: 0; z-index: 0; }
#game canvas { display: block; }
#ui { position: fixed; inset: 0; z-index: 1; pointer-events: none; display: flex; flex-direction: column; }
#ui > * { pointer-events: auto; }
.hidden { display: none !important; }

.icon-btn { position: fixed; top: calc(8px + env(safe-area-inset-top)); right: 10px; z-index: 20; width: 40px; height: 40px; border-radius: 50%; border: 0; background: var(--glass); color: #fff; font-size: 18px; cursor: pointer; backdrop-filter: blur(6px); }

/* paneles */
.screen { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; padding: 16px; overflow-y: auto; }
.panel { width: min(460px, 100%); background: var(--glass); border: 2px solid var(--glass-b); border-radius: 28px; padding: 26px 22px; backdrop-filter: blur(14px); box-shadow: 0 20px 60px rgba(20,0,60,.45); animation: pop .45s cubic-bezier(.2,1.4,.4,1) both; text-align: center; }
@keyframes pop { from { transform: scale(.85) translateY(20px); opacity: 0 } to { transform: none; opacity: 1 } }
.logo { font-size: 52px; font-weight: 700; line-height: 1; display: flex; align-items: center; justify-content: center; gap: 10px; text-shadow: 0 4px 0 rgba(0,0,0,.2); }
.logo span { background: linear-gradient(90deg, var(--yellow), var(--pink)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.logo.small { font-size: 32px; margin-bottom: 4px; }
.logo > :first-child { animation: bob 2.2s ease-in-out infinite; display: inline-block; }
@keyframes bob { 50% { transform: translateY(-6px) rotate(-8deg) } }
.tag { margin: 6px 0 20px; opacity: .85; }
h2 { margin: 6px 0 14px; font-size: 24px; }
input { width: 100%; font: inherit; font-size: 20px; padding: 14px 16px; border-radius: 16px; border: 3px solid transparent; outline: none; background: #fff; color: var(--ink); text-align: center; font-weight: 600; }
input:focus { border-color: var(--yellow); }
.btn { font: inherit; font-weight: 700; font-size: 20px; border: 0; border-radius: 16px; padding: 14px 22px; cursor: pointer; color: #fff; width: 100%; margin-top: 12px; transition: transform .08s, box-shadow .08s; }
.btn-primary { background: linear-gradient(180deg, #ff6bb5, var(--pink)); box-shadow: 0 6px 0 #c2185b; }
.btn-ok { background: linear-gradient(180deg, #4ce38b, var(--green)); box-shadow: 0 6px 0 #159a4d; }
.btn:active { transform: translateY(5px); box-shadow: 0 1px 0 rgba(0,0,0,.3); }
.btn:disabled { opacity: .6; cursor: default; }
.error { color: #ffd0d0; min-height: 22px; margin: 10px 0 0; font-weight: 500; }
.hint { opacity: .85; margin: 12px 0 0; min-height: 22px; }

.plist { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; text-align: left; }
.plist li { display: flex; align-items: center; gap: 10px; background: rgba(255,255,255,.16); border-radius: 16px; padding: 8px 12px; font-weight: 600; animation: pop .3s both; }
.plist .av { font-size: 26px; }
.plist .nm { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.plist .me { outline: 2px solid var(--yellow); }
.badge { font-size: 14px; padding: 4px 10px; border-radius: 999px; background: rgba(0,0,0,.25); }
.badge.ok { background: var(--green); color: #053b1b; }
.badge.crown { background: var(--yellow); color: #5a4300; }
.off { opacity: .45; }
.target-box { margin-top: 16px; font-weight: 600; }
.seg { display: flex; gap: 6px; justify-content: center; margin-top: 8px; flex-wrap: wrap; }
.seg button { font: inherit; font-weight: 700; border: 2px solid var(--glass-b); background: transparent; color: #fff; border-radius: 12px; padding: 6px 14px; cursor: pointer; }
.seg button.on { background: var(--yellow); color: var(--ink); border-color: var(--yellow); }
.seg button:disabled { cursor: default; }
.target-box .only { opacity: .8; font-size: 15px; }

/* HUD */
#hud { padding: calc(8px + env(safe-area-inset-top)) 56px 6px 10px; display: flex; flex-direction: column; gap: 6px; }
#hud-meta { font-size: 14px; font-weight: 600; opacity: .9; display: flex; gap: 12px; }
#hud-players { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
#hud-players::-webkit-scrollbar { display: none; }
.chip { flex: 0 0 auto; min-width: 92px; background: var(--glass); border: 2px solid var(--glass-b); border-radius: 16px; padding: 5px 10px 7px; backdrop-filter: blur(6px); position: relative; transition: transform .3s; }
.chip.me { border-color: var(--yellow); }
.chip.ans::after { content: '✓'; position: absolute; top: -6px; right: -4px; background: var(--green); color: #053b1b; font-weight: 700; width: 20px; height: 20px; border-radius: 50%; font-size: 13px; display: grid; place-items: center; animation: pop .3s both; }
.chip .top { display: flex; align-items: center; gap: 5px; font-weight: 600; font-size: 14px; white-space: nowrap; max-width: 130px; overflow: hidden; text-overflow: ellipsis; }
.chip .sc { font-size: 20px; font-weight: 700; line-height: 1.1; }
.chip .bar { height: 5px; border-radius: 3px; background: rgba(0,0,0,.28); margin-top: 3px; overflow: hidden; }
.chip .bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--yellow), var(--pink)); transition: width .8s cubic-bezier(.2,1,.3,1); }
.chip.bump { animation: bump .7s; }
@keyframes bump { 30% { transform: scale(1.18) } }

/* DOCK */
#dock { margin-top: auto; padding: 8px 12px calc(12px + env(safe-area-inset-bottom)); max-height: 56vh; overflow-y: auto; width: min(640px, 100%); align-self: center; }
.opts { display: grid; grid-template-columns: 1fr; gap: 8px; }
@media (min-width: 560px) { .opts { grid-template-columns: 1fr 1fr; } }
.opt { font: inherit; font-weight: 600; font-size: 18px; text-align: left; border: 0; border-radius: 16px; padding: 10px 14px; color: #fff; cursor: pointer; display: flex; align-items: center; gap: 10px; min-height: 48px; box-shadow: 0 5px 0 rgba(0,0,0,.3); animation: slideup .4s both; }
.opt:active { transform: translateY(4px); box-shadow: 0 1px 0 rgba(0,0,0,.3); }
.opt .l { flex: 0 0 30px; height: 30px; border-radius: 50%; background: rgba(255,255,255,.28); display: grid; place-items: center; font-weight: 700; }
.opt.c0 { background: #e84a5f } .opt.c1 { background: #2f80ed } .opt.c2 { background: #f2994a } .opt.c3 { background: #27ae60 } .opt.c4 { background: #9b51e0 }
.opt.sel { outline: 4px solid #fff; transform: scale(1.02); }
@keyframes slideup { from { transform: translateY(30px); opacity: 0 } to { transform: none; opacity: 1 } }
.num-wrap { background: var(--glass); border: 2px solid var(--glass-b); border-radius: 22px; padding: 14px; backdrop-filter: blur(8px); text-align: center; animation: slideup .4s both; }
.num-wrap input { font-size: 28px; }
.num-prev { min-height: 24px; margin-top: 6px; opacity: .85; font-weight: 500; }
.wait { text-align: center; background: var(--glass); border: 2px solid var(--glass-b); border-radius: 22px; padding: 16px; font-weight: 600; font-size: 18px; backdrop-filter: blur(8px); animation: slideup .4s both; }
.wait small { display: block; font-weight: 400; opacity: .8; margin-top: 4px; }
.res { background: var(--glass); border: 2px solid var(--glass-b); border-radius: 22px; padding: 12px; backdrop-filter: blur(10px); animation: slideup .4s both; }
.res h3 { margin: 2px 0 10px; text-align: center; font-size: 18px; }
.res .plist li { padding: 6px 10px; }
.res .plist li.win { background: rgba(46,213,115,.35); outline: 2px solid var(--green); }
.res .ans { font-weight: 500; opacity: .95; font-size: 15px; }
.res .plus { font-weight: 700; color: var(--yellow); animation: pop .5s .3s both; }
.next { height: 6px; background: rgba(0,0,0,.25); border-radius: 3px; margin-top: 10px; overflow: hidden; }
.next i { display: block; height: 100%; width: 100%; background: var(--yellow); transform-origin: left; animation: shrink linear forwards; }
@keyframes shrink { to { transform: scaleX(0) } }

.final-panel .trophy { font-size: 84px; animation: bob 1.6s ease-in-out infinite; }
.final-panel ol { counter-reset: r; }
.toast { position: fixed; left: 50%; top: 80px; transform: translateX(-50%); background: #fff; color: var(--ink); font-weight: 600; padding: 10px 18px; border-radius: 999px; box-shadow: 0 8px 24px rgba(0,0,0,.3); z-index: 30; max-width: 90vw; }
.conn { position: fixed; left: 0; right: 0; top: 0; text-align: center; background: var(--red); padding: 4px; font-weight: 600; z-index: 40; }
