/* WAIT IN LINE — cheesy arcade chrome */
:root {
  --ink: #2a1838;
  --pink: #ff2d92;
  --hot: #ff4d8d;
  --yellow: #ffe14a;
  --mint: #5ee0b5;
  --cream: #fff6e0;
  --sky: #ffb3d9;
  --neon: #39f7ff;
  --lime: #c8ff3d;
  --orange: #ff8a2a;
  --panel: rgba(42, 24, 56, 0.92);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  height: 100vh;
  height: 100dvh;
  height: var(--app-h, 100vh);
  background: #140c1c;
  color: var(--cream);
  font-family: "Trebuchet MS", "Arial Black", Impact, sans-serif;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  overscroll-behavior: none;
  touch-action: manipulation;
  position: fixed;
  inset: 0;
  width: 100%;
}

#app {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(ellipse at 50% 40%, #3a2048 0%, #140c1c 70%);
}

#game {
  width: min(100vw, calc(100vh * 16 / 9));
  height: min(100vh, calc(100vw * 9 / 16));
  width: min(100vw, calc(100dvh * 16 / 9));
  height: min(100dvh, calc(100vw * 9 / 16));
  max-width: 100%;
  max-height: 100%;
  image-rendering: auto;
  background: #7ed4b5;
  display: block;
  box-shadow: 0 0 0 6px var(--ink), 0 0 0 10px var(--yellow), 0 20px 80px rgba(0,0,0,.55);
  cursor: crosshair;
  touch-action: none;
}

.hidden { display: none !important; }

/* HUD */
#hud {
  position: absolute;
  inset: 0;
  pointer-events: none;
  width: 100%;
  height: 100%;
  margin: auto;
}

#hud-left {
  position: absolute;
  top: max(10px, env(safe-area-inset-top, 0px));
  left: max(12px, env(safe-area-inset-left, 0px));
}

#place-wrap {
  background: var(--ink);
  color: var(--yellow);
  border: 4px solid var(--cream);
  box-shadow: 6px 6px 0 var(--pink);
  padding: 8px 16px 10px;
  transform: rotate(-2deg);
}

#place-label {
  font-size: 11px;
  letter-spacing: 3px;
  color: var(--mint);
}

#place-value {
  font-size: 42px;
  line-height: 0.9;
  font-weight: 900;
  text-shadow: 3px 3px 0 var(--pink);
}

#now-serving {
  margin-top: 10px;
  font-size: 12px;
  background: var(--yellow);
  color: var(--ink);
  padding: 4px 8px;
  font-weight: 800;
  transform: rotate(1.5deg);
  display: inline-block;
}

#hud-score {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  text-align: center;
  min-width: 280px;
}

#score-label {
  font-size: 14px;
  letter-spacing: 6px;
  color: var(--yellow);
  text-shadow: 0 0 12px var(--pink), 2px 2px 0 var(--ink);
  animation: pulse 0.8s ease-in-out infinite;
}

#score-value {
  font-size: 56px;
  font-weight: 900;
  line-height: 0.9;
  color: #fff;
  -webkit-text-stroke: 4px var(--ink);
  paint-order: stroke fill;
  text-shadow: 0 6px 0 var(--pink), 0 0 24px rgba(255, 45, 146, 0.6);
}

#score-sub {
  font-size: 13px;
  color: var(--ink);
  background: var(--cream);
  display: inline-block;
  padding: 2px 10px;
  margin-top: 2px;
  transform: rotate(-1deg);
  font-weight: 800;
}

#combo {
  margin-top: 6px;
  font-size: 22px;
  color: var(--lime);
  text-shadow: 2px 2px 0 var(--ink);
  animation: wiggle 0.25s linear infinite;
}

#hud-right {
  position: absolute;
  top: max(10px, env(safe-area-inset-top, 0px));
  right: max(12px, env(safe-area-inset-right, 0px));
  text-align: right;
}

#dash-meter {
  width: 110px;
  height: 14px;
  border: 3px solid var(--ink);
  background: #1a1020;
  display: inline-block;
  box-shadow: 3px 3px 0 var(--neon);
}
#dash-meter span {
  display: block;
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, var(--neon), var(--mint));
}

