/* ===== LEXIGOLF STYLES ===== */

:root {
  --bg-dark: #0f1a0f;
  --bg-card: #1a2e1a;
  --bg-input: #1e3520;
  --text-primary: #e8f5e8;
  --text-secondary: #9cc49c;
  --text-muted: #5a8a5a;
  --accent-gold: #d4a843;
  --accent-green: #3da33d;
  --accent-red: #c0392b;
  --accent-purple: #8e44ad;
  --border: #2d4a2d;
  --font-display: 'Playfair Display', Georgia, serif;
  --font-body: 'Inter', -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: var(--font-body);
  background: var(--bg-dark);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
}

/* ===== SCREENS ===== */

.screen {
  display: none;
  min-height: 100vh;
}
.screen.active { display: flex; }

/* ===== MAIN MENU ===== */

#main-menu {
  flex-direction: column;
  align-items: center;
  justify-content: safe center;
  padding: 30px 20px;
  background: linear-gradient(180deg, #0a150a 0%, #122012 50%, #0f1a0f 100%);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.menu-content {
  max-width: 480px;
  width: 100%;
  text-align: center;
}

.game-title {
  font-family: var(--font-display);
  font-size: 3.2rem;
  font-weight: 900;
  color: var(--accent-gold);
  letter-spacing: 2px;
  margin-bottom: 6px;
  text-shadow: 0 2px 12px rgba(212, 168, 67, 0.3);
}

.game-subtitle {
  font-family: var(--font-display);
  font-size: 0.95rem;
  color: var(--text-secondary);
  font-style: italic;
  margin-bottom: 36px;
  line-height: 1.5;
}

.menu-section {
  margin-bottom: 24px;
  text-align: left;
}

.menu-label {
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--text-muted);
  margin-bottom: 10px;
}

/* Course grid */
.course-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.course-card {
  background: var(--bg-card);
  border: 2px solid var(--border);
  border-radius: 10px;
  padding: 12px 6px;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  color: var(--text-primary);
  font-family: var(--font-body);
}

.course-card:hover {
  border-color: var(--accent-gold);
  transform: translateY(-2px);
}

.course-card.selected {
  border-color: var(--accent-gold);
  background: rgba(212, 168, 67, 0.1);
  box-shadow: 0 0 15px rgba(212, 168, 67, 0.15);
}

.course-icon { font-size: 1.6rem; }
.course-name {
  font-size: 0.75rem;
  font-weight: 600;
  text-align: center;
}
.course-subtitle {
  font-size: 0.6rem;
  color: var(--text-muted);
  text-align: center;
}

/* Toggle buttons */
.toggle-group {
  display: flex;
  gap: 8px;
}

