/* Hallmark · shape: app screen · scope: app · genre: atmospheric · theme: custom
 * page: /krathong · surface: a moonlit river stage · type: Chonburi + Sarabun
 * night: ink sky, moon gold, jade water · controls: 44px · contrast: pass
 * states: idle, hover, focus, pressed, selected, disabled, low, paused · v3.0.0 */
/* critique: the stage is a moonlit window floating in ink; keep the wall dark and quiet so the gold action leads each screen. */
:root {
  --k-night: oklch(11% 0.04 255);
  --k-night-deep: oklch(7% 0.03 260);
  --k-ink: oklch(96% 0.015 86);
  --k-ink-2: oklch(86% 0.018 86);
  --k-ink-3: oklch(72% 0.02 86);
  --k-moon: oklch(84% 0.12 84);
  --k-moon-bright: oklch(93% 0.075 88);
  --k-moon-pale: oklch(97% 0.03 90);
  --k-amber-ink: oklch(24% 0.06 72);
  --k-jade: oklch(78% 0.1 165);
  --k-coral: oklch(66% 0.19 30);
  --k-flame: oklch(80% 0.17 58);
  --k-flame-core: oklch(97% 0.05 95);
  --k-leaf: oklch(32% 0.06 150);
  --k-line: color-mix(in oklab, var(--k-moon) 22%, transparent);
  --k-line-soft: color-mix(in oklab, var(--k-moon) 12%, transparent);
  --k-line-strong: color-mix(in oklab, var(--k-moon) 64%, transparent);
  --k-surface: color-mix(in oklab, var(--k-night) 92%, transparent);
  --k-surface-2: color-mix(in oklab, var(--k-ink) 7%, transparent);
  --k-surface-3: color-mix(in oklab, var(--k-ink) 12%, transparent);
  --k-scrim: color-mix(in oklab, var(--k-night-deep) 74%, transparent);
  --k-glow: color-mix(in oklab, var(--k-moon) 30%, transparent);
  --k-stage-rim: color-mix(in oklab, var(--k-moon) 26%, transparent);
  --k-stage-halo: color-mix(in oklab, var(--k-moon) 7%, transparent);
  --k-stage-shadow: color-mix(in oklab, var(--k-night-deep) 78%, transparent);
  --k-text-shadow: color-mix(in oklab, var(--k-night-deep) 62%, transparent);
  --k-page-glow: oklch(38% 0.06 255 / 0.55);
  --k-page-glow-2: oklch(28% 0.05 30 / 0.45);
  --k-focus: var(--k-moon-bright);
  --k-danger-soft: color-mix(in oklab, var(--k-coral) 58%, transparent);
  --k-glass: color-mix(in oklab, var(--k-night) 78%, transparent);
}

.k-page {
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(1100px 620px at 86% -12%, var(--k-page-glow), transparent 62%),
    radial-gradient(900px 620px at 6% 112%, var(--k-page-glow-2), transparent 60%),
    var(--k-night-deep);
  color: var(--k-ink);
}

.k-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-md);
  padding-block: var(--space-sm);
}

.k-brand {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  text-decoration: none;
  color: var(--k-ink);
}
.k-brand-mark { width: 32px; height: 32px; color: var(--k-moon); flex: none; }
.k-brand strong { display: block; font-family: var(--font-display); font-size: 1.05rem; line-height: 1.2; color: var(--k-moon-pale); }
.k-brand small { display: block; color: var(--k-ink-3); font-size: 0.72rem; line-height: 1.3; }

.k-nav { display: flex; align-items: center; gap: var(--space-xs); }
.k-nav-link {
  font-size: var(--text-sm);
  color: var(--k-ink-2);
  text-decoration: none;
  padding: var(--space-xs) var(--space-sm);
  border-radius: var(--radius-pill);
}
.k-nav-link:hover { color: var(--k-moon); }