#hint {
  margin-top: 8px;
  font-size: 11px;
  color: var(--cream);
  opacity: 0.8;
}

#spot-warning {
  position: absolute;
  top: 130px;
  left: 50%;
  transform: translateX(-50%) rotate(-3deg);
  background: var(--pink);
  color: #fff;
  border: 4px solid #fff;
  padding: 8px 18px 12px;
  box-shadow: 8px 8px 0 var(--ink);
  min-width: 260px;
  text-align: center;
  animation: flash 0.35s steps(2) infinite;
  pointer-events: none;
}
.spot-title {
  font-size: 28px;
  font-weight: 900;
  letter-spacing: 2px;
}
.spot-bar {
  margin-top: 6px;
  height: 12px;
  background: #1a1020;
  border: 2px solid #fff;
}
.spot-bar i {
  display: block;
  height: 100%;
  width: 100%;
  background: var(--yellow);
}

/* Screens */
#title-screen, #pause-screen, #victory-screen {
  position: absolute;
  width: 100%;
  height: 100%;
  margin: auto;
  inset: 0;
  overflow: hidden;
  z-index: 3;
}

#title-screen {
  background:
    repeating-linear-gradient(90deg, #ff4d8d 0 18px, #ffe14a 18px 36px, #5ee0b5 36px 54px, #39f7ff 54px 72px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

#title-screen::before {
  content: "";
  position: absolute;
  inset: 16px;
  background:
    radial-gradient(circle at 20% 20%, #ffd6a5, transparent 40%),
    radial-gradient(circle at 80% 30%, #ffb3d9, transparent 40%),
    linear-gradient(#7ec8ff, #c8f5d0);
  border: 6px solid var(--ink);
  pointer-events: none;
}

.marquee {
  position: absolute;
  top: 28px;
  left: 28px;
  right: 28px;
  overflow: hidden;
  background: var(--ink);
  color: var(--yellow);
  font-weight: 900;
  letter-spacing: 2px;
  padding: 6px 0;
  z-index: 2;
  border: 3px solid var(--yellow);
  white-space: nowrap;
}
.marquee span {
  display: inline-block;
  padding-left: 100%;
  animation: marquee 14s linear infinite;
}

.title-hero {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 22px;
  padding: 72px 36px 120px;
  max-width: 980px;
  width: 100%;
}

.title-poster-wrap {
  position: relative;
  flex: 0 0 auto;
  width: min(240px, 28vw);
  transform: rotate(-2.5deg);
  filter: drop-shadow(10px 12px 0 var(--ink));
}

.title-poster {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 2 / 3;
  object-fit: cover;
  object-position: center top;
  border: 5px solid var(--ink);
  background: #1a1020;
}

.title-poster-glow {
  position: absolute;
  inset: -10px;
  border: 3px solid var(--yellow);
  box-shadow: 0 0 28px rgba(255, 45, 146, 0.55), 0 0 0 6px var(--pink);
  pointer-events: none;
}

.title-card {
  position: relative;
  z-index: 2;
  text-align: center;
  background: var(--cream);
  color: var(--ink);
  border: 6px solid var(--ink);
  box-shadow: 12px 12px 0 var(--pink), -8px -8px 0 var(--mint);
  padding: 22px 36px 18px;
  transform: rotate(1deg);
  max-width: 520px;
  flex: 1 1 420px;
}

.eyebrow {
  font-size: 12px;
  letter-spacing: 4px;
  color: var(--pink);
  font-weight: 900;
}

.title-card h1 {
  font-size: clamp(48px, 7vw, 68px);
  line-height: 0.85;
  letter-spacing: -2px;
  text-shadow: 4px 4px 0 var(--yellow), 8px 8px 0 var(--pink);
  margin: 8px 0 10px;
}

.tagline {
  font-size: 17px;
  font-weight: 800;
  font-style: italic;
  line-height: 1.25;
}

.subtag {
  font-size: 12px;
  margin-top: 4px;
  opacity: 0.75;
}

@media (max-width: 820px) {
  .title-hero {
    flex-direction: column;
    gap: 14px;
    padding: 64px 20px 118px;
  }
  .title-poster-wrap {
    width: min(160px, 42vw);
  }
  .title-card {
    max-width: 92%;
    padding: 18px 22px 14px;
  }
  .title-card h1 { font-size: 44px; }
  .controls { font-size: 11px; }
}

#btn-start, #btn-resume, #btn-again, #btn-restart-pause {
  margin-top: 14px;
  font-family: inherit;
  font-size: 20px;
  font-weight: 900;
  padding: 10px 24px;
  border: 4px solid var(--ink);
  background: var(--yellow);
  color: var(--ink);
  cursor: pointer;
  box-shadow: 5px 5px 0 var(--ink);
  letter-spacing: 1px;
}
#btn-start:hover, #btn-resume:hover, #btn-again:hover {
  transform: translate(-2px, -2px);
  box-shadow: 7px 7px 0 var(--ink);
  background: var(--lime);
}
button.ghost {
  background: var(--cream);
  margin-left: 8px;
}

.controls {
  margin-top: 12px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px 14px;
  text-align: left;
  font-size: 12px;
}

#pause-screen, #victory-screen {
  background: rgba(20, 8, 28, 0.72);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 5;
}