.toggle-btn {
  flex: 1;
  padding: 10px;
  background: var(--bg-card);
  border: 2px solid var(--border);
  border-radius: 8px;
  color: var(--text-secondary);
  font-family: var(--font-body);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.toggle-btn:hover { border-color: var(--accent-green); }

.toggle-btn.active {
  border-color: var(--accent-green);
  background: rgba(61, 163, 61, 0.15);
  color: var(--text-primary);
}

/* Player names */
.player-names {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

.player-names input {
  flex: 1;
  padding: 8px 12px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 0.85rem;
}

.player-names input:focus {
  outline: none;
  border-color: var(--accent-gold);
}

/* Primary button */
.btn-primary {
  display: block;
  width: 100%;
  padding: 14px;
  margin-top: 20px;
  background: linear-gradient(135deg, var(--accent-gold), #b8912e);
  border: none;
  border-radius: 10px;
  color: #1a1a0a;
  font-family: var(--font-display);
  font-size: 1.2rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
  letter-spacing: 1px;
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 15px rgba(212, 168, 67, 0.3);
}

.btn-primary:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

.btn-how-to-play {
  display: block;
  width: 100%;
  padding: 10px;
  margin-top: 10px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-muted);
  font-family: var(--font-body);
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-how-to-play:hover {
  border-color: var(--accent-gold);
  color: var(--text-secondary);
}

.how-to-play-content {
  max-width: 500px;
}

.how-to-play-body {
  font-size: 0.88rem;
  line-height: 1.65;
  color: var(--text-secondary);
}

.how-to-play-body p {
  margin-bottom: 12px;
}

.how-to-play-body ul {
  margin: 0 0 12px 18px;
}

.how-to-play-body li {
  margin-bottom: 4px;
}

.how-to-play-body em {
  color: var(--accent-gold);
  font-style: italic;
}

.how-to-play-body strong {
  color: var(--text-primary);
}

/* High scores */
.high-scores {
  margin-top: 20px;
  text-align: left;
}

.high-scores-title {
  font-family: var(--font-display);
  color: var(--accent-gold);
  font-size: 1.1rem;
  margin-bottom: 10px;
  text-align: center;
}

.high-scores-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.72rem;
  font-family: var(--font-mono);
}

.high-scores-table th {
  background: var(--bg-card);
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  font-size: 0.6rem;
  padding: 5px 4px;
  border: 1px solid var(--border);
  text-align: center;
}

.high-scores-table td {
  padding: 4px;
  border: 1px solid var(--border);
  text-align: center;
  background: rgba(26, 46, 26, 0.3);
}

.high-scores-table tr.high-score-current td {
  background: rgba(212, 168, 67, 0.1);
  color: var(--accent-gold);
}

.hidden { display: none !important; }

/* ===== GAME SCREEN ===== */

#game-screen {
  flex-direction: column;
  background: var(--bg-dark);
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

.game-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 10px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.hole-info {
  display: flex;
  gap: 8px;
  align-items: center;
}

#hole-number {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1rem;
  color: var(--accent-gold);
}

#hole-par {
  font-size: 0.8rem;
  color: var(--text-secondary);
  background: rgba(61, 163, 61, 0.15);
  padding: 2px 8px;
  border-radius: 12px;
}

.player-info {
  display: flex;
  gap: 8px;
  align-items: center;
  font-size: 0.8rem;
}

#current-player-name {
  color: var(--accent-gold);
  font-weight: 600;
}

#stroke-count {
  color: var(--text-secondary);
}

.btn-icon {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  width: 36px;
  height: 36px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 1.1rem;
  transition: all 0.2s;
}

.btn-icon:hover {
  border-color: var(--accent-gold);
  color: var(--accent-gold);
}

/* Game body - vertical stack: course strip on top, controls below */
.game-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 0;
  gap: 0;
  overflow: hidden;
  min-height: 0;
}

/* Course strip: full width, short height */
.course-strip {
  flex-shrink: 0;
  width: 100%;
  overflow: hidden;
}

#golf-course {
  display: block;
  width: 100%;
  border-bottom: 1px solid var(--border);
}

/* Controls panel below the course */
.controls-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 6px 8px;
  overflow-y: auto;
  min-height: 0;
}

