@import url("https://fonts.googleapis.com/css2?family=Geist:wght@300;400;500;600;700&display=swap");

/* Wishbone: a turkey furcula on a plaid napkin. The bone, napkin, table, pieces and leaves are all drawn on
   one canvas (#scene); the DOM carries the wish card, the result lines and the buttons. */
:root {
  --font: "Geist", system-ui, -apple-system, sans-serif;
  --ink: #f7ead3;
  --ink-dim: rgba(247, 234, 211, 0.6);
  --mustard: #e9ae3c;
  --panel: rgba(38, 16, 9, 0.86);
  --line: rgba(255, 213, 158, 0.2);
  --ring: rgba(255, 207, 120, 0.95);
  --safe-t: max(12px, env(safe-area-inset-top));
  --safe-b: max(14px, env(safe-area-inset-bottom));
}
*,*::before,*::after { box-sizing: border-box; }
html, body { -webkit-tap-highlight-color: transparent; height: 100%; margin: 0; overflow: hidden; overscroll-behavior: none; }
body { font-family: var(--font); background: #2a120a; color: var(--ink); touch-action: none; }
#probe { position: fixed; left: 0; top: 0; width: 0; height: 0; visibility: hidden; padding-top: env(safe-area-inset-top); padding-bottom: env(safe-area-inset-bottom); pointer-events: none; }

canvas#scene {
  display: block; position: fixed; inset: 0; width: 100%; height: 100%; touch-action: none; z-index: 0;
  -webkit-touch-callout: none; -webkit-user-select: none; user-select: none;
}
body.m-ready canvas#scene { cursor: grab; }

/* ---- the wish card ---- */
.card {
  position: fixed; z-index: 14; left: 50%; transform: translateX(-50%); top: calc(var(--safe-t) + 44px);
  width: min(380px, calc(100vw - 24px)); padding: 18px 18px 16px; margin: 0; border-radius: 18px; text-align: center;
  background: var(--panel); border: 1px solid var(--line); box-shadow: 0 22px 54px rgba(0, 0, 0, 0.55), 0 1px 0 rgba(255, 255, 255, 0.06) inset;
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
}
body:not(.m-wish) .card { display: none; }
.card__kicker { margin: 0; font-size: 0.6rem; font-weight: 600; letter-spacing: 0.2em; text-transform: uppercase; color: var(--mustard); }
.card__title { margin: 4px 0 4px; font-size: 1.7rem; font-weight: 700; letter-spacing: -0.02em; line-height: 1.1; }
.card__sub { margin: 0 0 14px; font-size: 0.8rem; line-height: 1.45; color: var(--ink-dim); }
.card__fields { display: grid; gap: 10px; margin-bottom: 14px; }
.field { display: grid; gap: 5px; text-align: left; }
.field__lbl { font-size: 0.6rem; font-weight: 600; letter-spacing: 0.16em; text-transform: uppercase; color: var(--ink-dim); }
.inp { position: relative; display: block; }
.inp input {
  width: 100%; height: 42px; padding: 0 44px 0 14px; border-radius: 12px; font-family: var(--font); font-size: 16px; font-weight: 500;
  color: var(--ink); background: rgba(0, 0, 0, 0.32); border: 1px solid var(--line); outline: none; user-select: text; -webkit-user-select: text;
}
.inp input::placeholder { color: rgba(247, 234, 211, 0.34); }
.inp input:focus-visible { border-color: var(--ring); box-shadow: 0 0 0 2px rgba(255, 207, 120, 0.28); }
.inp input.masked { -webkit-text-security: disc; text-security: disc; letter-spacing: 0.08em; }
.peek { appearance: none; position: absolute; right: 3px; top: 3px; width: 36px; height: 36px; border: 0; border-radius: 9px; padding: 0; cursor: pointer; color: var(--ink-dim); background: transparent; display: grid; place-items: center; touch-action: manipulation; }
.peek[aria-pressed="true"] { color: var(--mustard); }
.peek:focus-visible { outline: 2px dashed var(--ring); outline-offset: 1px; }
.card__btns { display: flex; justify-content: center; gap: 10px; }

