/* Dondurma Tease — all art and type are local; no network requests. */
:root {
  --ink: #281720;
  --ink-soft: #4d3039;
  --cream: #fff5e2;
  --paper: #f4e2c2;
  --paper-deep: #e9d0a8;
  --red: #d94346;
  --red-dark: #9b2533;
  --gold: #ffc94d;
  --gold-deep: #dc9227;
  --teal: #24776f;
  --plum: #341d33;
  --shadow: 0 18px 50px rgba(16, 8, 15, .42);
  --page-pad: clamp(0px, 1.8vw, 18px);
  --font-body: ui-rounded, "SF Pro Rounded", "Segoe UI", system-ui, -apple-system, sans-serif;
  --font-display: Georgia, "Times New Roman", serif;
}

* { box-sizing: border-box; }

html, body { min-height: 100%; }

body {
  margin: 0;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--page-pad);
  color: var(--ink);
  font-family: var(--font-body);
  background:
    radial-gradient(90rem 50rem at 85% -10%, rgba(221, 130, 77, .30), transparent 58%),
    radial-gradient(70rem 60rem at 0% 115%, rgba(80, 41, 77, .9), transparent 65%),
    repeating-linear-gradient(115deg, rgba(255,255,255,.018) 0 1px, transparent 1px 6px),
    #1d131c;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
}

body::before,
body::after {
  content: "";
  position: fixed;
  width: 28rem;
  height: 28rem;
  border: 1px solid rgba(255, 222, 168, .12);
  border-radius: 50%;
  pointer-events: none;
}
body::before { left: -12rem; top: -13rem; box-shadow: 0 0 0 4rem rgba(255,222,168,.025), 0 0 0 9rem rgba(255,222,168,.018); }
body::after { right: -15rem; bottom: -17rem; box-shadow: 0 0 0 5rem rgba(255,222,168,.02), 0 0 0 12rem rgba(255,222,168,.012); }

button { font: inherit; }
button, canvas { -webkit-tap-highlight-color: transparent; }

.app {
  position: relative;
  z-index: 1;
  width: min(1100px, 100%);
  height: min(calc(100dvh - (var(--page-pad) * 2)), 940px);
  min-height: 380px;
  display: flex;
  flex-direction: column;
  gap: clamp(7px, 1.2vh, 12px);
  padding: clamp(10px, 1.7vw, 20px);
  border: 1px solid rgba(255, 247, 225, .55);
  border-radius: 30px;
  background:
    radial-gradient(70rem 35rem at 30% -20%, rgba(255,255,255,.55), transparent 56%),
    linear-gradient(145deg, #fbf0db, #f1ddba 55%, #e9cfa6);
  box-shadow: var(--shadow), inset 0 0 0 1px rgba(255,255,255,.35);
  overflow: hidden;
  isolation: isolate;
}

.app::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  opacity: .34;
  background-image:
    repeating-linear-gradient(102deg, rgba(92, 54, 39, .055) 0 1px, transparent 1px 7px),
    radial-gradient(rgba(70, 36, 30, .12) .65px, transparent .8px);
  background-size: auto, 7px 7px;
  pointer-events: none;
}

.topbar {
  flex: 0 0 auto;
  min-height: 48px;
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr) 46px;
  align-items: center;
  gap: 10px;
}

.icon-btn {
  width: 44px;
  height: 44px;
  display: inline-grid;
  place-items: center;
  padding: 0;
  color: var(--ink);
  border: 1.5px solid rgba(40, 23, 32, .34);
  border-radius: 50%;
  background: rgba(255, 249, 235, .6);
  box-shadow: 0 2px 0 rgba(40, 23, 32, .12);
  cursor: pointer;
  transition: transform .16s ease, background .16s ease, box-shadow .16s ease;
}
.icon-btn:hover { background: #fff8e9; box-shadow: 0 3px 0 rgba(40, 23, 32, .14); }
.icon-btn:active { transform: translateY(2px) scale(.97); box-shadow: none; }
.icon-btn:focus-visible, .grab-btn:focus-visible, .btn-primary:focus-visible, .text-btn:focus-visible, .close-btn:focus-visible {
  outline: 3px solid var(--teal);
  outline-offset: 3px;
}

.icon-sound { width: 22px; height: 22px; }
.sound-slash { display: none; }
.icon-btn[aria-pressed="true"] .sound-slash { display: block; }
.icon-btn[aria-pressed="true"] .sound-wave { display: none; }
.icon-btn[aria-pressed="true"] { color: var(--red-dark); background: rgba(255, 240, 235, .62); }

.help-btn {
  justify-self: end;
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-weight: 700;
  line-height: 1;
}

.brand { text-align: center; min-width: 0; }
.brand-kicker {
  display: block;
  margin-bottom: 2px;
  color: #8b5e4c;
  font-size: clamp(.48rem, .8vw, .58rem);
  font-weight: 800;
  letter-spacing: .22em;
  text-transform: uppercase;
  white-space: nowrap;
}
.brand-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(1.35rem, 3.2vw, 1.95rem);
  font-weight: 700;
  letter-spacing: -.035em;
  line-height: .96;
  white-space: nowrap;
}
.brand-title em {
  color: var(--red);
  font-weight: 700;
  letter-spacing: -.045em;
}