/* Word display */
.word-display {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.word-chain {
  display: flex;
  align-items: center;
  gap: 4px;
  overflow-x: auto;
  padding: 8px 12px;
  background: var(--bg-card);
  border-radius: 8px;
  min-height: 38px;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.chain-word {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  padding: 3px 8px;
  border-radius: 4px;
  background: rgba(61, 163, 61, 0.15);
  white-space: nowrap;
  color: var(--text-primary);
}

.chain-seed {
  background: rgba(212, 168, 67, 0.2);
  color: var(--accent-gold);
  font-weight: 600;
}

.chain-putt {
  background: rgba(142, 68, 173, 0.2);
  color: #bb8fce;
}

.chain-faded {
  opacity: 0.5;
}

.chain-layup {
  background: rgba(243, 156, 18, 0.2);
  color: #f0c050;
  font-weight: 600;
  border: 1px dashed rgba(243, 156, 18, 0.4);
}

.chain-miss {
  background: rgba(192, 57, 43, 0.25);
  color: var(--accent-red);
  font-size: 0.7rem;
  padding: 1px 4px;
}

.chain-arrow {
  color: var(--text-muted);
  font-size: 0.8rem;
  flex-shrink: 0;
}

.target-display {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
}

.target-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
}

.target-word {
  font-family: var(--font-mono);
  font-size: 1rem;
  font-weight: 600;
  color: var(--accent-red);
  background: rgba(192, 57, 43, 0.12);
  padding: 3px 10px;
  border-radius: 4px;
  border: 1px dashed rgba(192, 57, 43, 0.3);
}

.hole-hint {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 2px;
  padding-left: 2px;
}

.hole-hint-label {
  font-size: 0.6rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.hole-hint-word {
  font-family: var(--font-mono);
  color: var(--text-secondary);
  opacity: 0.6;
}

/* Gauges */
.gauges-container {
  display: flex;
  gap: 16px;
  padding: 8px 12px;
}

.gauge {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.gauge-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
}

.gauge-track {
  height: 16px;
  background: var(--bg-card);
  border-radius: 8px;
  overflow: hidden;
  position: relative;
  border: 1px solid var(--border);
}

/* Both gauges are 0-100, no center mark needed */

.gauge-fill {
  height: 100%;
  width: 50%;
  border-radius: 8px;
  transition: width 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.fanciness-fill {
  background: linear-gradient(90deg, #e74c3c, #9b59b6);
  width: 0%;
}

.relation-fill {
  background: linear-gradient(90deg, #e74c3c, #27ae60);
  width: 0%;
}

.gauge-value {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--text-secondary);
  text-align: right;
}

.gauge-animate {
  animation: gaugePop 0.5s ease;
}

@keyframes gaugePop {
  0% { transform: scaleY(1); }
  50% { transform: scaleY(1.2); }
  100% { transform: scaleY(1); }
}

/* Input area */
.input-area {
  padding: 8px 4px;
  position: relative;
}

.whiff-message {
  background: rgba(192, 57, 43, 0.15);
  border: 1px solid rgba(192, 57, 43, 0.3);
  border-radius: 8px;
  padding: 10px 14px;
  margin-bottom: 8px;
  font-size: 0.85rem;
  color: #e8a0a0;
  font-style: italic;
}

.whiff-message.whiff-success {
  background: rgba(39, 174, 96, 0.15);
  border-color: rgba(39, 174, 96, 0.3);
  color: #a0e8b0;
}

.whiff-animate {
  animation: whiffShake 0.5s ease;
}

@keyframes whiffShake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-5px); }
  40% { transform: translateX(5px); }
  60% { transform: translateX(-3px); }
  80% { transform: translateX(3px); }
}

.score-flash {
  position: absolute;
  top: -10px;
  left: 50%;
  transform: translateX(-50%);
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--accent-gold);
  pointer-events: none;
}

.flash-animate {
  animation: flashUp 1.2s ease forwards;
}

@keyframes flashUp {
  0% { opacity: 0; transform: translateX(-50%) translateY(0); }
  10% { opacity: 1; transform: translateX(-50%) translateY(-15px); }
  70% { opacity: 1; transform: translateX(-50%) translateY(-20px); }
  100% { opacity: 0; transform: translateX(-50%) translateY(-30px); }
}

.input-row {
  display: flex;
  gap: 8px;
}

#word-input {
  flex: 1;
  padding: 12px 16px;
  background: var(--bg-input);
  border: 2px solid var(--border);
  border-radius: 10px;
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 1rem;
  transition: border-color 0.2s;
}

#word-input:focus {
  outline: none;
  border-color: var(--accent-gold);
}

#word-input::placeholder {
  color: var(--text-muted);
  font-family: var(--font-body);
  font-size: 0.85rem;
}

