/* FREEDOM SMASH. Phone first. Loud on purpose. */
@font-face { font-family: 'Anton'; src: url(/fonts/anton.woff2) format('woff2'); font-display: swap; }
@font-face { font-family: 'Bungee'; src: url(/fonts/bungee.woff2) format('woff2'); font-display: swap; }

:root {
  --navy: #0a1a44; --navy2: #13286b; --navy3: #1d3a94; --red: #b22234; --red2: #ff3b3b; --white: #ffffff;
  --gold: #ffd23f; --blue: #3c6dff; --sky: #9fb4ff; --ink: #050c22; --green: #39d98a;
  --display: 'Anton', Impact, 'Arial Black', system-ui, sans-serif;
  --chunky: 'Bungee', 'Arial Black', Impact, system-ui, sans-serif;
  --body: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  color-scheme: dark;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; overscroll-behavior: none; }
body {
  background: var(--navy);
  background-image:
    radial-gradient(circle at 50% 38%, rgba(60, 109, 255, .35), transparent 60%),
    repeating-linear-gradient(180deg, rgba(178, 34, 52, .16) 0 26px, transparent 26px 52px);
  color: var(--white); font-family: var(--body);
  user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; touch-action: manipulation;
}
button { font: inherit; color: inherit; cursor: pointer; }
#fx { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 30; }

#app {
  position: relative; height: 100%; max-width: 560px; margin: 0 auto; display: flex; flex-direction: column;
  padding: calc(env(safe-area-inset-top) + 8px) 12px calc(env(safe-area-inset-bottom) + 6px);
  will-change: transform;
}

/* --- HUD --- */
#hud { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 40px; }
.who { background: rgba(255,255,255,.08); border: 2px solid rgba(255,255,255,.18); border-radius: 999px; padding: 6px 12px;
  font-family: var(--chunky); font-size: 14px; max-width: 58%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.who #mystate { color: var(--gold); margin-left: 6px; }
.hud-right { display: flex; gap: 6px; align-items: center; }
.pill { background: rgba(255,255,255,.08); border: 2px solid rgba(255,255,255,.18); border-radius: 999px; padding: 5px 10px;
  font-family: var(--chunky); font-size: 14px; line-height: 1.1; white-space: nowrap; }
.pill.danger { border-color: var(--red2); background: rgba(255,59,59,.25); animation: pulse 1s infinite; }
.pill.hot { border-color: var(--gold); color: var(--gold); }
.pill.boost { border-color: var(--green); color: var(--green); animation: pulse 1.2s infinite; }
#mute { min-width: 44px; }

/* --- score --- */
#scorebox { text-align: center; margin-top: 6px; }
#total { font-family: var(--display); font-size: clamp(44px, 13vw, 68px); line-height: 1; color: var(--gold);
  text-shadow: 3px 3px 0 var(--red), -1px -1px 0 var(--ink); letter-spacing: 1px; }
#total.bump { animation: bump .18s ease-out; }
.lbl { font-family: var(--chunky); font-size: 13px; letter-spacing: 2px; color: var(--sky); }
.lbl #today { color: var(--white); opacity: .8; letter-spacing: 0; }
#rankline { font-size: 13px; margin-top: 4px; opacity: .95; }
#rankline b { color: var(--gold); }
.bar { height: 8px; background: rgba(255,255,255,.12); border-radius: 99px; overflow: hidden; }
.bar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--red2), var(--gold)); border-radius: 99px; transition: width .3s; }
.rankbar { max-width: 260px; margin: 5px auto 0; height: 6px; }