.panel {
  background: var(--cream);
  color: var(--ink);
  border: 6px solid var(--ink);
  padding: 32px 40px;
  text-align: center;
  box-shadow: 10px 10px 0 var(--neon);
  max-width: 560px;
}
.panel h2 {
  font-size: 48px;
  text-shadow: 3px 3px 0 var(--yellow);
}
.panel.victory {
  box-shadow: 10px 10px 0 var(--pink), -6px -6px 0 var(--mint);
}
.confetti-label {
  background: var(--pink);
  color: #fff;
  display: inline-block;
  padding: 2px 10px;
  font-weight: 900;
  transform: rotate(-6deg);
}

.install-bar {
  margin-top: 10px;
  height: 16px;
  background: #000;
  border: 2px solid var(--yellow);
}
.install-bar i {
  display: block;
  height: 100%;
  width: 0%;
  background: repeating-linear-gradient(90deg, var(--lime) 0 10px, #8fd80a 10px 20px);
}

#toast {
  position: absolute;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--ink);
  color: var(--yellow);
  border: 3px solid var(--yellow);
  padding: 8px 16px;
  font-weight: 900;
  z-index: 9;
  pointer-events: none;
}

@keyframes pulse {
  50% { transform: scale(1.06); }
}
@keyframes wiggle {
  0% { transform: rotate(-4deg) scale(1); }
  50% { transform: rotate(4deg) scale(1.08); }
  100% { transform: rotate(-4deg) scale(1); }
}
@keyframes flash {
  50% { filter: brightness(1.35); }
}
@keyframes marquee {
  0% { transform: translateX(0); }
  100% { transform: translateX(-100%); }
}
@keyframes popin {
  from { transform: scale(0.6) rotate(-8deg); opacity: 0; }
  to { transform: scale(1) rotate(0); opacity: 1; }
}

.sparkle {
  position: absolute;
  color: var(--yellow);
  animation: pulse 0.4s infinite;
  pointer-events: none;
}

/* ---- mobile / touch chrome ---- */
.ctrl-touch, .hint-touch { display: none; }
body.touch-on .ctrl-kb, body.touch-on .hint-kb { display: none; }
body.touch-on .ctrl-touch, body.touch-on .hint-touch { display: block; }
body.touch-on .controls { grid-template-columns: 1fr; }

img {
  -webkit-user-drag: none;
  user-drag: none;
}

#btn-start, #btn-resume, #btn-again, #btn-restart-pause {
  -webkit-tap-highlight-color: rgba(255, 225, 74, 0.4);
  touch-action: manipulation;
}

#touch-controls {
  display: none;
  position: absolute;
  inset: 0;
  z-index: 4;
  pointer-events: none;
}

body.touch-on[data-state="play"] #touch-controls {
  display: block;
}

