/*
 * styles.css — one file, no framework.
 * Everything is sized from the viewport, never from a fixed pixel canvas, so a
 * 390x844 phone and a 1440 desktop both get the whole board with nothing clipped.
 */

:root {
  --cream: #FFF4E6;
  --cream-2: #FFE7CD;
  --ink: #2E2438;
  --ink-soft: #6B5D74;
  --line: #E8D6BE;
  --line-2: #DCC5A6;
  --marigold: #FFB020;
  --orange: #F2610C;
  --rose: #E8365D;
  --teal: #12A28E;
  --card: #FFFFFF;
  --shadow: 0 18px 44px rgba(64, 34, 8, .22);
  --font: ui-rounded, "SF Pro Rounded", "Segoe UI Variable", "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overscroll-behavior: none;
}

body {
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(120% 62% at 50% -8%, #FFE2B4 0%, rgba(255, 226, 180, 0) 62%),
    linear-gradient(178deg, var(--cream) 0%, var(--cream-2) 100%);
  background-attachment: fixed;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}

.app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  max-width: 560px;
  margin: 0 auto;
  padding: calc(env(safe-area-inset-top, 0px) + 8px) 9px calc(env(safe-area-inset-bottom, 0px) + 7px);
}

/* --------------------------------------------------------------------- hud */

.hud { flex: 0 0 auto; padding: 0 4px 6px; }

.hud-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }

.lvl { display: flex; flex-direction: column; line-height: 1.05; }
.lvl strong { font-size: 1.32rem; font-weight: 800; letter-spacing: -.02em; }
.lvl span {
  font-size: .68rem; font-weight: 800; letter-spacing: .12em; text-transform: uppercase;
  color: var(--orange); margin-top: 3px;
}

