/* Very Close! The Word Chase — styles */
* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --ink: #2b2d42;
  --ink-soft: #45506b;
  --sun: #ffb703;
  --sun-deep: #f78c1b;
  --grass: #3fae5a;
  --sky: #8ed3f5;
  --card: #ffffff;
  --p1: #ffd60a;
  --p2: #9b5de5;
  --danger: #ef476f;
  --ok: #06d6a0;
  --shadow: 0 6px 0 rgba(0,0,0,.18);
  --radius: 16px;
}

html, body {
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
}

body {
  font-family: "Baloo 2", "Arial Rounded MT Bold", "Comic Sans MS", "Chalkboard SE", "Trebuchet MS", system-ui, sans-serif;
  color: var(--ink);
  background: #8ed3f5;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}

#app { position: fixed; inset: 0; }

.screen {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  overflow: hidden;
}
.screen.active { display: flex; }

.hidden { display: none !important; }

/* ---------- shared background ---------- */
.title-bg, .arena-bg {
  position: absolute;
  inset: 0;
  background-image: url("../assets/runtime/background-chase-yard-wide.webp");
  background-size: cover;
  background-position: center 38%;
  background-repeat: no-repeat;
}
.title-bg::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(30,80,120,.30) 0%, rgba(30,80,120,.12) 45%, rgba(20,50,80,.55) 100%);
}

