* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; height: 100%; overflow: hidden; background: #1c120c; color: #fff;
  font-family: 'Lilita One', 'Arial Rounded MT Bold', 'Trebuchet MS', system-ui, sans-serif;
  touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
  overscroll-behavior: none;
}
#c { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
.hidden { display: none !important; }

/* ---------- HUD ---------- */
#hud { position: fixed; inset: 0; pointer-events: none; z-index: 5; }
#scores {
  position: absolute; top: max(10px, env(safe-area-inset-top)); left: max(12px, env(safe-area-inset-left));
  right: max(12px, env(safe-area-inset-right)); display: flex; justify-content: space-between; gap: 8px;
}
.badge {
  display: flex; align-items: center; gap: 8px; padding: 6px 12px 6px 6px; border-radius: 999px;
  background: rgba(20, 12, 8, .55); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  border: 2px solid rgba(255,255,255,.15); transition: opacity .4s, transform .2s;
}
.badge.out { opacity: .3; filter: grayscale(1); }
.badge .num {
  width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; font-size: 20px;
  border: 3px solid #fff; box-shadow: 0 2px 0 rgba(0,0,0,.4);
}
.badge .who { font-size: 13px; opacity: .8; letter-spacing: .5px; }
.badge .pips { display: flex; gap: 3px; }
.pip {
  width: 13px; height: 13px; border-radius: 50%; background: #ffd23a;
  box-shadow: inset 0 -2px 0 rgba(0,0,0,.25); transition: transform .3s, background .3s;
}
.pip.lost { background: rgba(255,255,255,.15); box-shadow: none; transform: scale(.7); }
.badge.hit { animation: badgeHit .5s; }
@keyframes badgeHit {
  0% { transform: scale(1); } 20% { transform: scale(1.35) rotate(-6deg); }
  40% { transform: scale(.9) rotate(5deg); } 70% { transform: scale(1.08); } 100% { transform: scale(1); }
}
#quit {
  pointer-events: auto; position: absolute; bottom: max(10px, env(safe-area-inset-bottom)); left: 50%;
  transform: translateX(-50%); width: 36px; height: 36px; border-radius: 50%; border: 0;
  background: rgba(20,12,8,.5); color: #fff; font: inherit; font-size: 16px; cursor: pointer;
}

