/* Golden Hour Open — menus, title, yardage book, scorecards. Warm paper over the living course. */
:root {
  /* The Fire Dragon kit's credits roll, in the game's colours. */
  --fd-bg: #22190f;
  --fd-accent: #e0a44a;
  --fd-accent-2: #f3c77a;
  --fd-text: #f7eedb;
  --fd-muted: rgba(247, 238, 219, 0.66);
  --fd-font: "Avenir Next", "Segoe UI", system-ui, sans-serif;
  --fd-title-font: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --fd-focus: #f3c77a;
  --fd-glow-hue: 20deg;
  --fd-splash-bg: #2d2419;
}

.screens { position: absolute; inset: 0; pointer-events: none; z-index: 20; }
.screen { position: absolute; inset: 0; pointer-events: auto; opacity: 0; transition: opacity 0.35s var(--ease-out); }
.screen.in { opacity: 1; }
.screen.out { opacity: 0; pointer-events: none; }
.screen.covered { visibility: hidden; }
.screen.sheet { display: grid; place-items: center; padding: max(16px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left)); background: radial-gradient(ellipse at 50% 40%, rgba(45, 36, 25, 0.18), rgba(30, 22, 12, 0.55)); overflow-y: auto; }
.screen.sheet .panel { transform: translateY(14px) scale(0.98); transition: transform 0.45s var(--ease-back); }
.screen.sheet.in .panel { transform: none; }

/* ---------------------------------------------------------------- panels */
.panel {
  position: relative; width: min(560px, 100%); max-height: calc(100vh - 32px); overflow-y: auto;
  padding: 26px 30px 22px; border-radius: 20px;
  background: url("./assets/ui/paper.webp") center / 512px repeat, linear-gradient(180deg, #fbf4e3, #efdfbf);
  background-blend-mode: multiply;
  border: 1px solid var(--paper-edge); box-shadow: 0 30px 80px rgba(30, 18, 4, 0.45), 0 3px 10px rgba(30, 18, 4, 0.25);
}
.panel.wide { width: min(1040px, 100%); }
.sheet.small .panel { width: min(420px, 100%); }
.panel-title { margin: 0 0 4px; font-weight: 500; font-style: italic; font-size: clamp(26px, 3vw, 34px); color: var(--ink); }
.panel-title.big { font-size: clamp(34px, 5vw, 56px); }
.panel-kicker { margin: 0; font-family: var(--sans); font-size: 12px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--honey-deep); }
.panel-sub { margin: 0 0 14px; font-family: var(--sans); color: var(--ink-soft); font-size: 15px; }
.fine-print { font-family: var(--sans); font-size: 13px; color: var(--ink-soft); }
.panel h3 { margin: 16px 0 6px; font-family: var(--sans); font-size: 12px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--honey-deep); }