.k-sound {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  min-height: 44px;
  border: 1px solid var(--k-line);
  background: var(--k-glass);
  color: var(--k-ink);
  border-radius: var(--radius-pill);
  padding: var(--space-2xs) var(--space-sm);
  font-size: var(--text-sm);
  backdrop-filter: blur(10px);
}
.k-sound-icon { width: 18px; height: 18px; flex: none; }
.k-sound[aria-pressed="false"] .k-sound-wave { opacity: 0; }
.k-sound[aria-pressed="false"] { color: var(--k-ink-3); }

.k-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-xs);
  padding: var(--space-3xs) var(--space-md) var(--space-md);
}

.k-stage {
  position: relative;
  width: min(100%, calc((100svh - 120px) * 9 / 16), 640px);
  aspect-ratio: 9 / 16;
  border: 1px solid transparent;
  border-radius: 28px;
  overflow: hidden;
  background: var(--k-night-deep);
  box-shadow:
    0 0 0 1px var(--k-stage-rim),
    0 0 0 8px var(--k-stage-halo),
    0 60px 120px -50px var(--k-stage-shadow);
  container-type: size;
  isolation: isolate;
  -webkit-tap-highlight-color: transparent;
}

#scene {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

.k-ui {
  position: absolute;
  inset: 0;
  z-index: 2;
  color: var(--k-ink);
  font-size: clamp(16px, 4.4cqw, 20px);
  line-height: 1.5;
  pointer-events: none;
}

.k-ui .k-panel,
.k-ui .k-btn,
.k-ui .k-opt,
.k-ui .k-chip,
.k-ui .k-tab,
.k-ui .k-icon-btn,
.k-ui .k-textarea,
.k-ui .k-label { pointer-events: auto; }

.k-ui ::selection { background: var(--k-glow); color: var(--k-moon-pale); }
.k-ui :focus-visible { outline: 2px solid var(--k-focus); outline-offset: 3px; }

.k-screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

/* ---------- หน้าแรก ---------- */
.k-intro { justify-content: flex-end; }
.k-intro-panel {
  padding: 14cqw 6cqw calc(6cqw + env(safe-area-inset-bottom));
  border: 0;
  background: linear-gradient(
    to top,
    var(--k-night) 0%,
    color-mix(in oklab, var(--k-night) 92%, transparent) 52%,
    transparent 100%
  );
  box-shadow: none;
}

.k-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(44px, 17cqw, 104px);
  line-height: 1;
  color: var(--k-moon-pale);
  text-shadow: 0 14px 48px var(--k-text-shadow);
  text-wrap: balance;
}

.k-lead {
  margin: 0.7em 0 0;
  font-size: 0.86em;
  color: var(--k-ink-2);
  max-width: 30em;
  line-height: 1.5;
}

.k-hint { margin: 1.1em 0 0; font-size: 0.68em; color: var(--k-ink-3); line-height: 1.5; }

.k-facts {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 2.4cqw;
  margin: 3.6cqw 0 0;
  padding-top: 3cqw;
  border-top: 1px solid var(--k-line-soft);
}
.k-facts div { display: flex; flex-direction: column; gap: var(--space-3xs); }
.k-facts dt {
  font-family: var(--font-display);
  font-size: 2.1em;
  line-height: 1;
  color: var(--k-moon);
  font-variant-numeric: tabular-nums;
}
.k-facts dd { margin: 0; font-size: 0.68em; color: var(--k-ink-3); }

.k-intro .k-actions { margin-top: 3.2cqw; }
.k-intro .k-actions .k-btn { flex: 1; }

/* ---------- ปุ่ม ---------- */
.k-actions { display: flex; align-items: center; gap: 2.2cqw; margin-top: 0.8cqw; }
.k-actions .k-btn { flex: 1; }
.k-actions-stack { flex-direction: column; align-items: stretch; }
.k-actions-stack .k-btn { width: 100%; }