.touch-stick {
  pointer-events: auto;
  position: absolute;
  left: max(4px, env(safe-area-inset-left, 0px));
  bottom: max(8px, env(safe-area-inset-bottom, 0px));
  width: min(176px, 46vmin);
  height: min(176px, 46vmin);
  touch-action: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
}

.stick-base {
  position: relative;
  width: 78%;
  height: 78%;
  border-radius: 50%;
  border: 5px solid var(--yellow);
  background: rgba(42, 24, 56, 0.42);
  box-shadow: 5px 5px 0 rgba(255, 45, 146, 0.45), inset 0 0 0 3px var(--ink);
}

.stick-cross {
  position: absolute;
  inset: 18%;
  border-radius: 50%;
  border: 2px dashed rgba(255, 246, 224, 0.35);
  pointer-events: none;
}
.stick-cross::before,
.stick-cross::after {
  content: "";
  position: absolute;
  background: rgba(255, 225, 74, 0.28);
  pointer-events: none;
}
.stick-cross::before {
  left: 50%;
  top: 8%;
  bottom: 8%;
  width: 3px;
  transform: translateX(-50%);
}
.stick-cross::after {
  top: 50%;
  left: 8%;
  right: 8%;
  height: 3px;
  transform: translateY(-50%);
}

.stick-knob {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 46%;
  height: 46%;
  margin: -23% 0 0 -23%;
  border-radius: 50%;
  background: radial-gradient(circle at 32% 28%, #ffb0d8, var(--pink) 62%, #c01060);
  border: 4px solid var(--ink);
  box-shadow: 0 5px 0 var(--yellow), 0 0 12px rgba(255, 45, 146, 0.55);
  pointer-events: none;
}

.stick-label {
  margin-top: 4px;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 2px;
  color: var(--yellow);
  text-shadow: 2px 2px 0 var(--ink);
  pointer-events: none;
}

.touch-stick.is-held .stick-base {
  background: rgba(42, 24, 56, 0.62);
  box-shadow: 5px 5px 0 var(--pink), inset 0 0 0 3px var(--ink);
}

.touch-dash {
  pointer-events: auto;
  position: absolute;
  right: max(10px, env(safe-area-inset-right, 0px));
  bottom: max(16px, env(safe-area-inset-bottom, 0px));
  width: min(118px, 30vmin);
  height: min(118px, 30vmin);
  border-radius: 50%;
  border: 5px solid var(--ink);
  background: radial-gradient(circle at 30% 28%, #ff8ec8, var(--pink) 55%, #ff2d92);
  color: #fff;
  font-family: inherit;
  font-size: clamp(16px, 4.2vmin, 22px);
  font-weight: 900;
  letter-spacing: 1px;
  line-height: 1.05;
  box-shadow: 0 0 0 4px var(--yellow), 6px 6px 0 var(--ink), 0 0 18px rgba(255, 45, 146, 0.55);
  touch-action: none;
  cursor: pointer;
  transform: rotate(-8deg);
  animation: pulse 0.9s ease-in-out infinite;
  text-shadow: 2px 2px 0 var(--ink);
}

.touch-dash.is-held,
.touch-dash:active {
  transform: rotate(-8deg) scale(0.94);
  background: var(--lime);
  color: var(--ink);
  animation: none;
}

.touch-pause {
  pointer-events: auto;
  position: absolute;
  right: max(14px, env(safe-area-inset-right, 0px));
  bottom: calc(max(16px, env(safe-area-inset-bottom, 0px)) + min(118px, 30vmin) + 10px);
  min-width: 72px;
  min-height: 44px;
  padding: 8px 12px;
  border-radius: 10px;
  border: 4px solid var(--ink);
  background: rgba(255, 225, 74, 0.82);
  color: var(--ink);
  font-family: inherit;
  font-size: 13px;
  font-weight: 900;
  letter-spacing: 1px;
  box-shadow: 4px 4px 0 var(--neon);
  touch-action: manipulation;
  cursor: pointer;
  transform: rotate(4deg);
}

.touch-pause:active {
  background: var(--lime);
  transform: rotate(4deg) translate(1px, 1px);
}

/* Portrait: cover-scale the 16:9 canvas so it fills the screen */
@media (orientation: portrait) {
  #game {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    width: max(100%, calc(var(--app-h, 100dvh) * 16 / 9));
    height: max(100%, calc(var(--app-w, 100vw) * 9 / 16));
    max-width: none;
    max-height: none;
    box-shadow: none;
  }

  #hud-score { min-width: 0; width: min(46vw, 280px); }
  #score-value { font-size: clamp(32px, 9vw, 48px); -webkit-text-stroke: 3px var(--ink); }
  #score-label { font-size: 11px; letter-spacing: 3px; }
  #place-value { font-size: clamp(26px, 8vw, 36px); }
  #place-wrap { padding: 6px 10px 8px; }
  #spot-warning {
    top: max(118px, calc(env(safe-area-inset-top, 0px) + 100px));
    bottom: auto;
    min-width: min(260px, 86vw);
    padding: 6px 12px 10px;
  }
  .spot-title { font-size: 20px; }
  #toast {
    bottom: 32%;
    max-width: 80vw;
    text-align: center;
  }
  #hud-score { top: max(8px, env(safe-area-inset-top, 0px)); }
}

