/* ตกปลาบ่อน้ำมนต์ — โทนเดียวกับ krathong.css (dark + atmospheric + token)
 * page: /fishing · surface: บ่อน้ำมนต์ยามเย็น · type: Chonburi + Sarabun
 */
:root {
  --f-night: oklch(11% 0.04 255);
  --f-night-deep: oklch(7% 0.03 260);
  --f-ink: oklch(96% 0.015 86);
  --f-ink-2: oklch(86% 0.018 86);
  --f-ink-3: oklch(72% 0.02 86);
  --f-gold: oklch(84% 0.12 84);
  --f-gold-bright: oklch(93% 0.075 88);
  --f-sunset: oklch(74% 0.14 55);
  --f-jade: oklch(78% 0.1 165);
  --f-coral: oklch(66% 0.19 30);
  --f-line: color-mix(in oklab, var(--f-gold) 22%, transparent);
  --f-line-strong: color-mix(in oklab, var(--f-gold) 64%, transparent);
  --f-surface: color-mix(in oklab, var(--f-night) 92%, transparent);
  --f-scrim: color-mix(in oklab, var(--f-night-deep) 74%, transparent);
  --f-glass: color-mix(in oklab, var(--f-night) 78%, transparent);
  --f-panel-glass: color-mix(in oklab, var(--f-night-deep) 86%, transparent);
  --f-focus: var(--f-gold-bright);
}

.f-page {
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  padding: var(--space-md);
  background:
    radial-gradient(1100px 620px at 86% -12%, oklch(38% 0.06 255 / 0.55), transparent 62%),
    radial-gradient(900px 620px at 6% 112%, oklch(28% 0.05 30 / 0.45), transparent 60%),
    var(--f-night-deep);
  color: var(--f-ink);
}

/* ---------- เวที ---------- */
.f-stage {
  position: relative;
  width: min(100%, calc((100svh - 140px) * 9 / 16), 640px);
  aspect-ratio: 9 / 16;
  border-radius: 28px;
  overflow: hidden;
  background: var(--f-night-deep);
  box-shadow:
    0 0 0 1px var(--f-line),
    0 60px 120px -50px oklch(7% 0.03 260 / 0.78);
  container-type: size;
  isolation: isolate;
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
}

.f-stage canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

.f-ui {
  position: absolute;
  inset: 0;
  z-index: 2;
  color: var(--f-ink);
  font-size: clamp(15px, 4.2cqw, 19px);
  line-height: 1.5;
  pointer-events: none;
}

/* ชั้น UI ทั้งชั้นโปร่งต่อการคลิก (ให้แตะกลางบ่อได้) — แต่ปุ่มและแผงต้องกดได้จริง */
.f-ui .f-panel,
.f-ui .f-btn,
.f-ui a { pointer-events: auto; }

.f-screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 5cqw;
}

/* ---------- แถบหัว (HUD) ---------- */
.f-hud {
  position: absolute;
  top: 3.4cqw;
  left: 4cqw;
  right: 4cqw;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 2cqw;
  pointer-events: none;
}

.f-merit {
  padding: 1.2cqw 2.4cqw;
  border-radius: 2.8cqw;
  background: var(--f-glass);
  border: 1px solid var(--f-line);
  backdrop-filter: blur(8px);
}
.f-merit span { display: block; font-size: 0.62em; color: var(--f-ink-3); margin-bottom: 0.15em; }
.f-merit strong {
  display: block;
  font-family: var(--font-display);
  font-size: 2.1em;
  line-height: 1;
  color: var(--f-gold);
  font-variant-numeric: tabular-nums;
  text-shadow: 0 0 18px oklch(84% 0.12 84 / 0.4);
}

.f-stats {
  display: flex;
  flex-direction: column;
  gap: 0.3cqw;
  padding: 1.2cqw 2cqw;
  border-radius: 2.8cqw;
  background: var(--f-glass);
  border: 1px solid var(--f-line);
  backdrop-filter: blur(8px);
  font-size: 0.74em;
  color: var(--f-ink-3);
  font-variant-numeric: tabular-nums;
}
.f-stats b { color: var(--f-gold-bright); margin-right: 0.3em; }