.k-btn {
  min-height: 48px;
  border: 0;
  border-radius: var(--radius-pill);
  padding: 2.6cqw 4.4cqw;
  font-family: var(--font-body);
  font-size: 0.9em;
  font-weight: 700;
  line-height: 1.2;
  text-align: center;
  transition: transform var(--dur-micro) ease, filter var(--dur-micro) ease, background-color var(--dur-micro) ease;
}
.k-btn:active { transform: scale(0.985); }
.k-btn:disabled { opacity: 0.45; cursor: not-allowed; }
.k-btn:disabled:hover { filter: none; }

.k-btn-primary {
  background: linear-gradient(180deg, var(--k-moon-bright), var(--k-moon));
  color: var(--k-amber-ink);
  box-shadow: 0 14px 34px -16px var(--k-glow), inset 0 1px 0 var(--k-moon-pale);
}
.k-btn-quiet {
  background: var(--k-glass);
  color: var(--k-ink);
  border: 1px solid var(--k-line);
  backdrop-filter: blur(8px);
}
.k-btn-text {
  background: transparent;
  color: var(--k-ink-3);
  text-decoration: underline;
  text-underline-offset: 0.2em;
  font-weight: 400;
  font-size: 0.74em;
  padding: 0.6cqw 1cqw;
  min-height: 36px;
}

/* ---------- ฟอร์มแต่งกระทง / อธิษฐาน ---------- */
.k-craft,
.k-wish { justify-content: flex-end; padding: 3cqw; }

.k-sheet {
  flex: 0 1 auto;
  max-height: 86%;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: none;
  border-radius: 5cqw 5cqw 0 0;
  padding: 4cqw 4.4cqw calc(4cqw + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 2.6cqw;
  background: linear-gradient(180deg, var(--k-glass), var(--k-surface));
  border: 1px solid var(--k-line);
  border-bottom: 0;
  backdrop-filter: blur(14px);
}
.k-sheet::-webkit-scrollbar { display: none; }

.k-sheet-head { display: flex; flex-direction: column; gap: 0.25em; }
.k-craft-head { flex-direction: row; align-items: center; gap: 2.6cqw; }
.k-craft-head-text { display: flex; flex-direction: column; gap: 0.35em; min-width: 0; }
.k-title-row { display: flex; align-items: baseline; justify-content: space-between; gap: 2cqw; }
.k-sheet-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.5em;
  line-height: 1.1;
  color: var(--k-moon-pale);
  text-wrap: balance;
}
.k-step {
  flex: none;
  font-size: 0.66em;
  color: var(--k-ink-3);
  font-variant-numeric: tabular-nums;
}

.k-sub { margin: 0; font-size: 0.78em; color: var(--k-ink-3); line-height: 1.5; }

.k-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  border-top: 1px solid var(--k-line-soft);
  border-bottom: 1px solid var(--k-line-soft);
  background: transparent;
  overflow: hidden;
}
.k-stat { padding: 1.6cqw 1.8cqw; }
.k-stat + .k-stat { border-left: 1px solid var(--k-line-soft); }
.k-stat span { display: block; font-size: 0.64em; color: var(--k-ink-3); margin-bottom: 0.2em; }
.k-stat b { font-size: 1.2em; color: var(--k-moon-bright); font-variant-numeric: tabular-nums; }
.k-stat-note {
  grid-column: 1 / -1;
  margin: 0;
  padding: 1.2cqw 1.8cqw 0;
  font-size: 0.64em;
  color: var(--k-ink-3);
  line-height: 1.4;
}

.k-tabs {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--space-2xs);
  padding: var(--space-2xs);
  border: 1px solid var(--k-line-soft);
  border-radius: 3cqw;
  background: var(--k-surface-2);
}
.k-tab {
  min-height: 44px;
  padding: 0 1.2cqw;
  border: 0;
  border-radius: 2.4cqw;
  background: transparent;
  color: var(--k-ink-3);
  font-size: 0.78em;
  line-height: 1.2;
}
.k-tab[aria-selected="true"] {
  background: var(--k-surface-3);
  color: var(--k-ink);
  box-shadow: inset 0 -2px 0 var(--k-moon);
}
.k-tab-count { color: var(--k-moon); font-variant-numeric: tabular-nums; }

