/* STUCK IN TRAFFIC — cheesy rush-hour chrome */
:root {
  --ink: #15171f;
  --asphalt: #2b2f3a;
  --yellow: #ffd23f;
  --gold: #ffb400;
  --red: #e5202b;
  --pink: #ff3d7f;
  --green: #3ddc84;
  --cream: #fff6e0;
  --sky: #6fc3ff;
  --orange: #ff8a1f;
}

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

html, body {
  height: 100%;
  height: 100vh;
  height: 100dvh;
  height: var(--app-h, 100vh);
  background: var(--ink);
  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%, #3a3f4f 0%, #15171f 70%);
}

#game {
  display: block;
  background: #2b2f3a;
  box-shadow: 0 0 0 5px var(--ink), 0 0 0 9px var(--yellow), 0 20px 80px rgba(0,0,0,.55);
  touch-action: none;
}

.hidden { display: none !important; }

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

#title-screen {
  background: repeating-linear-gradient(45deg, #15171f 0 22px, #ffd23f 22px 44px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  overflow-y: auto;
}
#title-screen::before {
  content: "";
  position: absolute;
  inset: 16px;
  background:
    radial-gradient(circle at 18% 22%, rgba(229, 32, 43, .55), transparent 40%),
    radial-gradient(circle at 82% 30%, rgba(255, 180, 0, .45), transparent 42%),
    linear-gradient(#3a4256, #15171f);
  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(--red);
  white-space: nowrap;
}
.marquee span {
  display: inline-block;
  padding-left: 100%;
  animation: marquee 18s linear infinite;
}

.title-hero {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 22px;
  padding: 72px 36px 48px;
  max-width: 980px;
  width: 100%;
}
.title-poster-wrap {
  position: relative;
  flex: 0 0 auto;
  width: min(260px, 30vw);
  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: #0a1216;
}
.title-poster-glow {
  position: absolute;
  inset: -10px;
  border: 3px solid var(--yellow);
  box-shadow: 0 0 28px rgba(255, 210, 63, 0.55), 0 0 0 6px var(--red);
  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(--red), -8px -8px 0 var(--yellow);
  padding: 22px 36px 18px;
  transform: rotate(1deg);
  max-width: 520px;
  flex: 1 1 420px;
}
.eyebrow { font-size: 12px; letter-spacing: 4px; color: var(--red); font-weight: 900; }
.title-card h1 {
  font-size: clamp(40px, 6.5vw, 62px);
  line-height: 0.85;
  letter-spacing: -2px;
  text-shadow: 4px 4px 0 var(--yellow), 8px 8px 0 #3a4256;
  margin: 8px 0 10px;
}
.tagline { font-size: 18px; font-weight: 900; letter-spacing: 2px; color: var(--red); line-height: 1.25; }
.subtag { font-size: 12px; margin-top: 6px; opacity: 0.8; font-weight: 700; }

#btn-start, #btn-resume, #btn-again, #btn-restart-pause, #btn-continue, #btn-retry, #btn-giveup {
  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;
  -webkit-tap-highlight-color: rgba(255, 210, 63, 0.4);
  touch-action: manipulation;
}
#btn-start { font-size: 28px; padding: 12px 48px; }
#btn-start small { display: block; font-size: 12px; letter-spacing: 2px; margin-top: 2px; }
#btn-start:hover, #btn-resume:hover, #btn-again:hover, #btn-restart-pause:hover,
#btn-continue:hover, #btn-retry:hover, #btn-giveup:hover {
  transform: translate(-2px, -2px);
  box-shadow: 7px 7px 0 var(--ink);
  background: var(--green);
}
button.ghost { background: var(--cream) !important; margin-left: 8px; }
#title-screen, #title-screen * { touch-action: manipulation; }

/* ---- save / continue on the title card ---- */
.title-continue { font-size: 13px; font-weight: 700; margin-top: 10px; opacity: 0.9; }
.title-continue b { color: var(--red); }
.title-save { margin-top: 8px; display: flex; flex-direction: column; align-items: center; gap: 6px; }
#btn-monday {
  margin: 4px 0 0; font-family: inherit; font-size: 14px; font-weight: 900; padding: 6px 16px;
  border: 3px solid var(--ink); color: var(--ink); cursor: pointer; box-shadow: 3px 3px 0 var(--ink); letter-spacing: 1px;
}
#btn-monday:hover { background: var(--green) !important; }
.day-picker { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 5px; }
.day-picker-label { font-size: 11px; font-weight: 900; letter-spacing: 1px; opacity: 0.85; margin-right: 2px; }
.day-picker button {
  font-family: inherit; font-weight: 900; font-size: 13px; padding: 4px 8px; min-width: 44px; min-height: 30px;
  border: 3px solid var(--ink); background: var(--yellow); color: var(--ink); cursor: pointer;
  box-shadow: 2px 2px 0 var(--ink); touch-action: manipulation;
}
.day-picker button:hover { background: var(--green); }
.day-picker button.current { background: var(--green); }
.day-picker button.locked {
  background: #5b6070; color: #9aa0ae; cursor: not-allowed; box-shadow: none;
  text-decoration: line-through; text-decoration-thickness: 2px;
}
.title-best { font-size: 12px; font-weight: 700; opacity: 0.85; }
.title-best b { color: var(--red); }