.hearts { display: flex; gap: 4px; }
.hearts svg { width: 26px; height: 26px; fill: var(--rose); filter: drop-shadow(0 2px 0 rgba(150, 20, 50, .25)); transition: transform .22s cubic-bezier(.34,1.56,.64,1), fill .22s, opacity .22s; }
.hearts svg.spent { fill: #E3D3C0; opacity: .85; transform: scale(.74); filter: none; }
.hearts.hit svg:not(.spent) { animation: pulse .3s ease; }

.bar-row { margin-top: 9px; }
.bar { flex: 1; height: 8px; border-radius: 99px; background: rgba(120, 84, 40, .16); overflow: hidden; }
.bar i { display: block; height: 100%; width: 0; border-radius: 99px; background: linear-gradient(90deg, var(--marigold), var(--orange)); transition: width .32s cubic-bezier(.22,1,.36,1); }
.left { font-size: .82rem; font-weight: 800; color: var(--ink-soft); font-variant-numeric: tabular-nums; min-width: 58px; text-align: right; }
.left.pop { animation: pop .28s ease; }

/* ------------------------------------------------------------------- board */

.stage { flex: 1 1 auto; min-height: 0; position: relative; }
#board { display: block; width: 100%; height: 100%; }

/* Centred with auto margins, never with translateX: the entry animation owns
   the transform property, and setting it in both places silently cancels the
   centring. */
.coach {
  position: absolute; left: 0; right: 0; bottom: 0;
  width: fit-content; max-width: calc(100% - 16px); margin: 0 auto;
  background: rgba(36, 28, 46, .94); color: #FFF2DA;
  font-size: .8rem; font-weight: 700; letter-spacing: .01em;
  padding: 7px 15px; border-radius: 99px; text-align: center;
  box-shadow: 0 6px 18px rgba(30, 18, 6, .3);
  animation: fade .35s ease both;
  pointer-events: none;
}

/* ------------------------------------------------------------------- tools */

.tools { flex: 0 0 auto; padding-top: 8px; }
.tool-row { display: flex; gap: 8px; }

.tool {
  position: relative;
  flex: 1;
  display: flex; align-items: center; justify-content: center; gap: 7px;
  height: 56px;
  font-family: inherit; font-size: .98rem; font-weight: 800; color: var(--ink);
  background: #FFFDF9;
  border: 2px solid var(--line);
  border-bottom-width: 4px;
  border-radius: 16px;
  cursor: pointer;
  transition: transform .08s, box-shadow .08s;
}
.tool:active { transform: translateY(2px); border-bottom-width: 2px; }
.tool svg { width: 22px; height: 22px; fill: none; stroke: var(--ink); }
.tool.hint { background: #FFF3DA; border-color: #F1DAAE; color: var(--orange); }
.tool.hint svg { stroke: var(--orange); }
.tool.square { flex: 0 0 56px; }
.tool.square svg { stroke: var(--ink-soft); }

.badge {
  position: absolute; top: -8px; right: -6px;
  min-width: 22px; height: 22px; padding: 0 6px;
  display: grid; place-items: center;
  font-size: .72rem; font-weight: 900; font-style: normal;
  color: #fff; background: var(--rose);
  border: 2px solid var(--cream); border-radius: 99px;
}
.badge.zero { background: #BBA894; }
.badge.inf { background: var(--teal); }

.legal-strip {
  display: flex; align-items: center; justify-content: center; gap: 12px;
  padding-top: 9px;
  font-size: .68rem;
}
.legal-strip a, .linkish {
  color: rgba(107, 93, 116, .8); text-decoration: none;
  font: inherit; background: none; border: 0; padding: 0; cursor: pointer;
}
.legal-strip a:hover, .linkish:hover { color: var(--ink); text-decoration: underline; }

/* ------------------------------------------------------------------ sheets */

.sheet {
  position: fixed; inset: 0; z-index: 40;
  display: flex; align-items: flex-end; justify-content: center;
  padding: 14px;
  background: rgba(38, 25, 12, .58);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  animation: fade .22s ease both;
}
.sheet[hidden] { display: none; }

.card {
  position: relative;
  width: 100%; max-width: 420px;
  max-height: calc(100dvh - 28px);
  overflow-y: auto;
  background: var(--card);
  border-radius: 26px;
  box-shadow: var(--shadow);
  padding: 22px 18px 12px;
  text-align: center;
  animation: rise .3s cubic-bezier(.22,1,.36,1) both;
}
.card.small { padding: 24px 20px 18px; }

@media (min-height: 720px) { .sheet { align-items: center; } }

.card h2 { margin: 8px 0 2px; font-size: 1.3rem; font-weight: 800; letter-spacing: -.02em; line-height: 1.2; }
.card .sub { margin: 0 0 16px; color: var(--ink-soft); font-size: .93rem; line-height: 1.45; }

.x {
  position: absolute; top: 10px; right: 10px;
  width: 38px; height: 38px; display: grid; place-items: center;
  background: #F6EFE4; border: 0; border-radius: 50%; cursor: pointer;
}
.x svg { width: 19px; height: 19px; stroke: var(--ink-soft); fill: none; }

.ribbon {
  display: inline-block;
  font-size: .68rem; font-weight: 900; letter-spacing: .14em;
  color: #6A3200;
  background: linear-gradient(180deg, #FFD874, var(--marigold));
  padding: 6px 14px; border-radius: 99px;
  box-shadow: 0 3px 0 #DE8F00;
}

.perks { list-style: none; margin: 12px 0 2px; padding: 0; text-align: left; }
.perks li {
  position: relative;
  padding: 5px 0 5px 28px;
  font-size: .89rem; line-height: 1.35; color: #4A3E55;
}
.perks li::before {
  content: ""; position: absolute; left: 0; top: 7px;
  width: 19px; height: 19px; border-radius: 50%;
  background: #E9F8EF url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M5 13l4 4 10-10' fill='none' stroke='%2312A28E' stroke-width='3.2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center/13px no-repeat;
}
.perks em { font-style: normal; font-weight: 800; color: var(--ink); }

.pricebox { margin: 13px 0 10px; }
.pricebox strong { display: block; font-size: 2.1rem; font-weight: 900; letter-spacing: -.03em; line-height: 1; }
.pricebox em { display: block; margin-top: 5px; font-style: normal; font-size: .8rem; font-weight: 700; color: var(--ink-soft); }

.btn {
  display: block; width: 100%;
  font-family: inherit; font-size: 1.02rem; font-weight: 800;
  padding: 14px 16px; border-radius: 16px; border: 0;
  cursor: pointer; margin-top: 10px;
  transition: transform .08s, box-shadow .08s;
}
.btn:active { transform: translateY(2px); }
.btn.primary {
  color: #fff;
  background: linear-gradient(180deg, #FF8A2B, var(--orange));
  box-shadow: 0 4px 0 #C4470A, 0 10px 22px rgba(242, 97, 12, .32);
}
.btn.primary:active { box-shadow: 0 2px 0 #C4470A; }
.btn.big { font-size: 1.05rem; padding: 16px 14px; }
.btn.ghost {
  color: var(--ink); background: #FFF7EA; border: 2px solid var(--line);
  border-bottom-width: 4px;
}
.btn.ghost:active { border-bottom-width: 2px; }
.btn.text { background: none; color: var(--ink-soft); font-weight: 700; font-size: .9rem; padding: 10px; text-decoration: underline; }

.err { margin: 10px 0 0; color: #C4270D; font-size: .86rem; font-weight: 700; }

.fineprint { margin: 10px 0 0; font-size: .67rem; line-height: 1.5; color: rgba(107, 93, 116, .82); }
.fineprint a { color: inherit; }

.stars { display: flex; justify-content: center; gap: 6px; margin-bottom: 6px; }
.stars svg { width: 46px; height: 46px; fill: #E6DACB; transition: fill .2s, transform .3s cubic-bezier(.34,1.56,.64,1); transform: scale(.8); }
.stars svg.on { fill: var(--marigold); transform: scale(1); filter: drop-shadow(0 3px 0 #DE8F00); }

.fail-mark { display: grid; place-items: center; margin-bottom: 4px; }
.fail-mark svg { width: 54px; height: 54px; fill: #E9DCCB; }

.vip {
  position: fixed; top: calc(env(safe-area-inset-top, 0px) + 10px); right: 12px; z-index: 30;
  font-size: .62rem; font-weight: 900; letter-spacing: .12em;
  color: #6A3200; background: linear-gradient(180deg, #FFD874, var(--marigold));
  padding: 4px 9px; border-radius: 99px; box-shadow: 0 2px 0 #DE8F00;
}
.vip[hidden] { display: none; }

/* ---------------------------------------------------------------- keyframes */

@keyframes fade { from { opacity: 0 } to { opacity: 1 } }
@keyframes rise { from { opacity: 0; transform: translateY(26px) } to { opacity: 1; transform: none } }
@keyframes pop { 0% { transform: scale(1) } 40% { transform: scale(1.28) } 100% { transform: scale(1) } }
@keyframes pulse { 0% { transform: scale(1) } 50% { transform: scale(1.22) } 100% { transform: scale(1) } }

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