.k-panes { flex: 1 1 auto; display: flex; flex-direction: column; min-height: 0; }
.k-group { border: 0; margin: 0; padding: 0; min-height: 0; }
.k-group[hidden] { display: none; }
.k-pane { display: flex; flex-direction: column; gap: 1.6cqw; }
.k-pane-note { margin: 0; font-size: 0.64em; color: var(--k-ink-3); }

.k-options { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1.6cqw; }

.k-opt {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 1.8cqw;
  min-height: 54px;
  padding: 1.8cqw 2cqw;
  border-radius: 2.4cqw;
  border: 1px solid var(--k-line-soft);
  background: var(--k-surface-2);
  color: inherit;
  text-align: left;
  transition: border-color var(--dur-micro) ease, background-color var(--dur-micro) ease, transform var(--dur-micro) ease;
}
.k-opt:active { transform: scale(0.985); }
.k-opt[aria-pressed="true"] {
  border-color: var(--k-line-strong);
  background: var(--k-glow);
  box-shadow: inset 0 0 0 1px var(--k-line);
}
.k-opt[aria-pressed="true"]::after {
  content: "✓";
  position: absolute;
  top: 1.2cqw;
  right: 1.6cqw;
  font-size: 0.62em;
  font-weight: 700;
  color: var(--k-moon-bright);
}
.k-opt:disabled { opacity: 0.4; cursor: not-allowed; }

.k-opt-dot {
  flex: none;
  width: 10px;
  height: 10px;
  margin-top: 0.45em;
  border-radius: 50%;
  background: var(--dot, var(--k-moon));
  box-shadow: 0 0 0 3px var(--k-surface-3);
}
.k-opt-body { display: flex; flex-direction: column; min-width: 0; gap: 0.1em; }
.k-opt-label { font-size: 0.84em; font-weight: 600; line-height: 1.3; }
.k-opt-hint { font-size: 0.66em; color: var(--k-ink-3); line-height: 1.35; }
.k-opt-stats {
  display: flex;
  flex-wrap: wrap;
  font-size: 0.62em;
  color: var(--k-ink-3);
  font-variant-numeric: tabular-nums;
  line-height: 1.4;
}
.k-opt-stats span + span {
  margin-left: 1cqw;
  padding-left: 1.2cqw;
  border-left: 1px solid var(--k-line-soft);
}

.k-label { font-size: 0.74em; color: var(--k-ink-2); }
.k-textarea {
  width: 100%;
  min-height: 24cqw;
  padding: 2.4cqw 2.8cqw;
  border-radius: 3cqw;
  border: 1px solid var(--k-line);
  background: color-mix(in oklab, var(--k-night-deep) 70%, transparent);
  color: var(--k-ink);
  font-family: var(--font-body);
  font-size: 0.92em;
  line-height: 1.5;
  resize: vertical;
}
.k-textarea::placeholder { color: var(--k-ink-3); }
.k-count { margin: 0; text-align: right; font-size: 0.64em; color: var(--k-ink-3); font-variant-numeric: tabular-nums; }

.k-chips { display: flex; flex-wrap: wrap; gap: 1.6cqw; }
.k-chip {
  min-height: 44px;
  border: 1px solid var(--k-line);
  background: var(--k-surface-2);
  color: var(--k-ink-2);
  border-radius: var(--radius-pill);
  padding: 1.2cqw 2.4cqw;
  font-size: 0.68em;
}
.k-wish-sheet .k-actions { margin-top: auto; }