.btn-submit {
  padding: 12px 24px;
  background: linear-gradient(135deg, var(--accent-green), #2d8a2d);
  border: none;
  border-radius: 10px;
  color: white;
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
  letter-spacing: 0.5px;
}

.btn-submit:hover {
  transform: translateY(-1px);
  box-shadow: 0 3px 10px rgba(61, 163, 61, 0.3);
}

.btn-submit:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.btn-putt {
  width: 100%;
  margin-top: 8px;
  padding: 10px;
  background: linear-gradient(135deg, var(--accent-purple), #6c3483);
  border: none;
  border-radius: 10px;
  color: white;
  font-family: var(--font-display);
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
  letter-spacing: 0.5px;
}

.btn-putt:hover {
  transform: translateY(-1px);
  box-shadow: 0 3px 10px rgba(142, 68, 173, 0.3);
}

.putt-row {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.putt-row .btn-putt {
  flex: 1;
  margin-top: 0;
}

.btn-aim-pin {
  padding: 10px 14px;
  background: linear-gradient(135deg, #c0392b, #96281b);
  border: none;
  border-radius: 10px;
  color: white;
  font-family: var(--font-display);
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-aim-pin:hover {
  transform: translateY(-1px);
  box-shadow: 0 3px 10px rgba(192, 57, 43, 0.3);
}

.btn-cancel-putt {
  padding: 10px 16px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text-muted);
  font-family: var(--font-body);
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-cancel-putt:hover {
  border-color: var(--text-secondary);
  color: var(--text-secondary);
}

/* ===== HOLE SUMMARY ===== */

#hole-summary {
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 30px 20px;
  background: linear-gradient(180deg, #0a150a 0%, #122012 100%);
}

.summary-content {
  max-width: 480px;
  width: 100%;
  text-align: center;
}

.summary-content h2 {
  font-family: var(--font-display);
  color: var(--accent-gold);
  margin-bottom: 20px;
}

.score-display {
  margin-bottom: 24px;
}

.big-score {
  font-family: var(--font-display);
  font-size: 4rem;
  font-weight: 900;
  color: var(--text-primary);
  line-height: 1;
}

.score-name {
  font-family: var(--font-display);
  font-size: 1.5rem;
  color: var(--accent-gold);
  margin: 6px 0;
}

.score-relative {
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.word-review {
  margin-bottom: 20px;
}

.review-chain {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 4px;
  padding: 12px;
  background: var(--bg-card);
  border-radius: 10px;
}

.review-seed, .review-target {
  font-family: var(--font-mono);
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 4px;
}

.review-seed {
  background: rgba(212, 168, 67, 0.2);
  color: var(--accent-gold);
}

.review-target {
  background: rgba(192, 57, 43, 0.15);
  color: #e8a0a0;
}

.review-word {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  padding: 3px 8px;
  border-radius: 4px;
  background: rgba(61, 163, 61, 0.1);
  color: var(--text-secondary);
}

.review-arrow {
  color: var(--text-muted);
  align-self: center;
}

.hole-stats {
  text-align: left;
  background: var(--bg-card);
  border-radius: 10px;
  padding: 12px 16px;
  margin-bottom: 16px;
}

.stat-row {
  display: flex;
  justify-content: space-between;
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.85rem;
}

.stat-row:last-child { border-bottom: none; }

.stat-row span:first-child { color: var(--text-secondary); }
.stat-row span:last-child {
  font-family: var(--font-mono);
  font-weight: 600;
}

/* ===== HANDOFF ===== */

#handoff-screen {
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 30px 20px;
  background: linear-gradient(180deg, #0a150a, #122012);
}

.handoff-content {
  max-width: 400px;
  text-align: center;
}

.handoff-content h2 {
  font-family: var(--font-display);
  color: var(--accent-gold);
  font-size: 2rem;
  margin-bottom: 16px;
}

#handoff-message {
  color: var(--text-secondary);
  margin-bottom: 24px;
  line-height: 1.6;
}

/* ===== ROUND SUMMARY ===== */

#round-summary {
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 30px 20px;
  background: linear-gradient(180deg, #0a150a, #122012);
  overflow-y: auto;
}

#round-summary .summary-content {
  max-width: 600px;
}

#round-summary h2 {
  font-family: var(--font-display);
  color: var(--accent-gold);
  font-size: 2rem;
  margin-bottom: 20px;
}

/* Scorecard table */
.scorecard {
  margin-bottom: 20px;
  overflow-x: auto;
}

.scorecard-player-name {
  font-family: var(--font-display);
  color: var(--accent-gold);
  margin: 12px 0 6px;
  font-size: 1rem;
}

.scorecard-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.75rem;
  font-family: var(--font-mono);
}

.scorecard-table th, .scorecard-table td {
  padding: 6px 4px;
  text-align: center;
  border: 1px solid var(--border);
}

.scorecard-table th {
  background: var(--bg-card);
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  font-size: 0.65rem;
}

.scorecard-table td {
  background: rgba(26, 46, 26, 0.5);
}

.scorecard-table td.label {
  text-align: left;
  color: var(--text-secondary);
  font-weight: 600;
}

.score-eagle { color: #f1c40f; font-weight: 700; }
.score-birdie { color: #e74c3c; font-weight: 600; }
.score-par { color: var(--text-primary); }
.score-bogey { color: #5dade2; }
.score-bad { color: #5dade2; }

/* Final score displays */
.final-scores-comparison {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 24px;
  margin-bottom: 16px;
}

.final-player { text-align: center; }
.final-name {
  font-family: var(--font-display);
  color: var(--text-secondary);
  font-size: 0.9rem;
  margin-bottom: 4px;
}
.final-total {
  font-family: var(--font-display);
  font-size: 3rem;
  font-weight: 900;
  color: var(--text-primary);
}
.final-relative {
  font-family: var(--font-mono);
  color: var(--accent-gold);
}
.final-vs {
  font-family: var(--font-display);
  font-style: italic;
  color: var(--text-muted);
}
.final-winner {
  font-family: var(--font-display);
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--accent-gold);
  margin-top: 8px;
}

.final-solo { text-align: center; }
.final-total-big {
  font-family: var(--font-display);
  font-size: 4.5rem;
  font-weight: 900;
  color: var(--text-primary);
  line-height: 1;
}
.final-relative-big {
  font-family: var(--font-mono);
  font-size: 1.5rem;
  color: var(--accent-gold);
  margin: 6px 0;
}
.final-par-note {
  color: var(--text-muted);
  font-size: 0.85rem;
}

/* ===== OVERLAYS ===== */

.overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.overlay-content {
  background: var(--bg-dark);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  max-width: 90vw;
  max-height: 80vh;
  overflow: auto;
  width: 560px;
}

.overlay-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.overlay-header h3 {
  font-family: var(--font-display);
  color: var(--accent-gold);
}

.btn-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.5rem;
  cursor: pointer;
  padding: 4px 8px;
}

.btn-close:hover { color: var(--text-primary); }

/* Celebration overlay */
.celebration-content {
  text-align: center;
  padding: 40px;
  animation: celebrationPop 0.6s ease;
}

#celebration-text {
  font-family: var(--font-display);
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--accent-gold);
  text-shadow: 0 0 30px rgba(212, 168, 67, 0.5);
}

@keyframes celebrationPop {
  0% { transform: scale(0.5); opacity: 0; }
  50% { transform: scale(1.1); }
  100% { transform: scale(1); opacity: 1; }
}

/* ===== MOBILE / TOUCH OPTIMIZATION ===== */

/* Prevent iOS text size adjustment and double-tap zoom */
html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  touch-action: manipulation;
}

/* Prevent pull-to-refresh on the game screen */
body {
  overscroll-behavior: none;
}

/* Ensure all interactive elements have minimum 44px touch targets (Apple HIG) */
button, .toggle-btn, .course-card, .btn-icon, .btn-close {
  min-height: 44px;
  -webkit-tap-highlight-color: transparent;
}

/* ===== RESPONSIVE: PHONES (up to 480px) ===== */

@media (max-width: 480px) {
  /* Compact menu for phones */
  #main-menu { padding: 16px 16px; }
  .game-title { font-size: 1.8rem; margin-bottom: 2px; }
  .game-subtitle { font-size: 0.78rem; margin-bottom: 14px; line-height: 1.3; }
  .menu-section { margin-bottom: 10px; }
  .menu-label { font-size: 0.65rem; margin-bottom: 5px; }

  /* Course grid: 3 columns to save vertical space */
  .course-grid { grid-template-columns: repeat(3, 1fr); gap: 5px; }
  .course-card { padding: 8px 3px; min-height: 36px; }
  .course-icon { font-size: 1.1rem; }
  .course-name { font-size: 0.6rem; }
  .course-subtitle { font-size: 0.48rem; }

  /* Tighter toggles */
  .toggle-group { gap: 6px; }
  .toggle-btn { padding: 8px; font-size: 0.8rem; min-height: 36px; }

  /* Compact buttons */
  .btn-primary { padding: 12px; margin-top: 12px; font-size: 1.05rem; }
  .btn-how-to-play { padding: 8px; margin-top: 6px; font-size: 0.8rem; }

  /* Player names */
  .player-names { margin-top: 6px; flex-direction: column; gap: 4px; }
  .player-names input { padding: 6px 10px; font-size: 16px; /* prevent iOS zoom */ }

  /* Game screen: fit above keyboard */
  #game-screen {
    height: 100vh;
    height: 100dvh;
  }

  /* Game header: compact */
  .game-header { padding: 4px 8px; flex-shrink: 0; }
  #hole-number { font-size: 0.9rem; }
  #hole-par { font-size: 0.75rem; padding: 1px 6px; }
  .player-info { font-size: 0.75rem; gap: 6px; }

  /* === HORIZONTAL COURSE STRIP: full width, short === */
  .course-strip {
    height: 120px;
  }

  #golf-course {
    height: 120px !important;
    border-radius: 0;
  }

  .controls-panel {
    gap: 4px;
    padding: 4px 8px;
  }

  /* Word chain: horizontal scroll */
  .word-chain {
    padding: 4px 6px;
    min-height: 26px;
  }
  .chain-word { font-size: 0.75rem; padding: 2px 5px; }
  .chain-arrow { font-size: 0.65rem; }

  .target-display { padding: 2px 6px; }
  .target-word { font-size: 0.85rem; padding: 2px 8px; }

  /* Gauges side by side, thin */
  .gauges-container { padding: 2px 6px; gap: 10px; }
  .gauge-track { height: 12px; }
  .gauge-value { font-size: 0.7rem; }
  .gauge-label { font-size: 0.6rem; }

  /* Input */
  .input-area { padding: 4px 4px; }
  .input-row { gap: 6px; }
  #word-input {
    padding: 12px 10px;
    font-size: 16px; /* prevents iOS zoom */
    border-radius: 8px;
  }
  .btn-submit {
    padding: 12px 16px;
    font-size: 0.9rem;
    border-radius: 8px;
  }
  .btn-putt {
    padding: 10px;
    font-size: 0.85rem;
    margin-top: 4px;
  }

  .whiff-message { padding: 6px 8px; font-size: 0.78rem; }
  .score-flash { font-size: 0.95rem; }

  /* Hole summary */
  #hole-summary { padding: 20px 16px; }
  .big-score { font-size: 3rem; }
  .score-name { font-size: 1.2rem; }
  .review-chain { padding: 8px; gap: 3px; }
  .review-word { font-size: 0.78rem; padding: 2px 6px; }
  .hole-stats { padding: 10px 12px; }
  .stat-row { font-size: 0.8rem; padding: 5px 0; }

  /* Scoreboard */
  .scorecard { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .scorecard-table { font-size: 0.62rem; min-width: 360px; }
  .scorecard-table th, .scorecard-table td { padding: 5px 3px; }

  .final-total { font-size: 2.5rem; }
  .final-total-big { font-size: 3.5rem; }
  .final-winner { font-size: 1.4rem; }

  .overlay-content { max-width: 95vw; max-height: 90vh; padding: 14px; border-radius: 10px; }
  .celebration-content { padding: 24px; }
  #celebration-text { font-size: 1.2rem; }
  .handoff-content h2 { font-size: 1.6rem; }
  #handoff-message { font-size: 0.9rem; }
  #round-summary { padding: 20px 12px; }
  #round-summary h2 { font-size: 1.6rem; }
}