/* ---------- buttons ---------- */
.btn {
  font-family: inherit;
  font-weight: 800;
  border: none;
  cursor: pointer;
  color: #fff;
  background: var(--sun);
  box-shadow: var(--shadow);
  border-radius: 999px;
  padding: 14px 30px;
  font-size: clamp(16px, 2.4vmin, 22px);
  letter-spacing: .03em;
  transition: transform .08s ease, filter .15s ease;
  touch-action: manipulation;
}
.btn:active { transform: translateY(3px); box-shadow: 0 3px 0 rgba(0,0,0,.18); }
.btn-primary { background: linear-gradient(180deg, #ffc933, var(--sun-deep)); color: #fff; text-shadow: 0 2px 0 rgba(0,0,0,.25); }
.btn-ghost { background: rgba(255,255,255,.85); color: var(--ink); box-shadow: 0 4px 0 rgba(0,0,0,.12); }
.btn-say { padding: 12px 22px; font-size: clamp(15px, 2.2vmin, 20px); }

/* ---------- mute ---------- */
.mute-btn {
  font-family: inherit;
  font-weight: 800;
  font-size: 13px;
  background: rgba(255,255,255,.9);
  color: var(--ink);
  border: none;
  border-radius: 999px;
  padding: 8px 14px;
  cursor: pointer;
  box-shadow: 0 3px 0 rgba(0,0,0,.12);
  white-space: nowrap;
}

/* ---------- title / howto / end screens ---------- */
.title-inner, .howto-inner, .intro-inner, .end-inner {
  position: relative;
  z-index: 2;
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: clamp(8px, 1.6vmin, 16px);
  padding: 24px 20px calc(24px + env(safe-area-inset-bottom));
  text-align: center;
}

.game-title {
  font-size: clamp(44px, 11vmin, 96px);
  font-weight: 900;
  letter-spacing: .04em;
  color: #fff;
  text-shadow: 0 4px 0 var(--sun-deep), 0 8px 0 rgba(0,0,0,.25), 0 0 24px rgba(255,183,3,.45);
  line-height: 1;
}
.game-subtitle {
  font-size: clamp(20px, 4.2vmin, 34px);
  font-weight: 800;
  color: #fff;
  text-shadow: 0 3px 0 rgba(0,0,0,.3);
}
.game-tagline {
  font-size: clamp(13px, 2.2vmin, 18px);
  font-weight: 700;
  color: #ffe9b3;
  text-shadow: 0 2px 0 rgba(0,0,0,.35);
  letter-spacing: .08em;
}

.title-ball-wrap { position: relative; width: clamp(70px, 14vmin, 130px); height: clamp(70px, 14vmin, 130px); }
.title-ball {
  width: 100%;
  height: 100%;
  object-fit: contain;
  animation: bob 1.6s ease-in-out infinite;
  filter: drop-shadow(0 10px 8px rgba(0,0,0,.28));
}
@keyframes bob {
  0%, 100% { transform: translateY(0) rotate(-4deg); }
  50% { transform: translateY(-14px) rotate(4deg); }
}

.mode-buttons { display: flex; gap: 14px; margin-top: 8px; flex-wrap: wrap; justify-content: center; }
.mode-buttons .btn { min-width: 150px; }

/* how to */
.howto-title { font-size: clamp(26px, 5vmin, 40px); color: #fff; text-shadow: 0 3px 0 rgba(0,0,0,.3); }
.howto-steps { display: flex; flex-direction: column; gap: 12px; max-width: 620px; width: 100%; }
.howto-step {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  background: rgba(255,255,255,.94);
  border-radius: var(--radius);
  padding: 12px 16px;
  text-align: left;
  box-shadow: var(--shadow);
}
.howto-num {
  flex: 0 0 auto;
  width: 34px; height: 34px;
  border-radius: 50%;
  background: var(--sun);
  color: #fff;
  font-weight: 900;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
  text-shadow: 0 2px 0 rgba(0,0,0,.2);
}
.howto-step p { font-size: clamp(14px, 2vmin, 17px); line-height: 1.45; color: var(--ink-soft); }
.howto-step strong { color: var(--ink); }

/* end screen */
@keyframes pop { 0% { transform: scale(0); } 100% { transform: scale(1); } }
.end-title { font-size: clamp(28px, 6vmin, 52px); color: #fff; text-shadow: 0 4px 0 rgba(0,0,0,.3); }
.end-sub { font-size: clamp(15px, 2.6vmin, 21px); color: #ffe9b3; font-weight: 700; text-shadow: 0 2px 0 rgba(0,0,0,.35); }
.end-stats {
  background: rgba(255,255,255,.94);
  border-radius: var(--radius);
  padding: 12px 22px;
  box-shadow: var(--shadow);
  font-size: clamp(14px, 2.2vmin, 18px);
  color: var(--ink-soft);
  display: flex; flex-direction: column; gap: 6px;
  min-width: min(420px, 90vw);
}
.end-stats .stat { display: flex; justify-content: space-between; gap: 18px; }
.end-stats .stat b { color: var(--ink); }
.end-buttons { display: flex; gap: 14px; flex-wrap: wrap; justify-content: center; margin-top: 6px; }

/* ---------- top bar ---------- */
.topbar {
  position: relative;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: calc(8px + env(safe-area-inset-top)) 12px 8px;
  background: linear-gradient(180deg, rgba(255,255,255,.96), rgba(255,255,255,.88));
  border-bottom: 3px solid rgba(0,0,0,.08);
  flex-wrap: wrap;
}
.round-tag {
  font-weight: 900;
  font-size: clamp(13px, 2vmin, 17px);
  color: var(--ink);
  background: #fff3d0;
  border-radius: 999px;
  padding: 6px 14px;
  box-shadow: 0 2px 0 rgba(0,0,0,.1);
}
.clock-wrap, .distance-wrap { position: relative; margin-left: auto; display: flex; align-items: center; gap: 8px; }
.clock-wrap { width: 54px; height: 54px; }
.clock-ring { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring-bg { fill: none; stroke: #e3e8f0; stroke-width: 5; }
.ring-fg { fill: none; stroke: var(--ok); stroke-width: 5; stroke-linecap: round; transition: stroke-dashoffset .15s linear, stroke .3s; }
.ring-fg.low { stroke: var(--danger); }
.clock-text {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-weight: 900; font-size: 20px; color: var(--ink);
}
.distance-wrap {
  background: #fff;
  border-radius: 999px;
  padding: 6px 16px;
  box-shadow: 0 2px 0 rgba(0,0,0,.12);
  gap: 4px;
}
.distance-label { font-size: 12px; font-weight: 800; color: var(--ink-soft); text-transform: uppercase; letter-spacing: .05em; }
.distance-value { font-size: clamp(22px, 4vmin, 30px); font-weight: 900; color: var(--sun-deep); line-height: 1; }
.distance-unit { font-size: 12px; font-weight: 800; color: var(--ink-soft); }

.score-wrap { display: flex; gap: 8px; }
.score-pill {
  font-weight: 900;
  font-size: clamp(12px, 1.9vmin, 15px);
  border-radius: 999px;
  padding: 6px 12px;
  color: var(--ink);
  background: #fff;
  box-shadow: 0 2px 0 rgba(0,0,0,.12);
  transition: transform .15s;
  white-space: nowrap;
}
.score-pill.p1 { border-bottom: 4px solid var(--p1); }
.score-pill.p2 { border-bottom: 4px solid var(--p2); }
.score-pill.active { transform: scale(1.08); }
.score-pill.winner { background: #fff6d8; box-shadow: 0 0 0 3px var(--sun); }

/* ---------- arena ---------- */
.arena {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}
.arena-bg { background-position: center 30%; }

/* rally players */
.rally-player {
  position: absolute;
  bottom: 18%;
  z-index: 3;
  display: flex;
  flex-direction: column;
  align-items: center;
  transform: translateX(-50%);
  transition: filter .2s;
}
.rally-player img { height: clamp(110px, 34vmin, 240px); width: auto; object-fit: contain; filter: drop-shadow(0 6px 4px rgba(0,0,0,.25)); }
.rally-player.p1 { left: 18%; }
.rally-player.p2 { left: 82%; }
.rally-player .player-tag {
  margin-top: 2px;
  font-weight: 900;
  font-size: clamp(12px, 2vmin, 16px);
  background: #fff;
  border-radius: 999px;
  padding: 3px 12px;
  box-shadow: 0 2px 0 rgba(0,0,0,.15);
}
.rally-player.on-turn img { animation: ready-bounce 1s ease-in-out infinite; }
.rally-player.off-turn { filter: grayscale(.55) brightness(.92); }
@keyframes ready-bounce { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }

/* ball */
.ball, .chase-ball {
  position: absolute;
  z-index: 4;
  width: clamp(34px, 7.5vmin, 64px);
  height: clamp(34px, 7.5vmin, 64px);
  object-fit: contain;
  filter: drop-shadow(0 5px 4px rgba(0,0,0,.28));
  transition: left .45s cubic-bezier(.34,1.4,.5,1), transform .45s cubic-bezier(.34,1.4,.5,1);
}
#rally-ball { left: 18%; bottom: calc(18% + clamp(110px, 34vmin, 240px) + 30px); transform: translateX(-50%); }
#rally-ball.at-p1 { left: 18%; }
#rally-ball.at-p2 { left: 82%; }
#rally-ball.bounce { animation: ball-bounce .45s ease; }
@keyframes ball-bounce {
  0% { transform: translateX(-50%) translateY(0) scale(1); }
  40% { transform: translateX(-50%) translateY(-34px) scale(1.06); }
  70% { transform: translateX(-50%) translateY(4px) scale(.94); }
  100% { transform: translateX(-50%) translateY(0) scale(1); }
}

/* rally center board */
.rally-center {
  position: absolute;
  top: 8%;
  left: 50%;
  transform: translateX(-50%);
  z-index: 3;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  width: min(560px, 92%);
  pointer-events: none;
}
.category-banner {
  background: rgba(43,45,66,.92);
  color: #fff;
  font-weight: 900;
  font-size: clamp(14px, 2.6vmin, 21px);
  padding: 8px 20px;
  border-radius: 999px;
  letter-spacing: .02em;
  box-shadow: 0 4px 0 rgba(0,0,0,.25);
  text-align: center;
}
.slot-row { display: flex; gap: 6px; justify-content: center; flex-wrap: wrap; }
.slot {
  width: clamp(38px, 8vmin, 64px);
  height: clamp(38px, 8vmin, 64px);
  background: rgba(255,255,255,.92);
  border-radius: 14px;
  box-shadow: 0 3px 0 rgba(0,0,0,.18);
  display: flex; align-items: center; justify-content: center;
  font-size: clamp(9px, 1.5vmin, 12px);
  font-weight: 800;
  color: var(--ink-soft);
  text-align: center;
  padding: 3px;
  word-break: break-word;
  line-height: 1.15;
}
.slot.filled { background: #d9f99d; color: var(--ink); border: 3px solid var(--ok); animation: slot-pop .3s ease; }
@keyframes slot-pop { 0% { transform: scale(.6); } 100% { transform: scale(1); } }
.board-strip { display: flex; gap: 5px; flex-wrap: wrap; justify-content: center; }
.board-chip {
  font-size: clamp(10px, 1.6vmin, 13px);
  font-weight: 800;
  background: rgba(255,255,255,.9);
  color: var(--ink-soft);
  border-radius: 999px;
  padding: 4px 10px;
  box-shadow: 0 2px 0 rgba(0,0,0,.15);
  white-space: nowrap;
}
.board-chip.done { background: #d9f99d; color: var(--ink); }
.board-chip.now { background: var(--sun); color: #fff; }
.board-chip .bc-count { opacity: .75; }

.sudden-death {
  position: absolute;
  top: 34%;
  left: 50%;
  transform: translateX(-50%);
  z-index: 6;
  background: var(--danger);
  color: #fff;
  font-weight: 900;
  font-size: clamp(20px, 4.5vmin, 40px);
  padding: 10px 26px;
  border-radius: 999px;
  box-shadow: 0 6px 0 rgba(0,0,0,.3);
  animation: blink .6s step-end infinite;
  pointer-events: none;
  white-space: nowrap;
}
@keyframes blink { 50% { opacity: .25; } }

/* ---------- HUD ---------- */
.hud {
  position: relative;
  z-index: 5;
  background: linear-gradient(180deg, rgba(255,255,255,.96), #fff);
  border-top: 3px solid rgba(0,0,0,.08);
  padding: 10px 12px calc(12px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
}
.turn-line {
  font-weight: 900;
  font-size: clamp(15px, 2.4vmin, 19px);
  color: var(--ink);
  text-align: center;
}
.turn-bar {
  width: min(560px, 100%);
  height: 8px;
  background: #e3e8f0;
  border-radius: 999px;
  overflow: hidden;
  box-shadow: inset 0 1px 2px rgba(0,0,0,.12);
}
.turn-bar-fill {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, var(--ok), #a7f3d0);
  border-radius: 999px;
  transition: width .1s linear;
}
.turn-line small { display: block; font-weight: 700; font-size: 12px; color: var(--ink-soft); }
.input-row { display: flex; gap: 8px; width: min(560px, 100%); }
.input-row input {
  flex: 1;
  font-family: inherit;
  font-size: clamp(16px, 2.6vmin, 20px);
  font-weight: 700;
  color: var(--ink);
  border: 3px solid #d7dee9;
  border-radius: 999px;
  padding: 11px 18px;
  outline: none;
  background: #fbfcfe;
  min-width: 0;
}
.input-row input:focus { border-color: var(--sun); background: #fff; }
.input-row input.shake { animation: shake .3s ease; border-color: var(--danger); }
@keyframes shake { 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }

.chip-row { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; width: min(640px, 100%); }
.chip {
  font-family: inherit;
  font-weight: 800;
  font-size: clamp(14px, 2vmin, 17px);
  color: var(--ink);
  background: #eef3fa;
  border: 2px solid #d7dee9;
  border-radius: 999px;
  padding: 8px 16px;
  cursor: pointer;
  transition: transform .08s, background .15s;
  min-height: 44px;
  touch-action: manipulation;
}
.chip:active { transform: scale(.94); background: #dff3ff; }
.chip:hover { background: #e3f2ff; }

.hint-line {
  font-size: clamp(12px, 1.8vmin, 15px);
  font-weight: 700;
  color: var(--ink-soft);
  min-height: 1.2em;
  text-align: center;
}
.hint-line.good { color: #0a8f6c; }
.hint-line.bad { color: var(--danger); }

/* ---------- chase intro ---------- */
.intro-players { display: flex; align-items: center; gap: clamp(12px, 4vmin, 40px); }
.intro-player { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.intro-player img { height: clamp(90px, 24vmin, 190px); filter: drop-shadow(0 8px 6px rgba(0,0,0,.3)); }
.intro-vs { font-weight: 900; font-size: clamp(24px, 6vmin, 48px); color: #fff; text-shadow: 0 4px 0 rgba(0,0,0,.3); }
.intro-role { font-weight: 900; font-size: clamp(18px, 3.4vmin, 28px); color: #fff; text-shadow: 0 3px 0 rgba(0,0,0,.35); }
.intro-role-label {
  font-weight: 800; font-size: 12px; letter-spacing: .1em; text-transform: uppercase;
  background: rgba(255,255,255,.92); color: var(--ink);
  border-radius: 999px; padding: 3px 12px;
}
.intro-line { color: #fff; font-weight: 700; font-size: clamp(14px, 2.4vmin, 19px); text-shadow: 0 2px 0 rgba(0,0,0,.35); max-width: 560px; }
.intro-distance {
  font-weight: 900;
  font-size: clamp(20px, 4vmin, 32px);
  color: #ffe9b3;
  text-shadow: 0 3px 0 rgba(0,0,0,.4);
}

/* ---------- chase arena ---------- */
.track-marks { position: absolute; left: 4%; right: 4%; top: 61%; height: 0; z-index: 2; pointer-events: none; }
.track-marks::before {
  content: "";
  position: absolute;
  left: 0; right: 0; top: 0;
  height: 5px;
  background: repeating-linear-gradient(90deg, rgba(255,255,255,.85) 0 18px, transparent 18px 34px);
  border-radius: 3px;
  box-shadow: 0 2px 0 rgba(0,0,0,.18);
}
.track-mark {
  position: absolute;
  top: 10px;
  transform: translateX(-50%);
  font-size: clamp(9px, 1.5vmin, 12px);
  font-weight: 800;
  color: rgba(255,255,255,.95);
  text-shadow: 0 1px 2px rgba(0,0,0,.5);
}
.track-mark::before {
  content: "";
  position: absolute;
  left: 50%; top: -8px;
  width: 3px; height: 8px;
  background: rgba(255,255,255,.85);
  transform: translateX(-50%);
}

.chase-runner, .chase-keeper {
  position: absolute;
  z-index: 3;
  height: clamp(90px, 24vmin, 190px);
  width: auto;
  object-fit: contain;
  filter: drop-shadow(0 6px 4px rgba(0,0,0,.3));
  transition: left .65s cubic-bezier(.3,1,.4,1);
  will-change: left;
}
.chase-runner { bottom: 26%; left: 8%; transform: translateX(-50%); }
.chase-keeper { bottom: 26%; left: 90%; transform: translateX(-50%); }
.chase-ball {
  left: 11.5%; bottom: 22%;
  width: clamp(26px, 5.5vmin, 48px);
  height: clamp(26px, 5.5vmin, 48px);
  transform: translateX(-50%);
  transition: left .65s cubic-bezier(.3,1,.4,1);
  z-index: 3;
}
.chase-runner.frog { animation: frog-hop .65s ease; }
@keyframes frog-hop {
  0% { transform: translateX(-50%) translateY(0); }
  35% { transform: translateX(-50%) translateY(-46px) scale(1.08); }
  70% { transform: translateX(-50%) translateY(6px) scale(.94); }
  100% { transform: translateX(-50%) translateY(0); }
}
.chase-runner.dog { animation: dog-step .65s ease; }
@keyframes dog-step {
  0%, 100% { transform: translateX(-50%) translateY(0); }
  25% { transform: translateX(-50%) translateY(-10px) rotate(-2deg); }
  60% { transform: translateX(-50%) translateY(-6px) rotate(2deg); }
}
.chase-runner.cat { animation: cat-glide .65s ease; }
@keyframes cat-glide {
  0% { transform: translateX(-50%) translateY(0) scale(1,.1); }
  30% { transform: translateX(-50%) translateY(-14px) scale(.92,1.1); }
  60% { transform: translateX(-50%) translateY(4px) scale(1.05,.92); }
  100% { transform: translateX(-50%) translateY(0) scale(1); }
}

.flag {
  position: absolute;
  z-index: 2;
  top: 47%;
  font-weight: 900;
  font-size: clamp(9px, 1.6vmin, 13px);
  color: #fff;
  text-shadow: 0 2px 0 rgba(0,0,0,.4);
  letter-spacing: .05em;
}
.flag::before {
  content: "";
  position: absolute;
  left: 50%; top: 14px;
  transform: translateX(-50%);
  width: 3px; height: 34px;
  background: rgba(255,255,255,.8);
  border-radius: 2px;
}
.flag.start { left: 6%; }
.flag.finish { right: 3%; }

.very-close {
  position: absolute;
  top: 30%;
  left: 50%;
  transform: translateX(-50%) rotate(-4deg);
  z-index: 7;
  background: var(--danger);
  color: #fff;
  font-weight: 900;
  font-size: clamp(22px, 5vmin, 44px);
  padding: 10px 30px;
  border-radius: 999px;
  box-shadow: 0 6px 0 rgba(0,0,0,.3);
  animation: vc-pulse .5s ease-in-out infinite alternate;
  pointer-events: none;
  white-space: nowrap;
}
@keyframes vc-pulse { from { transform: translateX(-50%) rotate(-4deg) scale(1); } to { transform: translateX(-50%) rotate(-4deg) scale(1.12); } }

/* move picker */
.move-picker {
  width: min(640px, 100%);
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  animation: rise .25s ease;
}
@keyframes rise { from { transform: translateY(14px); opacity: 0; } to { transform: none; opacity: 1; } }
.move-picker-title { font-weight: 900; font-size: clamp(15px, 2.4vmin, 19px); color: var(--ink); }
.move-cards { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }
.move-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  background: #fff;
  border: 3px solid #d7dee9;
  border-radius: var(--radius);
  padding: 10px 14px;
  cursor: pointer;
  min-width: 96px;
  box-shadow: var(--shadow);
  transition: transform .08s;
  touch-action: manipulation;
  font-family: inherit;
}
.move-card:active { transform: scale(.94); }
.move-card img { width: clamp(52px, 10vmin, 84px); height: auto; }
.move-name { font-weight: 900; font-size: clamp(13px, 2vmin, 16px); color: var(--ink); }
.move-value { font-weight: 900; font-size: clamp(16px, 2.6vmin, 21px); color: var(--sun-deep); }

/* end screen emoji guard: we render the ball art as the trophy */
.end-trophy { width: clamp(80px, 16vmin, 150px); filter: drop-shadow(0 10px 8px rgba(0,0,0,.3)); animation: pop .5s cubic-bezier(.2,1.6,.4,1); }

@media (max-height: 620px) {
  .arena .rally-center { top: 3%; }
  .rally-player { bottom: 12%; }
  .hud { padding-top: 6px; gap: 5px; }
}