/* ---------- HUD ระหว่างลอย ---------- */
.k-float { pointer-events: none; }
.k-hud {
  position: absolute;
  top: 3.2cqw;
  left: 4cqw;
  right: 4cqw;
  display: flex;
  flex-direction: column;
  gap: 1.6cqw;
}
.k-hud-row {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: start;
  gap: 2cqw;
}
.k-merit {
  justify-self: start;
  padding: 1.2cqw 2.4cqw;
  border-radius: 2.8cqw;
  background: var(--k-glass);
  border: 1px solid var(--k-line-soft);
  backdrop-filter: blur(8px);
}
.k-merit span { display: block; font-size: 0.62em; color: var(--k-ink-3); margin-bottom: 0.15em; }
.k-merit strong {
  display: block;
  font-family: var(--font-display);
  font-size: 2.2em;
  line-height: 1;
  color: var(--k-moon);
  font-variant-numeric: tabular-nums;
  text-shadow: 0 0 18px var(--k-glow);
}
.k-timer {
  justify-self: center;
  padding: 1.6cqw 2.6cqw;
  border-radius: 2.6cqw;
  background: var(--k-glass);
  border: 1px solid var(--k-line-soft);
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  font-size: 0.86em;
  backdrop-filter: blur(8px);
}

.k-icon-btn {
  pointer-events: auto;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 2.6cqw;
  border: 1px solid var(--k-line);
  background: var(--k-glass);
  color: var(--k-ink);
  font-size: 0.78em;
  line-height: 1;
  backdrop-filter: blur(8px);
}
.k-icon-btn svg { display: block; }

.k-combo {
  align-self: flex-start;
  display: flex;
  align-items: baseline;
  gap: 1cqw;
  padding: 1cqw 2.2cqw;
  border-radius: 2.6cqw;
  background: var(--k-glow);
  border: 1px solid var(--k-line-strong);
  color: var(--k-moon-bright);
  box-shadow: 0 8px 24px -12px var(--k-glow);
  backdrop-filter: blur(6px);
}
.k-combo strong { font-size: 1em; font-variant-numeric: tabular-nums; }
.k-combo span { font-size: 0.6em; color: var(--k-moon-bright); }

.k-buoy {
  position: absolute;
  left: 4cqw;
  right: 4cqw;
  bottom: calc(4cqw + env(safe-area-inset-bottom));
  display: flex;
  align-items: center;
  gap: 2cqw;
}
.k-buoy-label { font-size: 0.66em; color: var(--k-ink-2); }
.k-buoy-track {
  flex: 1;
  height: 6px;
  border-radius: var(--radius-pill);
  background: var(--k-scrim);
  border: 1px solid var(--k-line);
  overflow: hidden;
}
.k-buoy-fill {
  display: block;
  height: 100%;
  width: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--k-jade), var(--k-moon));
  transform-origin: left center;
  transform: scaleX(var(--buoy, 1));
  transition: transform 180ms linear;
}
.k-buoy-fill.is-low { background: linear-gradient(90deg, var(--k-flame), var(--k-coral)); }

.k-pause {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 6cqw;
  background: var(--k-scrim);
  backdrop-filter: blur(8px);
  pointer-events: auto;
}
.k-pause-card {
  width: 100%;
  max-width: 420px;
  border-radius: 5cqw;
  padding: 5cqw;
  display: flex;
  flex-direction: column;
  gap: 0.7em;
  background: var(--k-glass);
  border: 1px solid var(--k-line);
}

