:root {
  --ink: #f6f3ea;
  --dim: rgba(246, 243, 234, 0.7);
  --glass: rgba(18, 22, 38, 0.62);
  --line: rgba(255, 255, 255, 0.14);
  --gold: #ffcf4a;
  --hot: #ff7a45;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #0b0d16; color: var(--ink);
  font: 15px/1.4 Inter, system-ui, sans-serif; user-select: none; -webkit-user-select: none; }
#c { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; cursor: grab; }
#c:active { cursor: grabbing; }
.hidden { display: none !important; }
button { font: inherit; color: inherit; cursor: pointer; }

#loading { position: fixed; inset: 0; display: grid; place-items: center; background: #0b0d16; font-family: 'Baloo 2', sans-serif;
  font-size: 22px; letter-spacing: 0.04em; z-index: 50; transition: opacity 0.6s; }

/* ---------- HUD ---------- */
.card { position: fixed; background: var(--glass); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--line); border-radius: 16px; padding: 10px 14px; }
.hole-info { top: 14px; left: 14px; min-width: 190px; }
.hole-num { font: 800 13px 'Baloo 2', sans-serif; letter-spacing: 0.18em; text-transform: uppercase; color: var(--gold); }
.hole-name { font: 800 26px/1.05 'Baloo 2', sans-serif; margin-top: 2px; }
.hole-meta { color: var(--dim); font-size: 13px; }
.players { top: 14px; right: 14px; min-width: 200px; padding: 8px 10px; }
.players .p { display: grid; grid-template-columns: 14px 1fr auto auto; gap: 8px; align-items: center; padding: 3px 4px; border-radius: 8px; font-size: 14px; }
.players .p.active { background: rgba(255, 255, 255, 0.1); }
.players .dot { width: 12px; height: 12px; border-radius: 50%; box-shadow: 0 0 8px currentColor; }
.players .strokes { font: 700 16px 'Baloo 2', sans-serif; min-width: 18px; text-align: right; }
.players .tot { color: var(--dim); font-size: 12px; min-width: 30px; text-align: right; }
.players .done { color: #8ff0a4; }
.turn { position: fixed; top: 18px; left: 50%; transform: translateX(-50%); font: 700 18px 'Baloo 2', sans-serif;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.6); pointer-events: none; }

.controls { position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%); display: flex; flex-direction: column;
  align-items: center; gap: 8px; width: min(560px, calc(100vw - 24px)); }
