:root {
  color-scheme: light;
  --ink: #17221e;
  --muted: #65736c;
  --cream: #f8f1df;
  --paper: #fffdf6;
  --yellow: #f4b942;
  --orange: #ef7849;
  --green: #36735c;
  --red: #d94b4b;
  --blue: #4685a8;
}

* { box-sizing: border-box; }

html, body { width: 100%; height: 100%; }

body {
  margin: 0;
  overflow: hidden;
  background: #d8caa8;
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
}

button { color: inherit; font: inherit; }

.app {
  min-height: 100vh;
  min-height: 100svh;
  display: grid;
  grid-template-rows: 66px minmax(0, 1fr);
  background:
    radial-gradient(circle at 20% 20%, #fff6d6aa 0 2px, transparent 3px),
    linear-gradient(135deg, #e9dcb9, #d4c29b);
  background-size: 32px 32px, auto;
}

.topbar {
  position: relative;
  z-index: 10;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 12px;
  padding: 8px clamp(10px, 3vw, 26px);
  border-bottom: 2px solid #1e2a25;
  background: rgb(255 253 246 / 92%);
  box-shadow: 0 4px 0 rgb(40 48 42 / 9%);
  backdrop-filter: blur(12px);
}

.brand {
  justify-self: start;
  display: inline-flex;
  align-items: center;
  gap: 9px;
  color: var(--ink);
  text-decoration: none;
  font-size: clamp(.77rem, 2.2vw, 1rem);
  font-weight: 950;
  letter-spacing: -.055em;
  white-space: nowrap;
}

.brand b { color: var(--orange); }
.brand-mark { position: relative; width: 28px; height: 38px; }
.brand-mark::before, .brand-mark::after {
  content: "";
  position: absolute;
  bottom: 1px;
  width: 4px;
  height: 24px;
  border-radius: 4px;
  background: var(--ink);
  transform-origin: bottom;
}
.brand-mark::before { left: 12px; transform: rotate(-25deg); }
.brand-mark::after { right: 7px; transform: rotate(25deg); }
.brand-mark i {
  position: absolute;
  top: 1px;
  left: 1px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--orange);
  box-shadow: 1px 2px 0 #a13c29;
}

.scoreboard { display: flex; align-items: center; gap: clamp(14px, 5vw, 54px); }
.scoreboard > div { display: grid; justify-items: center; gap: 1px; min-width: 52px; }
.scoreboard span { color: var(--muted); font-size: .56rem; font-weight: 900; letter-spacing: .16em; }
.scoreboard strong { font-size: clamp(.85rem, 2.7vw, 1.08rem); font-variant-numeric: tabular-nums; }

.sound-button {
  justify-self: end;
  display: grid;
  width: 38px;
  height: 38px;
  padding: 8px;
  place-items: center;
  border: 1.5px solid #b5aa8d;
  border-radius: 50%;
  background: #fffdf7;
  cursor: pointer;
}
.sound-button:hover { border-color: var(--ink); transform: translateY(-1px); }
.sound-button svg { width: 20px; fill: var(--ink); }
.sound-button path:not(:first-child) { fill: none; stroke: var(--ink); stroke-linecap: round; stroke-width: 1.8; }
.sound-slash { display: none; }
.sound-button[aria-pressed="true"] .sound-waves { display: none; }
.sound-button[aria-pressed="true"] .sound-slash { display: block; }

.game-shell {
  min-height: 0;
  width: min(100%, 1120px);
  margin: 0 auto;
  padding: clamp(8px, 2vw, 18px) clamp(8px, 2vw, 18px) max(7px, env(safe-area-inset-bottom));
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  gap: 7px;
}

.stage {
  position: relative;
  min-height: 0;
  overflow: hidden;
  border: 2px solid var(--ink);
  border-radius: clamp(14px, 2.5vw, 24px);
  background: #e6d8ac;
  box-shadow: 0 8px 0 #766e59, 0 15px 36px #554d3930;
  isolation: isolate;
  touch-action: none;
}

#game { width: 100%; height: 100%; display: block; outline: none; cursor: crosshair; touch-action: none; }

.feedback {
  position: absolute;
  z-index: 5;
  top: 14%;
  left: 50%;
  width: min(92%, 700px);
  translate: -50% -9px;
  color: #fffdf6;
  font-size: clamp(1.25rem, 5vw, 2.7rem);
  font-weight: 1000;
  line-height: .95;
  letter-spacing: -.055em;
  text-align: center;
  text-shadow: 0 3px 0 #29342f, 0 8px 25px #17221e88;
  opacity: 0;
  pointer-events: none;
  transition: opacity 150ms ease, translate 150ms ease;
}
.feedback.show { opacity: 1; translate: -50% 0; }
.feedback.bad { color: #ffe3da; text-shadow: 0 3px 0 #8d302a, 0 8px 25px #74271d88; }
.feedback.good { color: #fff2a6; }

.power-card {
  position: absolute;
  z-index: 4;
  right: 14px;
  bottom: 14px;
  width: min(32vw, 150px);
  padding: 8px 10px;
  border: 1.5px solid #26332d;
  border-radius: 10px;
  background: rgb(255 253 246 / 86%);
  opacity: 0;
  translate: 0 8px;
  pointer-events: none;
  transition: 140ms ease;
  backdrop-filter: blur(5px);
}
.power-card.show { opacity: 1; translate: 0; }
.power-card > span { display: block; margin-bottom: 5px; color: var(--muted); font-size: .52rem; font-weight: 900; letter-spacing: .14em; }
.power-track { height: 8px; overflow: hidden; border: 1px solid #807b68; border-radius: 99px; background: #d9d2bd; }
.power-track i { display: block; width: 100%; height: 100%; transform: scaleX(0); transform-origin: left; background: linear-gradient(90deg, var(--green), var(--yellow) 58%, var(--red)); }

.overlay {
  position: absolute;
  inset: 0;
  z-index: 8;
  display: grid;
  place-items: center;
  padding: 14px;
  background: rgb(42 48 42 / 24%);
  backdrop-filter: blur(3px);
  transition: opacity 180ms ease;
}
.overlay.hidden { opacity: 0; pointer-events: none; }

.game-card {
  width: min(100%, 440px);
  padding: clamp(21px, 5vw, 34px);
  border: 2px solid var(--ink);
  border-radius: 22px;
  background: var(--paper);
  box-shadow: 0 9px 0 #aa7f3d, 0 24px 70px #33403755;
  text-align: center;
}

.hero-sling { position: relative; width: 72px; height: 52px; margin: -2px auto 5px; }
.hero-head { position: absolute; left: 26px; bottom: 1px; width: 25px; height: 25px; border: 3px solid var(--ink); border-radius: 50%; background: #e7a878; }
.hero-orbit { position: absolute; inset: 1px 11px; border: 2px dashed #a19a85; border-radius: 50%; animation: hero-spin 2s linear infinite; }
.hero-orbit i { position: absolute; top: 0; left: -5px; width: 12px; height: 12px; border: 2px solid var(--ink); border-radius: 50%; background: #748078; }
@keyframes hero-spin { to { transform: rotate(-360deg); } }

.eyebrow { margin: 0 0 8px; color: var(--green); font-size: .61rem; font-weight: 950; letter-spacing: .16em; }
.game-card h1 { margin: 0; font-size: clamp(2.55rem, 9vw, 4rem); line-height: .78; letter-spacing: -.085em; text-transform: uppercase; }
.game-card h1 span { color: var(--orange); }
.game-card > p:not(.eyebrow) { margin: 17px auto 0; max-width: 355px; color: #5d6862; font-size: .89rem; line-height: 1.45; }
.how-to { display: flex; justify-content: center; flex-wrap: wrap; gap: 7px 16px; margin-top: 17px; color: #6e776f; font-size: .58rem; font-weight: 800; letter-spacing: .055em; }
.how-to b { color: var(--ink); }

.round-stats { grid-template-columns: repeat(3, 1fr); gap: 5px; margin-top: 18px; }
.round-stats:not([hidden]) { display: grid; }
.round-stats div { padding: 8px 3px; border: 1px solid #d3cbb8; border-radius: 9px; background: #f6f0e1; }
.round-stats span { display: block; color: #788078; font-size: .5rem; font-weight: 900; letter-spacing: .09em; }
.round-stats strong { display: block; margin-top: 2px; font-size: 1.05rem; }

.primary-button, .share-button { width: 100%; border-radius: 11px; font-weight: 950; cursor: pointer; }
.primary-button { margin-top: 20px; padding: 13px 18px; border: 2px solid var(--ink); background: var(--yellow); box-shadow: 0 4px 0 var(--ink); }
.primary-button:hover { background: #ffc94f; translate: 0 -1px; box-shadow: 0 5px 0 var(--ink); }
.primary-button:active { translate: 0 3px; box-shadow: 0 1px 0 var(--ink); }
.share-button { margin-top: 11px; padding: 8px 12px; border: 0; background: transparent; color: #68736c; font-size: .68rem; }
.share-button:hover { color: var(--ink); text-decoration: underline; }

.legend { display: flex; justify-content: center; flex-wrap: wrap; gap: 8px 22px; padding: 5px 4px 1px; color: #4f584f; font-size: .59rem; font-weight: 850; letter-spacing: .04em; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.dot { width: 9px; height: 9px; border: 1px solid var(--ink); border-radius: 50%; }
.target-dot { background: var(--yellow); }
.person-dot { background: var(--orange); }
.bank-dot { border-radius: 2px; background: var(--green); }

@media (max-width: 610px) {
  .app { grid-template-rows: 58px minmax(0, 1fr); }
  .topbar { grid-template-columns: auto 1fr auto; }
  .brand { font-size: 0; gap: 0; }
  .brand-mark { display: block; transform: scale(.88); }
  .scoreboard { justify-content: center; gap: clamp(8px, 5vw, 24px); }
  .scoreboard > div { min-width: 43px; }
  .sound-button { width: 34px; height: 34px; }
  .game-shell { padding: 6px 6px max(5px, env(safe-area-inset-bottom)); }
  .legend { gap: 5px 12px; font-size: .52rem; }
  .game-card { padding: 18px; }
  .game-card > p:not(.eyebrow) { font-size: .8rem; }
}

@media (max-height: 650px) {
  .app { grid-template-rows: 54px minmax(0, 1fr); }
  .game-shell { padding-top: 5px; }
  .hero-sling { display: none; }
  .game-card { padding: 15px 20px; }
  .game-card h1 { font-size: 2.5rem; }
  .game-card > p:not(.eyebrow) { margin-top: 11px; line-height: 1.3; }
  .how-to { margin-top: 10px; }
  .primary-button { margin-top: 13px; padding: 10px 16px; }
  .share-button { margin-top: 4px; }
  .round-stats { margin-top: 10px; }
}

@media (prefers-reduced-motion: reduce) {
  .hero-orbit { animation-duration: 6s; }
  .overlay, .feedback, .power-card { transition: none; }
}