/* ---- global mute button (works on touch + mouse) ---- */
.mute-btn {
  position: absolute;
  top: max(8px, env(safe-area-inset-top, 0px));
  right: max(8px, env(safe-area-inset-right, 0px));
  z-index: 8;
  width: 44px; height: 44px;
  display: flex; align-items: center; justify-content: center;
  padding: 0; border: 3px solid var(--cream); border-radius: 50%;
  background: rgba(21, 23, 31, 0.85); color: var(--cream);
  box-shadow: 3px 3px 0 var(--red);
  cursor: pointer; touch-action: manipulation; -webkit-tap-highlight-color: transparent;
}
.mute-btn:hover { background: var(--ink); color: var(--yellow); }
.mute-btn .snd-off { display: none; }
.mute-btn.is-muted { background: var(--red); }
.mute-btn.is-muted .snd-on { display: none; }
.mute-btn.is-muted .snd-off { display: inline; }
body[data-state="title"] .marquee { right: 64px; }
body.ad-wait .panel button { pointer-events: none; opacity: 0.55; cursor: progress; }
#btn-continue, #btn-retry { background: var(--green); width: 100%; font-size: 22px; margin-left: 0; }
#btn-giveup { width: 100%; margin-left: 0; margin-top: 8px; font-size: 16px; }

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

#pause-screen, #victory-screen, #clear-screen, #lost-screen {
  background: rgba(12, 14, 20, 0.78);
  display: flex;
  align-items: center;
  justify-content: center;
}
.panel {
  background: var(--cream);
  color: var(--ink);
  border: 6px solid var(--ink);
  padding: 28px 36px;
  text-align: center;
  box-shadow: 10px 10px 0 var(--yellow);
  max-width: 560px;
  width: 92%;
}
.panel h2 { font-size: 36px; line-height: 1; text-shadow: 3px 3px 0 var(--yellow); margin: 8px 0; }
.panel.victory { box-shadow: 10px 10px 0 var(--green), -6px -6px 0 var(--yellow); }
.panel.clear { box-shadow: 10px 10px 0 var(--green), -6px -6px 0 var(--sky); }
.panel.dead { box-shadow: 10px 10px 0 var(--red), -6px -6px 0 var(--orange); }
.panel.dead h2 { text-shadow: 3px 3px 0 #ffb3b3; }
.confetti-label {
  background: var(--red);
  color: #fff;
  display: inline-block;
  padding: 2px 10px;
  font-weight: 900;
  transform: rotate(-6deg);
  letter-spacing: 2px;
}
.clear-stage { font-size: 20px; font-weight: 900; color: var(--red); letter-spacing: 1px; margin: 4px 0 8px; }
.clear-next {
  margin: 10px 0;
  padding: 10px;
  background: var(--ink);
  color: var(--yellow);
  border: 3px solid var(--gold);
  font-weight: 900;
  font-size: 14px;
  line-height: 1.4;
  transform: rotate(-1deg);
}
.clear-stats { font-size: 14px; font-weight: 700; margin: 8px 0 4px; line-height: 1.5; }
.clear-hint { margin-top: 8px; font-size: 11px; opacity: 0.65; font-weight: 700; }

#toast {
  position: absolute;
  top: calc(var(--canvas-top, 0px) + var(--canvas-scale, 1) * 48px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--ink);
  color: var(--yellow);
  border: 3px solid var(--yellow);
  padding: 8px 16px;
  font-weight: 900;
  font-size: 15px;
  z-index: 6;
  pointer-events: none;
  text-align: center;
  max-width: min(90%, 620px);
  box-shadow: 4px 4px 0 var(--red);
}
body.portrait #toast { top: calc(var(--canvas-top, 0px) + var(--canvas-scale, 1) * 138px); font-size: 13px; }

@keyframes marquee { 0% { transform: translateX(0); } 100% { transform: translateX(-100%); } }

/* ---- touch chrome ---- */
.ctrl-touch { display: none; }
body.touch-on .ctrl-kb { display: none; }
body.touch-on .ctrl-touch { display: block; }
body.touch-on .controls { grid-template-columns: 1fr 1fr; }
img { -webkit-user-drag: none; }