.game-shell {
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: clamp(7px, 1.2vh, 11px);
}

.hud {
  min-height: 34px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 3px;
}

.hud-block {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}
.hud-block-right { margin-left: auto; align-items: flex-end; }

.hud-label {
  color: #845d4d;
  font-size: clamp(.48rem, .72vw, .56rem);
  font-weight: 800;
  letter-spacing: .17em;
  line-height: 1;
  text-transform: uppercase;
  white-space: nowrap;
}

.progress { display: flex; align-items: flex-end; gap: 5px; height: 22px; }
.pip {
  display: block;
  width: 18px;
  height: 24px;
  opacity: .52;
  filter: grayscale(.88);
  transform-origin: 50% 100%;
  transition: opacity .25s ease, filter .25s ease, transform .35s cubic-bezier(.2, 1.7, .4, 1);
}
.pip svg { display: block; width: 100%; height: 100%; overflow: visible; }
.pip-waffle {
  fill: #b9793f;
  stroke: var(--ink);
  stroke-width: 1.3;
  stroke-linejoin: round;
}
.pip-scoop {
  fill: #e4bb67;
  stroke: var(--ink);
  stroke-width: 1.3;
}
.pip.done { opacity: 1; filter: none; transform: translateY(-2px) rotate(-2deg); }
.pip.done .pip-scoop { fill: #a8c477; }
.pip.done .pip-waffle { fill: #e0a253; }

.legend {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(6px, 1.3vw, 12px);
  margin: 0 auto;
  padding: 5px 9px;
  border: 1px solid rgba(40, 23, 32, .18);
  border-radius: 999px;
  background: rgba(255, 248, 232, .52);
  color: #5f4138;
  font-size: clamp(.49rem, .8vw, .6rem);
  font-weight: 850;
  letter-spacing: .06em;
  line-height: 1;
  white-space: nowrap;
}
.legend span { display: inline-flex; align-items: center; gap: 4px; }
.dot {
  display: inline-block;
  flex: 0 0 auto;
  width: 7px;
  height: 7px;
  border-radius: 50%;
}
.dot-gold { background: var(--gold); box-shadow: 0 0 0 2px rgba(255, 201, 77, .24), 0 0 8px rgba(255, 201, 77, .6); }
.dot-red { background: var(--red); box-shadow: 0 0 0 2px rgba(217, 67, 70, .18), 0 0 8px rgba(217, 67, 70, .35); }

.hearts { display: flex; gap: 1px; height: 22px; align-items: center; }
.heart {
  display: inline-block;
  color: var(--red);
  font-size: clamp(1.05rem, 1.8vw, 1.3rem);
  line-height: 1;
  text-shadow: 0 1px 0 #fff3db;
  transform-origin: 50% 60%;
  transition: opacity .18s ease, transform .25s cubic-bezier(.2, 1.6, .4, 1), filter .18s ease;
}
.heart.lost { opacity: .2; filter: grayscale(1); transform: scale(.72); }
.heart.pulse { animation: heartPulse .55s ease; }

.stage {
  position: relative;
  min-height: 0;
  overflow: hidden;
  border: 2px solid var(--ink);
  border-radius: clamp(17px, 2.7vw, 25px);
  background: #301c2d;
  box-shadow:
    inset 0 0 0 1px rgba(255, 245, 219, .18),
    0 8px 0 rgba(66, 35, 31, .18),
    0 15px 30px rgba(61, 32, 32, .18);
  isolation: isolate;
  touch-action: manipulation;
}
#gameCanvas {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  cursor: pointer;
  touch-action: manipulation;
}
.stage-grain {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  opacity: .2;
  background-image: radial-gradient(rgba(255,255,255,.2) .6px, transparent .8px);
  background-size: 5px 5px;
  mix-blend-mode: soft-light;
}
.stage-vignette {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  border-radius: inherit;
  box-shadow: inset 0 0 80px rgba(23, 10, 20, .35), inset 0 -40px 60px rgba(20, 8, 18, .22);
}
.stage-flash {
  position: absolute;
  inset: 0;
  z-index: 4;
  pointer-events: none;
  opacity: 0;
  border-radius: inherit;
}
.stage-flash.gold { animation: flashGold .52s ease-out; }
.stage-flash.red { animation: flashRed .46s ease-out; }
.stage-flash.green { animation: flashGreen .5s ease-out; }

.speech {
  position: absolute;
  z-index: 5;
  top: clamp(8px, 2.2vw, 15px);
  left: 50%;
  width: max-content;
  max-width: min(370px, 76%);
  padding: 7px 13px 8px;
  color: var(--ink);
  text-align: center;
  font-family: var(--font-display);
  font-size: clamp(.77rem, 1.55vw, .98rem);
  font-weight: 700;
  line-height: 1.14;
  background: rgba(255, 248, 232, .96);
  border: 1.5px solid var(--ink);
  border-radius: 12px 12px 12px 4px;
  box-shadow: 3px 4px 0 rgba(40, 23, 32, .3);
  transform: translateX(-50%);
  transition: background .2s ease, border-color .2s ease, box-shadow .2s ease;
  pointer-events: none;
  overflow-wrap: break-word;
}
.speech::after {
  content: "";
  position: absolute;
  left: 22px;
  bottom: -7px;
  width: 12px;
  height: 12px;
  background: inherit;
  border-right: 1.5px solid var(--ink);
  border-bottom: 1.5px solid var(--ink);
  transform: rotate(45deg);
}
.speech[data-tone="gold"] {
  background: #fff5bd;
  border-color: #a36413;
  box-shadow: 3px 4px 0 rgba(106, 65, 15, .35), 0 0 22px rgba(255, 201, 77, .55);
}
.speech[data-tone="red"] {
  color: #641623;
  background: #ffe5df;
  border-color: #9b2533;
  box-shadow: 3px 4px 0 rgba(91, 21, 34, .35);
}
.speech[data-tone="teal"] {
  color: #123f3b;
  background: #dff6ec;
  border-color: #24776f;
}
.speech.pop { animation: speechPop .3s cubic-bezier(.2, 1.6, .4, 1); }

.stage-tip {
  position: absolute;
  z-index: 5;
  left: 50%;
  bottom: clamp(7px, 1.2vw, 12px);
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  color: rgba(255, 244, 221, .94);
  font-size: clamp(.52rem, .82vw, .63rem);
  font-weight: 750;
  letter-spacing: .04em;
  line-height: 1;
  white-space: nowrap;
  background: rgba(34, 18, 29, .56);
  border: 1px solid rgba(255, 240, 207, .18);
  border-radius: 999px;
  transform: translateX(-50%);
  backdrop-filter: blur(5px);
  pointer-events: none;
  transition: opacity .25s ease;
}
.stage-tip .dot { width: 5px; height: 5px; box-shadow: none; }

.controls {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
}

.grab-btn {
  position: relative;
  width: min(570px, 100%);
  min-height: clamp(58px, 8.4vh, 74px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  padding: 8px 22px;
  color: #fff7e4;
  border: 2px solid var(--ink);
  border-radius: 18px;
  background:
    radial-gradient(70% 120% at 50% -20%, rgba(255, 208, 118, .38), transparent 60%),
    linear-gradient(180deg, #ec5350, #c52f3c 64%, #ab2535);
  box-shadow: 0 6px 0 #6f1c2b, 0 11px 20px rgba(79, 27, 38, .24), inset 0 1px 0 rgba(255,255,255,.28);
  cursor: pointer;
  overflow: hidden;
  transition: transform .11s ease, box-shadow .11s ease, background .2s ease, color .2s ease;
  user-select: none;
  touch-action: manipulation;
}
.grab-btn::before {
  content: "";
  position: absolute;
  inset: 4px;
  border-radius: 13px;
  border: 1px solid rgba(255, 237, 199, .26);
  pointer-events: none;
}
.grab-btn::after {
  content: "";
  position: absolute;
  inset: auto -10% -50% -10%;
  height: 80%;
  background: radial-gradient(ellipse at center, rgba(255, 208, 104, .24), transparent 68%);
  pointer-events: none;
}
.grab-btn:hover { background: radial-gradient(70% 120% at 50% -20%, rgba(255, 208, 118, .45), transparent 60%), linear-gradient(180deg, #f15b57, #ca3440 64%, #af2738); }
.grab-btn:active { transform: translateY(4px); box-shadow: 0 2px 0 #6f1c2b, 0 4px 9px rgba(79, 27, 38, .22), inset 0 1px 0 rgba(255,255,255,.28); }
.grab-main {
  position: relative;
  z-index: 1;
  font-size: clamp(1.35rem, 3.1vw, 1.8rem);
  font-weight: 900;
  letter-spacing: .13em;
  line-height: 1;
  text-shadow: 0 2px 0 rgba(67, 15, 24, .35);
}
.grab-sub {
  position: relative;
  z-index: 1;
  color: rgba(255, 244, 219, .78);
  font-size: clamp(.52rem, .8vw, .62rem);
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
}
.grab-btn.armed {
  color: #3b2110;
  background:
    radial-gradient(70% 120% at 50% -20%, rgba(255, 255, 226, .9), transparent 55%),
    linear-gradient(180deg, #ffdc74, #f6b937 65%, #e39b19);
  box-shadow: 0 6px 0 #855010, 0 0 0 5px rgba(255, 201, 77, .2), 0 0 30px rgba(255, 190, 52, .4), inset 0 1px 0 rgba(255,255,255,.65);
  animation: grabThump .5s ease both;
}
.grab-btn.armed .grab-main { color: #3b2110; text-shadow: 0 1px 0 rgba(255, 243, 190, .55); }
.grab-btn.armed .grab-sub { color: rgba(59, 33, 16, .7); }
.grab-btn.cooling { filter: saturate(.65) brightness(.92); }
.grab-btn.cooling .grab-main { opacity: .72; }

.feedback {
  min-height: 1.05em;
  margin: 0;
  padding: 0 8px;
  color: #7c5647;
  font-size: clamp(.58rem, .88vw, .68rem);
  font-weight: 650;
  letter-spacing: .015em;
  line-height: 1.25;
  text-align: center;
}
.feedback.good { color: #1d675d; }
.feedback.bad { color: #a52d3a; }

.footer {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 15px;
  color: #916c5a;
  font-size: clamp(.5rem, .7vw, .57rem);
  font-weight: 750;
  letter-spacing: .13em;
  line-height: 1;
  text-transform: uppercase;
}
.footer-dot { color: var(--red); }

/* Dialogs and cards */
.modal-dialog {
  width: min(600px, calc(100vw - 24px));
  max-width: none;
  max-height: calc(100dvh - 24px);
  margin: auto;
  padding: 0;
  border: 0;
  color: var(--ink);
  background: transparent;
  overflow: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: #a97955 transparent;
  z-index: 50;
}
.modal-dialog::backdrop {
  background: rgba(24, 12, 22, .68);
  backdrop-filter: blur(7px) saturate(.82);
  -webkit-backdrop-filter: blur(7px) saturate(.82);
}
.end-dialog::backdrop { background: rgba(24, 12, 22, .46); backdrop-filter: blur(3px); }
.modal-dialog[open] .modal { animation: modalIn .38s cubic-bezier(.2, 1.2, .3, 1) both; }

.modal {
  position: relative;
  overflow: hidden;
  padding: clamp(24px, 5vw, 42px);
  border: 2px solid var(--ink);
  border-radius: clamp(22px, 4vw, 30px);
  background:
    radial-gradient(50rem 30rem at 90% -20%, rgba(255,255,255,.7), transparent 55%),
    linear-gradient(150deg, #fff8e9, #f4e3c5 66%, #eed7b2);
  box-shadow:
    0 10px 0 rgba(47, 25, 25, .25),
    0 35px 90px rgba(0, 0, 0, .45),
    inset 0 0 0 1px rgba(255,255,255,.45);
}
.modal::before {
  content: "";
  position: absolute;
  inset: 0;
  opacity: .25;
  background-image: repeating-linear-gradient(105deg, rgba(93, 51, 35, .06) 0 1px, transparent 1px 8px);
  pointer-events: none;
}
.modal > * { position: relative; z-index: 1; }

.modal-stamp {
  position: absolute;
  z-index: 2;
  top: clamp(16px, 3vw, 24px);
  right: clamp(16px, 3vw, 24px);
  width: 63px;
  height: 63px;
  display: grid;
  place-content: center;
  color: #a4775a;
  border: 1px dashed #b48866;
  border-radius: 50%;
  font-size: .4rem;
  font-weight: 800;
  letter-spacing: .16em;
  line-height: 1.3;
  text-align: center;
  text-transform: uppercase;
  transform: rotate(8deg);
}
.modal-stamp strong { color: var(--red-dark); font-size: .66rem; letter-spacing: .08em; }

.mini-cone {
  width: clamp(48px, 7vw, 62px);
  margin-bottom: 12px;
  filter: drop-shadow(0 5px 0 rgba(99, 55, 35, .12));
}
.mini-cone svg { display: block; width: 100%; height: auto; }

.eyebrow {
  margin: 0 0 7px;
  color: var(--red-dark);
  font-size: clamp(.54rem, .9vw, .66rem);
  font-weight: 850;
  letter-spacing: .2em;
  line-height: 1.2;
  text-transform: uppercase;
}
.modal-title {
  max-width: 90%;
  margin: 0 0 12px;
  font-family: var(--font-display);
  font-size: clamp(2rem, 5.7vw, 3.25rem);
  font-weight: 700;
  letter-spacing: -.045em;
  line-height: .96;
  text-wrap: balance;
}
.modal-title em { color: var(--red); font-style: italic; }
.lede {
  max-width: 85%;
  margin: 0 0 20px;
  color: #65483e;
  font-size: clamp(.8rem, 1.55vw, .95rem);
  line-height: 1.45;
  text-wrap: pretty;
}

.rules { display: grid; gap: 12px; margin: 0 0 22px; }
.rule { display: grid; grid-template-columns: 30px 1fr; align-items: start; gap: 11px; }
.rule-num {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  color: var(--cream);
  background: var(--ink);
  border-radius: 50%;
  font-family: var(--font-display);
  font-size: .88rem;
  font-weight: 700;
  box-shadow: 0 2px 0 #a77b56;
}
.rule strong {
  display: block;
  margin-bottom: 2px;
  font-family: var(--font-display);
  font-size: 1.03rem;
  line-height: 1.1;
}
.rule span:not(.rule-num) {
  display: block;
  color: #715347;
  font-size: clamp(.71rem, 1.2vw, .82rem);
  line-height: 1.36;
}
.rule b { color: var(--ink); }

.btn-primary {
  width: 100%;
  min-height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 11px;
  padding: 10px 18px;
  color: #fff6e2;
  border: 2px solid var(--ink);
  border-radius: 15px;
  background: linear-gradient(180deg, #e04a4c, #b52a38);
  box-shadow: 0 5px 0 #6d1c2a, inset 0 1px 0 rgba(255,255,255,.25);
  font-size: clamp(.9rem, 1.8vw, 1.05rem);
  font-weight: 850;
  letter-spacing: .04em;
  cursor: pointer;
  transition: transform .12s ease, box-shadow .12s ease, filter .15s ease;
}
.btn-primary:hover { filter: brightness(1.06); }
.btn-primary:active { transform: translateY(3px); box-shadow: 0 2px 0 #6d1c2a, inset 0 1px 0 rgba(255,255,255,.2); }
.btn-primary span { font-size: 1.25em; line-height: .8; }
.modal-foot {
  margin: 11px 0 0;
  color: #96715c;
  font-size: clamp(.51rem, .82vw, .59rem);
  font-weight: 650;
  letter-spacing: .035em;
  line-height: 1.35;
  text-align: center;
}

.end-modal { text-align: center; }
.end-modal .eyebrow { color: #936a38; }
.end-modal .modal-title { max-width: 100%; margin-right: auto; margin-left: auto; font-size: clamp(2.1rem, 6vw, 3.45rem); }
.end-modal .lede { max-width: 90%; margin-right: auto; margin-left: auto; }
.end-badge {
  position: relative;
  width: 78px;
  height: 78px;
  margin: -4px auto 13px;
  display: grid;
  place-items: center;
  border: 1.5px solid rgba(40, 23, 32, .35);
  border-radius: 50%;
  background: #fff6e2;
  box-shadow: 0 4px 0 rgba(109, 65, 49, .14);
}
.end-badge::before {
  content: "";
  position: absolute;
  inset: -7px;
  border: 1px dashed rgba(155, 37, 51, .45);
  border-radius: 50%;
  transform: rotate(-9deg);
}
.end-badge svg { width: 44px; height: 62px; }
.badge-empty { display: none; }
.end-dialog[data-result="lose"] .end-badge { background: #f4e3d5; }
.end-dialog[data-result="lose"] .badge-cone { display: none; }
.end-dialog[data-result="lose"] .badge-empty { display: block; }
.end-dialog[data-result="lose"] .eyebrow { color: #9b2533; }
.end-dialog[data-result="lose"] .end-badge::before { border-color: rgba(109, 83, 72, .35); }

.result-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1px;
  margin: 0 0 21px;
  border: 1.5px solid rgba(40, 23, 32, .25);
  border-radius: 14px;
  background: rgba(40, 23, 32, .15);
  overflow: hidden;
}
.result-stats div {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 11px 5px 10px;
  background: rgba(255, 248, 233, .74);
}
.result-stats strong {
  font-family: var(--font-display);
  font-size: clamp(1.25rem, 2.6vw, 1.55rem);
  line-height: 1;
}
.result-stats span {
  color: #846454;
  font-size: clamp(.48rem, .8vw, .56rem);
  font-weight: 800;
  letter-spacing: .1em;
  text-transform: uppercase;
}
.text-btn {
  margin-top: 13px;
  padding: 5px 8px;
  color: #8e604b;
  font-size: .7rem;
  font-weight: 750;
  letter-spacing: .04em;
  border: 0;
  border-bottom: 1px solid rgba(142, 96, 75, .4);
  background: transparent;
  cursor: pointer;
}
.text-btn:hover { color: var(--ink); }

.help-dialog { width: min(560px, calc(100vw - 24px)); }
.help-modal { padding-top: clamp(30px, 6vw, 44px); }
.close-btn {
  position: absolute;
  z-index: 3;
  top: 14px;
  right: 14px;
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  padding: 0;
  color: var(--ink);
  border: 1.5px solid rgba(40, 23, 32, .3);
  border-radius: 50%;
  background: rgba(255, 248, 233, .65);
  font-family: var(--font-display);
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
}
.close-btn:hover { background: #fff8e9; }
.help-list { display: grid; gap: 13px; margin: 18px 0; }
.help-item { display: grid; grid-template-columns: 15px 1fr; gap: 12px; align-items: start; }
.help-item strong { display: block; margin-bottom: 2px; font-family: var(--font-display); font-size: 1rem; }
.help-item p { margin: 0; color: #715347; font-size: clamp(.73rem, 1.25vw, .82rem); line-height: 1.4; }
.help-swatch {
  width: 13px;
  height: 13px;
  margin-top: 3px;
  border-radius: 50%;
  border: 1.5px solid rgba(40, 23, 32, .45);
}
.help-swatch.gold { background: var(--gold); box-shadow: 0 0 0 3px rgba(255, 201, 77, .22); }
.help-swatch.red { background: var(--red); box-shadow: 0 0 0 3px rgba(217, 67, 70, .16); }
.help-swatch.neutral { background: #f5e3c3; }
.help-extra {
  margin: 0 0 20px;
  padding: 12px 14px;
  color: #6b4d40;
  border-left: 3px solid var(--red);
  background: rgba(255, 248, 233, .5);
  font-size: clamp(.7rem, 1.2vw, .79rem);
  font-style: italic;
  line-height: 1.42;
}

.noscript {
  position: fixed;
  z-index: 100;
  inset: 20px;
  display: grid;
  place-items: center;
  padding: 24px;
  color: var(--cream);
  background: var(--plum);
  border: 2px solid var(--cream);
  border-radius: 20px;
  font-size: 1rem;
  text-align: center;
}

/* Short screens: keep the action and the button above the fold. */
@media (max-height: 690px) {
  .app { gap: 6px; padding: 10px 14px; }
  .topbar { min-height: 38px; grid-template-columns: 38px minmax(0, 1fr) 38px; }
  .icon-btn { width: 36px; height: 36px; }
  .icon-sound { width: 18px; height: 18px; }
  .brand-kicker { display: none; }
  .brand-title { font-size: clamp(1.25rem, 3vw, 1.65rem); }
  .hud { min-height: 28px; }
  .grab-btn { min-height: 52px; border-radius: 15px; }
  .grab-main { font-size: 1.2rem; }
  .grab-sub { display: none; }
  .footer { display: none; }
  .stage-tip { bottom: 6px; font-size: .48rem; }
  .speech { padding: 5px 10px 6px; font-size: .76rem; }
  .modal { padding: 22px 24px; }
  .mini-cone { width: 42px; margin-bottom: 8px; }
  .modal-title { font-size: clamp(1.8rem, 5vw, 2.5rem); }
  .rules { gap: 8px; margin-bottom: 15px; }
  .rule { grid-template-columns: 25px 1fr; gap: 9px; }
  .rule-num { width: 24px; height: 24px; font-size: .76rem; }
  .rule span:not(.rule-num) { font-size: .68rem; }
  .lede { margin-bottom: 14px; }
}

@media (max-width: 560px) {
  body { padding: 0; }
  body::before, body::after { display: none; }
  .app {
    width: 100%;
    height: 100dvh;
    min-height: 360px;
    padding: max(8px, env(safe-area-inset-top)) max(9px, env(safe-area-inset-right)) max(8px, env(safe-area-inset-bottom)) max(9px, env(safe-area-inset-left));
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }
  .topbar { grid-template-columns: 46px minmax(0, 1fr) 46px; min-height: 46px; }
  .icon-btn { width: 44px; height: 44px; }
  .brand-kicker { font-size: .46rem; letter-spacing: .16em; }
  .brand-title { font-size: clamp(1.25rem, 6.3vw, 1.55rem); }
  .hud { gap: 7px; }
  .hud-label { font-size: .46rem; letter-spacing: .12em; }
  .legend { gap: 6px; padding: 4px 7px; font-size: .47rem; letter-spacing: .03em; }
  .legend .dot { width: 5px; height: 5px; }
  .pip { width: 16px; height: 22px; }
  .progress { gap: 4px; }
  .grab-btn { border-radius: 17px; }
  .stage { border-width: 1.5px; border-radius: 19px; box-shadow: inset 0 0 0 1px rgba(255,245,219,.16), 0 5px 0 rgba(66,35,31,.16); }
  .speech { max-width: 78%; font-size: clamp(.74rem, 3.2vw, .88rem); padding: 6px 10px 7px; }
  .speech::after { left: 16px; }
  .stage-tip { font-size: .5rem; max-width: calc(100% - 14px); }
  .grab-main { font-size: clamp(1.25rem, 6vw, 1.55rem); }
  .grab-sub { font-size: .49rem; }
  .feedback { font-size: .58rem; }
  .modal-dialog { width: calc(100vw - 18px); max-height: calc(100dvh - 18px); }
  .modal { padding: 24px 21px 21px; border-radius: 24px; }
  .modal-stamp { width: 52px; height: 52px; font-size: .34rem; top: 15px; right: 14px; }
  .modal-stamp strong { font-size: .56rem; }
  .modal-title { max-width: 86%; font-size: clamp(1.8rem, 8.4vw, 2.4rem); }
  .lede { max-width: 100%; font-size: .79rem; }
  .rule strong { font-size: .93rem; }
  .rule span:not(.rule-num) { font-size: .69rem; }
  .btn-primary { min-height: 52px; }
  .mini-cone { width: 44px; margin-bottom: 9px; }
  .modal-foot { font-size: .49rem; }
  .end-modal .modal-title { max-width: 100%; font-size: clamp(1.95rem, 8.8vw, 2.6rem); }
  .result-stats div { padding: 9px 3px 8px; }
  .help-extra { font-size: .69rem; }
}

@media (max-width: 370px) {
  .legend span:last-child { display: none; }
  .legend::after { content: "RED = HOLD"; }
  .brand-kicker { display: none; }
  .feedback { font-size: .54rem; }
}

@media (max-height: 500px) and (orientation: landscape) {
  /* Fill the short viewport: body padding was clipping the feedback line. */
  body { padding: 0; }
  .app { padding: 4px 10px 6px; gap: 3px; border-radius: 0; height: 100dvh; min-height: 0; width: 100%; }
  .topbar { min-height: 44px; grid-template-columns: 46px 1fr 46px; }
  .icon-btn { width: 44px; height: 44px; }
  .icon-sound { width: 22px; height: 22px; }
  .brand-title { font-size: 1.15rem; }
  .hud { min-height: 24px; }
  .hud-label { display: none; }
  .hud-block { flex-direction: row; align-items: center; }
  .hud-block-right { margin-left: 0; }
  .hearts { height: 18px; }
  .heart { font-size: .95rem; }
  .progress { height: 19px; }
  .pip { width: 15px; height: 21px; }
  .legend { font-size: .44rem; padding: 3px 6px; }
  .game-shell { gap: 3px; }
  .controls { gap: 3px; }
  .grab-btn { min-height: 48px; max-width: 520px; }
  .grab-main { font-size: 1.15rem; }
  .feedback { font-size: .55rem; min-height: 1.15em; padding-bottom: 1px; }
  .stage-tip { display: none; }
  .speech { font-size: .7rem; padding: 4px 8px 5px; top: 5px; }
  .footer { display: none; }

  /* Use landscape width so the start header and Start fit on one screen. */
  .start-dialog { width: min(760px, calc(100vw - 16px)); max-height: calc(100dvh - 10px); }
  .start-modal {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    column-gap: 12px;
    row-gap: 6px;
    align-items: center;
    padding: 12px 18px 10px;
  }
  .start-modal .mini-cone {
    grid-column: 1;
    grid-row: 1 / span 2;
    width: 40px;
    margin: 0;
    align-self: center;
  }
  .start-modal .eyebrow {
    grid-column: 2;
    grid-row: 1;
    margin: 0;
    align-self: end;
  }
  .start-modal .modal-title {
    grid-column: 2;
    grid-row: 2;
    max-width: 100%;
    margin: 0;
    font-size: clamp(1.35rem, 3.2vw, 1.7rem);
    align-self: start;
  }
  .start-modal .modal-stamp {
    position: static;
    grid-column: 3;
    grid-row: 1 / span 2;
    top: auto;
    right: auto;
    width: 52px;
    height: 52px;
    transform: rotate(8deg);
    justify-self: end;
  }
  .start-modal .lede {
    grid-column: 1 / -1;
    max-width: 100%;
    margin: 2px 0 0;
    font-size: .78rem;
    line-height: 1.3;
  }
  .start-modal .rules {
    grid-column: 1 / -1;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px 14px;
    margin: 2px 0 4px;
  }
  .start-modal .rule { grid-template-columns: 22px 1fr; gap: 7px; }
  .start-modal .rule-num { width: 22px; height: 22px; font-size: .7rem; }
  .start-modal .rule strong { font-size: .86rem; }
  .start-modal .rule span:not(.rule-num) { font-size: .62rem; line-height: 1.25; }
  .start-modal .btn-primary { grid-column: 1 / -1; min-height: 48px; }
  .start-modal .modal-foot { grid-column: 1 / -1; margin: 0; }

  /* Fit How to play and Back to the street on one short-landscape screen. */
  .help-dialog { width: min(760px, calc(100vw - 16px)); max-height: calc(100dvh - 10px); }
  .help-modal { padding: 10px 18px 10px; }
  .help-modal .close-btn { top: 6px; right: 8px; }
  .help-modal .eyebrow { margin: 0; max-width: calc(100% - 52px); }
  .help-modal .modal-title {
    max-width: calc(100% - 52px);
    margin: 0 0 8px;
    font-size: clamp(1.35rem, 3.2vw, 1.7rem);
  }
  .help-list {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px 14px;
    margin: 4px 0 6px;
  }
  .help-item { grid-template-columns: 13px 1fr; gap: 7px; }
  .help-item strong { font-size: .86rem; margin-bottom: 0; }
  .help-item p { font-size: .62rem; line-height: 1.25; }
  .help-extra { margin: 0 0 8px; padding: 6px 10px; font-size: .7rem; line-height: 1.3; }
  .help-modal .btn-primary { min-height: 48px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: .001ms !important;
  }
}

@keyframes modalIn {
  from { opacity: 0; transform: translateY(14px) scale(.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes speechPop {
  0% { transform: translateX(-50%) scale(.92); }
  70% { transform: translateX(-50%) scale(1.03); }
  100% { transform: translateX(-50%) scale(1); }
}
@keyframes grabThump {
  0% { transform: scale(1); }
  40% { transform: scale(1.035); }
  70% { transform: scale(.995); }
  100% { transform: scale(1); }
}
@keyframes heartPulse {
  0%, 100% { transform: scale(1); }
  30% { transform: scale(1.38) rotate(-6deg); }
  65% { transform: scale(.9) rotate(3deg); }
}
@keyframes flashGold {
  0% { opacity: 0; background: radial-gradient(circle at 50% 45%, rgba(255, 222, 112, .8), transparent 62%); }
  22% { opacity: .9; }
  100% { opacity: 0; background: radial-gradient(circle at 50% 45%, rgba(255, 222, 112, 0), transparent 70%); }
}
@keyframes flashRed {
  0% { opacity: 0; box-shadow: inset 0 0 80px rgba(217, 67, 70, .8); }
  25% { opacity: .9; }
  100% { opacity: 0; box-shadow: inset 0 0 80px rgba(217, 67, 70, 0); }
}
@keyframes flashGreen {
  0% { opacity: 0; background: radial-gradient(circle at 50% 50%, rgba(141, 220, 178, .55), transparent 64%); }
  30% { opacity: .8; }
  100% { opacity: 0; background: radial-gradient(circle at 50% 50%, rgba(141, 220, 178, 0), transparent 68%); }
}