.club-row { display: flex; gap: 10px; align-items: center; }
.clubs { display: flex; gap: 6px; }
.look { background: var(--glass); border: 1px solid var(--line); border-radius: 12px; padding: 6px 12px; font: 700 14px 'Baloo 2', sans-serif; backdrop-filter: blur(8px); }
.look.on { background: #3fd6ff; color: #04212b; border-color: #3fd6ff; }
.clubs button { background: var(--glass); border: 1px solid var(--line); border-radius: 12px; padding: 6px 14px;
  font: 700 15px 'Baloo 2', sans-serif; backdrop-filter: blur(8px); }
.clubs button .k { opacity: 0.55; margin-right: 6px; font-size: 12px; }
.clubs button.on { background: var(--gold); color: #251c05; border-color: var(--gold); }
.clubs button:disabled { opacity: 0.3; cursor: not-allowed; }
.power-row { display: flex; gap: 8px; align-items: center; width: 100%; }
.loft { display: flex; align-items: center; gap: 4px; background: var(--glass); border: 1px solid var(--line);
  border-radius: 12px; padding: 4px 6px; font-size: 13px; white-space: nowrap; backdrop-filter: blur(8px); }
.loft button { width: 24px; height: 24px; border-radius: 8px; border: 1px solid var(--line); background: rgba(255, 255, 255, 0.08); }
.loft.off { opacity: 0.35; pointer-events: none; }
.meter { position: relative; flex: 1; height: 26px; border-radius: 13px; background: rgba(10, 12, 22, 0.7); border: 1px solid var(--line); overflow: hidden; }
.meter .fill { position: absolute; inset: 0 auto 0 0; width: 0; background: linear-gradient(90deg, #3ddc84, #ffcf4a 60%, #ff5a36); border-radius: 13px; }
.meter .ghost { position: absolute; top: 0; bottom: 0; width: 3px; background: #fff; opacity: 0.55; left: 50%; }
.swing { background: var(--hot); border: none; border-radius: 13px; padding: 0 16px; height: 36px;
  font: 800 15px 'Baloo 2', sans-serif; color: #fff; box-shadow: 0 4px 18px rgba(255, 122, 69, 0.45); white-space: nowrap; touch-action: none; }
.swing:active { transform: scale(0.97); }
.help { position: fixed; left: 14px; bottom: 14px; max-width: 260px; font-size: 12px; color: var(--dim);
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.7); pointer-events: none; }
.toast { position: fixed; top: 58px; left: 50%; transform: translateX(-50%); padding: 6px 14px; border-radius: 12px;
  background: rgba(0, 0, 0, 0.5); font-weight: 600; opacity: 0; transition: opacity 0.3s; pointer-events: none; }
.toast.on { opacity: 1; }
.bigmsg { position: fixed; top: 34%; left: 50%; transform: translate(-50%, -50%) scale(0.8); font: 800 clamp(40px, 8vw, 88px)/1 'Baloo 2', sans-serif;
  text-align: center; opacity: 0; pointer-events: none; transition: opacity 0.35s, transform 0.35s;
  text-shadow: 0 4px 0 rgba(0, 0, 0, 0.25), 0 0 30px rgba(255, 207, 74, 0.6); color: var(--gold); }
.bigmsg.on { opacity: 1; transform: translate(-50%, -50%) scale(1); }
.bigmsg small { display: block; font-size: 0.32em; color: var(--ink); letter-spacing: 0.04em; margin-top: 6px; }
.holecard { position: fixed; left: 50%; bottom: 22%; transform: translateX(-50%); text-align: center; pointer-events: none;
  text-shadow: 0 3px 16px rgba(0, 0, 0, 0.7); animation: rise 0.6s ease-out; }
.holecard .n { font: 800 16px 'Baloo 2', sans-serif; letter-spacing: 0.3em; color: var(--gold); text-transform: uppercase; }
.holecard .t { font: 800 clamp(40px, 7vw, 76px)/1 'Baloo 2', sans-serif; }
.holecard .m { font-size: 16px; color: var(--ink); margin-top: 6px; }
.holecard .tip { max-width: 520px; margin: 8px auto 0; color: var(--dim); font-size: 15px; }
.holecard .skip { margin-top: 14px; font-size: 12px; color: var(--dim); }
@keyframes rise { from { opacity: 0; transform: translate(-50%, 20px); } to { opacity: 1; transform: translate(-50%, 0); } }

/* ---------- screens ---------- */
.screen { position: fixed; inset: 0; display: grid; place-items: center; background: radial-gradient(ellipse at center, rgba(10, 12, 24, 0.15), rgba(10, 12, 24, 0.7)); z-index: 10; padding: 16px; }
.title-box { background: var(--glass); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); border: 1px solid var(--line);
  border-radius: 24px; padding: 26px 28px; width: min(470px, 100%); max-height: calc(100vh - 32px); overflow: auto;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.45); }
.title-box.small { width: min(320px, 100%); text-align: center; }
h1 { margin: 0; font: 800 64px/0.9 'Baloo 2', sans-serif; letter-spacing: -0.01em; }
h1 span { color: var(--gold); margin-left: 10px; }
h2 { margin: 0 0 12px; font: 800 32px 'Baloo 2', sans-serif; }
.sub { margin: 6px 0 18px; color: var(--dim); }
.field { margin-bottom: 14px; }
.field.two { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.field label { display: block; font-size: 12px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--dim); margin-bottom: 6px; }
.seg { display: flex; background: rgba(0, 0, 0, 0.25); border-radius: 12px; padding: 3px; gap: 3px; }
.seg.wrap { flex-wrap: wrap; }
.seg button { flex: 1; border: none; background: transparent; border-radius: 9px; padding: 7px 8px; font-weight: 600; font-size: 14px; white-space: nowrap; }
.seg button.on { background: var(--gold); color: #251c05; }
.names { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-top: 8px; }
.names label { display: flex; align-items: center; gap: 6px; margin: 0; text-transform: none; letter-spacing: 0; }
.names .dot { width: 12px; height: 12px; border-radius: 50%; flex: none; }
.names input { width: 100%; background: rgba(0, 0, 0, 0.3); border: 1px solid var(--line); border-radius: 8px; color: var(--ink);
  font: inherit; padding: 5px 8px; user-select: text; }
.play { width: 100%; margin-top: 6px; padding: 12px; border: none; border-radius: 14px; background: var(--hot); color: #fff;
  font: 800 24px 'Baloo 2', sans-serif; box-shadow: 0 6px 24px rgba(255, 122, 69, 0.5); }
.play:hover { filter: brightness(1.08); }
.best { text-align: center; color: var(--dim); font-size: 13px; margin: 8px 0 0; min-height: 1em; }
.how { margin-top: 10px; color: var(--dim); font-size: 13px; }
.how summary { cursor: pointer; color: var(--ink); }
.how ul { padding-left: 18px; margin: 8px 0 0; }
.how li { margin-bottom: 4px; }
.menu-btn { display: block; width: 100%; margin: 8px 0; padding: 10px; border-radius: 12px; border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.08); font-weight: 600; }
.menu-btn:hover { background: rgba(255, 255, 255, 0.16); }

.score-box { background: var(--glass); backdrop-filter: blur(14px); border: 1px solid var(--line); border-radius: 22px;
  padding: 22px 24px; max-width: calc(100vw - 32px); overflow: auto; box-shadow: 0 20px 60px rgba(0, 0, 0, 0.45); }
.score-box h2 { text-align: center; }
.score-box table { border-collapse: collapse; margin: 0 auto; font-variant-numeric: tabular-nums; }
.score-box th, .score-box td { padding: 6px 9px; text-align: center; border-bottom: 1px solid var(--line); }
.score-box th { font-size: 12px; color: var(--dim); font-weight: 600; }
.score-box td.name { text-align: left; font-weight: 600; white-space: nowrap; }
.score-box td .s { display: inline-grid; place-items: center; min-width: 28px; height: 28px; border-radius: 8px; font-weight: 700; }
.s.ace { background: #ffcf4a; color: #251c05; }
.s.eagle { background: #7c5cff; }
.s.birdie { background: #2fbf71; }
.s.par { background: rgba(255, 255, 255, 0.1); }
.s.bogey { background: #b3543a; }
.s.worse { background: #7a2f2f; }
.score-box .tot { font: 800 18px 'Baloo 2', sans-serif; }
.score-box .current { outline: 2px solid var(--gold); outline-offset: -2px; border-radius: 6px; }
.score-box .winner { text-align: center; font: 800 26px 'Baloo 2', sans-serif; color: var(--gold); margin: 14px 0 4px; }
.score-box .actions { display: flex; gap: 10px; justify-content: center; margin-top: 14px; }
.score-box .actions button { padding: 10px 18px; border-radius: 12px; border: none; font: 800 18px 'Baloo 2', sans-serif; background: var(--hot); color: #fff; }
.score-box .actions button.alt { background: rgba(255, 255, 255, 0.12); }

@media (max-width: 700px) {
  .help { display: none; }
  .hole-name { font-size: 20px; }
  .players { top: auto; bottom: 150px; right: 10px; min-width: 0; }
  h1 { font-size: 48px; }
}

/* ---------- polish ---------- */
.meter { box-shadow: inset 0 1px 6px rgba(0, 0, 0, 0.45); }
.meter::after { content: ''; position: absolute; inset: 0; pointer-events: none; border-radius: 13px;
  background: repeating-linear-gradient(90deg, transparent 0 calc(10% - 1px), rgba(255, 255, 255, 0.14) calc(10% - 1px) 10%); }
.meter .fill { box-shadow: 0 0 14px rgba(255, 190, 80, 0.75), inset 0 1px 0 rgba(255, 255, 255, 0.5); }
.meter .ghost { box-shadow: 0 0 6px #fff; }
.swing { transition: transform 0.08s, box-shadow 0.2s; }
.swing:hover { box-shadow: 0 6px 26px rgba(255, 122, 69, 0.7); }
.card, .clubs button, .loft, .look { box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25), inset 0 1px 0 rgba(255, 255, 255, 0.08); }
.holecard .num { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -58%); z-index: -1;
  font: 800 clamp(140px, 22vw, 260px)/1 'Baloo 2', sans-serif; color: transparent;
  -webkit-text-stroke: 2px rgba(255, 207, 74, 0.35); letter-spacing: -0.04em; }
.holecard .t { color: #fff; text-shadow: 0 4px 18px rgba(0, 0, 0, 0.55), 0 0 2px rgba(0, 0, 0, 0.4); }
.bigmsg { background: linear-gradient(180deg, #fff6c8, #ffcf4a 60%, #ff9a3d); -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 6px 18px rgba(0, 0, 0, 0.45)) drop-shadow(0 0 24px rgba(255, 207, 74, 0.55)); text-shadow: none; }
.bigmsg small { -webkit-text-fill-color: var(--ink); }
.bigmsg.on { animation: pop 0.45s cubic-bezier(0.2, 1.6, 0.4, 1); }
@keyframes pop { from { transform: translate(-50%, -50%) scale(0.5); } to { transform: translate(-50%, -50%) scale(1); } }
.title-box h1 span { background: linear-gradient(180deg, #fff1b8, #ffcf4a 55%, #ff9a3d); -webkit-background-clip: text; background-clip: text; color: transparent; }
.holecard { padding: 34px 60px 26px; }
.holecard::before { content: ''; position: absolute; inset: -40px -80px; z-index: -2; border-radius: 50%;
  background: radial-gradient(ellipse at center, rgba(8, 10, 22, 0.62) 0%, rgba(8, 10, 22, 0.35) 45%, rgba(8, 10, 22, 0) 72%); }