/* ===== RESPONSIVE: SMALL PHONES (up to 360px) ===== */

@media (max-width: 360px) {
  .game-title { font-size: 1.5rem; }
  .game-subtitle { font-size: 0.7rem; margin-bottom: 10px; }
  .course-grid { grid-template-columns: repeat(3, 1fr); gap: 3px; }
  .course-card { padding: 6px 2px; min-height: 32px; }
  .course-icon { font-size: 0.9rem; }
  .course-name { font-size: 0.55rem; }
  .course-subtitle { font-size: 0.45rem; }
  .menu-section { margin-bottom: 8px; }

  .course-strip { height: 100px; }
  #golf-course { height: 100px !important; }
  .chain-word { font-size: 0.65rem; }
  .big-score { font-size: 2.5rem; }
  .scorecard-table { font-size: 0.58rem; }
}

/* ===== RESPONSIVE: TABLETS (481px - 768px) ===== */

@media (min-width: 481px) and (max-width: 768px) {
  .course-grid { grid-template-columns: repeat(3, 1fr); }
  .game-body { max-width: 700px; margin: 0 auto; }
  .course-strip { height: 200px; }
}

/* ===== RESPONSIVE: DESKTOP (769px+) ===== */

@media (min-width: 769px) {
  .game-body { max-width: 800px; margin: 0 auto; }
  .course-strip { height: 300px; }
}

