:root {
  --bg: #0f2418;
  --glass: rgba(12, 28, 20, 0.72);
  --glass2: rgba(20, 44, 31, 0.86);
  --line: rgba(255, 255, 255, 0.14);
  --text: #f2f6f1;
  --muted: #a9bcae;
  --accent: #ffd34d;
  --green: #5ccf7a;
  --red: #ff6b5e;
  --blue: #52b4ff;
  --radius: 14px;
  font-family: "Pretendard", "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans KR", system-ui, -apple-system, "Segoe UI", sans-serif;
  color: var(--text);
  -webkit-tap-highlight-color: transparent;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--bg); }
body { touch-action: none; user-select: none; -webkit-user-select: none; }
canvas#view { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
[hidden] { display: none !important; }
button {
  font: inherit; color: var(--text); background: rgba(255, 255, 255, 0.1); border: 1px solid var(--line);
  border-radius: 10px; padding: 8px 14px; cursor: pointer; transition: background 0.15s, transform 0.1s;
}
button:hover { background: rgba(255, 255, 255, 0.18); }
button:active { transform: translateY(1px); }
button.primary { background: linear-gradient(180deg, #ffd95e, #f0b92b); color: #1e2a12; border-color: transparent; font-weight: 700; }
button.primary:hover { background: linear-gradient(180deg, #ffe27e, #f5c440); }
button.big { width: 100%; padding: 14px 18px; font-size: 17px; border-radius: 12px; }
button.link { background: none; border: none; color: var(--muted); padding: 6px 8px; text-decoration: underline; text-underline-offset: 3px; }
button.back { background: none; border: none; font-size: 20px; padding: 4px 10px; }
button:disabled { opacity: 0.45; cursor: default; }
input, select, textarea {
  font: inherit; color: var(--text); background: rgba(0, 0, 0, 0.3); border: 1px solid var(--line); border-radius: 9px; padding: 8px 10px;
  user-select: text; -webkit-user-select: text;
}
input[type=range] { padding: 0; accent-color: var(--accent); }
select option { color: #111; }
.grow { flex: 1; }
.row { display: flex; align-items: center; }
.gap { gap: 8px; }
.wrap { flex-wrap: wrap; }
.muted { color: var(--muted); font-size: 14px; }
.code { font-family: ui-monospace, Consolas, monospace; letter-spacing: 0.12em; color: var(--accent); }

/* ---------- screens ---------- */
.screen {
  position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; padding: 16px;
  background: radial-gradient(ellipse at 50% 120%, rgba(10, 30, 18, 0.2), rgba(8, 20, 12, 0.72));
  overflow-y: auto;
}
.menu-card, .panel {
  background: var(--glass); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--line); border-radius: 20px; padding: 22px; width: min(460px, 100%);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35); max-height: calc(100vh - 32px); overflow-y: auto;
}
.panel.wide { width: min(940px, 100%); }
.logo { display: flex; gap: 14px; align-items: center; margin-bottom: 18px; }
.logo h1 { margin: 0; font-size: 34px; letter-spacing: -0.02em; }
.logo .sub { margin: 4px 0 0; color: var(--muted); font-size: 14px; line-height: 1.4; }
.logo-ball {
  width: 56px; height: 56px; border-radius: 50%; flex: none;
  background: radial-gradient(circle at 35% 30%, #fff 0 18%, #e9eee9 40%, #b9c4bd 100%);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.35), inset -4px -6px 10px rgba(0, 0, 0, 0.12);
  position: relative;
}
.logo-ball::after { content: '9'; position: absolute; inset: 0; display: grid; place-items: center; font-weight: 800; color: #2f7a45; font-size: 24px; }
.field { display: flex; flex-direction: column; gap: 6px; margin: 10px 0 14px; font-size: 14px; color: var(--muted); }
.field input { font-size: 16px; }
.speed-row { display: flex; gap: 12px; align-items: center; }
.speed-row input { flex: 1; }
.speed-row output { min-width: 70px; text-align: right; color: var(--text); font-weight: 700; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chips button { padding: 4px 10px; font-size: 13px; border-radius: 20px; }
.chips button.on { background: var(--accent); color: #1e2a12; }
.menu-buttons { display: grid; gap: 10px; margin-top: 8px; }
.menu-foot { display: flex; flex-wrap: wrap; justify-content: center; margin-top: 12px; }
/* Link to the studio home, in the studio's own colours (www.breyes.net: ink #0b0d12, orange #ff7a3d). */
.studio-banner {
  display: flex; align-items: center; gap: 12px; margin-top: 14px; padding: 10px 14px 10px 10px;
  border-radius: 14px; color: var(--text); text-decoration: none;
  background: linear-gradient(100deg, rgba(11, 13, 18, 0.88), rgba(11, 13, 18, 0.6) 70%, rgba(255, 122, 61, 0.16));
  border: 1px solid rgba(255, 122, 61, 0.35); transition: border-color 0.15s, background 0.15s;
}
.studio-banner:hover { border-color: #ff7a3d; background: linear-gradient(100deg, rgba(11, 13, 18, 0.92), rgba(11, 13, 18, 0.65) 70%, rgba(255, 122, 61, 0.26)); }
.studio-banner:focus-visible { outline: 2px solid #ff7a3d; outline-offset: 2px; }
.studio-mark {
  flex: none; background: #ff7a3d; color: #1a0d05; font-weight: 800; font-size: 13px; letter-spacing: 0.14em;
  padding: 9px 8px 9px 10px; border-radius: 9px; box-shadow: 0 4px 12px rgba(255, 122, 61, 0.25);
}
.studio-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.studio-text b { font-size: 15px; }
.studio-text small { color: var(--muted); font-size: 12px; line-height: 1.35; word-break: keep-all; }
.studio-go { margin-left: auto; flex: none; color: #ff7a3d; font-size: 20px; font-weight: 700; transition: transform 0.15s; }
.studio-banner:hover .studio-go { transform: translateX(3px); }
@media (max-width: 420px) {
  .studio-banner { gap: 10px; padding-right: 10px; }
  .studio-mark { font-size: 11px; padding: 8px 6px 8px 8px; }
  .studio-text b { font-size: 14px; }
}
.panel-head { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.panel-head h2 { margin: 0; font-size: 20px; }
.panel-foot { display: flex; align-items: center; gap: 12px; margin-top: 16px; justify-content: flex-end; }
.panel-foot .big { width: auto; min-width: 200px; }
h3 { font-size: 14px; color: var(--muted); margin: 14px 0 8px; font-weight: 600; }
.cols { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
@media (max-width: 720px) { .cols { grid-template-columns: 1fr; } }
.plist { display: grid; gap: 8px; }
.prow { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; background: rgba(255, 255, 255, 0.05); border: 1px solid var(--line); border-radius: 12px; padding: 8px; }
.prow .dot { width: 14px; height: 14px; border-radius: 50%; flex: none; }
.prow input.pname { flex: 1; min-width: 110px; }
.prow select { max-width: 120px; }
.prow .tag { font-size: 12px; color: var(--muted); }
.settings { display: grid; gap: 10px; }
.set { display: grid; grid-template-columns: 130px 1fr; align-items: center; gap: 8px; font-size: 14px; }
.set > span { color: var(--muted); }
.seg-inline { display: flex; flex-wrap: wrap; gap: 4px; }
.seg-inline button { padding: 5px 9px; font-size: 13px; }
.seg-inline button.on { background: var(--accent); color: #1e2a12; border-color: transparent; }
.room-list { display: grid; gap: 8px; min-height: 60px; }
.room-item { display: flex; align-items: center; gap: 10px; background: rgba(255, 255, 255, 0.06); border-radius: 12px; padding: 10px 12px; }
.code-in { width: 90px; text-transform: uppercase; letter-spacing: 0.15em; text-align: center; }

/* ---------- HUD ---------- */
#hud { position: fixed; inset: 0; pointer-events: none; }
#hud > * { pointer-events: auto; }
.hud-box { position: absolute; background: var(--glass); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); border: 1px solid var(--line); border-radius: var(--radius); }
#hud-hole { top: 12px; left: 12px; padding: 10px 14px; min-width: 170px; font-size: 14px; }
.hole-no { font-size: 13px; color: var(--muted); }
.hole-no b { font-size: 26px; color: var(--text); margin-left: 2px; }
.hole-meta { display: flex; gap: 12px; color: var(--muted); }
.hole-meta b { color: var(--text); }
.hole-pin b { font-size: 20px; color: var(--accent); }
.hole-lie b { color: var(--text); }
#hud-players { top: 12px; left: 200px; padding: 6px; display: flex; gap: 4px; }
.pl { display: flex; flex-direction: column; padding: 4px 10px; border-radius: 10px; min-width: 84px; font-size: 13px; opacity: 0.75; border: 2px solid transparent; }
.pl.turn { opacity: 1; background: rgba(255, 255, 255, 0.1); border-color: var(--pc); }
.pl .nm { display: flex; align-items: center; gap: 6px; font-weight: 700; white-space: nowrap; max-width: 120px; overflow: hidden; text-overflow: ellipsis; }
.pl .nm i { width: 10px; height: 10px; border-radius: 50%; background: var(--pc); flex: none; }
.pl .sc { color: var(--muted); }
.pl .sc b { color: var(--text); }
.pl.done { opacity: 0.55; }
#hud-wind { top: 12px; right: 12px; padding: 6px 10px 6px 6px; display: flex; align-items: center; gap: 4px; }
#hud-wind b { font-size: 22px; display: block; line-height: 1; }
#hud-wind small { color: var(--muted); }
#hud-turn { position: absolute; top: 14px; left: 50%; transform: translateX(-50%); font-size: 18px; font-weight: 700; text-shadow: 0 2px 6px rgba(0, 0, 0, 0.6); pointer-events: none; white-space: nowrap; }
#hud-clubs { left: 12px; top: 150px; padding: 6px; display: flex; flex-direction: column; gap: 2px; max-height: calc(100vh - 360px); overflow-y: auto; }
.club { display: flex; justify-content: space-between; gap: 10px; padding: 5px 10px; border-radius: 8px; border: none; background: none; font-size: 14px; min-width: 124px; }
.club b { font-weight: 700; }
.club span { color: var(--muted); font-size: 12px; }
.club.on { background: var(--accent); color: #1e2a12; }
.club.on span { color: #3c4a22; }
.club.sugg:not(.on) { box-shadow: inset 0 0 0 1px var(--accent); }
#hud-bottom { position: absolute; left: 50%; bottom: 12px; transform: translateX(-50%); width: min(720px, calc(100vw - 24px)); background: var(--glass); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); border: 1px solid var(--line); border-radius: var(--radius); padding: 8px 12px 10px; }
.tabs { display: flex; gap: 4px; margin-bottom: 8px; }
.tabs button { flex: 1; padding: 6px; font-size: 14px; background: transparent; }
.tabs button.on { background: rgba(255, 255, 255, 0.16); border-color: rgba(255, 255, 255, 0.3); font-weight: 700; }
.tabs.small button { flex: none; padding: 4px 12px; font-size: 13px; }
.shape-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 8px; font-size: 13px; }
.seg { display: flex; border: 1px solid var(--line); border-radius: 9px; overflow: hidden; }
.seg button { border: none; border-radius: 0; padding: 5px 10px; font-size: 13px; background: transparent; }
.seg button.on { background: rgba(255, 211, 77, 0.9); color: #1e2a12; }
.aoa { display: flex; align-items: center; gap: 6px; color: var(--muted); }
.aoa input { width: 110px; }
.aoa output { color: var(--text); min-width: 40px; }
.meter { display: flex; gap: 10px; align-items: center; }
.meter-track { position: relative; flex: 1; height: 30px; border-radius: 15px; background: linear-gradient(90deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.18)); overflow: hidden; border: 1px solid var(--line); }
.meter-zone { position: absolute; top: 0; bottom: 0; left: calc(10% - 12px); width: 24px; background: rgba(92, 207, 122, 0.35); }
.meter-impact { position: absolute; top: -2px; bottom: -2px; left: 10%; width: 3px; background: #fff; box-shadow: 0 0 6px #fff; }
.meter-fill { position: absolute; top: 4px; bottom: 4px; left: 10%; width: 0; background: linear-gradient(90deg, #6bd98a, #ffd34d 80%, #ff6b5e); border-radius: 10px; opacity: 0.8; }
.meter-power { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--accent); display: none; }
.meter-mark { position: absolute; top: 2px; bottom: 2px; width: 6px; margin-left: -3px; background: #fff; border-radius: 3px; left: 10%; box-shadow: 0 0 8px rgba(0, 0, 0, 0.5); }
.meter-ticks { position: absolute; inset: 0; background-image: linear-gradient(90deg, transparent calc(100% - 1px), rgba(255, 255, 255, 0.25) 1px); background-size: 8.1818% 100%; background-position: 10% 0; pointer-events: none; }
.swing-btn { min-width: 110px; padding: 12px 16px; font-weight: 800; font-size: 16px; background: linear-gradient(180deg, #6bd98a, #3fb262); color: #0d2414; border: none; }
.swing-btn:disabled { background: rgba(255, 255, 255, 0.1); color: var(--muted); }
.meter-help { text-align: center; font-size: 12px; color: var(--muted); margin-top: 6px; }
.fields { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 6px; margin-bottom: 8px; }
.fields label { display: flex; flex-direction: column; font-size: 12px; color: var(--muted); gap: 2px; }
.fields input { width: 100%; padding: 6px 8px; font-size: 15px; }
#in-paste { flex: 1; resize: none; font-size: 13px; height: 36px; }
.lm-line { display: flex; align-items: center; gap: 8px; font-size: 14px; margin: 4px 0; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: #777; flex: none; }
.dot.on { background: var(--green); box-shadow: 0 0 8px var(--green); }
.check { display: flex; gap: 6px; align-items: center; cursor: pointer; }

#hud-shot { right: 12px; top: 96px; padding: 8px 10px; width: 356px; font-size: 13px; max-height: calc(100vh - 124px - var(--bottom-h, 160px)); overflow-y: auto; z-index: 3; }
@media (min-width: 1500px) { #hud-shot { max-height: calc(100vh - 110px); } }
#hud-shot h4 { margin: 0 0 6px; font-size: 14px; display: flex; gap: 8px; align-items: baseline; }
#hud-shot h4 small { margin-left: auto; }
#hud-shot h4 .x { background: none; border: none; padding: 0 2px; color: var(--muted); font-size: 13px; }
#hud-shot:not([hidden]) ~ #hud-map { display: none; }
#hud-shot h4 small { color: var(--muted); font-weight: 400; }
.tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 3px; }
.tile { background: rgba(0, 0, 0, 0.25); border-radius: 7px; padding: 3px 6px; }
.tile .k { font-size: 10px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile .v { font-size: 15px; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tile .v small { font-size: 10px; color: var(--muted); font-weight: 400; margin-left: 2px; }
.tile.hi { background: rgba(255, 211, 77, 0.18); }
.tiles-sep { grid-column: 1 / -1; font-size: 10.5px; color: var(--muted); margin-top: 3px; }
.dplane { display: flex; gap: 8px; align-items: center; margin-top: 6px; }
.dplane canvas { background: rgba(0, 0, 0, 0.25); border-radius: 8px; }
.dplane .txt { font-size: 12px; color: var(--muted); line-height: 1.4; }
.tour { font-size: 11.5px; color: var(--muted); margin-top: 6px; }
#hud-map { right: 12px; bottom: 12px; padding: 4px; }
#hud-map canvas { display: block; border-radius: 10px; }
#hud-tools { position: absolute; right: 12px; top: 96px; display: flex; flex-direction: column; gap: 6px; }
#hud-tools button { width: 44px; height: 40px; padding: 0; font-size: 18px; background: var(--glass); }
#hud-tools #btn-pickup { font-size: 11px; }
#hud-tools button.on { border-color: var(--accent); }
#hud-shot:not([hidden]) ~ #hud-tools { right: 380px; }
.hud-box, #hud-bottom, #hud-tools { z-index: 2; }
#pin-tag, #ball-tags { z-index: 1; }
.tag { position: absolute; transform: translate(-50%, -100%); pointer-events: none; font-size: 12px; font-weight: 700; padding: 3px 8px; border-radius: 10px; background: rgba(0, 0, 0, 0.55); white-space: nowrap; }
.tag::after { content: ''; position: absolute; left: 50%; bottom: -5px; margin-left: -5px; border: 5px solid transparent; border-top-color: rgba(0, 0, 0, 0.55); border-bottom: 0; }
#pin-tag { color: #fff; }
#ball-tags .tag { border: 1px solid var(--pc); }
#toast { position: absolute; left: 50%; top: 32%; transform: translate(-50%, -50%); pointer-events: none; text-align: center; }
#toast .t { font-size: 44px; font-weight: 900; text-shadow: 0 4px 18px rgba(0, 0, 0, 0.55); letter-spacing: -0.02em; animation: pop 2.2s ease forwards; }
#toast .s { font-size: 18px; font-weight: 700; text-shadow: 0 2px 8px rgba(0, 0, 0, 0.6); animation: pop 2.2s ease forwards; }
@keyframes pop { 0% { opacity: 0; transform: scale(0.7); } 12% { opacity: 1; transform: scale(1.05); } 20% { transform: scale(1); } 80% { opacity: 1; } 100% { opacity: 0; } }
#flash { position: absolute; inset: 0; pointer-events: none; background: #fff; opacity: 0; }

/* ---------- overlays ---------- */
.overlay { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; padding: 16px; background: rgba(4, 12, 8, 0.5); z-index: 10; }
.overlay.dim { background: rgba(4, 12, 8, 0.35); }
.loading-box { display: flex; gap: 12px; align-items: center; background: var(--glass2); padding: 14px 20px; border-radius: 14px; font-weight: 600; }
.spinner { width: 20px; height: 20px; border: 3px solid rgba(255, 255, 255, 0.25); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.howto { font-size: 15px; line-height: 1.6; }
.howto p { margin: 0 0 12px; }
#net-status { position: fixed; top: 0; left: 50%; transform: translateX(-50%); background: #b3412f; color: #fff; padding: 6px 14px; border-radius: 0 0 10px 10px; font-size: 14px; z-index: 20; }
/* sharing and the party relay: over every screen and overlay */
#notice { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 30; max-width: calc(100vw - 32px); background: var(--glass2); border: 1px solid var(--line); border-radius: 12px; padding: 10px 16px; font-size: 15px; font-weight: 700; text-align: center; pointer-events: none; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35); }
#relay-banner { position: fixed; left: 50%; top: 12px; transform: translateX(-50%); z-index: 30; width: min(620px, calc(100vw - 24px)); display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; background: var(--glass2); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border: 1px solid var(--accent); border-radius: 14px; padding: 10px 12px; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4); }
#relay-text { flex: 1 1 240px; font-weight: 700; line-height: 1.4; }
#card-foot { flex-wrap: wrap; }
button.share { border-color: var(--accent); color: var(--accent); font-weight: 700; }
.relay-row h3 { margin-top: 6px; }
.relay-games { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.relay-games button { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; text-align: left; padding: 10px 12px; }
.relay-games small { color: var(--muted); font-size: 12px; }

/* scorecard */
.sc-table { width: 100%; border-collapse: collapse; font-size: 14px; font-variant-numeric: tabular-nums; }
.sc-table th, .sc-table td { padding: 6px 4px; text-align: center; border-bottom: 1px solid var(--line); }
.sc-table th:first-child, .sc-table td:first-child { text-align: left; padding-left: 8px; white-space: nowrap; }
.sc-table .par td, .sc-table .len td { color: var(--muted); font-size: 12px; }
.sc-table .cur { background: rgba(255, 211, 77, 0.12); }
.sc-table tr.nine th { padding-top: 16px; }
.s-e { display: inline-grid; place-items: center; min-width: 26px; height: 26px; border-radius: 50%; }
.s-birdie { border: 2px solid var(--blue); }
.s-eagle { border: 2px solid var(--blue); box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.3), 0 0 0 4px var(--blue); }
.s-bogey { border: 2px solid var(--red); border-radius: 4px; }
.s-double { border: 2px solid var(--red); border-radius: 4px; box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.3), 0 0 0 4px var(--red); }
.sc-stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 8px; margin-top: 12px; font-size: 13px; color: var(--muted); }
.sc-stats b { color: var(--text); }
.podium { display: grid; gap: 8px; margin: 10px 0; }
.podium .row { background: rgba(255, 255, 255, 0.06); border-radius: 12px; padding: 10px 14px; gap: 12px; font-size: 16px; }
.podium .pos { font-size: 22px; font-weight: 900; width: 44px; }
.podium .first { background: linear-gradient(90deg, rgba(255, 211, 77, 0.3), rgba(255, 255, 255, 0.06)); }
.lm-help-body code, #lm-help-body code { display: block; background: rgba(0, 0, 0, 0.35); padding: 8px 10px; border-radius: 8px; margin: 6px 0 12px; font-size: 13px; overflow-x: auto; white-space: pre; user-select: text; -webkit-user-select: text; }
#lm-help-body p { font-size: 14px; line-height: 1.55; margin: 6px 0; }
.range-log { max-height: 180px; overflow-y: auto; font-size: 12px; }
.range-log-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 4px; }
.range-log-head .tiles-sep { margin: 0; }
.range-clear { padding: 2px 10px; font-size: 12px; border-radius: 7px; }

/* ---------- narrow / phone ---------- */
.shape-toggle { display: none; }
@media (max-width: 820px) and (min-height: 501px) {
  #hud-players { left: 12px; top: auto; bottom: calc(12px + var(--bottom-h, 150px)); flex-wrap: wrap; max-width: calc(100vw - 24px); }
  #hud-hole { padding: 6px 10px; min-width: 0; font-size: 12px; }
  .hole-no b { font-size: 20px; }
  .hole-pin b { font-size: 16px; }
  #hud-clubs { top: auto; bottom: calc(12px + var(--bottom-h, 150px) + 60px); flex-direction: row; max-width: calc(100vw - 24px); overflow-x: auto; max-height: none; left: 12px; }
  .club { min-width: 0; flex-direction: column; align-items: center; gap: 0; padding: 4px 8px; }
  #hud-shot { width: 262px; top: 80px; right: 8px; font-size: 12px; max-height: calc(100vh - 100px - var(--bottom-h, 150px)); }
  .tiles { grid-template-columns: repeat(3, 1fr); }
  .tile .v { font-size: 13px; }
  #hud-map { display: none; }
  #hud-tools { top: 80px; }
  #hud-shot:not([hidden]) ~ #hud-tools { right: 276px; }
  .pl { min-width: 70px; padding: 2px 8px; }
  #hud-turn { top: auto; bottom: calc(12px + var(--bottom-h, 150px) + 118px); font-size: 16px; }
}
/* Phones held sideways: everything hugs the edges, the middle stays for the course. */
@media (max-height: 500px) {
  #hud-hole { top: 6px; left: 6px; padding: 4px 8px; min-width: 0; font-size: 11px; }
  .hole-no b { font-size: 16px; }
  .hole-pin b { font-size: 14px; }
  #hud-players { top: 6px; left: 132px; bottom: auto; padding: 3px; max-width: calc(100vw - 260px); flex-wrap: nowrap; overflow-x: auto; }
  .pl { min-width: 0; padding: 1px 6px; font-size: 11px; }
  .pl .nm { max-width: 70px; }
  #hud-wind { top: 6px; right: 6px; padding: 2px 6px 2px 2px; }
  #hud-wind canvas { width: 40px; height: 40px; }
  #hud-wind b { font-size: 15px; }
  #hud-tools { top: 54px; right: 6px; gap: 4px; }
  #hud-tools button { width: 36px; height: 30px; font-size: 14px; }
  #hud-clubs { left: 6px; top: 86px; bottom: 8px; max-height: none; flex-direction: column; flex-wrap: nowrap; overflow-y: auto; overflow-x: hidden; padding: 3px; }
  .club { min-width: 0; flex-direction: column; align-items: center; gap: 0; padding: 2px 6px; font-size: 12px; }
  .club span { font-size: 10px; }
  #hud-bottom { width: min(560px, calc(100vw - 150px)); bottom: 6px; padding: 4px 8px 6px; left: calc(50% + 10px); }
  .tabs { margin-bottom: 4px; }
  .tabs button { padding: 3px 6px; font-size: 12px; }
  .shape-toggle { display: inline-block; flex: none !important; }
  .shape-row { display: none; margin-bottom: 4px; }
  #hud-bottom.shape-open .shape-row { display: flex; }
  .meter-track { height: 24px; }
  .swing-btn { min-width: 84px; padding: 8px 10px; font-size: 14px; }
  .meter-help { font-size: 10.5px; margin-top: 3px; }
  #hud-shot { width: 300px; top: 6px; right: 48px; max-height: calc(100vh - var(--bottom-h, 90px) - 20px); font-size: 11px; }
  #hud-shot .tiles { grid-template-columns: repeat(3, 1fr); }
  .tile .v { font-size: 12.5px; }
  .dplane canvas { width: 80px; height: 80px; }
  #hud-shot:not([hidden]) ~ #hud-tools { right: 6px; top: 54px; }
  #hud-map { display: none; }
  #hud-turn { top: 52px; font-size: 14px; }
  .fields { grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); }
  .fields input { padding: 3px 6px; font-size: 13px; }
  #toast .t { font-size: 30px; }
  .screen { align-items: flex-start; }
  .menu-card, .panel { padding: 14px; }
  .logo { margin-bottom: 8px; }
  .logo h1 { font-size: 24px; }
  .studio-banner { margin-top: 8px; padding: 6px 12px 6px 6px; }
  .studio-mark { padding: 6px 7px 6px 9px; font-size: 12px; }
  .studio-text b { font-size: 14px; }
}

/* shot lab */
.lab { display: grid; grid-template-columns: 300px 1fr; gap: 16px; }
@media (max-width: 800px) { .lab { grid-template-columns: 1fr; } }
.lab-row { display: grid; grid-template-columns: 110px 1fr 70px; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); margin: 4px 0; }
.lab-row select { grid-column: 2 / 4; }
.lab-row output { color: var(--text); text-align: right; font-variant-numeric: tabular-nums; }
.lab-presets { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 8px; }
.lab-presets button { padding: 4px 8px; font-size: 12px; }
.lab-out canvas { width: 100%; height: auto; display: block; margin-top: 6px; border-radius: 8px; }
.lab-out .tiles { grid-template-columns: repeat(4, 1fr); }
#lab-table td, #lab-table th { font-size: 12.5px; }

#rotate-hint { display: none; position: absolute; left: 50%; top: 88px; transform: translateX(-50%); background: rgba(0,0,0,.55); padding: 6px 12px; border-radius: 10px; font-size: 13px; pointer-events: none; white-space: nowrap; }
@media (orientation: portrait) and (max-width: 600px) { #rotate-hint { display: block; animation: fadeout 6s forwards; } }
@keyframes fadeout { 0%, 80% { opacity: 1; } 100% { opacity: 0; } }

/* ---------- tutorial ---------- */
.tut-offer { max-width: 420px; }
.tut-offer h2 { margin: 0 0 8px; }
.tut-offer p { color: var(--muted); line-height: 1.55; margin: 0 0 16px; }
.tut-card { position: fixed; z-index: 40; width: min(360px, calc(100vw - 24px)); background: var(--glass2); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border: 1px solid var(--accent); border-radius: var(--radius); padding: 12px 14px 10px; box-shadow: 0 12px 34px rgba(0, 0, 0, 0.45); }
.tut-head { display: flex; align-items: baseline; gap: 8px; font-size: 16px; }
.tut-head small { margin-left: auto; color: var(--muted); font-variant-numeric: tabular-nums; }
.tut-card p { margin: 6px 0 10px; font-size: 14px; line-height: 1.55; }
.tut-foot { display: flex; align-items: center; gap: 8px; }
.tut-foot button.link { padding: 4px 2px; font-size: 13px; }
.tut-done { color: var(--green); font-weight: 800; }
.tut-ring { position: fixed; z-index: 39; pointer-events: none; border: 2px solid var(--accent); border-radius: 12px; box-shadow: 0 0 0 4px rgba(255, 211, 77, 0.25); animation: tut-pulse 1.4s ease-in-out infinite; }
@keyframes tut-pulse { 50% { box-shadow: 0 0 0 9px rgba(255, 211, 77, 0.08); } }
@media (prefers-reduced-motion: reduce) { .tut-ring { animation: none; } }
@media (max-height: 600px) { .tut-card { width: min(300px, calc(100vw - 24px)); padding: 9px 12px 8px; } .tut-card p { font-size: 13px; line-height: 1.45; margin: 4px 0 6px; } }
