/* Beejr Games: honey palette, mobile first (344px Fold cover screen is the floor). */
:root {
  --bg: #fff8e7;
  --surface: #ffffff;
  --surface-2: #fdf0cf;
  --text: #2b2118;
  --muted: #6b5747;
  --accent: #e8a317;
  --accent-strong: #9a6108;
  --on-accent: #2b2118;
  --tile: #ffe7ad;
  --tile-empty: #f3e3bd;
  --good: #2f7d32;
  --bad: #b3261e;
  --line: rgba(232, 163, 23, 0.75);
  --border: #ead7a8;
  --shadow: 0 2px 10px rgba(80, 50, 10, 0.12);
  --petal: #ffd54a;
  --petal-edge: #e8a317;
  --stem: #5a8f3c;
  --radius: 14px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1b1712;
    --surface: #2a231b;
    --surface-2: #332a1f;
    --text: #f6ebdd;
    --muted: #c4b29c;
    --accent: #f2b632;
    --accent-strong: #f5c85e;
    --on-accent: #1b1712;
    --tile: #4a3a22;
    --tile-empty: #2f271d;
    --good: #7cc47f;
    --bad: #ff8a80;
    --line: rgba(242, 182, 50, 0.8);
    --border: #4a3d2c;
    --shadow: 0 2px 10px rgba(0, 0, 0, 0.4);
    --petal: #f2c440;
    --petal-edge: #b98512;
    --stem: #6fa84f;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #1b1712;
  --surface: #2a231b;
  --surface-2: #332a1f;
  --text: #f6ebdd;
  --muted: #c4b29c;
  --accent: #f2b632;
  --accent-strong: #f5c85e;
  --on-accent: #1b1712;
  --tile: #4a3a22;
  --tile-empty: #2f271d;
  --good: #7cc47f;
  --bad: #ff8a80;
  --line: rgba(242, 182, 50, 0.8);
  --border: #4a3d2c;
  --shadow: 0 2px 10px rgba(0, 0, 0, 0.4);
  --petal: #f2c440;
  --petal-edge: #b98512;
  --stem: #6fa84f;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  line-height: 1.4;
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
}
#app {
  max-width: 520px;
  margin: 0 auto;
  min-height: 100dvh;
  padding: env(safe-area-inset-top) 16px env(safe-area-inset-bottom);
  display: flex;
  flex-direction: column;
}
a { color: var(--accent-strong); }
button { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--accent-strong); outline-offset: 2px; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
[hidden] { display: none !important; }

/* ---- buttons ---- */
.btn {
  appearance: none; border: 0; cursor: pointer;
  background: var(--accent); color: var(--on-accent);
  font-weight: 700; border-radius: 999px;
  padding: 10px 20px; min-height: 44px;
}
.btn:hover { filter: brightness(1.05); }
.btn--ghost { background: transparent; color: var(--text); box-shadow: inset 0 0 0 2px var(--border); }
.btn--sm { padding: 6px 16px; min-height: 40px; font-size: 0.95rem; }
.btn--lg { padding: 14px 28px; font-size: 1.1rem; width: 100%; }
.btn:disabled { opacity: 0.45; cursor: default; }
.chip {
  appearance: none; border: 0; cursor: pointer;
  background: var(--surface); box-shadow: var(--shadow);
  border-radius: 999px; padding: 6px 12px; min-height: 40px; min-width: 56px;
  font-weight: 700;
}
.chip:disabled { opacity: 0.5; cursor: default; }
.chip--static { cursor: default; display: inline-flex; align-items: center; justify-content: center; }

/* ---- home ---- */
.home__hdr { text-align: center; padding: 28px 0 12px; }
.home__logo { display: block; margin: 0 auto 8px; }
.home__title { margin: 0; font-size: 2rem; letter-spacing: -0.02em; }
.home__sub { margin: 4px 0 0; color: var(--muted); }
.home { flex: 1; }
.games { list-style: none; padding: 0; margin: 16px 0; display: grid; gap: 12px; }
.game-card {
  display: flex; align-items: center; gap: 14px;
  padding: 16px; border-radius: var(--radius);
  background: var(--surface); box-shadow: var(--shadow);
  color: var(--text); text-decoration: none;
}
.game-card:hover { transform: translateY(-1px); }
.game-card__icon {
  font-size: 2rem; width: 56px; height: 56px; flex: none;
  display: grid; place-items: center;
  background: var(--surface-2); border-radius: 12px;
}
.game-card__text { display: grid; gap: 2px; }
.game-card__title { font-weight: 800; font-size: 1.15rem; }
.game-card__blurb { color: var(--muted); font-size: 0.95rem; }
.privacy { margin: 20px 0; padding: 12px 16px; border-radius: var(--radius); background: var(--surface-2); }
.privacy summary { font-weight: 700; cursor: pointer; min-height: 32px; display: flex; align-items: center; }
.privacy p { color: var(--muted); margin: 8px 0 0; font-size: 0.95rem; }
.home__ftr { text-align: center; color: var(--muted); font-size: 0.9rem; padding: 16px 0 24px; }
.doc { padding: 16px 0 40px; }
.doc h1 { margin: 8px 0 4px; }
.doc h2 { font-size: 1.15rem; margin: 24px 0 6px; }
.doc__meta { color: var(--muted); margin-top: 0; }
.doc code { font-size: 0.9em; background: var(--surface-2); padding: 1px 4px; border-radius: 4px; overflow-wrap: anywhere; }
.loading { text-align: center; color: var(--muted); padding: 40px 0; }