@media (orientation: landscape) and (max-height: 500px) {
  .touch-stick {
    width: min(128px, 34vmin);
    height: min(128px, 34vmin);
  }
  .touch-dash {
    width: min(88px, 24vmin);
    height: min(88px, 24vmin);
    font-size: 14px;
  }
  .touch-pause {
    bottom: calc(max(8px, env(safe-area-inset-bottom, 0px)) + min(88px, 24vmin) + 8px);
    min-height: 36px;
    font-size: 11px;
  }
  #hud-score { min-width: 180px; }
  #score-value { font-size: 36px; }
  #place-value { font-size: 28px; }
  .title-poster-wrap { width: min(110px, 22vw); }
  .title-hero { padding: 48px 16px 96px; gap: 12px; }
  .title-card { padding: 10px 16px 10px; }
  .title-card h1 { font-size: 36px; }
  .tagline { font-size: 13px; }
  .marquee { top: 10px; left: 12px; right: 12px; }
}

@media (max-width: 820px), (pointer: coarse) {
  #btn-start, #btn-resume, #btn-again, #btn-restart-pause {
    min-height: 52px;
    font-size: 18px;
    padding: 12px 22px;
    width: 100%;
    margin-left: 0;
    margin-right: 0;
  }
  button.ghost { margin-left: 0; }
  .panel { padding: 22px 18px; max-width: min(560px, 94vw); }
  .panel h2 { font-size: clamp(28px, 8vw, 44px); }
  .title-hero {
    padding: max(56px, calc(env(safe-area-inset-top, 0px) + 44px)) 16px max(118px, calc(env(safe-area-inset-bottom, 0px) + 108px));
  }
  .marquee {
    top: max(10px, env(safe-area-inset-top, 0px));
    left: max(10px, env(safe-area-inset-left, 0px));
    right: max(10px, env(safe-area-inset-right, 0px));
  }
}

@media (orientation: portrait) and (max-width: 600px) {
  .title-hero {
    flex-direction: column;
    gap: 10px;
    padding-left: 14px;
    padding-right: 14px;
  }
  .title-poster-wrap { width: min(140px, 38vw); }
  .title-card { max-width: 100%; padding: 14px 14px 12px; }
  .title-card h1 { font-size: clamp(36px, 12vw, 52px); }
  .controls { font-size: 12px; }
}

@media (prefers-reduced-motion: reduce) {
  .touch-dash, .marquee span, #score-label {
    animation: none;
  }
}

/* rewarded-ad CTA (only shown on portals with rewarded ads; hidden elsewhere) */
#btn-reward-bonus {
  background: var(--yellow, #ffe14a);
  color: var(--ink, #1a1a1a);
  width: 100%;
  margin-left: 0;
  margin-top: 6px;
  font-size: 18px;
}
#btn-reward-bonus:hover { background: var(--lime, #c8ff3d); }

/* flat title art rendered from the game itself: centre it (posters were top-anchored) */
.title-poster { object-position: center center; }