/* ---------- ผลลัพธ์ ---------- */
.k-result { justify-content: flex-end; }
.k-result-sheet {
  max-height: 90%;
  border-radius: 6cqw 6cqw 0 0;
  padding: 5cqw 5cqw calc(5cqw + env(safe-area-inset-bottom));
  gap: 2cqw;
  background: linear-gradient(180deg, var(--k-glass), var(--k-surface));
  border: 1px solid var(--k-line);
  border-bottom: 0;
  backdrop-filter: blur(14px);
}
.k-result-meta { margin: 0; font-size: 0.74em; color: var(--k-moon); letter-spacing: 0.02em; }
.k-score { display: flex; align-items: baseline; gap: 1.6cqw; margin-top: 0.2cqw; }
.k-score strong {
  font-family: var(--font-display);
  font-size: 3.4em;
  line-height: 1;
  color: var(--k-moon);
  font-variant-numeric: tabular-nums;
  text-shadow: 0 0 24px var(--k-glow);
}
.k-score span { font-size: 0.78em; color: var(--k-ink-3); }
.k-best { margin: 0; font-size: 0.68em; color: var(--k-ink-3); }
.k-best.is-record { color: var(--k-moon-bright); }
.k-summary {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1.4cqw;
  margin: 0;
  padding: 0;
  list-style: none;
}
.k-summary li {
  padding: 1.6cqw 2cqw;
  border-radius: 2.4cqw;
  border: 1px solid var(--k-line-soft);
  background: var(--k-surface-2);
  font-size: 0.66em;
  color: var(--k-ink-3);
}
.k-summary b { display: block; font-size: 1.15em; color: var(--k-ink); margin-bottom: 0.15em; }
.k-blessing {
  margin: 0.2em 0 0;
  padding: 2.2cqw 2.6cqw;
  border-left: 2px solid var(--k-line-strong);
  background: transparent;
  font-size: 0.82em;
  color: var(--k-moon-bright);
  line-height: 1.5;
}
.k-wish-quote {
  margin: 0;
  padding: 0;
  border: 0;
  font-size: 0.8em;
  color: var(--k-ink-2);
  font-style: italic;
}
.k-wish-quote::before { content: "\201C"; color: var(--k-moon); font-style: normal; }
.k-wish-quote::after { content: "\201D"; color: var(--k-moon); font-style: normal; }

/* ---------- สมุดคำอธิษฐาน ---------- */
.k-dialog[open] { display: flex; }
.k-dialog:not([open]) { display: none; }
.k-dialog {
  width: min(92vw, 560px);
  max-height: min(88svh, 740px);
  padding: 0;
  border: 1px solid var(--k-line);
  border-radius: var(--radius-card);
  background: var(--k-night);
  color: var(--k-ink);
  flex-direction: column;
  overflow: hidden;
  overscroll-behavior: contain;
  backdrop-filter: blur(16px);
}
.k-dialog::backdrop { background: var(--k-scrim); backdrop-filter: blur(4px); }
.k-dialog-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-md);
  padding: var(--space-lg) var(--space-lg) 0;
}
.k-dialog-head h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.5rem;
  color: var(--k-moon-pale);
  text-wrap: balance;
}
.k-dialog-head .k-sub { margin-top: var(--space-2xs); }
.k-wishlist {
  margin: 0;
  padding: var(--space-md) var(--space-lg) var(--space-lg);
  list-style: none;
  display: grid;
  gap: var(--space-sm);
  overflow-y: auto;
  overscroll-behavior: contain;
  min-height: 0;
}
.k-wishlist li {
  padding: var(--space-sm) var(--space-md);
  border-radius: 14px;
  border: 1px solid var(--k-line-soft);
  background: var(--k-surface-2);
}
.k-wishlist p { margin: 0; font-size: 0.92rem; color: var(--k-ink); }
.k-wishlist small { display: block; margin-top: var(--space-2xs); font-size: 0.72rem; color: var(--k-ink-3); }
.k-wishlist .k-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-lg) var(--space-md);
  border-style: dashed;
  background: transparent;
  text-align: center;
  color: var(--k-ink-3);
  font-size: 0.86rem;
}
.k-empty .k-btn { min-height: 40px; padding: var(--space-xs) var(--space-lg); font-size: 0.9rem; }
.k-dialog-foot {
  display: flex;
  gap: var(--space-sm);
  justify-content: space-between;
  padding: var(--space-md) var(--space-lg) var(--space-lg);
  border-top: 1px solid var(--k-line-soft);
}
.k-dialog-foot .k-btn { min-height: 40px; padding: var(--space-xs) var(--space-lg); font-size: 0.86rem; }
.k-dialog .k-icon-btn { width: 40px; height: 40px; }

/* ---------- เอฟเฟกต์จอสั่น / ถูกกระแทก ---------- */
@keyframes k-shake {
  0%, 100% { transform: translate3d(0, 0, 0); }
  20% { transform: translate3d(-5px, 2px, 0); }
  40% { transform: translate3d(4px, -2px, 0); }
  60% { transform: translate3d(-3px, 1px, 0); }
  80% { transform: translate3d(2px, -1px, 0); }
}
.k-stage.is-shaking { animation: k-shake 320ms ease; }