/* --- boss --- */
#boss { flex: 1; display: flex; flex-direction: column; min-height: 0; margin-top: 8px; }
#bosshead { text-align: center; }
#bosslbl { font-family: var(--chunky); font-size: 11px; letter-spacing: 2px; color: var(--sky); }
#bosslvl { color: var(--red2); }
#bossname { font-family: var(--display); font-size: clamp(22px, 7vw, 32px); line-height: 1.05; text-transform: uppercase; }
.hpbar { position: relative; height: 22px; margin-top: 6px; border-radius: 6px; background: rgba(0,0,0,.45); border: 2px solid rgba(255,255,255,.25); overflow: hidden; }
.hpbar i { position: absolute; inset: 0 auto 0 0; width: 100%; background: linear-gradient(90deg, #ff1f3d, #ff7b2e); transition: width .25s; }
.hpbar span { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-family: var(--chunky); font-size: 12px; text-shadow: 1px 1px 0 #000; }
#bossmeta { display: flex; justify-content: space-between; gap: 8px; font-size: 12px; margin-top: 4px; opacity: .9; white-space: nowrap; }
#bossmeta span { overflow: hidden; text-overflow: ellipsis; }
#online b { color: var(--green); }

#arena { position: relative; flex: 1; min-height: 200px; display: flex; align-items: center; justify-content: center; touch-action: none; cursor: pointer; }
#target {
  position: relative; width: min(64vw, 40vh, 300px); aspect-ratio: 1; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: radial-gradient(circle, #ffffff 0 18%, var(--red) 18% 34%, #ffffff 34% 50%, var(--red) 50% 66%, var(--navy3) 66% 100%);
  box-shadow: 0 0 0 6px rgba(255,255,255,.15), 0 12px 40px rgba(0,0,0,.6), inset 0 -10px 30px rgba(0,0,0,.35);
  will-change: transform, filter;
}
#bossemoji { font-size: min(30vw, 19vh, 140px); line-height: 1; filter: drop-shadow(0 6px 6px rgba(0,0,0,.5)); }
#dmgmarks { position: absolute; inset: 0; pointer-events: none; font-size: min(10vw, 6vh, 46px); }
#dmgmarks span { position: absolute; }
#target.dead #bossemoji { animation: die .7s ease-in forwards; }
#target.spawn { animation: drop .6s cubic-bezier(.2,1.6,.4,1); }
#hint { position: absolute; bottom: 6%; font-family: var(--chunky); font-size: 18px; color: var(--gold); animation: pulse 1s infinite; pointer-events: none; text-shadow: 2px 2px 0 #000; }
#speech { position: absolute; top: 2%; left: 4%; right: 4%; background: #fff; color: #111; border-radius: 14px; padding: 8px 12px;
  font-family: var(--chunky); font-size: 12px; text-align: center; z-index: 2; box-shadow: 0 4px 0 rgba(0,0,0,.35); pointer-events: none; }
#speech:after { content: ''; position: absolute; bottom: -10px; left: 50%; margin-left: -10px; border: 10px solid transparent; border-bottom: 0; border-top-color: #fff; }
#speech.roast { background: var(--red2); color: #fff; }
#speech.roast:after { border-top-color: var(--red2); }

#combo { position: absolute; right: 0; top: 50%; transform: translateY(-50%); text-align: center; width: 92px; pointer-events: none; z-index: 3; }
#combonum { font-family: var(--display); font-size: 46px; line-height: 1; color: #fff; text-shadow: 3px 3px 0 var(--red); }
#combox { font-family: var(--chunky); font-size: 22px; color: var(--gold); text-shadow: 2px 2px 0 #000; }
#comboname { font-family: var(--chunky); font-size: 10px; line-height: 1.1; color: var(--sky); min-height: 22px; }
.cbar { height: 6px; margin-top: 4px; }
.cbar i { transition: none; background: var(--gold); }
#combo.t3 #combonum, #combo.t4 #combonum { color: var(--gold); }
#combo.t5 #combonum, #combo.t6 #combonum { color: var(--red2); text-shadow: 3px 3px 0 #fff; animation: wobble .3s infinite; }

#floaters { position: absolute; inset: 0; pointer-events: none; overflow: visible; z-index: 4; }
#floaters > div { position: absolute; opacity: 0; }
.fl { position: absolute; font-family: var(--display); font-size: 26px; color: #fff; text-shadow: 2px 2px 0 #000; white-space: nowrap;
  transform: translate(-50%, -50%); animation: floatup .8s ease-out forwards; opacity: 1; }
.fl.crit { font-size: 40px; color: var(--gold); text-shadow: 3px 3px 0 var(--red), -2px -2px 0 #000; animation-duration: 1.1s; }
.fl.mega { font-size: 58px; color: var(--red2); text-shadow: 3px 3px 0 #fff, -3px -3px 0 #000; animation-duration: 1.4s; }
.fl.slow { font-size: 16px; color: #aaa; }

#rival { min-height: 22px; text-align: center; font-family: var(--chunky); font-size: 12px; color: var(--sky); margin: 2px 0; }
#rival b { color: var(--gold); }
#ticker { overflow: hidden; white-space: nowrap; background: rgba(0,0,0,.4); border-top: 2px solid var(--red); border-bottom: 2px solid var(--red);
  font-family: var(--chunky); font-size: 12px; padding: 5px 0; margin-bottom: 6px; }
#tickertext { display: inline-block; padding-left: 100%; animation: ticker 18s linear infinite; }

/* --- dock --- */
#dock { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
#dock button { position: relative; background: linear-gradient(180deg, var(--navy3), var(--navy2)); border: 2px solid rgba(255,255,255,.22);
  border-radius: 14px; padding: 6px 2px 5px; display: flex; flex-direction: column; align-items: center; gap: 2px; box-shadow: 0 4px 0 rgba(0,0,0,.45); }
#dock button:active { transform: translateY(3px); box-shadow: 0 1px 0 rgba(0,0,0,.45); }
#dock span { font-size: 22px; line-height: 1; }
#dock b { font-family: var(--chunky); font-size: 9px; letter-spacing: .5px; font-weight: normal; }
#dock .dot { display: none; position: absolute; top: -5px; right: -3px; width: 16px; height: 16px; border-radius: 50%; background: var(--red2); border: 2px solid #fff; animation: pulse 1s infinite; }
#dock button.ready .dot { display: block; }
#dock button.ready { border-color: var(--gold); }

/* --- shouts & toasts --- */
#shout { position: fixed; left: 0; right: 0; top: 34%; z-index: 40; text-align: center; pointer-events: none; font-family: var(--display);
  font-size: clamp(34px, 11vw, 64px); line-height: 1; color: var(--gold); text-shadow: 4px 4px 0 var(--red), -2px -2px 0 #000; padding: 0 12px; opacity: 0; }
#shout.go { animation: shout 1.1s ease-out forwards; }
#shout.big { font-size: clamp(42px, 14vw, 84px); color: #fff; text-shadow: 5px 5px 0 var(--red2), -3px -3px 0 var(--blue); }
#toast { position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom) + 92px); transform: translateX(-50%) translateY(20px); z-index: 45;
  background: var(--ink); border: 2px solid var(--gold); border-radius: 14px; padding: 10px 14px; max-width: min(92vw, 520px);
  font-family: var(--chunky); font-size: 13px; text-align: center; opacity: 0; transition: opacity .2s, transform .2s; pointer-events: none; }
#toast.on { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast.bad { border-color: var(--red2); }

/* --- sheets --- */
#sheet { position: fixed; inset: 0; z-index: 50; background: rgba(0,0,0,.6); display: flex; align-items: flex-end; justify-content: center; }
#sheet[hidden] { display: none; }
.sheet-card { position: relative; width: 100%; max-width: 560px; max-height: 88vh; overflow-y: auto; background: var(--navy2);
  border: 3px solid var(--gold); border-bottom: 0; border-radius: 22px 22px 0 0; padding: 18px 16px calc(env(safe-area-inset-bottom) + 20px);
  animation: up .22s ease-out; user-select: text; -webkit-user-select: text; touch-action: pan-y; }
.sheet-card .x { position: absolute; top: 8px; right: 10px; background: none; border: 0; font-size: 22px; padding: 6px 10px; }
.sheet-card h2 { font-family: var(--display); font-size: 30px; margin: 0 34px 8px 0; line-height: 1.05; letter-spacing: .5px; }
.sheet-card h3 { font-family: var(--chunky); font-size: 14px; margin: 16px 0 6px; color: var(--gold); }
.sheet-card p { margin: 6px 0; line-height: 1.4; }
.small { font-size: 13px; opacity: .85; }
.muted { opacity: .7; }
.big-emoji { font-size: 96px; text-align: center; line-height: 1.1; margin: 8px 0; }
.countdown { font-family: var(--display); font-size: 40px; color: var(--gold); text-align: center; }
.btn { display: block; width: 100%; border: 0; border-radius: 14px; padding: 14px; margin-top: 12px; background: var(--red2); color: #fff;
  font-family: var(--chunky); font-size: 18px; box-shadow: 0 5px 0 #8a1020; }
.btn:active { transform: translateY(4px); box-shadow: 0 1px 0 #8a1020; }
.btn.gold { background: var(--gold); color: var(--ink); box-shadow: 0 5px 0 #a8830a; }
.btn.blue { background: var(--blue); box-shadow: 0 5px 0 #1d3a94; }
.btn[disabled] { opacity: .45; filter: grayscale(.6); }
.btn.huge { font-size: 24px; padding: 18px; }
.linkish { background: none; border: 0; color: var(--sky); text-decoration: underline; margin-top: 14px; font-size: 14px; }
.tabs { display: flex; gap: 4px; margin-bottom: 8px; flex-wrap: wrap; }
.tabs button { flex: 1; background: rgba(255,255,255,.08); border: 2px solid rgba(255,255,255,.2); border-radius: 10px; padding: 7px 4px; font-family: var(--chunky); font-size: 11px; }
.tabs button.on { background: var(--gold); color: var(--ink); border-color: var(--gold); }
.lb { list-style: none; margin: 0; padding: 0; }
.lb li { display: grid; grid-template-columns: 38px 1fr auto; gap: 8px; align-items: center; padding: 7px 6px; border-bottom: 1px solid rgba(255,255,255,.08); font-size: 15px; }
.lb li.me { background: rgba(255,210,63,.18); border-radius: 8px; }
.lb .pos { font-family: var(--chunky); color: var(--sky); text-align: right; }
.lb .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb .nm small { color: var(--gold); margin-left: 4px; }
.lb .v { font-family: var(--chunky); color: var(--gold); font-size: 14px; }
.lb .roast { grid-column: 2 / 4; font-size: 12px; opacity: .7; margin-top: -4px; }
.mine { margin-top: 8px; padding: 8px; border-radius: 10px; background: rgba(255,255,255,.08); font-family: var(--chunky); font-size: 13px; text-align: center; }
.sides { display: grid; gap: 10px; margin-top: 10px; }
.side { position: relative; overflow: hidden; border-radius: 14px; border: 3px solid rgba(255,255,255,.3); padding: 14px; text-align: left; background: rgba(0,0,0,.3); font-family: var(--chunky); font-size: 16px; }
.side .fill { position: absolute; inset: 0 auto 0 0; background: rgba(255,59,59,.35); z-index: 0; transition: width .4s; }
.side.b .fill { background: rgba(60,109,255,.45); }
.side span { position: relative; z-index: 1; }
.side .pct { float: right; color: var(--gold); }
.side.mine { border-color: var(--gold); }
.prog { height: 16px; margin: 10px 0; }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 8px; }
.stats div { background: rgba(255,255,255,.07); border-radius: 10px; padding: 8px; font-size: 12px; }
.stats b { display: block; font-family: var(--chunky); font-size: 16px; color: var(--gold); }
input[type=text], select { width: 100%; font-size: 18px; padding: 12px; border-radius: 10px; border: 2px solid var(--sky); background: var(--ink); color: #fff; font-family: var(--chunky); }
label { display: block; font-family: var(--chunky); font-size: 12px; margin: 12px 0 4px; color: var(--sky); }
.err { color: var(--red2); font-family: var(--chunky); font-size: 13px; min-height: 18px; margin-top: 6px; }
.sharebox { background: var(--ink); border-radius: 12px; padding: 12px; font-size: 15px; line-height: 1.4; border: 2px dashed var(--gold); }
.crate-box { font-size: 120px; text-align: center; cursor: pointer; touch-action: none; transition: transform .08s; }
.crate-box.s1 { transform: rotate(-6deg) scale(1.04); } .crate-box.s2 { transform: rotate(8deg) scale(1.08); }
.crate-box.s3 { transform: rotate(-10deg) scale(1.12); } .crate-box.s4 { transform: rotate(12deg) scale(1.18); }
.reward { text-align: center; font-family: var(--display); font-size: 48px; color: var(--gold); text-shadow: 3px 3px 0 var(--red); }

/* --- gate --- */
#gate { position: fixed; inset: 0; z-index: 60; display: flex; align-items: center; justify-content: center; padding: 16px;
  background: repeating-linear-gradient(135deg, #111 0 22px, #2b2400 22px 44px); }
#gate[hidden] { display: none; }
.gate-card { max-width: 460px; background: var(--navy); border: 4px solid var(--gold); border-radius: 20px; padding: 22px 18px; text-align: center; box-shadow: 0 10px 40px #000; }
.gate-warn { font-family: var(--chunky); color: var(--gold); font-size: 20px; letter-spacing: 2px; animation: pulse 1s infinite; }
.gate-card h1 { font-family: var(--display); font-size: clamp(34px, 10vw, 50px); line-height: 1; margin: 10px 0; color: #fff; text-shadow: 3px 3px 0 var(--red); }
.gate-card p { line-height: 1.45; }

/* --- animations --- */
@keyframes pulse { 50% { opacity: .55; } }
@keyframes bump { 40% { transform: scale(1.12); } }
@keyframes wobble { 25% { transform: rotate(-4deg); } 75% { transform: rotate(4deg); } }
@keyframes floatup { 0% { opacity: 1; transform: translate(-50%, -50%) scale(.6); } 15% { transform: translate(-50%, -70%) scale(1.15); } 100% { opacity: 0; transform: translate(-50%, -220%) scale(1); } }
@keyframes shout { 0% { opacity: 0; transform: scale(2.4) rotate(-6deg); } 12% { opacity: 1; transform: scale(.95) rotate(2deg); } 20% { transform: scale(1.05) rotate(-1deg); } 75% { opacity: 1; transform: scale(1); } 100% { opacity: 0; transform: scale(1.1) translateY(-30px); } }
@keyframes ticker { to { transform: translateX(-100%); } }
@keyframes up { from { transform: translateY(40px); opacity: 0; } }
@keyframes die { 30% { transform: scale(1.4) rotate(20deg); filter: brightness(3); } 100% { transform: scale(0) rotate(-200deg); opacity: 0; } }
@keyframes drop { 0% { transform: translateY(-120%) scale(.5); } 100% { transform: none; } }

@media (min-width: 700px) {
  #dock b { font-size: 11px; }
  #ticker, #rival { font-size: 13px; }
}
@media (max-height: 640px) {
  #rankline { display: none; } .rankbar { display: none; }
  #total { font-size: 40px; }
  #bossname { font-size: 20px; }
}
@media (prefers-reduced-motion: reduce) {
  #tickertext { animation-duration: 40s; }
}