.icobtn, .pill, .dock .opt-share.opt-share {
  appearance: none; cursor: pointer; font-family: var(--font); margin: 0;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 40px; padding: 0 16px;
  border-radius: 999px; font-size: 0.8rem; font-weight: 600; letter-spacing: 0.01em; opacity: 1; white-space: nowrap;
  color: var(--ink); background: var(--panel); border: 1px solid var(--line);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.06) inset, 0 6px 16px rgba(0, 0, 0, 0.45);
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
  transition: transform .12s ease, background .15s ease, border-color .15s ease; touch-action: manipulation; text-decoration: none;
}
.pill:hover, .dock .opt-share.opt-share:hover { background: rgba(70, 30, 16, 0.94); border-color: rgba(255, 213, 158, 0.4); text-decoration: none; }
.pill:active, .dock .opt-share.opt-share:active { transform: scale(0.96); }
.pill:focus-visible, .dock .opt-share.opt-share:focus-visible { outline: 2px dashed var(--ring); outline-offset: 2px; }
.pill svg, .dock .opt-share.opt-share svg { width: 17px; height: 17px; flex: none; }
.pill--go {
  background: linear-gradient(180deg, #f6cb66, #dc8d2c); color: #2a1206; border-color: rgba(255, 240, 200, 0.65);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.6) inset, 0 8px 20px rgba(220, 140, 40, 0.3);
}
.pill--go:hover { background: linear-gradient(180deg, #ffd777, #e79b3a); border-color: #fff3d6; }
.share-host { display: inline-flex; }
.share-host:empty { display: none; }
.dock .opt-share.opt-share { padding: 0 15px 0 13px; font-size: 0.8rem; }

/* ---- the result lines ---- */
.result {
  position: fixed; z-index: 9; left: 50%; transform: translateX(-50%); top: calc(var(--safe-t) + 40px); width: min(92vw, 560px);
  text-align: center; pointer-events: none; transition: opacity .45s ease;
  text-shadow: 0 2px 18px rgba(20, 5, 0, 0.95), 0 0 4px rgba(20, 5, 0, 0.8);
}
.result[hidden] { display: none; }
.result.is-in { opacity: 1; }
.result:not(.is-in) { opacity: 0; }
.result p { margin: 0; }
.result__who { font-size: 0.64rem; font-weight: 700; letter-spacing: 0.22em; text-transform: uppercase; color: var(--mustard); }
.result__title { font-size: clamp(1.7rem, 7.4vw, 2.7rem); font-weight: 700; letter-spacing: -0.025em; line-height: 1.08; margin-top: 3px !important; color: #fff3da; }
.result__wish { margin-top: 6px !important; font-size: clamp(0.95rem, 3.6vw, 1.2rem); font-weight: 500; color: #ffd9a0; overflow-wrap: anywhere; }
.result__wish:empty { display: none; }

/* ---- the bottom dock ---- */
.dock {
  position: fixed; z-index: 8; left: 50%; transform: translateX(-50%);
  bottom: calc(var(--safe-b) + 44px); width: max-content; max-width: calc(100vw - 20px);
  display: flex; flex-direction: column; align-items: center; gap: 8px;
}
.dock__done { display: none; align-items: center; justify-content: center; flex-wrap: wrap; gap: 8px; }
body.m-done .dock__done { display: flex; }
body.m-wish .dock, body.m-wish .tally { display: none; }
body.m-done .hint, body.m-snap .hint { display: none; }
body.m-snap .dock { pointer-events: none; }
.tally {
  margin: 0; padding: 5px 13px; border-radius: 999px; font-size: 0.64rem; font-weight: 600; letter-spacing: 0.16em; text-transform: uppercase; color: var(--ink);
  background: rgba(38, 16, 9, 0.72); border: 1px solid var(--line); white-space: nowrap;
}
.tally[hidden] { display: none; }
.tally b { color: var(--mustard); font-weight: 700; margin-left: 2px; }
.hint {
  margin: 0; max-width: min(90vw, 520px); text-align: center; pointer-events: none; min-height: 1.6em;
  font-size: 0.64rem; font-weight: 600; letter-spacing: 0.14em; text-transform: uppercase; line-height: 1.6;
  color: rgba(247, 234, 211, 0.86); text-shadow: 0 0 10px rgba(20, 5, 0, 1), 0 0 3px rgba(20, 5, 0, 0.9), 0 1px 14px rgba(20, 5, 0, 0.95); transition: opacity .6s;
}
.hint.is-hidden { opacity: 0; }

.sound-btn {
  appearance: none; position: fixed; z-index: 12; cursor: pointer; padding: 0;
  top: var(--safe-t); right: max(12px, env(safe-area-inset-right));
  width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center;
  color: var(--ink); background: var(--panel); border: 1px solid var(--line);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.45); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
  transition: transform 0.12s ease, opacity 0.15s ease;
}
.sound-btn:active { transform: scale(0.94); }
.sound-btn[aria-pressed="false"] { opacity: 0.55; }
.sound-btn[aria-pressed="false"] .sound-btn__wave { opacity: 0; }
.sound-btn:focus-visible { outline: 2px dashed var(--ring); outline-offset: 3px; }

.frame { position: fixed; inset: 0; pointer-events: none; z-index: 10; }
.frame__corner {
  position: absolute; font-size: clamp(0.58rem, 1.2vw, 0.7rem); font-weight: 600; letter-spacing: 0.22em; text-transform: uppercase;
  color: rgba(247, 234, 211, 0.55); white-space: nowrap; font-family: var(--font); text-shadow: 0 1px 6px rgba(20, 5, 0, 0.9);
}
.frame__corner--tl { top: calc(var(--safe-t) + 13px); left: max(18px, env(safe-area-inset-left)); }
.frame__corner--tr { top: calc(var(--safe-t) + 13px); right: calc(max(12px, env(safe-area-inset-right)) + 54px); }
.frame__corner--bl { bottom: max(18px, env(safe-area-inset-bottom)); left: max(18px, env(safe-area-inset-left)); }
.frame__corner a { color: inherit; text-decoration: none; pointer-events: auto; border-bottom: 1px solid transparent; transition: color .14s, border-color .14s; }
.frame__corner a:hover { color: #ffe2a8; border-bottom-color: rgba(255, 226, 168, 0.5); }

/* the shared tip-jar and fullscreen badges sit side by side in the bottom-right corner */
.opt-tipjar.opt-tipjar { top: auto; bottom: max(14px, env(safe-area-inset-bottom)); transform: none; }
.opt-fs.opt-fs { top: auto; bottom: max(14px, env(safe-area-inset-bottom)); right: calc(max(14px, env(safe-area-inset-right)) + 54px); transform: none; }
.opt-tipjar.opt-tipjar.tj-nudge { animation: none; }

@media (max-width: 560px) and (orientation: portrait) { .dock { bottom: calc(var(--safe-b) + 84px); } }
@media (max-width: 560px) {
  .pill .lbl { display: none; }
  .pill#wishesBtn, .pill#cardBtn { width: 40px; padding: 0; }
}
@media (max-height: 520px) and (orientation: landscape) {
  .card { top: calc(var(--safe-t) + 30px); width: min(640px, calc(100vw - 24px)); padding: 12px 16px 12px; }
  .card__title { font-size: 1.25rem; margin: 2px 0 2px; }
  .card__sub { margin-bottom: 8px; font-size: 0.72rem; }
  .card__fields { grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 8px; }
  .inp input { height: 38px; }
  .peek { height: 32px; }
  .result { top: calc(var(--safe-t) + 26px); }
  .result__title { font-size: 1.35rem; margin-top: 0 !important; }
  .result__wish { margin-top: 2px !important; font-size: 0.85rem; }
  .dock { bottom: calc(var(--safe-b) + 34px); gap: 5px; }
  .pill, .dock .opt-share.opt-share { height: 36px; }
}
@media (prefers-reduced-motion: reduce) {
  .pill, .sound-btn, .hint, .result { transition: none; }
}
