* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; overflow: hidden; }
body {
  font-family: system-ui, -apple-system, sans-serif;
  background: #14482c;
  color: #fff;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

#game-canvas {
  position: fixed; inset: 0;
  width: 100vw; height: 100vh;
  touch-action: none;
}

.hidden { display: none !important; }

/* ---------------------------------------------------------- screens */

.screen {
  position: fixed; inset: 0;
  display: grid; place-items: center;
  background: radial-gradient(ellipse at 50% 30%, #1e6b40 0%, #14482c 70%);
  overflow-y: auto;
  padding: 16px;
  z-index: 10;
}
.screen.passthru { pointer-events: none; background: none; }

.card {
  background: rgba(10, 34, 20, 0.92);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 18px;
  padding: 28px;
  width: min(430px, 94vw);
  box-shadow: 0 18px 60px rgba(0,0,0,0.4);
  text-align: center;
}
.card.wide { width: min(560px, 94vw); }

h1 { font-size: 2.4rem; letter-spacing: -0.5px; }
h1 span { font-size: 2rem; }
h2 { font-size: 1.4rem; margin-bottom: 14px; }
h3 { font-size: 0.85rem; text-transform: uppercase; letter-spacing: 1px; opacity: 0.7; margin: 14px 0 6px; }
.tagline { opacity: 0.8; margin: 8px 0 22px; }
.muted { opacity: 0.6; font-size: 0.9rem; margin-top: 10px; }

button {
  font: inherit;
  border: 0;
  border-radius: 12px;
  padding: 10px 18px;
  background: rgba(255,255,255,0.12);
  color: #fff;
  cursor: pointer;
  transition: transform 0.06s, background 0.15s;
}
button:hover { background: rgba(255,255,255,0.2); }
button:active { transform: scale(0.97); }
button.primary { background: #35b26b; font-weight: 700; }
button.primary:hover { background: #3fc97a; }
button.big { width: 100%; padding: 14px; font-size: 1.05rem; margin-top: 14px; }

input, select {
  font: inherit;
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 10px;
  background: rgba(0,0,0,0.3);
  color: #fff;
  padding: 10px 12px;
  width: 100%;
}
input:focus, select:focus { outline: 2px solid #35b26b; }

.joinrow { display: flex; gap: 8px; margin-top: 18px; }
.joinrow input { text-transform: uppercase; letter-spacing: 3px; text-align: center; font-weight: 700; }

/* --------------------------------------------------------- cosmetics */

.swatches { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.swatch {
  width: 34px; height: 34px; border-radius: 50%;
  border: 3px solid transparent; padding: 0;
}
.swatch.sel { border-color: #fff; transform: scale(1.1); }
.hat { width: 40px; height: 40px; font-size: 1.15rem; border-radius: 10px; padding: 0; }
.hat.sel { background: #35b26b; }

/* ------------------------------------------------------------- lobby */

.code { font-family: ui-monospace, monospace; letter-spacing: 4px; color: #7ee787; }
.sharebox { background: rgba(0,0,0,0.28); border-radius: 12px; padding: 12px; margin-bottom: 14px; }
.linktext { font-family: ui-monospace, monospace; font-size: 0.8rem; opacity: 0.85; word-break: break-all; margin-bottom: 10px; user-select: all; }
.sharebtns { display: flex; gap: 8px; justify-content: center; }
.sharebtns button { flex: 1; }

#lobby-players { list-style: none; display: flex; flex-direction: column; gap: 6px; margin: 8px 0 14px; }
.player-chip {
  display: flex; align-items: center; gap: 10px;
  background: rgba(255,255,255,0.07);
  padding: 8px 12px; border-radius: 10px;
  text-align: left;
}
.player-chip.dc { opacity: 0.45; }
.player-chip .kick { margin-left: auto; padding: 2px 9px; border-radius: 8px; background: rgba(224,69,69,0.35); }
.dot { width: 14px; height: 14px; border-radius: 50%; display: inline-block; flex-shrink: 0; border: 2px solid rgba(255,255,255,0.6); }

.options { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; text-align: left; }
.options label { font-size: 0.82rem; opacity: 0.9; display: flex; flex-direction: column; gap: 4px; }
.options label.check { flex-direction: row; align-items: center; gap: 8px; }
.options label.check input { width: auto; }

/* --------------------------------------------------------------- HUD */

#hud {
  position: fixed; top: 0; left: 0; right: 0;
  z-index: 20; pointer-events: none;
  display: flex; flex-direction: column; align-items: center;
}
.hud-top {
  display: flex; gap: 16px; align-items: baseline;
  background: rgba(8, 28, 16, 0.82);
  border-radius: 0 0 14px 14px;
  padding: 8px 18px;
  font-size: 0.9rem;
  backdrop-filter: blur(4px);
}
#hud-hole { font-weight: 700; }
#hud-par { opacity: 0.75; }
#hud-timer { font-family: ui-monospace, monospace; font-weight: 700; color: #7ee787; min-width: 3ch; }
#hud-timer.low { color: #f06a4d; animation: pulse 1s infinite; }
#hud-strokes { opacity: 0.9; }
#hud-conn {
  margin-top: 6px; background: #b3541e; border-radius: 8px;
  padding: 3px 12px; font-size: 0.8rem; animation: pulse 1.2s infinite;
}
@keyframes pulse { 50% { opacity: 0.45; } }

#banner {
  position: fixed; top: 22vh; left: 50%; transform: translateX(-50%);
  z-index: 30; pointer-events: none;
  font-size: clamp(1.6rem, 6vw, 3rem); font-weight: 900;
  text-shadow: 0 3px 14px rgba(0,0,0,0.6);
  letter-spacing: 1px;
}
#banner.pop { animation: bannerpop 0.45s cubic-bezier(0.2, 2.2, 0.4, 1); }
@keyframes bannerpop { 0% { transform: translateX(-50%) scale(0.3); opacity: 0; } 100% { transform: translateX(-50%) scale(1); opacity: 1; } }

/* ---------------------------------------------------------- overlays */

.overlay {
  position: fixed; inset: 0; z-index: 40;
  display: grid; place-items: center;
  background: rgba(0, 10, 5, 0.55);
  overflow-y: auto; padding: 16px;
}
.results { width: 100%; border-collapse: collapse; }
.results td { padding: 7px 8px; text-align: left; border-bottom: 1px solid rgba(255,255,255,0.08); }
.results td:nth-child(3) { font-weight: 800; }
.results td:last-child { text-align: right; font-family: ui-monospace, monospace; }

#podium-list { list-style: none; margin-bottom: 16px; }
#podium-list li {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border-radius: 10px; margin-bottom: 6px;
  background: rgba(255,255,255,0.07);
  text-align: left;
}
#podium-list li.place-1 { background: linear-gradient(90deg, rgba(255,200,60,0.3), rgba(255,255,255,0.06)); font-weight: 800; }
.pname { flex: 1; }
.pscore { font-family: ui-monospace, monospace; }

.scorecard { overflow-x: auto; margin-bottom: 14px; }
.scorecard table { border-collapse: collapse; margin: 0 auto; font-size: 0.82rem; }
.scorecard th, .scorecard td { padding: 4px 7px; border: 1px solid rgba(255,255,255,0.12); text-align: center; }
.scorecard td:first-child { text-align: left; max-width: 12ch; overflow: hidden; text-overflow: ellipsis; }

/* ------------------------------------------------------------ toasts */

/* ------------------------------------------------- practice controls */

#practice-controls {
  position: fixed; left: 14px; bottom: 18px; z-index: 25;
  display: flex; gap: 8px;
}
#practice-controls button {
  width: 46px; height: 46px; border-radius: 12px;
  font-size: 1.15rem;
  background: rgba(8, 28, 16, 0.8);
  border: 1px solid rgba(255,255,255,0.15);
}

#practice-course-row select { margin-top: 4px; }

/* ---------------------------------------------------- corner buttons */

.corner-btn {
  position: fixed; z-index: 25;
  width: 48px; height: 48px;
  border-radius: 50%;
  font-size: 1.3rem;
  background: rgba(8, 28, 16, 0.8);
  border: 1px solid rgba(255,255,255,0.15);
  display: grid; place-items: center;
}
.corner-btn.tl { top: 12px; left: 12px; }
.corner-btn.br { right: 14px; bottom: 18px; }

#emote-panel {
  position: fixed; right: 14px; bottom: 76px; z-index: 26;
  display: grid; grid-template-columns: repeat(4, 46px); gap: 6px;
  background: rgba(8, 28, 16, 0.92);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 14px; padding: 8px;
}
#emote-panel button { font-size: 1.25rem; padding: 8px 0; }

#toasts {
  position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%);
  z-index: 50; display: flex; flex-direction: column; gap: 8px; align-items: center;
  pointer-events: none;
}
.toast {
  background: rgba(8, 28, 16, 0.92);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 12px;
  padding: 9px 16px;
  font-size: 0.9rem;
  animation: toastin 0.25s ease-out;
  transition: opacity 0.4s;
  max-width: 90vw;
}
.toast.gone { opacity: 0; }
@keyframes toastin { from { transform: translateY(12px); opacity: 0; } }