/* ===== SAFE AREA INSETS (notched phones) ===== */

@supports (padding: env(safe-area-inset-bottom)) {
  .game-header {
    padding-top: calc(4px + env(safe-area-inset-top));
  }
  .input-area {
    padding-bottom: calc(4px + env(safe-area-inset-bottom));
  }
  #main-menu {
    padding-top: calc(30px + env(safe-area-inset-top));
    padding-bottom: calc(20px + env(safe-area-inset-bottom));
  }
}

/* ===== KEYBOARD-OPEN STATE (detected via JS visualViewport) ===== */

body.keyboard-open #game-screen {
  height: var(--available-h, 50vh);
  overflow: hidden;
}

body.keyboard-open .game-header { padding: 2px 6px; }
body.keyboard-open #hole-number { font-size: 0.8rem; }
body.keyboard-open #hole-par { font-size: 0.65rem; padding: 1px 4px; }

/* Course strip shrinks when keyboard is open */
body.keyboard-open .course-strip { height: 70px; min-height: 60px; }
body.keyboard-open #golf-course { height: 70px !important; }

/* Hide gauges when typing — unless pinned after a recent hit */
body.keyboard-open .gauges-container { display: none; }
body.keyboard-open .gauges-container.gauges-pinned { display: flex !important; }