/* ---- screen header ---- */
.screen { flex: 1; display: flex; flex-direction: column; }
.hdr {
  display: grid; grid-template-columns: 48px 1fr auto; align-items: center; gap: 8px;
  padding: 10px 0 6px;
}
.hdr__back {
  appearance: none; border: 0; background: var(--surface); box-shadow: var(--shadow);
  width: 44px; height: 44px; border-radius: 50%; font-size: 1.8rem; line-height: 1; cursor: pointer;
  padding-bottom: 4px;
}
.hdr__heading { margin: 0; font-size: 1.2rem; text-align: center; }

/* ---- promo ---- */
.promo-slot { margin-top: auto; padding: 10px 0 12px; min-height: 64px; }
.promo-strip {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 10px; border-radius: 12px;
  background: var(--surface-2); color: var(--text); text-decoration: none;
  opacity: 0.9;
}
.promo-strip:hover { opacity: 1; }
.promo-strip__img { width: 44px; height: 44px; object-fit: contain; border-radius: 8px; background: #fff; flex: none; }
.promo-strip__text { display: grid; min-width: 0; }
.promo-strip__label { font-size: 0.75rem; color: var(--muted); }
.promo-strip__name { font-size: 0.9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.done {
  flex: 1; display: flex; flex-direction: column; align-items: stretch; gap: 14px;
  padding: 20px 0 24px; text-align: center; animation: rise 0.35s ease-out;
}
.done__title { margin: 8px 0 0; font-size: 1.6rem; }
.done__sub { margin: 0; color: var(--muted); }
.promo-card {
  background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 14px; display: grid; gap: 6px; justify-items: center;
}
.promo-card__heading { margin: 0; font-size: 0.85rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }
.promo-card__img { width: 100%; max-width: 260px; aspect-ratio: 1; object-fit: contain; background: #fff; border-radius: 10px; }
.promo-card__name { margin: 0; font-weight: 700; }
.promo-card__price { margin: 0; color: var(--muted); }
.promo-card__link { text-decoration: none; display: inline-flex; align-items: center; }

@keyframes rise { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }

/* ---- word wheel ---- */
.wheel-screen { flex: 1; display: flex; flex-direction: column; gap: 6px; min-height: 0; }
.xw-wrap { flex: 1 1 200px; min-height: 150px; max-height: 42dvh; display: grid; place-items: center; }
.xw { display: grid; gap: 4px; }
.xw__row { display: grid; grid-template-columns: repeat(var(--cols), var(--cell)); gap: 4px; }
.xw__cell {
  width: var(--cell); height: var(--cell); border-radius: 6px;
  background: var(--tile-empty); display: grid; place-items: center;
  font-weight: 800; font-size: calc(var(--cell) * 0.55);
}
.xw__cell--empty { background: transparent; }
.xw__cell.is-shown { background: var(--accent); color: var(--on-accent); }
.xw__cell.is-pop { animation: pop 0.35s ease-out; }
@keyframes pop { 50% { transform: scale(1.18); } }

.wheel-current {
  height: 40px; display: grid; place-items: center;
  font-size: 1.5rem; font-weight: 800; letter-spacing: 0.08em;
}
.wheel-current.is-bad { color: var(--bad); font-size: 1rem; letter-spacing: 0; animation: shake 0.35s; }
.wheel-current.is-good { color: var(--good); }
.wheel-current.is-bonus { color: var(--accent-strong); font-size: 1rem; letter-spacing: 0; }
.wheel-current.is-same { color: var(--muted); font-size: 1rem; letter-spacing: 0; }
@keyframes shake { 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }

.wheel-row { display: grid; grid-template-columns: 52px 1fr 52px; align-items: end; gap: 4px; }
.wheel {
  position: relative; width: min(100%, 290px); aspect-ratio: 1; justify-self: center;
  border-radius: 50%; background: var(--surface); box-shadow: var(--shadow);
  touch-action: none; user-select: none; -webkit-user-select: none;
}
.wheel__lines { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.wheel__lines polyline { fill: none; stroke: var(--line); stroke-width: 10; stroke-linecap: round; stroke-linejoin: round; }
.wheel__letters { position: absolute; inset: 0; }
.wheel__letter {
  position: absolute; appearance: none; border: 0; cursor: pointer;
  border-radius: 50%; background: transparent;
  font-size: 1.7rem; font-weight: 800; color: var(--text);
  display: grid; place-items: center; touch-action: none;
}
.wheel__letter.is-on { background: var(--accent); color: var(--on-accent); }
.wheel__shuffle {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: 44px; height: 44px; border-radius: 50%; border: 0; cursor: pointer;
  background: var(--surface-2); font-size: 1.4rem; color: var(--muted);
}
.wheel-tapbar { display: flex; justify-content: center; gap: 12px; }
.wheel-row__spacer { display: block; }

.jar {
  appearance: none; border: 0; background: none; cursor: pointer; padding: 0;
  display: grid; justify-items: center; gap: 2px; min-height: 44px;
}
.jar__pot {
  position: relative; width: 34px; height: 40px; border-radius: 8px 8px 12px 12px;
  box-shadow: inset 0 0 0 2px var(--accent); overflow: hidden; background: var(--surface);
}
.jar__fill { position: absolute; left: 0; right: 0; bottom: 0; background: var(--accent); transition: height 0.3s; }
.jar__label { font-size: 0.8rem; font-weight: 700; color: var(--muted); }
.bonus-list {
  font-size: 0.9rem; color: var(--muted); text-align: center;
  background: var(--surface-2); border-radius: 12px; padding: 8px 12px;
}

/* ---- petals ---- */
.petals-screen { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.petals__category {
  margin: 0; display: grid; justify-items: center; gap: 0;
  background: var(--surface-2); border-radius: 14px; padding: 4px 18px 6px;
  box-shadow: inset 0 0 0 2px var(--border);
}
.petals__category-label { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }
.petals__category-name { font-size: 1.2rem; font-weight: 800; color: var(--accent-strong); }
.petals__clue { margin: 0; text-align: center; color: var(--text); font-style: italic; max-width: 32ch; }

.modes { flex: 1; display: flex; flex-direction: column; gap: 12px; padding: 12px 0 24px; }
.modes__title { margin: 4px 0; font-size: 1.3rem; text-align: center; }
.mode-card {
  appearance: none; border: 0; cursor: pointer; text-align: left;
  display: grid; gap: 2px; padding: 16px; border-radius: var(--radius);
  background: var(--surface); box-shadow: var(--shadow);
}
.mode-card.is-last { box-shadow: var(--shadow), inset 0 0 0 3px var(--accent); }
.mode-card__label { font-weight: 800; font-size: 1.2rem; }
.mode-card__blurb { color: var(--muted); }
.mode-card__stats { font-size: 0.85rem; color: var(--accent-strong); margin-top: 4px; }
.petals__flower { width: min(46vw, 170px); }
.flower { display: block; width: 100%; height: auto; overflow: visible; }
.flower__stem { fill: none; stroke: var(--stem); stroke-width: 6; stroke-linecap: round; }
.flower__leaf { fill: var(--stem); }
.flower__petal { fill: var(--petal); stroke: var(--petal-edge); stroke-width: 2; transform-box: fill-box; transform-origin: 50% 100%; }
.flower__center { fill: #8a5a17; }
.flower__petal.is-falling { animation: fall 1.1s ease-in forwards; }
.flower__petal.is-fallen { opacity: 0; }
@keyframes fall {
  0% { transform: rotate(0); opacity: 1; }
  30% { transform: translate(6px, 10px) rotate(25deg); opacity: 1; }
  100% { transform: translate(-10px, 150px) rotate(80deg); opacity: 0; }
}
.flower.is-happy { animation: bounce 0.8s ease-in-out 2; }
.flower.is-sad .flower__center { fill: #6b5747; }
@keyframes bounce { 50% { transform: translateY(-8px) rotate(-4deg); } }
.petals__left { margin: 0; color: var(--muted); font-size: 0.9rem; }
.petals__word { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 16px; padding: 6px 0; }
.petals__part { display: flex; gap: 4px; }
.petals__slot {
  width: 26px; height: 34px; border-bottom: 3px solid var(--muted);
  display: grid; place-items: center; font-weight: 800; font-size: 1.35rem;
}
.petals__slot.is-shown { border-color: var(--accent); }
.petals__slot.is-missed { color: var(--bad); }
.kb { display: grid; gap: 6px; width: 100%; margin-top: 4px; }
.kb__row { display: flex; justify-content: center; gap: 4px; }
.kb__key {
  appearance: none; border: 0; cursor: pointer;
  flex: 0 1 34px; min-width: 0; height: 46px; border-radius: 8px;
  background: var(--surface); box-shadow: var(--shadow); font-weight: 700; font-size: 1.05rem;
}
.kb__key.is-hit { background: var(--accent); color: var(--on-accent); }
.kb__key.is-miss { background: var(--tile-empty); color: var(--muted); text-decoration: line-through; }
.kb__key:disabled { cursor: default; }
.kb__key:disabled:not(.is-hit):not(.is-miss) { opacity: 0.5; }
.petals__actions { padding-top: 4px; }

/* ---- trio ---- */
.trio-screen { flex: 1; display: flex; flex-direction: column; min-height: 0; position: relative; }
.trio-board {
  position: relative; flex: 1 1 320px; min-height: 260px; margin: 4px 0 10px;
  border-radius: 22px; background: radial-gradient(circle at 50% 45%, var(--surface) 0%, var(--surface-2) 75%);
  box-shadow: inset 0 0 0 2px var(--border);
  touch-action: manipulation; user-select: none; -webkit-user-select: none;
}
.trio-tok {
  position: absolute; width: var(--tok, 60px); height: var(--tok, 60px);
  appearance: none; padding: 0; border: 3px solid #fff; border-radius: 50%;
  background: #fff; overflow: hidden; cursor: pointer;
  transform: rotate(var(--rot, 0deg));
  box-shadow: 0 4px 10px rgba(60, 35, 5, 0.35);
  filter: brightness(calc(1 - var(--cover, 0) * 0.14));
  transition: filter 0.25s;
}
.trio-tok img { display: block; width: 100%; height: 100%; object-fit: cover; pointer-events: none; -webkit-user-drag: none; }
.trio-tok__alt { display: none; }
.trio-tok.is-noimg { background: hsl(var(--hue, 40) 65% 45%); }
.trio-tok.is-noimg .trio-tok__alt {
  display: grid; place-items: center; height: 100%;
  color: #fff; font-weight: 800; font-size: calc(var(--tok, 60px) * 0.34);
}
.trio-tok.is-queued { transform: rotate(var(--rot, 0deg)) scale(0.9); }
.trio-board.is-shuffling .trio-tok { transition: left 0.4s ease, top 0.4s ease, transform 0.4s ease, filter 0.25s; }

.trio-tray {
  display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px;
  padding: 6px; border-radius: 18px; background: var(--accent);
  box-shadow: inset 0 -4px 0 rgba(0, 0, 0, 0.14), var(--shadow);
  transition: box-shadow 0.3s;
}
.trio-tray.is-warn { box-shadow: inset 0 -4px 0 rgba(0, 0, 0, 0.14), 0 0 0 3px var(--bad); }
.trio-tray__slot { aspect-ratio: 1; border-radius: 50%; background: rgba(255, 255, 255, 0.4); display: grid; }
.trio-tray .trio-tok { position: static; width: 100%; height: 100%; border-width: 2px; transform: none; filter: none; cursor: default; }
.trio-tray .trio-tok.is-noimg .trio-tok__alt, .trio-fx .trio-tok.is-noimg .trio-tok__alt { font-size: 0.8rem; }
.trio-fx { position: fixed; inset: 0; pointer-events: none; z-index: 600; }
.trio-fx .trio-tok { position: fixed; transform: none; filter: none; }

.trio-powers { display: flex; justify-content: center; gap: 10px; padding-top: 12px; }
.trio-power {
  appearance: none; border: 0; cursor: pointer; position: relative;
  display: inline-flex; align-items: center; gap: 6px;
  min-height: 48px; padding: 6px 14px; border-radius: 14px;
  background: var(--surface); box-shadow: var(--shadow); font-weight: 700;
}
.trio-power:disabled { opacity: 0.45; cursor: default; }
.trio-power__icon { font-size: 1.25rem; line-height: 1; }
.trio-power__count {
  position: absolute; top: -7px; right: -7px; min-width: 22px; height: 22px; padding: 0 5px;
  display: grid; place-items: center; border-radius: 999px;
  background: var(--accent); color: var(--on-accent); font-size: 0.78rem; font-weight: 800;
}
@media (max-width: 380px) {
  .trio-powers { gap: 8px; }
  .trio-power { padding: 6px 10px; font-size: 0.9rem; }
}

.trio-over {
  position: absolute; inset: 0; z-index: 500; border-radius: 22px;
  display: flex; flex-direction: column; justify-content: center; align-items: stretch; gap: 12px;
  padding: 24px; text-align: center; animation: rise 0.3s ease-out;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
}
.trio-lineup { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; }
.trio-lineup img { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; border: 2px solid #fff; box-shadow: var(--shadow); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition: none !important; }
}
