:root {
  color-scheme: dark;
  --bg: #070006;
  --panel: #150012;
  --panel-2: #22001d;
  --pink: #ff4db8;
  --fuchsia: #ff00a8;
  --hot: #ff1493;
  --soft: #ff9bd8;
  --text: #fff5fb;
  --muted: #d9a9ca;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--bg); }
body {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  overscroll-behavior: none;
  background:
    radial-gradient(circle at 50% -10%, rgba(255,0,168,.22), transparent 42%),
    linear-gradient(180deg, #0d000b, #050004 70%);
}

button { font: inherit; }
.app-shell { width: min(100%, 980px); margin: 0 auto; padding: 14px 14px 24px; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 10px; }
.brand-kicker { display: block; font-size: .7rem; font-weight: 900; letter-spacing: .19em; color: var(--soft); }
h1 { margin: 1px 0 0; font-size: clamp(1.5rem, 4vw, 2.25rem); line-height: 1; }
.top-actions { display: flex; align-items: center; gap: 8px; }

.start-btn {
  border: 1px solid rgba(255,255,255,.22);
  border-radius: 999px;
  padding: 10px 18px;
  font-weight: 900;
  color: #fff;
  background: linear-gradient(135deg, #ff1493, #c400ff);
  box-shadow: 0 0 18px rgba(255,0,168,.34), inset 0 0 0 1px rgba(255,255,255,.14);
  cursor: pointer;
  transition: transform .14s ease, filter .14s ease;
}
.start-btn:hover { filter: brightness(1.1); transform: translateY(-1px); }
.start-btn:active { transform: translateY(1px) scale(.98); }
.start-btn.big { padding: 12px 28px; font-size: 1.05rem; }
.help-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(255,155,216,.5);
  border-radius: 999px;
  padding: 9px 16px;
  color: #ffe4f5;
  background: linear-gradient(180deg, rgba(72,0,60,.95), rgba(31,0,27,.95));
  box-shadow: inset 0 0 14px rgba(255,0,168,.1);
  font-weight: 900;
  text-decoration: none;
  transition: transform .14s ease, filter .14s ease;
}
.help-btn:hover { filter: brightness(1.16); transform: translateY(-1px); }
.help-btn:active { transform: translateY(1px) scale(.98); }

.dev-panel {
  display: grid;
  grid-template-columns: minmax(190px, 1.5fr) auto 76px repeat(4, auto);
  align-items: center;
  gap: 7px;
  margin: 0 0 10px;
  padding: 9px;
  border: 1px solid rgba(255,211,90,.48);
  border-radius: 14px;
  background: linear-gradient(180deg, rgba(66,35,0,.9), rgba(28,10,0,.94));
  box-shadow: inset 0 0 18px rgba(255,178,31,.08);
}
.dev-intro { display: flex; flex-direction: column; min-width: 0; }
.dev-intro strong { color: #ffe48d; }
.dev-intro span { color: #dcbf91; font-size: .68rem; }
.dev-toggle,.dev-level { display: flex; align-items: center; gap: 6px; color: #fff1c9; font-size: .78rem; font-weight: 850; }
.dev-toggle input { width: 20px; height: 20px; accent-color: #ffb21f; }
.dev-level { flex-direction: column; gap: 1px; }
.dev-level input { width: 68px; min-height: 32px; border: 1px solid rgba(255,255,255,.28); border-radius: 8px; color: #fff; background: #270e00; text-align: center; font-weight: 900; }
.dev-panel button { min-height: 34px; border: 1px solid rgba(255,255,255,.25); border-radius: 9px; padding: 6px 9px; color: #241000; background: linear-gradient(#ffe17b,#f5a91f); font-size: .73rem; font-weight: 950; cursor: pointer; }
.dev-panel button:active { transform: translateY(1px); }
.dev-panel output { grid-column: 1 / -1; color: #ffdc82; font-size: .7rem; font-weight: 850; text-align: right; }

.hud { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)) minmax(180px, 2fr); gap: 6px; margin-bottom: 10px; }
.hud-card {
  min-width: 0;
  border: 1px solid rgba(255,77,184,.33);
  background: linear-gradient(180deg, rgba(45,0,36,.92), rgba(20,0,17,.92));
  border-radius: 14px;
  padding: 8px 10px;
  box-shadow: inset 0 0 20px rgba(255,0,168,.06);
}
.hud-card span { display: block; color: var(--muted); font-size: .72rem; font-weight: 800; text-transform: uppercase; letter-spacing: .07em; }
.hud-card strong { display: block; margin-top: 1px; font-size: clamp(1.05rem, 3vw, 1.45rem); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.distance-card strong { color: #ffd8f0; text-shadow: 0 0 10px rgba(255,0,168,.45); }
.egg-card strong { color: #ffd79c; text-shadow: 0 0 9px rgba(255,184,75,.45); }
.boost-card { padding-right: 7px; }
.boost-state { display: flex; align-items: center; gap: 5px; min-height: 29px; }
.boost-state canvas { flex: 0 0 96px; width: 96px; height: 28px; }
.boost-card .boost-state strong {
  flex: 1 1 auto;
  min-width: 0;
  margin: 0;
  color: #fff1b8;
  font-size: .7rem;
  line-height: 1.12;
  white-space: normal;
  overflow: visible;
  text-overflow: clip;
  text-shadow: 0 0 8px rgba(255,146,36,.4);
}

.boost-notice {
  display: flex;
  align-items: center;
  justify-content: center;
  width: min(100%, 680px);
  min-height: 31px;
  margin: -2px auto 7px;
  padding: 4px 12px;
  border: 1px solid transparent;
  border-radius: 11px;
  color: transparent;
  font-size: .82rem;
  font-weight: 1000;
  letter-spacing: .045em;
  text-align: center;
  text-transform: uppercase;
  opacity: 0;
  transform: translateY(-3px);
  transition: opacity .16s ease, transform .16s ease;
}
.boost-notice.show {
  color: #fff;
  opacity: 1;
  transform: translateY(0);
  border-color: rgba(255,255,255,.24);
  background: linear-gradient(90deg, rgba(86,0,70,.94), rgba(31,0,27,.94));
  box-shadow: 0 0 14px rgba(255,0,168,.2);
}
.boost-notice.rainbow { background: linear-gradient(90deg, #b71d75, #6949b9, #167aa0); }
.boost-notice.filippo { color: #321600; background: linear-gradient(90deg, #ffb21f, #ffe16a, #ff962b); }
.boost-notice.spray { color: #002b26; background: linear-gradient(90deg, #40d3ba, #b9fff1, #35b9ac); }
.boost-notice.smart { color: #001d32; background: linear-gradient(90deg, #39a8df, #bdefff, #438be2); }
.boost-notice.tutorial { color: #04210e; background: linear-gradient(90deg, #43d96f, #c7ffd6, #35bd65); }
.boost-notice.annie { color: #3d1700; background: linear-gradient(90deg, #ff8a18, #ffd36b, #ff7a00); }
.boost-notice.egg { color: #3b2100; background: linear-gradient(90deg, #d78a1e, #ffe1a1, #c97016); }

.game-wrap {
  position: relative;
  width: min(100%, 680px);
  margin: 0 auto;
  border-radius: 20px;
  padding: 8px;
  background: linear-gradient(135deg, rgba(255,77,184,.75), rgba(129,0,255,.55));
  box-shadow: 0 0 28px rgba(255,0,168,.28);
}

.tap-zones {
  position: absolute;
  inset: 8px;
  z-index: 2;
  display: none;
  pointer-events: none;
  overflow: hidden;
  border-radius: 14px;
}
.tap-zone {
  position: absolute;
  margin: 0;
  padding: 0;
  border: 1px solid transparent;
  color: transparent;
  background: transparent;
  pointer-events: auto;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.tap-zone span {
  position: absolute;
  left: 50%;
  top: 50%;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  transform: translate(-50%,-50%);
  border-radius: 50%;
  color: #effff3;
  background: rgba(3,78,30,.74);
  box-shadow: 0 0 18px rgba(68,255,129,.85);
  font-size: 1.25rem;
  opacity: 0;
}
.tap-up,.tap-down { left: 25%; width: 50%; height: 24%; }
.tap-left,.tap-right { top: 25%; width: 24%; height: 50%; }
.tap-up { top: 0; }
.tap-right { right: 0; }
.tap-down { bottom: 0; }
.tap-left { left: 0; }
.tap-zones.tutorial .tap-zone {
  border-color: rgba(109,255,153,.72);
  background: rgba(45,224,101,.22);
  box-shadow: inset 0 0 30px rgba(61,255,123,.2);
  animation: tap-zone-pulse 1s ease-in-out infinite alternate;
}
.tap-zones.tutorial .tap-zone span,.tap-zone.pressed span { opacity: 1; }
.tap-zone.pressed { background: rgba(45,224,101,.28); }
canvas {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 1 / 1;
  background: #030003;
  border-radius: 14px;
  touch-action: none;
}

.overlay {
  position: absolute;
  inset: 8px;
  display: grid;
  place-items: center;
  border-radius: 14px;
  background: rgba(6,0,5,.58);
  backdrop-filter: blur(5px);
  opacity: 0;
  pointer-events: none;
  z-index: 3;
  transition: opacity .22s ease;
}
.overlay.show { opacity: 1; pointer-events: auto; }
.overlay-card {
  width: min(88%, 430px);
  padding: 22px 20px;
  border: 1px solid rgba(255,255,255,.16);
  border-radius: 20px;
  text-align: center;
  background: linear-gradient(180deg, rgba(47,0,39,.96), rgba(16,0,14,.96));
  box-shadow: 0 0 42px rgba(255,0,168,.34);
}
.overlay-icon { font-size: 3rem; filter: drop-shadow(0 0 14px #ff00a8); animation: bob 1.7s ease-in-out infinite; }
.overlay-icon img { display: block; width: 78px; height: 78px; object-fit: contain; margin: 0 auto; }
.overlay h2 { margin: 4px 0 8px; font-size: clamp(1.7rem, 5vw, 2.6rem); }
.overlay p { margin: 0 auto 16px; max-width: 38ch; color: #f5c9e6; line-height: 1.45; }

.controls-help { margin: 10px auto 0; text-align: center; color: var(--muted); font-size: .88rem; }
.touch-controls {
  display: none;
  grid-template-columns: repeat(5, 58px);
  grid-template-rows: repeat(2, 58px);
  justify-content: center;
  gap: 7px;
  margin: 12px auto 0;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}
.dpad, .egg-action, .pause-action {
  border: 1px solid rgba(255,255,255,.22);
  border-radius: 16px;
  color: #fff;
  font-weight: 1000;
  font-size: 1.25rem;
  background: linear-gradient(180deg, #420038, #22001d);
  box-shadow: inset 0 0 18px rgba(255,0,168,.14), 0 4px 14px rgba(0,0,0,.35);
  touch-action: none;
}
.dpad:active, .dpad.pressed { background: linear-gradient(180deg, #ff1493, #8a005d); transform: translateY(1px); }
.egg-action {
  grid-column: 5;
  grid-row: 1;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 0;
  padding: 2px;
  border-color: rgba(255,212,123,.5);
  background: linear-gradient(180deg, #6a3b05, #2c1600);
  font-size: 1.25rem;
}
.egg-action small { font-size: .52rem; font-weight: 1000; letter-spacing: .06em; line-height: 1; }
.egg-action:active, .egg-action.pressed { background: linear-gradient(180deg, #ffae35, #9b3b00); transform: translateY(1px); }
.egg-action:disabled { opacity: .38; filter: grayscale(.7); }
.pause-action {
  grid-column: 1;
  grid-row: 1;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 1px;
  padding: 2px;
  border-color: rgba(120,190,255,.55);
  background: linear-gradient(180deg, #143867, #071a36);
  font-size: 1.15rem;
}
.pause-action small { font-size: .48rem; font-weight: 1000; letter-spacing: .05em; line-height: 1; }
.pause-action:active, .pause-action.pressed { background: linear-gradient(180deg, #287bd1, #0c386d); transform: translateY(1px); }
.pause-action:disabled { opacity: .38; filter: grayscale(.7); }
.pause-icon {
  position: relative;
  display: inline-block;
  width: 18px;
  height: 19px;
  color: #fff;
}
.pause-icon::before,
.pause-icon::after {
  content: "";
  position: absolute;
  top: 1px;
  width: 5px;
  height: 17px;
  border-radius: 2px;
  background: currentColor;
  box-shadow: 0 0 6px rgba(130, 205, 255, .65);
}
.pause-icon::before { left: 2px; }
.pause-icon::after { right: 2px; }
.pause-icon.play::before {
  left: 3px;
  top: 1px;
  width: 0;
  height: 0;
  border-top: 8.5px solid transparent;
  border-bottom: 8.5px solid transparent;
  border-left: 14px solid currentColor;
  border-radius: 1px;
  background: transparent;
  box-shadow: none;
}
.pause-icon.play::after { display: none; }
.control-slot {
  border: 1px dashed rgba(255,255,255,.22);
  border-radius: 16px;
  background: rgba(25,0,22,.38);
  box-shadow: inset 0 0 14px rgba(255,0,168,.04);
}
.reserve-left { grid-column: 1; grid-row: 2; }
.reserve-right { grid-column: 5; grid-row: 2; }
.up { grid-column: 3; grid-row: 1; }
.left { grid-column: 2; grid-row: 2; }
.down { grid-column: 3; grid-row: 2; }
.right { grid-column: 4; grid-row: 2; }

@keyframes bob { 0%,100% { transform: translateY(0) rotate(-2deg); } 50% { transform: translateY(-7px) rotate(2deg); } }
@keyframes tap-zone-pulse { from { opacity: .68; } to { opacity: 1; } }

@media (pointer: coarse), (max-width: 900px) {
  .touch-controls { display: grid; }
  .tap-zones { display: block; }
  .dev-panel { grid-template-columns: repeat(4, minmax(0,1fr)); }
  .dev-intro,.dev-panel output { grid-column: 1 / -1; }
  .dev-toggle { grid-column: span 2; }
  .dev-level { grid-column: span 2; flex-direction: row; justify-content: flex-end; }
}

@media (max-width: 560px) {
  .app-shell { padding: 9px 8px 16px; }
  .topbar { align-items: flex-end; }
  .top-actions { gap: 5px; }
  .start-btn, .help-btn { padding: 8px 12px; font-size: .88rem; }
  .dev-panel { gap: 5px; padding: 7px; }
  .dev-panel button { min-height: 38px; padding: 5px 4px; font-size: .64rem; }
  .hud { grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 4px; }
  .hud-card { padding: 7px 4px; border-radius: 10px; }
  .hud-card span { font-size: .54rem; letter-spacing: .045em; }
  .hud-card strong { font-size: .94rem; }
  .boost-card { grid-column: 1 / -1; display: flex; align-items: center; gap: 9px; padding: 5px 9px; }
  .boost-card > span { flex: 0 0 auto; }
  .boost-state { flex: 1 1 auto; min-width: 0; min-height: 27px; }
  .boost-card .boost-state strong { font-size: .72rem; }
  .boost-notice { min-height: 27px; margin-bottom: 5px; padding: 3px 8px; font-size: .67rem; }
  .game-wrap { border-radius: 14px; padding: 5px; }
  .tap-zones { inset: 5px; }
  .overlay { inset: 5px; }
  .controls-help { font-size: .76rem; }
  .touch-controls { grid-template-columns: repeat(5, 54px); grid-template-rows: repeat(2, 52px); gap: 6px; margin-top: 8px; }
}