/* ---------------------------------------------------------------- buttons */
.menu-list { display: grid; gap: 8px; }
.mbtn {
  position: relative; display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
  padding: 11px 16px; border-radius: 12px; border: 1px solid var(--paper-edge);
  background: linear-gradient(180deg, rgba(255, 252, 244, 0.9), rgba(244, 232, 206, 0.9));
  box-shadow: 0 1px 2px rgba(40, 26, 10, 0.12); color: var(--ink);
  transition: transform 0.18s var(--ease-out), background 0.2s, box-shadow 0.2s;
}
.mbtn:hover, .mbtn:focus-visible { transform: translateX(4px); background: linear-gradient(180deg, #fffaf0, #f7e3b8); box-shadow: 0 4px 14px rgba(120, 80, 20, 0.22); }
.mbtn:focus-visible { outline: 3px solid var(--honey); outline-offset: 2px; }
.mbtn:active { transform: translateX(4px) scale(0.985); }
.mbtn-text { display: grid; gap: 1px; }
.mbtn-label { font-size: 20px; }
.mbtn-sub { font-family: var(--sans); font-size: 12.5px; color: var(--ink-soft); }
.mbtn-icon { width: 34px; height: 34px; object-fit: contain; }
.mbtn.accent { background: linear-gradient(180deg, #f6d38b, var(--honey)); border-color: rgba(120, 80, 20, 0.45); }
.mbtn.accent .mbtn-sub { color: #5b3f16; }
.mbtn.danger .mbtn-label { color: #8e3b28; }
.mbtn.small { padding: 7px 12px; }
.mbtn.small .mbtn-label { font-size: 16px; }
.mbtn.ghost { background: transparent; box-shadow: none; }
.mbtn.locked { color: var(--ink-soft); background: linear-gradient(180deg, rgba(240, 232, 214, 0.8), rgba(226, 214, 190, 0.8)); }
.mbtn.locked .mbtn-sub { color: var(--honey-deep); font-weight: 600; }
.lock { margin-left: auto; width: 18px; height: 20px; position: relative; flex: none; }
.lock::before { content: ""; position: absolute; left: 3px; top: 0; width: 12px; height: 11px; border: 2.5px solid var(--honey-deep); border-bottom: none; border-radius: 7px 7px 0 0; box-sizing: border-box; }
.lock::after { content: ""; position: absolute; left: 0; bottom: 0; width: 18px; height: 12px; border-radius: 3px; background: var(--honey-deep); }
.confirm-row { display: flex; gap: 10px; justify-content: flex-end; margin-top: 18px; }
.confirm-row .mbtn { width: auto; min-width: 150px; }
.prompt-bar { display: flex; gap: 16px; flex-wrap: wrap; margin-top: 14px; font-family: var(--sans); font-size: 12px; color: var(--ink-soft); }
kbd { display: inline-block; min-width: 1.8em; padding: 1px 6px; border-radius: 5px; border: 1px solid var(--paper-edge); border-bottom-width: 2px; background: #fffaf0; font-family: var(--sans); font-size: 11px; text-align: center; color: var(--ink); }
@media (pointer: coarse) { .prompt-bar { display: none; } }

/* ---------------------------------------------------------------- options */
.opt { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 4px 12px; padding: 8px 10px; border-radius: 10px; border: 1px solid transparent; }
.opt:focus-visible, .opt:hover { border-color: var(--paper-edge); background: rgba(255, 250, 238, 0.7); outline: none; }
.opt:focus-visible { box-shadow: 0 0 0 3px var(--honey); }
.opt-label { font-size: 17px; }
.opt-control { display: flex; align-items: center; gap: 6px; }
.opt-arrow { width: 30px; height: 30px; border-radius: 50%; border: 1px solid var(--paper-edge); background: #fffaf0; font-size: 18px; line-height: 1; }
.opt-value { min-width: 150px; text-align: center; font-family: var(--sans); font-size: 14px; font-weight: 600; }
.opt-value.locked { color: var(--honey-deep); }
.opt-hint { grid-column: 1 / -1; font-family: var(--sans); font-size: 11px; color: var(--honey-deep); min-height: 0; }
.opt-hint:empty { display: none; }
.opt-bar { grid-column: 2; height: 5px; border-radius: 3px; background: rgba(94, 70, 40, 0.18); overflow: hidden; }
.opt-bar i { display: block; height: 100%; width: calc(var(--v, 0) * 100%); background: var(--honey); transition: width 0.2s; }
.settings-group { display: grid; gap: 2px; }
.settings-actions { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 16px; }

/* ---------------------------------------------------------------- title */
.title-screen { display: grid; grid-template-rows: 1fr auto auto auto; justify-items: center; padding-bottom: max(26px, env(safe-area-inset-bottom)); background: #2d2419; cursor: pointer; }
.title-art { position: absolute; inset: 0; background: url("./assets/ui/key-art.webp") center / cover no-repeat; animation: titleDrift 30s ease-in-out infinite alternate; }
.title-glow { position: absolute; inset: 0; background: linear-gradient(180deg, rgba(20, 12, 4, 0) 55%, rgba(20, 12, 4, 0.62)); }
@keyframes titleDrift { from { transform: scale(1.02); } to { transform: scale(1.07) translate(-1%, 0.5%); } }
.title-screen > :not(.title-art):not(.title-glow) { position: relative; }
.title-tagline { grid-row: 2; margin: 0 0 12px; color: #fff2d8; font-style: italic; font-size: clamp(15px, 1.8vw, 21px); text-shadow: 0 2px 10px rgba(30, 12, 0, 0.8); text-align: center; padding: 0 16px; }
.press-start { grid-row: 3; border: none; background: none; color: #fff7e6; font-family: var(--sans); font-size: clamp(13px, 1.4vw, 16px); letter-spacing: 0.24em; text-transform: uppercase; text-shadow: 0 2px 8px rgba(30, 12, 0, 0.9); animation: breathe 2.6s ease-in-out infinite; padding: 10px 18px; }
@keyframes breathe { 0%, 100% { opacity: 0.55; } 50% { opacity: 1; } }
.title-demo { grid-row: 4; margin: 4px 0 0; font-family: var(--sans); font-size: 12px; letter-spacing: 0.1em; color: #f3c77a; text-shadow: 0 1px 6px rgba(0, 0, 0, 0.8); }
.copyright { position: absolute; right: max(16px, env(safe-area-inset-right)); bottom: max(12px, env(safe-area-inset-bottom)); margin: 0; font-family: var(--sans); font-size: 12px; color: rgba(255, 244, 222, 0.82); text-shadow: 0 1px 4px rgba(0, 0, 0, 0.8); }
.title-screen.leaving .title-art { transition: transform 0.4s ease-in, filter 0.4s; transform: scale(1.1); filter: brightness(1.2); }

/* ---------------------------------------------------------------- logo */
.logo { display: grid; place-items: center; }
.logo-img { width: 100%; height: auto; filter: drop-shadow(0 6px 18px rgba(40, 18, 0, 0.45)); }
.logo-type { margin: 0; font-weight: 600; font-style: italic; font-size: 44px; color: #f3c77a; text-shadow: 0 2px 0 #8a5a18, 0 6px 16px rgba(30, 12, 0, 0.6); text-align: center; line-height: 1; }
.logo-small { font-size: 0.5em; }
.logo-open { display: block; font-style: normal; letter-spacing: 0.3em; font-size: 0.55em; color: #fff; }

/* ---------------------------------------------------------------- main menu */
.main-menu { display: flex; align-items: stretch; }
.menu-shade { position: absolute; inset: 0; background: linear-gradient(90deg, rgba(34, 24, 12, 0.72) 0%, rgba(34, 24, 12, 0.35) 34%, rgba(34, 24, 12, 0) 58%); pointer-events: none; }
.menu-column { position: relative; display: flex; flex-direction: column; justify-content: center; gap: 18px; width: min(430px, 92vw); padding: max(20px, env(safe-area-inset-top)) 0 max(20px, env(safe-area-inset-bottom)) max(34px, env(safe-area-inset-left)); overflow-y: auto; }
.menu-logo { width: min(360px, 80%); margin-bottom: 4px; }
.main-menu .menu-list { animation: rise 0.6s var(--ease-out) both 0.1s; }
.main-menu .prompt-bar { color: rgba(255, 244, 222, 0.8); }
.main-menu .prompt-bar kbd { background: rgba(255, 250, 240, 0.9); }
@keyframes rise { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: none; } }

/* ---------------------------------------------------------------- controls */
.swing-steps { margin: 6px 0 14px; padding-left: 22px; font-size: 16px; line-height: 1.45; }
.controls-table { width: 100%; border-collapse: collapse; font-family: var(--sans); font-size: 13px; margin-bottom: 10px; }
.controls-table th, .controls-table td { padding: 6px 8px; border-bottom: 1px dashed var(--paper-edge); text-align: left; }
.controls-table thead th { font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--honey-deep); }
.controls-screen .panel { width: min(760px, 100%); }

/* ---------------------------------------------------------------- quick round */
.course-cards { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin: 10px 0 8px; }
.course-card { position: relative; padding: 0; border-radius: 12px; overflow: hidden; border: 2px solid transparent; background: #3a2c1c; aspect-ratio: 16 / 10; box-shadow: 0 4px 14px rgba(30, 18, 4, 0.25); transition: transform 0.2s var(--ease-out), border-color 0.2s; }
.course-card:hover, .course-card:focus-visible { transform: translateY(-3px); }
.course-card.on { border-color: var(--honey); box-shadow: 0 0 0 3px rgba(224, 164, 74, 0.4), 0 8px 20px rgba(30, 18, 4, 0.3); }
.cc-img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.cc-img.missing { display: none; }
.course-card.locked .cc-img { filter: saturate(0.55) brightness(0.8); }
.cc-text { position: absolute; left: 0; right: 0; bottom: 0; display: grid; padding: 18px 10px 8px; text-align: left; color: #fff6e4; background: linear-gradient(180deg, transparent, rgba(20, 12, 4, 0.78)); }
.cc-text strong { font-size: 16px; font-weight: 500; }
.cc-kind { font-family: var(--sans); font-size: 11px; opacity: 0.85; }
.cc-lock { position: absolute; top: -130%; right: 8px; padding: 3px 8px; border-radius: 10px; background: rgba(34, 24, 12, 0.8); font-family: var(--sans); font-size: 11px; color: #f3c77a; }
.qr-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.players { display: grid; gap: 8px; }
.player-row { display: grid; grid-template-columns: 44px 1fr auto auto; align-items: center; gap: 8px; }
.pl-portrait { width: 44px; height: 44px; border-radius: 50%; object-fit: contain; border: 2px solid var(--paper-edge); background: #e9d7b1; }
.pl-portrait.missing { visibility: hidden; }
.pl-name { min-width: 0; padding: 8px 10px; border-radius: 9px; border: 1px solid var(--paper-edge); background: #fffaf0; font: inherit; font-size: 16px; color: var(--ink); }
.pl-name:focus-visible { outline: 3px solid var(--honey); }
.player-row .opt { padding: 4px; }
.player-row .opt-label { display: none; }
.player-row .opt-value { min-width: 80px; }

/* ---------------------------------------------------------------- hole intro (yardage book) */
.hole-intro { pointer-events: auto; cursor: pointer; }
.yardage-book {
  position: absolute; left: max(22px, env(safe-area-inset-left)); top: 50%; transform: translate(-30px, -50%) rotate(-1.2deg); opacity: 0;
  width: min(330px, 40vw); max-height: 88vh; overflow: hidden; padding: 18px 20px 16px; border-radius: 6px 16px 16px 6px;
  background: url("./assets/ui/paper.webp") center / 512px repeat, linear-gradient(180deg, #fbf4e3, #ecdab4); background-blend-mode: multiply;
  box-shadow: -6px 0 0 #6d4f2c inset, 0 24px 60px rgba(30, 18, 4, 0.45);
  transition: transform 0.6s var(--ease-back), opacity 0.4s;
}
.hole-intro.in .yardage-book { transform: translate(0, -50%) rotate(-1.2deg); opacity: 1; }
.yb-head { display: flex; gap: 12px; align-items: center; }
.yb-no { display: grid; place-items: center; width: 52px; height: 52px; border-radius: 50%; background: var(--green); color: var(--paper); font-size: 30px; flex: none; }
.yb-name { margin: 0; font-weight: 500; font-style: italic; font-size: 24px; }
.yb-meta { margin: 0; font-family: var(--sans); font-size: 12px; color: var(--ink-soft); letter-spacing: 0.04em; }
.yb-map { margin: 12px auto 10px; display: grid; place-items: center; }
.yb-map canvas { display: block; max-width: 100%; max-height: 38vh; border-radius: 8px; box-shadow: 0 2px 8px rgba(30, 18, 4, 0.3); transform: rotate(0.6deg); }
.yb-note { margin: 0 0 8px; font-size: 15px; line-height: 1.42; }
.yb-wind, .yb-players { margin: 0 0 4px; font-family: var(--sans); font-size: 12px; color: var(--ink-soft); }
.yb-go { margin: 10px 0 0; font-family: var(--sans); font-size: 12px; color: var(--honey-deep); }
@media (max-height: 500px) {
  .yardage-book { width: min(300px, 44vw); padding: 10px 14px; }
  .yb-map canvas { max-height: 30vh; }
  .yb-note { font-size: 13px; }
}

/* ---------------------------------------------------------------- next golfer */
.next-golfer { display: grid; place-items: center; pointer-events: auto; background: rgba(30, 22, 12, 0.25); }
.ng-card { display: flex; align-items: center; gap: 18px; padding: 16px 28px 16px 16px; border-radius: 60px; background: linear-gradient(180deg, #fbf4e3, #eedcb6); box-shadow: 0 20px 50px rgba(30, 18, 4, 0.4); transform: scale(0.8); transition: transform 0.45s var(--ease-back); }
.next-golfer.in .ng-card { transform: scale(1); }
.ng-portrait { width: 84px; height: 84px; border-radius: 50%; object-fit: contain; border: 3px solid var(--honey); background: #e9d7b1; }
.ng-hole { margin: 0; font-family: var(--sans); font-size: 12px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--honey-deep); }
.ng-name { margin: 0; font-weight: 500; font-style: italic; font-size: 30px; }

/* ---------------------------------------------------------------- scorecard */
.scorecard { overflow-x: auto; margin: 8px 0 4px; border-radius: 10px; border: 1px solid var(--paper-edge); background: rgba(255, 252, 244, 0.75); }
.sc-table { width: 100%; border-collapse: collapse; font-family: var(--sans); font-size: 13px; text-align: center; }
.sc-table caption { padding: 6px; font-size: 12px; color: var(--ink-soft); }
.sc-table th, .sc-table td { padding: 5px 4px; border-right: 1px solid rgba(94, 70, 40, 0.12); min-width: 26px; }
.sc-table thead th { background: var(--green); color: var(--paper); font-weight: 600; }
.sc-yardrow td { font-size: 11px; color: var(--ink-soft); }
.sc-parrow td { font-weight: 700; border-bottom: 2px solid rgba(94, 70, 40, 0.3); }
.sc-name { text-align: left !important; padding-left: 10px !important; white-space: nowrap; font-weight: 600; min-width: 90px !important; }
.sc-sub, .sc-total { background: rgba(224, 164, 74, 0.14); font-weight: 700; }
.sc-table thead .sc-sub, .sc-table thead .sc-total { background: #37502e; }
.sc-score span { display: inline-grid; place-items: center; width: 24px; height: 24px; font-weight: 600; }
.tone-birdie span { border-radius: 50%; border: 2px solid var(--rose); color: #8e3b28; }
.tone-eagle span, .tone-ace span { border-radius: 50%; border: 2px solid var(--rose); box-shadow: 0 0 0 2px #fbf4e3, 0 0 0 4px var(--rose); color: #8e3b28; }
.tone-bogey span { border: 1.5px solid var(--ink-soft); }
.tone-worse span { border: 1.5px solid var(--ink-soft); box-shadow: 0 0 0 2px #fbf4e3, 0 0 0 3.5px var(--ink-soft); }
.sc-table tr.me th, .sc-table tr.me td { background-color: rgba(224, 164, 74, 0.12); }
.sc-topar { color: var(--green); }
.standings { display: flex; flex-wrap: wrap; gap: 8px 22px; margin: 0 0 8px; padding: 0; list-style: none; counter-reset: st; }
.standings li { display: flex; gap: 8px; align-items: baseline; font-size: 18px; counter-increment: st; }
.standings li::before { content: counter(st); font-family: var(--sans); font-size: 12px; color: var(--honey-deep); }
.st-score { font-family: var(--sans); font-weight: 700; color: var(--green); }
.stat-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin: 8px 0 12px; }
.stat-row div { padding: 8px 10px; border-radius: 10px; background: rgba(255, 252, 244, 0.7); border: 1px solid var(--paper-edge); }
.stat-row dt { font-family: var(--sans); font-size: 11px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--ink-soft); }
.stat-row dd { margin: 2px 0 0; font-size: 24px; }
.badge-best { display: inline-block; margin: 0 0 10px; padding: 4px 12px; border-radius: 20px; background: var(--honey); font-family: var(--sans); font-size: 12px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; animation: pop 0.6s var(--ease-back) both 0.3s; }
@keyframes pop { from { transform: scale(0.4); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------------------------------------------------------------- small screens */
@media (max-width: 900px) {
  .course-cards { grid-template-columns: repeat(2, 1fr); }
  .qr-grid { grid-template-columns: 1fr; }
  .settings-actions { grid-template-columns: 1fr; }
  .stat-row { grid-template-columns: repeat(2, 1fr); }
}
@media (max-height: 500px) {
  .panel { padding: 14px 18px 12px; max-height: calc(100vh - 20px); }
  .panel-title { font-size: 22px; }
  .mbtn { padding: 7px 12px; }
  .mbtn-label { font-size: 17px; }
  .menu-column { gap: 8px; width: min(380px, 60vw); }
  .menu-logo { width: min(240px, 70%); }
  .course-cards { grid-template-columns: repeat(4, 1fr); gap: 8px; }
  .cc-text strong { font-size: 13px; }
}
.reduce-motion .title-art { animation: none; }