body.keyboard-open .word-chain { min-height: 20px; padding: 3px 5px; }
body.keyboard-open .chain-word { font-size: 0.65rem; }
body.keyboard-open .target-display { padding: 1px 5px; }
body.keyboard-open .target-word { font-size: 0.75rem; }
body.keyboard-open .controls-panel { gap: 2px; padding: 2px 6px; }
body.keyboard-open .input-area { padding: 2px; }
body.keyboard-open #word-input { padding: 8px 6px; }
body.keyboard-open .btn-submit { padding: 8px 12px; font-size: 0.8rem; }
body.keyboard-open .btn-putt { padding: 6px; font-size: 0.75rem; margin-top: 2px; }
body.keyboard-open .whiff-message { font-size: 0.65rem; padding: 4px 6px; }

/* ===== LANDSCAPE / SHORT VIEWPORT ===== */

@media (max-height: 420px) {
  #main-menu { padding: 10px 20px; justify-content: flex-start; overflow-y: auto; }
  .game-title { font-size: 1.8rem; margin-bottom: 2px; }
  .game-subtitle { margin-bottom: 14px; }
  .menu-section { margin-bottom: 12px; }
  .course-strip { height: 120px; }
  #hole-summary, #round-summary { justify-content: flex-start; overflow-y: auto; }
  .big-score { font-size: 2.5rem; }
}
