:root {
  --cell-size: 20px;
  --gap: 1px;
  --bg: #0b0f1a;
  --panel: rgba(255, 255, 255, 0.05);
  --text: #eef2ff;
  --muted: rgba(255, 255, 255, 0.65);
  --water: #005d8f;
  --trees: #145214;
  --fairway: #4a7a31;
  --tee: #d9c14b;
  --green: #7ceb5f;
  --hole: #111;
  --player: #ffec59;
  --panel-bg: #1a1e2e;
  --primary: #4caf50;
  --secondary: #f44336;
  --border: rgba(255, 255, 255, 0.2);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: system-ui, sans-serif;
  background: radial-gradient(circle at 40% 0%, #1b2a4b 0%, #05070d 55%);
  color: var(--text);
  display: flex;
  flex-direction: column;
  align-items: center;
}

header {
  width: 100%;
  max-width: 1200px;
  padding: 1.2rem 1rem 0.5rem;
  text-align: center;
}

.layout-container {
  display: flex;
  gap: 1rem;
  max-width: 1400px;
  width: 100%;
  justify-content: center;
}

.left-panel {
  flex-grow: 1;
  display: flex;
  justify-content: center;
  align-items: flex-start;
}

.right-panel {
  width: 320px;
  flex-shrink: 0;
}

.left-action-bar {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  padding: 1rem;
  background: rgba(0, 0, 0, 0.6);
  border-radius: 8px;
  backdrop-filter: blur(4px);
  width: 80px;
  align-items: center;
  border: 1px solid var(--border);
}

.club-buttons {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  width: 100%;
}

.club-btn {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  border: 2px solid var(--border);
  background: var(--panel-bg);
  color: var(--text);
  font-weight: bold;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  transition: all 0.2s;
}

.club-btn.active {
  background: var(--primary);
  border-color: #ffeb3b;
  box-shadow: 0 0 10px rgba(76, 175, 80, 0.5);
}

.club-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.vertical-power-meter-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  flex-grow: 1;
  width: 100%;
  padding-bottom: 1rem;
}

.power-meter-container.vertical {
  width: 20px;
  height: 300px;
  background: rgba(0, 0, 0, 0.4);
  border: 2px solid rgba(255, 255, 255, 0.2);
  border-radius: 10px;
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column-reverse;
}

.power-meter-fill.vertical {
  width: 100%;
  background: #4caf50; /* Pure green */
  position: absolute;
  bottom: 0;
  left: 0;
  transition: none;
}

.swing-btn {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: #f44336; /* Red trigger */
  color: white;
  border: 3px solid white;
  font-weight: 800;
  font-size: 0.7rem;
  cursor: pointer;
  box-shadow: 0 4px 10px rgba(0,0,0,0.5);
  transition: transform 0.1s;
}

.swing-btn:active {
  transform: scale(0.9);
}

/* Make game view take full width and remove unnecessary spacing */
#game-view.layout-container {
  margin-top: 0;
  padding-top: 1rem;
  position: relative;
}

.controls-overlay {
  position: absolute;
  bottom: 20px;
  right: 20px;
  z-index: 10;
  pointer-events: auto;
}

.view-container {
  display: none;
  width: 100%;
  max-width: 600px;
  margin: 2rem auto;
}

.view-container.active {
  display: block;
}

