:root {
  --ink: #1b2a38;
  --muted: #566778;
  --paper: #fffdf7;
  --green: #2fae4a;
  --green-dark: #1f7f33;
  --pink: #ff3f6c;
  --sky: #4fa8ef;
  --glass: rgba(255, 255, 255, 0.82);
  --font: ui-rounded, 'SF Pro Rounded', 'Nunito', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --safe-l: max(12px, env(safe-area-inset-left));
  --safe-r: max(12px, env(safe-area-inset-right));
  --safe-b: max(10px, env(safe-area-inset-bottom));
  --safe-t: max(8px, env(safe-area-inset-top));
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--sky);
  font-family: var(--font);
  color: var(--ink);
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  touch-action: none;
}
canvas#game { position: fixed; inset: 0; width: 100%; height: 100%; display: block; cursor: grab; }
canvas#game:active { cursor: grabbing; }
.hidden { display: none !important; }
button { font-family: var(--font); }

/* ---------- Screens and cards ---------- */
.screen {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--safe-t) var(--safe-r) var(--safe-b) var(--safe-l);
  background: radial-gradient(ellipse at center, rgba(15, 40, 70, 0.15), rgba(15, 40, 70, 0.45));
  z-index: 20;
}
.card {
  background: var(--paper);
  border-radius: 26px;
  box-shadow: 0 14px 0 rgba(0, 0, 0, 0.08), 0 20px 50px rgba(10, 30, 60, 0.35);
  border: 3px solid #fff;
  padding: 18px 22px;
  width: min(420px, 100%);
  max-height: 100%;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  text-align: center;
  animation: pop 0.3s cubic-bezier(0.2, 1.4, 0.4, 1);
}
@keyframes pop { from { transform: scale(0.85) translateY(10px); opacity: 0; } }
.logo { margin: 0; font-size: 46px; letter-spacing: -1.5px; font-weight: 900; line-height: 1; }
.logo .g1 { color: var(--green); text-shadow: 0 3px 0 var(--green-dark); }
.logo .g2 { color: var(--pink); text-shadow: 0 3px 0 #c22650; }
.tag { margin: 0; color: var(--muted); font-weight: 600; }
h2 { margin: 0; font-size: 24px; font-weight: 900; }
.small { font-size: 13px; color: var(--muted); margin: 0; }
.field { display: flex; flex-direction: column; gap: 4px; font-size: 13px; font-weight: 700; color: var(--muted); text-align: left; }
.field input { font: inherit; font-size: 17px; font-weight: 700; padding: 9px 12px; border-radius: 14px; border: 2px solid #dbe5ec; background: #fff; color: var(--ink); }
.field input:focus { outline: none; border-color: var(--sky); }
.swatches { display: flex; justify-content: center; gap: 10px; }
.swatches button { width: 32px; height: 32px; border-radius: 50%; border: 3px solid #fff; box-shadow: 0 0 0 2px #dbe5ec, 0 3px 0 rgba(0,0,0,0.12); cursor: pointer; transition: transform 0.15s; }
.swatches button.on { box-shadow: 0 0 0 3px var(--ink); transform: scale(1.12); }
.btn {
  font-size: 19px;
  font-weight: 900;
  border: 0;
  border-radius: 18px;
  padding: 13px 16px;
  cursor: pointer;
  transition: transform 0.08s, box-shadow 0.08s;
}
.btn:disabled { opacity: 0.5; cursor: default; }
.btn-primary { background: linear-gradient(#45c75e, var(--green)); color: #fff; box-shadow: 0 5px 0 var(--green-dark); text-shadow: 0 1px 0 rgba(0,0,0,0.2); }
.btn-primary:active:not(:disabled) { transform: translateY(3px); box-shadow: 0 2px 0 var(--green-dark); }
.btn-ghost { background: #edf3f7; color: var(--ink); box-shadow: 0 4px 0 #d3dde5; }
.btn-ghost:active { transform: translateY(2px); box-shadow: 0 2px 0 #d3dde5; }
.link-btn { background: none; border: 0; color: #2f7de2; font-weight: 700; cursor: pointer; padding: 4px; font-size: 15px; }
.howto { text-align: left; font-size: 14px; color: var(--muted); }
.howto summary { cursor: pointer; font-weight: 800; color: var(--ink); text-align: center; }
.howto ul { margin: 8px 0 0; padding-left: 18px; display: flex; flex-direction: column; gap: 4px; }

/* ---------- HUD (as the original: plain white text, no panels) ---------- */
#hud {
  position: fixed;
  top: var(--safe-t);
  left: var(--safe-l);
  right: var(--safe-r);
  display: flex;
  align-items: flex-start;
  gap: 8px;
  pointer-events: none;
  z-index: 5;
  color: #fff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.55);
}
.hud-hole { display: flex; align-items: flex-start; gap: 12px; }
.hud-num { display: flex; flex-direction: column; line-height: 0.95; }
.hud-num small { font-size: 13px; font-weight: 900; letter-spacing: 0.5px; }
.hud-num b { font-size: 38px; font-weight: 900; }
.hud-meta { display: flex; flex-direction: column; font-size: 13px; font-weight: 900; letter-spacing: 0.5px; line-height: 1.25; }
.hud-right { margin-left: auto; display: flex; align-items: flex-start; gap: 10px; }
#hud-board { list-style: none; margin: 0; padding: 0; display: flex; gap: 12px; font-size: 13px; }
#hud-board:empty { display: none; }
#hud-board li { display: flex; align-items: center; gap: 5px; font-weight: 900; }
#hud-board li.in { opacity: 0.55; }
#hud-board li .pts { font-size: 15px; }
.dot { width: 12px; height: 12px; border-radius: 50%; display: inline-block; border: 2px solid #fff; box-shadow: 0 0 0 1px rgba(0,0,0,0.2); flex: none; }
.pause-btn, .ghost-btn {
  pointer-events: auto; background: none; border: 0; cursor: pointer; padding: 6px;
  display: flex; gap: 5px; align-items: center; justify-content: center;
  filter: drop-shadow(0 1px 2px rgba(0,0,0,0.5));
}
.pause-btn i { display: block; width: 7px; height: 22px; border-radius: 2px; background: #fff; }
.ghost-btn { font-size: 20px; }

/* ---------- On-screen controls ---------- */
#controls { position: fixed; inset: 0; pointer-events: none; z-index: 4; }
.pad { position: absolute; bottom: var(--safe-b); display: flex; align-items: flex-end; gap: 12px; pointer-events: auto; }
.pad-left { left: calc(var(--safe-l) + 30px); bottom: calc(var(--safe-b) + 10px); }
.pad-right { right: var(--safe-r); }

/* Dark see-through buttons with a thick pale outline, as the original. */
.aim-btn, .view-btn, .go {
  border: 3.5px solid #d9dde0;
  background: rgba(30, 34, 38, 0.38);
  color: #e9ecee;
  box-shadow: inset 0 0 0 1.5px rgba(0, 0, 0, 0.35), 0 0 0 1.5px rgba(0, 0, 0, 0.35);
  cursor: pointer; touch-action: none;
  -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px);
  transition: transform 0.06s, background 0.06s;
}
.aim-btn { width: 92px; height: 42px; border-radius: 21px; padding: 8px 0; border-width: 4px; background: rgba(28, 30, 33, 0.5); }
.aim-btn svg { height: 100%; display: block; margin: 0 auto; filter: drop-shadow(0 1px 0 rgba(0,0,0,0.4)); }
.view-btn { width: 50px; height: 50px; border-radius: 50%; padding: 6px; margin-bottom: -5px; }
.view-btn svg { width: 100%; height: 100%; display: block; fill: #e9ecee; stroke: #e9ecee; }
.aim-btn.held, .view-btn:active { transform: scale(0.94); background: rgba(30, 34, 38, 0.6); }
#controls.busy .aim-btn, #controls.busy .go-wrap { opacity: 0.45; pointer-events: none; }

.go-wrap { position: relative; width: 150px; height: 150px; }
#controls.busy .go-wrap { opacity: 0; pointer-events: none; }

/* The meter: a C-shaped bezel round the GO button, only while it runs. */
.meter { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; pointer-events: none; transition: opacity 0.12s; filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.45)); }
#controls.idle .meter { opacity: 0; }
.meter-rim { fill: none; stroke: #eef0f2; stroke-width: 31; stroke-linecap: butt; }
.meter-track { fill: none; stroke: #18191b; stroke-width: 24; stroke-linecap: butt; }
.meter-seg { stroke: #2c2e31; stroke-width: 2.4; }
.meter-fill { fill: none; stroke: #7ff03c; stroke-width: 24; stroke-linecap: butt; }
.meter-dash { stroke: rgba(255, 255, 255, 0.92); stroke-linecap: round; opacity: 0; }
.meter-dash.on { opacity: 1; }
.meter-perfect { fill: none; stroke: #ffd23f; stroke-width: 24; stroke-linecap: butt; opacity: 0.35; }
.meter-star { fill: #ffd23f; font: 900 15px var(--font); text-anchor: middle; filter: drop-shadow(0 1px 1px rgba(0,0,0,0.7)); }
#controls.perfect .meter-perfect { opacity: 1; filter: drop-shadow(0 0 7px #ffd23f); }
#controls.perfect .meter-fill { stroke: #c8ff6a; }

/* GO: a glossy charcoal button in a thick pale ring, with a white club. */
.go {
  position: absolute; right: 4px; bottom: 6px;
  width: 92px; height: 92px; border-radius: 50%;
  border: 0; padding: 0;
  background: radial-gradient(circle at 50% 30%, #55585c 0%, #2a2c2f 45%, #141516 100%);
  box-shadow: 0 0 0 5px #d3d6d9, 0 0 0 6.5px rgba(0, 0, 0, 0.45), inset 0 3px 3px rgba(255, 255, 255, 0.18), inset 0 -4px 8px rgba(0, 0, 0, 0.6), 0 6px 12px 4px rgba(0, 0, 0, 0.35);
  -webkit-backdrop-filter: none; backdrop-filter: none;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  cursor: pointer; touch-action: none;
  transition: transform 0.06s, background 0.08s;
}
.go-ring { display: none; }
.go-icon { width: 58px; height: 44px; background: no-repeat center / contain; filter: drop-shadow(0 1.5px 0 rgba(0,0,0,0.45)); }
.go b { display: none; }
.go:active { transform: scale(0.95); }
/* Power set: the whole button turns lime, as the original's does. */
#controls.locked .go { background: radial-gradient(circle at 50% 30%, #c8ff8a 0%, #7ff03c 50%, #4cc21c 100%); }
#controls.locked .go-icon { filter: drop-shadow(0 1px 0 rgba(0,60,0,0.5)) brightness(0.92); }
#controls.perfect .go { background: radial-gradient(circle at 50% 30%, #fff3a8 0%, #ffd23f 55%, #e0a400 100%); box-shadow: 0 0 0 5px #fff1b3, 0 0 0 6.5px rgba(0, 0, 0, 0.45), 0 0 24px 8px rgba(255, 210, 63, 0.75); }
.go-icon.iron { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 54 40'%3E%3Cpath d='M44 3 L30 25' stroke='white' stroke-width='4' stroke-linecap='round'/%3E%3Cpath d='M31 22 Q20 21 10 25 Q4 28 6 33 Q8 37 16 36 L33 33 Q37 32 36 27 Z' fill='white'/%3E%3Cpath d='M12 30 L30 27 M12 33 L31 30' stroke='%23c9d0d6' stroke-width='1.4' stroke-linecap='round'/%3E%3C/svg%3E"); }
.go-icon.putter { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 54 40'%3E%3Cpath d='M36 3 L30 26' stroke='white' stroke-width='4' stroke-linecap='round'/%3E%3Cpath d='M12 26 H34 Q38 26 38 30 V32 Q38 35 34 35 H14 Q10 35 10 31 V29 Q10 26 12 26 Z' fill='white'/%3E%3C/svg%3E"); }
.go b { display: none; font-size: 15px; font-weight: 900; letter-spacing: 1px; line-height: 1; }
.go:active { transform: scale(0.95); }
@keyframes flash { 50% { filter: brightness(1.4); } }

/* Spin: an outlined curved track with a SPIN knob to slide along it. */
.spin { touch-action: none; cursor: grab; animation: pop 0.25s cubic-bezier(0.2, 1.4, 0.4, 1); }
.dial { width: 150px; height: 150px; overflow: visible; display: block; filter: drop-shadow(0 0 1.5px rgba(0, 0, 0, 0.5)); }
.dial-track { fill: rgba(30, 34, 38, 0.38); stroke: #d9dde0; stroke-width: 3.5; stroke-linejoin: round; }
.dial-mid { stroke: rgba(217, 221, 224, 0.7); stroke-width: 2.5; }
.dial-icon path { fill: none; stroke: #d9dde0; stroke-width: 2.6; stroke-linecap: round; }
.dial-icon path.fill { fill: #d9dde0; stroke: none; }
.dial-knob circle { fill: #fff; stroke: #e7e9eb; stroke-width: 2; }
.dial-knob text { fill: #ff2f72; font: 900 11px var(--font); text-anchor: middle; letter-spacing: 0.3px; }
.spin:active .dial-knob circle { fill: #ffeef3; }

.hint {
  position: absolute; left: 50%; top: calc(var(--safe-t) + 4px); transform: translateX(-50%);
  max-width: min(46vw, 420px);
  background: rgba(20, 30, 40, 0.5);
  color: #fff; font-size: 13px; font-weight: 800; text-align: center;
  padding: 5px 12px; border-radius: 12px;
  box-shadow: 0 4px 14px rgba(0,0,0,0.25);
  transition: opacity 0.2s;
}
.hint:empty { opacity: 0; }
.hint kbd { background: rgba(255,255,255,0.2); border-radius: 6px; padding: 0 5px; font-family: var(--font); }

/* ---------- Banners ---------- */
#banner {
  position: fixed; top: 20%; left: 50%; transform: translateX(-50%);
  font-size: 48px; font-weight: 900; color: #fff;
  -webkit-text-stroke: 1.5px rgba(20, 40, 60, 0.35);
  text-shadow: 0 4px 0 rgba(20,40,60,0.3), 0 0 24px rgba(0,0,0,0.25);
  pointer-events: none; z-index: 6; text-align: center; white-space: nowrap;
  animation: bannerIn 0.35s cubic-bezier(0.2, 1.6, 0.4, 1);
}
#banner small { display: block; font-size: 18px; font-weight: 800; -webkit-text-stroke: 0; }
@keyframes bannerIn { from { transform: translateX(-50%) scale(0.5); opacity: 0; } }
#waiting {
  position: fixed; top: 64px; left: 50%; transform: translateX(-50%);
  background: rgba(0,0,0,0.6); color: #fff; padding: 6px 14px; border-radius: 12px;
  font-size: 14px; font-weight: 700; z-index: 6;
}

.results { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 6px; text-align: left; }
.results li { display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-radius: 12px; background: #eef4f8; font-weight: 700; }
.results li.me { background: #ddf5d8; font-weight: 900; }
.results li .pts { margin-left: auto; font-weight: 900; }
.mp-hosts { display: flex; flex-direction: column; gap: 8px; }
.big-score { font-size: 40px; font-weight: 900; margin: 0; }

@media (max-height: 420px) {
  .go-wrap { transform: scale(0.9); transform-origin: bottom right; }
  .dial { width: 136px; height: 136px; }
  #banner { font-size: 40px; top: 18%; }
}
}