/* ---------- popups ---------- */
#popups { position: fixed; inset: 0; pointer-events: none; z-index: 6; overflow: hidden; }
.pop {
  position: absolute; transform: translate(-50%, -50%); white-space: nowrap; font-size: 44px;
  color: #ffd23a; -webkit-text-stroke: 3px #2a1206; paint-order: stroke fill;
  text-shadow: 0 5px 0 #2a1206; animation: pop 1s cubic-bezier(.2,1.6,.4,1) forwards;
}
.pop.small { font-size: 28px; color: #fff; }
.pop.minus { font-size: 34px; color: #ff4d4d; animation-name: rise; }
@keyframes pop {
  0% { transform: translate(-50%,-50%) scale(0) rotate(-20deg); opacity: 1; }
  25% { transform: translate(-50%,-60%) scale(1.3) rotate(6deg); }
  45% { transform: translate(-50%,-60%) scale(1) rotate(-3deg); }
  80% { opacity: 1; }
  100% { transform: translate(-50%,-110%) scale(.9); opacity: 0; }
}
@keyframes rise {
  0% { transform: translate(-50%,-50%) scale(.3); opacity: 0; }
  20% { transform: translate(-50%,-90%) scale(1.2); opacity: 1; }
  100% { transform: translate(-50%,-260%) scale(1); opacity: 0; }
}

#countdown {
  position: fixed; inset: 0; display: grid; place-items: center; pointer-events: none; z-index: 7;
  font-size: min(30vw, 40vh); color: #fff; -webkit-text-stroke: 8px #2a1206; paint-order: stroke fill;
  text-shadow: 0 12px 0 #2a1206;
}
#countdown .go { color: #ffd23a; font-size: .7em; }
#countdown span { animation: cd .8s cubic-bezier(.2,1.5,.4,1) forwards; display: inline-block; }
@keyframes cd {
  0% { transform: scale(2.5); opacity: 0; } 30% { transform: scale(1); opacity: 1; }
  80% { transform: scale(.95); opacity: 1; } 100% { transform: scale(.6); opacity: 0; }
}
#flash { position: fixed; inset: 0; background: #fff; opacity: 0; pointer-events: none; z-index: 4; }

/* ---------- touch controls ---------- */
#touch { position: fixed; inset: 0; z-index: 3; }
.stick {
  position: absolute; width: 130px; height: 130px; margin: -65px 0 0 -65px; border-radius: 50%;
  border: 3px solid rgba(255,255,255,.35); background: rgba(255,255,255,.08); pointer-events: none;
  transition: opacity .2s;
}
.stick.idle { opacity: .45; }
.stick .knob {
  position: absolute; left: 50%; top: 50%; width: 58px; height: 58px; margin: -29px 0 0 -29px;
  border-radius: 50%; background: var(--c, #fff); box-shadow: 0 4px 0 rgba(0,0,0,.35), inset 0 -5px 0 rgba(0,0,0,.2);
}
.dash {
  position: absolute; bottom: max(18px, env(safe-area-inset-bottom)); width: 88px; height: 88px; border-radius: 50%;
  display: grid; place-items: center; font-size: 18px; background: var(--c, #ffd23a); color: #fff;
  -webkit-text-stroke: 2px rgba(0,0,0,.35); paint-order: stroke fill;
  box-shadow: 0 6px 0 rgba(0,0,0,.35), inset 0 -6px 0 rgba(0,0,0,.2); opacity: .85;
}
.dash[data-p="0"] { left: max(18px, env(safe-area-inset-left)); }
.dash[data-p="1"] { right: max(18px, env(safe-area-inset-right)); }
.dash.down { transform: translateY(4px) scale(.94); box-shadow: 0 2px 0 rgba(0,0,0,.35); }
.dash.cool { filter: grayscale(.8) brightness(.7); }

/* ---------- screens ---------- */
.screen {
  position: fixed; inset: 0; z-index: 10; display: grid; place-items: center; padding: 16px;
  background: radial-gradient(ellipse at center, rgba(28,18,12,.25), rgba(28,18,12,.8));
  overflow-y: auto; touch-action: pan-y;
}
.panel { text-align: center; max-width: 720px; width: 100%; }
.logo {
  margin: 0; font-size: clamp(48px, 13vmin, 120px); line-height: .9; font-weight: 400;
  -webkit-text-stroke: 6px #2a1206; paint-order: stroke fill; text-shadow: 0 10px 0 #2a1206;
  transform: rotate(-4deg);
}
.logo span { display: inline-block; animation: bob 1.6s ease-in-out infinite; }
.logo span:first-child { color: #ff4040; }
.logo span:last-child { color: #3aa8ff; margin-left: .2em; animation-delay: -.8s; }
@keyframes bob { 0%,100% { transform: translateY(0) rotate(-2deg); } 50% { transform: translateY(-8px) rotate(2deg); } }
.tag { margin: 18px 0 16px; font-size: clamp(14px, 3.2vmin, 20px); opacity: .9; text-shadow: 0 2px 0 rgba(0,0,0,.5); }
.modes { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.modes.two { grid-template-columns: repeat(2, minmax(0, 220px)); justify-content: center; }
@media (max-width: 600px) { .modes { grid-template-columns: repeat(2, 1fr); } }
button.big {
  font: inherit; font-size: clamp(20px, 4.4vmin, 30px); color: #fff; border: 0; border-radius: 18px; padding: 14px 8px 12px;
  cursor: pointer; box-shadow: 0 7px 0 rgba(0,0,0,.35), inset 0 -6px 0 rgba(0,0,0,.18);
  -webkit-text-stroke: 2px rgba(0,0,0,.25); paint-order: stroke fill; transition: transform .1s, box-shadow .1s;
}
button.big small { display: block; font-size: 13px; opacity: .85; -webkit-text-stroke: 0; margin-top: 2px; }
button.big:active { transform: translateY(5px); box-shadow: 0 2px 0 rgba(0,0,0,.35); }
button.big:hover { filter: brightness(1.08); }
.red { background: #e8322e; } .blue { background: #1f8ff0; } .green { background: #2fb45a; } .yellow { background: #f0a800; }
.row { display: flex; align-items: center; justify-content: center; gap: 12px; margin-top: 18px; font-size: 17px; }
.seg { display: flex; background: rgba(0,0,0,.35); border-radius: 12px; padding: 4px; gap: 4px; }
.seg button {
  font: inherit; font-size: 18px; color: #fff; background: transparent; border: 0; border-radius: 9px;
  width: 44px; height: 36px; cursor: pointer;
}
.seg button.on { background: #ffd23a; color: #2a1206; }
.help { margin-top: 18px; font-family: system-ui, sans-serif; font-size: 13px; line-height: 1.6; opacity: .8; }
.help b { font-family: 'Lilita One', system-ui; font-weight: 400; letter-spacing: .3px; }
#win h2 {
  font-size: clamp(48px, 12vmin, 110px); margin: 0 0 24px; font-weight: 400;
  -webkit-text-stroke: 6px #2a1206; paint-order: stroke fill; text-shadow: 0 10px 0 #2a1206;
  animation: bob 1.4s ease-in-out infinite;
}

#rotate {
  position: fixed; inset: 0; z-index: 20; display: none; place-items: center; align-content: center; gap: 12px;
  background: #1c120c; font-size: 24px; text-align: center;
}
#rotate div { font-size: 80px; animation: spin 2s ease-in-out infinite; }
@keyframes spin { 0%,30% { transform: rotate(0); } 60%,100% { transform: rotate(90deg); } }
@media (orientation: portrait) and (pointer: coarse) { body.playing #rotate { display: grid; } }