#touch-controls {
  display: none;
  position: absolute;
  inset: 0;
  z-index: 4;
  pointer-events: none;
}
body.touch-on[data-state="play"] #touch-controls,
body.touch-on[data-state="intro"] #touch-controls { display: block; }

#touch-controls button {
  pointer-events: auto;
  font-family: inherit;
  font-weight: 900;
  border: 5px solid var(--ink);
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
  color: var(--ink);
  line-height: 1;
  padding: 0;
}
#touch-controls button small { display: block; font-size: 11px; letter-spacing: 1px; margin-top: 2px; }
#touch-controls button.is-held { transform: translateY(4px); filter: brightness(1.2); }

.touch-left-group, .touch-right-group {
  position: absolute;
  bottom: max(14px, env(safe-area-inset-bottom, 0px));
  display: flex;
  align-items: flex-end;
  gap: 12px;
}
.touch-left-group { left: max(12px, env(safe-area-inset-left, 0px)); }
.touch-right-group { right: max(12px, env(safe-area-inset-right, 0px)); }

.touch-lane {
  width: min(118px, 24vmin);
  height: min(118px, 24vmin);
  border-radius: 22px;
  background: radial-gradient(circle at 35% 30%, #fff6a0, #ffd23f 50%, #ffb400 85%);
  font-size: clamp(30px, 8vmin, 46px);
  box-shadow: 0 8px 0 #7a5600, 0 0 18px rgba(255, 210, 63, 0.5);
}
.touch-inch {
  width: min(80px, 17vmin);
  height: min(80px, 17vmin);
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #d8ffe9, #3ddc84 60%, #1d9a55);
  font-size: clamp(13px, 3.4vmin, 17px);
  box-shadow: 0 6px 0 #0f5a31;
}
.touch-honk {
  width: min(96px, 20vmin);
  height: min(96px, 20vmin);
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #ffd0d0, #ff3d4f 55%, #b3121d);
  color: #fff !important;
  font-size: clamp(14px, 3.8vmin, 19px);
  box-shadow: 0 7px 0 #5e070d, 0 0 16px rgba(255, 61, 79, .5);
}
.touch-pause {
  position: absolute;
  right: calc(max(8px, env(safe-area-inset-right, 0px)) + 54px);
  top: max(12px, env(safe-area-inset-top, 0px));
  font-size: 13px !important;
  letter-spacing: 1px;
  padding: 8px 12px !important;
  border: 3px solid var(--cream) !important;
  background: rgba(21, 23, 31, 0.8);
  color: var(--cream) !important;
  box-shadow: 3px 3px 0 var(--red);
}

/* title hero is scaled to fit by JS (fitTitle) so it never needs scrolling in any iframe */
.title-hero { transform-origin: 50% 50%; flex: 0 0 auto; }
@media (max-width: 820px) and (orientation: portrait) {
  .title-hero { flex-direction: column; gap: 14px; padding: 64px 16px 30px; }
  .title-poster-wrap { width: min(150px, 40vw); }
  .title-card { max-width: 94%; padding: 14px 16px 12px; }
  .title-card h1 { font-size: 38px; }
  .controls { font-size: 11px; }
}
@media (max-height: 560px) {
  .title-hero { padding: 58px 20px 20px; }
  .title-poster-wrap { width: min(170px, 24vw); }
  .title-card h1 { font-size: 34px; }
  .subtag { display: none; }
}
@media (max-height: 500px), (max-width: 600px) {
  .panel { padding: 16px 18px; }
  .panel h2 { font-size: 26px; }
  .clear-stage { font-size: 16px; }
  .clear-next, .clear-stats { font-size: 12px; }
  #toast { font-size: 12px; padding: 6px 10px; }
}
/* short landscape (phones, small portal iframes): drop the long copy, keep it big + readable */
@media (max-height: 520px) and (orientation: landscape) {
  .title-hero { padding: 54px 16px 12px; gap: 18px; }
  .controls, .subtag, .eyebrow { display: none; }
  .title-card { padding: 12px 20px 12px; }
  .title-card h1 { font-size: 40px; margin: 2px 0 6px; }
  .tagline { font-size: 16px; }
  #btn-start { margin-top: 8px; padding: 8px 40px; }
  .title-continue { margin-top: 6px; }
}
@media (orientation: portrait) and (max-height: 900px) {
  .controls { display: none; }
}
@media (orientation: portrait) and (max-width: 520px) {
  .eyebrow { letter-spacing: 2px; font-size: 11px; }
}
@media (orientation: portrait) and (max-height: 740px) {
  .subtag { display: none; }
}