/* ---------- ชั้นข้อความลอย (toast) ---------- */
.f-toasts {
  position: absolute;
  /* ค่าเริ่มต้น: JS จะวางใต้ HUD จริงอีกที (positionToastLayer) */
  top: 34cqw;
  left: 0;
  right: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.6cqw;
  pointer-events: none;
  z-index: 3;
}
.toast-line {
  max-width: 92%;
  padding: 1.2cqw 2.6cqw;
  border-radius: 999px;
  background: color-mix(in oklab, var(--f-night-deep) 82%, transparent);
  border: 1px solid var(--f-line);
  color: var(--f-ink);
  font-size: 1em;
  font-weight: 600;
  text-align: center;
  backdrop-filter: blur(8px);
  box-shadow: 0 10px 30px -12px oklch(0% 0 0 / 0.6);
  animation: f-toast-in 320ms ease-out;
  transition: opacity 380ms ease, transform 380ms ease;
}
.toast-line.is-out {
  opacity: 0;
  transform: translateY(-10px);
}

@keyframes f-toast-in {
  from { opacity: 0; transform: translateY(12px) scale(0.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* ---------- แผงกลาง (เริ่มเกม / สรุปผล) ---------- */
.f-panel {
  display: flex;
  flex-direction: column;
  gap: 1.6cqw;
  padding: 4.4cqw;
  border-radius: 5cqw;
  background: var(--f-panel-glass);
  border: 1px solid var(--f-line);
  backdrop-filter: blur(14px);
  box-shadow: 0 30px 70px -30px oklch(0% 0 0 / 0.7);
}

.f-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(34px, 10cqw, 58px);
  line-height: 1.1;
  color: var(--f-gold-bright);
  text-wrap: balance;
}

.f-subtitle {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.4em;
  color: var(--f-gold);
}

.f-lead { margin: 0; font-size: 0.88em; color: var(--f-ink-2); line-height: 1.55; }

.f-hint { margin: 0.4em 0 0; font-size: 0.72em; color: var(--f-ink-3); }

.f-actions { display: flex; gap: 2cqw; margin-top: 2cqw; }

.f-btn {
  min-height: 48px;
  flex: 1;
  border: 0;
  border-radius: 999px;
  padding: 2.6cqw 4.4cqw;
  font-family: var(--font-body);
  font-size: 0.92em;
  font-weight: 700;
  line-height: 1.2;
  text-align: center;
  cursor: pointer;
  transition: transform 160ms ease, filter 160ms ease;
}
.f-btn:active { transform: scale(0.985); }
.f-btn-primary {
  background: linear-gradient(180deg, var(--f-gold-bright), var(--f-gold));
  color: oklch(24% 0.06 72);
  box-shadow: 0 14px 34px -16px oklch(84% 0.12 84 / 0.55);
}
.f-btn-primary:hover { filter: brightness(1.06); }

/* แถวสรุปผลในหน้าจบรอบ */
#resultBody .result-row {
  margin: 0;
  padding: 1.2cqw 2cqw;
  border-radius: 2.4cqw;
  background: color-mix(in oklab, var(--f-night-deep) 55%, transparent);
  border: 1px solid var(--f-line);
  font-size: 0.82em;
  color: var(--f-ink-2);
}
#resultBody .result-row + .result-row { margin-top: 0.7cqw; }

/* ---------- ปุ่มกลับหน้าแรก ---------- */
.f-footnote {
  margin: 0;
  font-size: 0.78rem;
  color: var(--f-ink-3);
  text-align: center;
}
.f-footnote a {
  color: var(--f-gold-bright);
  text-decoration: none;
  border-bottom: 1px solid color-mix(in oklab, var(--f-gold) 40%, transparent);
}
.f-footnote a:hover { color: var(--f-ink); }

/* ลิงก์กลับหน้าเลือกเกมในหน้าเริ่ม/หน้าสรุป (ใช้แทน footnote บนมือถือ) */
.f-back {
  display: inline-flex;
  align-self: center;
  margin-top: 0.6rem;
  padding: 0.3rem 0.2rem;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--f-ink-3);
  text-decoration: none;
  border-bottom: 1px solid color-mix(in oklab, var(--f-gold) 32%, transparent);
}

.f-back:hover {
  color: var(--f-gold-bright);
}

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

  .f-main {
    width: 100%;
    height: 100%;
  }

  .f-stage {
    width: 100vw;
    height: 100dvh;
    max-width: none;
    aspect-ratio: auto;
    border-radius: 0;
    box-shadow: none;
  }

  .f-stage canvas {
    inset: 0 auto 0 50%;
    width: auto;
    height: 100%;
    max-width: none;
    transform: translateX(-50%);
  }

  .f-footnote {
    display: none;
  }
}

/* ---------- รองรับ reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  .toast-line { animation: none; transition: none; }
  .f-btn { transition: none; }
}