.menu-box {
  background-color: var(--panel-bg);
  padding: 2rem;
  border-radius: 8px;
  box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

.menu-box h2 {
  margin-top: 0;
  margin-bottom: 1.5rem;
  text-align: center;
  color: var(--text);
}

.menu-group {
  margin-bottom: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.divider {
  text-align: center;
  margin: 1rem 0;
  color: var(--muted);
  font-weight: bold;
}

.error-text {
  color: #ffb3b3;
  text-align: center;
  min-height: 1.5rem;
}

.primary-btn {
  background-color: var(--primary);
  color: white;
  padding: 0.75rem;
  font-size: 1.1rem;
}

.tab-btn {
  background-color: var(--panel-bg);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 0.5rem;
  font-size: 1rem;
  cursor: pointer;
  border-radius: 4px;
}

.primary-btn:hover {
  background-color: #3aa64b;
}

h1 {
  margin: 0 0 0.25rem;
  font-size: 1.9rem;
}

p {
  margin: 0 0 0.75rem;
}

.game-info {
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  align-items: flex-start;
  gap: 0.5rem;
  margin: 0;
  padding: 1rem;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 0.5rem;
}

.players {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  width: 100%;
}

.player {
  padding: 0.25rem 0.5rem;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 0.25rem;
  font-size: 0.9rem;
}

.player.current {
  background: rgba(255, 255, 255, 0.2);
  font-weight: bold;
}

.hole-info {
  font-size: 0.9rem;
  color: var(--muted);
}

.controls {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  align-items: stretch;
  background: rgba(255, 255, 255, 0.05);
  padding: 1rem;
  border-radius: 0.5rem;
}

button {
  padding: 0.5rem 0.75rem;
  border-radius: 0.4rem;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  cursor: pointer;
  font-weight: 600;
}

button:hover {
  background: rgba(255, 255, 255, 0.15);
}

#status {
  color: var(--muted);
  font-size: 0.95rem;
}

.left-panel {
  width: 100%;
  display: flex;
  justify-content: center;
  padding: 1rem;
}

.grid {
  display: grid;
  border: 2px solid rgba(255, 255, 255, 0.25);
  border-radius: 0.5rem;
  background: rgba(0, 0, 0, 0.35);
  overflow: auto;
  max-width: calc(var(--cell-size) * 50 + var(--gap) * 2);
  max-height: calc(var(--cell-size) * 50 + var(--gap) * 2);
}

.grid-cell {
  width: var(--cell-size);
  height: var(--cell-size);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.65rem;
  color: rgba(255, 255, 255, 0.85);
  cursor: pointer;
  transition: transform 0.1s ease, box-shadow 0.1s ease;
  border-radius: 0.2rem;
  position: relative;
}

.grid-cell:hover {
  transform: translateY(-1px);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.25);
}

.grid-cell[data-type="fairway"] {
  background: var(--fairway);
}

.grid-cell[data-type="tee"] {
  background: var(--tee);
}

.grid-cell[data-type="green"] {
  background: var(--green);
}

.grid-cell[data-type="hole"] {
  background: var(--hole);
}

.grid-cell[data-type="water"] {
  background: var(--water);
}

.grid-cell[data-type="trees"] {
  background: var(--trees);
  background-image: repeating-linear-gradient(
    45deg,
    transparent,
    transparent 4px,
    rgba(0, 0, 0, 0.4) 4px,
    rgba(0, 0, 0, 0.4) 8px
  );
}

.grid-cell.possible-move {
  background-color: transparent !important;
}

.grid-cell.possible-move::after {
  content: '';
  position: absolute;
  width: 40%;
  height: 40%;
  border-radius: 50%;
  background-color: var(--indicator-color, #ffeb3b);
  box-shadow: 0 0 6px var(--indicator-color, #ffeb3b);
  animation: pulse 1.5s infinite;
  z-index: 2;
  pointer-events: none;
}

@keyframes pulse {
  0% { transform: scale(0.85); opacity: 0.7; }
  50% { transform: scale(1.1); opacity: 1; }
  100% { transform: scale(0.85); opacity: 0.7; }
}

footer {
  width: 100%;
  max-width: 960px;
  padding: 0 1rem 1rem;
  font-size: 0.9rem;
  color: var(--muted);
}

@media (max-width: 800px) {
  :root {
    --cell-size: 16px;
  }
}

.roll-overlay-btn {
  position: relative !important;
  top: auto !important;
  left: auto !important;
  transform: none !important;
  padding: 1.5rem 3rem;
  font-size: 1.5rem;
  background-color: #2e7d32; /* Strong, opaque green */
  color: #ffffff;
  border: 4px solid rgba(255, 255, 255, 0.4);
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.8);
  cursor: pointer;
  transition: transform 0.2s;
  opacity: 1;
}

.roll-overlay-btn:hover {
  transform: scale(1.05) !important;
  background-color: #388e3c;
}

/* Power Meter & Swing Overlay */
.power-meter-container {
  /* No display: none here */
}

.power-meter-fill {
  /* No display: none here */
}

.grid-cell.range-highlight {
  position: relative;
}

.grid-cell.range-highlight::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(255, 255, 255, 0.15);
  pointer-events: none;
  z-index: 1;
}

.swing-result-overlay {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 6rem;
  font-weight: 800;
  color: white;
  text-shadow: 0 0 20px rgba(0,0,0,0.8), 0 0 10px rgba(0,0,0,0.5);
  pointer-events: none;
  z-index: 100;
  opacity: 0;
  transition: opacity 0.2s ease, transform 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.swing-result-overlay.visible {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1.5);
}

.ingame-options-panel {
    background: var(--panel);
    border-radius: 8px;
    padding: 0.5rem;
    margin-top: 1rem;
    border: 1px solid var(--border);
}

.ingame-options-panel[open] > summary {
    margin-bottom: 0.5rem;
}

.ingame-options-panel > summary {
    font-weight: bold;
    font-size: 1.1rem;
    cursor: pointer;
    padding: 0.5rem;
    color: #ffeb3b;
}