.k-stage::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 4;
  pointer-events: none;
  opacity: 0;
  box-shadow: inset 0 0 120px 18px var(--k-danger-soft);
}
.k-stage.is-hit::after { animation: k-hit 520ms ease-out; }
@keyframes k-hit {
  0% { opacity: 0.9; }
  100% { opacity: 0; }
}

.k-footnote {
  margin: 0;
  font-size: 0.74rem;
  color: var(--k-ink-3);
  text-align: center;
  max-width: 46ch;
}

@media (hover: hover) {
  .k-nav-link:hover { background: color-mix(in oklab, var(--k-moon) 8%, transparent); color: var(--k-moon); }
  .k-sound:hover { border-color: var(--k-moon); }
  .k-opt:hover { background: var(--k-surface-3); border-color: var(--k-line); }
  .k-chip:hover { background: var(--k-surface-3); color: var(--k-ink); }
  .k-btn-primary:hover { filter: brightness(1.06); }
  .k-btn-quiet:hover { background: color-mix(in oklab, var(--k-ink) 10%, transparent); }
  .k-btn-text:hover { color: var(--k-ink); }
  .k-tab:hover { color: var(--k-ink-2); }
  .k-icon-btn:hover { background: color-mix(in oklab, var(--k-ink) 12%, transparent); }
}

@container (max-width: 420px) {
  .k-craft,
  .k-wish { padding: 2.4cqw; }
  .k-intro-panel { padding-inline: 6cqw; }
  .k-sheet { border-radius: 4.5cqw 4.5cqw 0 0; padding: 3.6cqw; gap: 2.2cqw; }
  .k-opt { padding: 1.6cqw 1.8cqw; gap: 1.4cqw; }
  .k-opt-hint { font-size: 0.64em; }
  .k-opt-stats { font-size: 0.6em; }
}

@container (max-height: 620px) {
  .k-intro-panel { padding-top: 5cqw; }
  .k-title { font-size: 13cqw; }
  .k-lead { font-size: 0.82em; }
  .k-sheet-title { font-size: 1.35em; }
  .k-textarea { min-height: 20cqw; }
  .k-merit strong { font-size: 1.9em; }
}

@media (max-width: 430px) {
  .k-nav-link { display: none; }
  .k-brand small { display: none; }
  .k-top { padding-block: var(--space-xs); }
}

/* ── มือถือแนวตั้ง: ให้เวทีเต็มขอบจอ (edge-to-edge) ─────────
   ใช้เฉพาะจอที่แคบกว่า 9:16 (มือถือส่วนใหญ่) เพื่อไม่ให้เกิดการยืดภาพ
   - ซ่อน footnote และระยะห่างรอบเวที
   - เวทีกินความสูงที่เหลือทั้งหมดหลังแถบหัว
   - canvas ใช้ความสูงเต็มและครอปด้านข้างเล็กน้อย (cover) */
@media (max-width: 600px) and (orientation: portrait) and (max-aspect-ratio: 9 / 16) {
  .k-page {
    height: 100dvh;
    min-height: 100dvh;
    overflow: hidden;
  }

  .k-top {
    flex: none;
    padding-block: max(4px, env(safe-area-inset-top)) 4px;
  }

  .k-main {
    flex: 1;
    min-height: 0;
    padding: 0;
    gap: 0;
  }

  .k-stage {
    flex: 1;
    width: 100vw;
    min-height: 0;
    max-width: none;
    aspect-ratio: auto;
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }

  #scene {
    inset: 0 auto 0 50%;
    width: auto;
    height: 100%;
    max-width: none;
    transform: translateX(-50%);
  }

  .k-footnote {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .k-stage.is-shaking { animation: none; }
  .k-stage.is-hit::after { animation: none; opacity: 0; }
  .k-buoy-fill { transition: none; }
  .k-btn,
  .k-opt,
  .k-chip,
  .k-tab { transition: none; }
}
