:root {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --bg-primary: #111;
  --bg-secondary: #181818;
  --bg-canvas: radial-gradient(circle at center, #222 0, #000 70%);
  --bg-hex-empty: #1b1b1b;
  --text-primary: #eee;
  --text-secondary: #ccc;
  --text-tertiary: #aaa;
  --border-color: #333;
  --border-hex: #111;
  --shadow-color: rgba(0,0,0,0.8);
  background: var(--bg-primary);
  color: var(--text-primary);
}

:root.light-mode {
  --bg-primary: #f5f5f5;
  --bg-secondary: #ffffff;
  --bg-canvas: radial-gradient(circle at center, #e8e8e8 0, #d0d0d0 70%);
  --bg-hex-empty: #e0e0e0;
  --text-primary: #222;
  --text-secondary: #444;
  --text-tertiary: #666;
  --border-color: #ccc;
  --border-hex: #999;
  --shadow-color: rgba(0,0,0,0.1);
}

body {
  margin: 0;
  padding: 0;
  padding-top: 65px; /* Make room for sticky top bar */
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 100vh;
  overflow-x: hidden;
}

.top-bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  background: var(--bg-secondary);
  border-bottom: 2px solid var(--border-color);
  box-shadow: 0 2px 10px var(--shadow-color);
  z-index: 1000;
  padding: 6px 8px;
}

.top-bar-content {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
  flex-wrap: nowrap;
}

.top-bar h1 {
  margin: 0;
  font-size: clamp(0.9rem, 3vw, 1.2rem);
  white-space: nowrap;
}

.top-bar-right {
  display: flex;
  align-items: center;
  gap: clamp(4px, 1vw, 8px);
  flex-wrap: nowrap;
}

.score-display {
  display: flex;
  align-items: baseline;
  gap: clamp(4px, 1vw, 8px);
  font-size: clamp(0.75rem, 1.8vw, 0.85rem);
}

#score {
  font-weight: 600;
  font-size: clamp(0.75rem, 1.8vw, 0.9rem);
  white-space: nowrap;
}

#combo {
  font-size: clamp(0.7rem, 1.6vw, 0.8rem);
  color: var(--text-secondary);
  white-space: nowrap;
}

.queue-section {
  display: flex;
  align-items: center;
  gap: clamp(3px, 1vw, 6px);
}

.queue-label {
  font-size: clamp(0.7rem, 1.6vw, 0.8rem);
  color: var(--text-secondary);
  white-space: nowrap;
}

.queue-tiles {
  display: flex;
  gap: clamp(2px, 1vw, 4px);
}

.queue-tile {
  width: clamp(20px, 4vw, 24px);
  height: clamp(20px, 4vw, 24px);
  border-radius: 50%;
  border: 2px solid var(--border-color);
  box-sizing: border-box;
  box-shadow: 0 0 4px var(--shadow-color);
  opacity: 0.7;
  transform: scale(0.9);
  transition: all 0.2s ease;
}

.queue-tile.next {
  width: clamp(24px, 5vw, 30px);
  height: clamp(24px, 5vw, 30px);
  opacity: 1;
  transform: scale(1);
  border-color: var(--text-primary);
}

.top-bar button {
  margin: 0;
  white-space: nowrap;
}

.game-wrapper {
  display: flex;
  justify-content: center;
  align-items: center;
  max-width: 100%;
  width: 100%;
  padding: clamp(8px, 2vw, 16px);
  box-sizing: border-box;
}

.board-container {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
  max-width: min(90vw, 800px);
}

#board {
  width: 100%;
  max-width: min(90vw, 600px);
  aspect-ratio: 1 / 1;
  background: var(--bg-canvas);
  border-radius: clamp(8px, 2vw, 12px);
  box-shadow: 0 0 20px var(--shadow-color);
  display: block;
}

.modal {
  display: none;
  position: fixed;
  z-index: 2000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.7);
  animation: fadeIn 0.3s ease;
}

.modal.show {
  display: flex;
  justify-content: center;
  align-items: center;
}

.modal-content {
  background: var(--bg-secondary);
  border-radius: 12px;
  padding: 32px;
  max-width: 500px;
  width: 90%;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: 0 4px 20px var(--shadow-color);
  position: relative;
  animation: slideIn 0.3s ease;
}

.modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
  background: transparent;
  border: none;
  font-size: 2rem;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 0;
  width: 40px;
  height: 40px;
  line-height: 40px;
  text-align: center;
  margin: 0;
  box-shadow: none;
  transition: color 0.2s ease;
}

.modal-close:hover {
  color: var(--text-primary);
  background: transparent;
  transform: none;
}

.modal-close:active {
  transform: scale(0.95);
}

.modal-content h2 {
  margin: 0 0 16px;
  font-size: 1.8rem;
  text-align: center;
}

.modal-content h3 {
  margin: 0 0 12px;
  font-size: 1.2rem;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes slideIn {
  from {
    transform: translateY(-50px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.help-btn {
  padding: clamp(3px, 0.8vw, 5px) clamp(6px, 1.5vw, 8px);
  font-size: clamp(0.9rem, 2vw, 1.1rem);
  font-weight: bold;
  background: var(--border-color);
  box-shadow: 0 2px 6px var(--shadow-color);
  border-radius: 50%;
  width: clamp(26px, 5vw, 32px);
  height: clamp(26px, 5vw, 32px);
  display: flex;
  align-items: center;
  justify-content: center;
}

.help-btn:hover {
  background: var(--text-secondary);
  transform: scale(1.1) translateY(-1px);
}

.help-btn:active {
  transform: scale(1.05) translateY(0);
}

.header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.side-panel h1 {
  margin: 0;
  font-size: 1.6rem;
}

.score-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  font-size: 0.95rem;
}

#round-status {
  min-height: 1.2em;
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.instructions {
  margin-top: 8px;
  font-size: 0.85rem;
  color: var(--text-tertiary);
  line-height: 1.4;
}

.instructions p {
  margin: 8px 0 0;
  font-style: italic;
}

.instructions ul {
  padding-left: 18px;
  margin: 4px 0;
}

.instructions li {
  margin-bottom: 2px;
}

button {
  padding: clamp(4px, 1vw, 6px) clamp(8px, 2vw, 12px);
  border-radius: 5px;
  border: none;
  cursor: pointer;
  font-size: clamp(0.7rem, 1.6vw, 0.85rem);
  font-weight: 600;
  background: linear-gradient(135deg, #2ecc71, #27ae60);
  color: #fff;
  box-shadow: 0 2px 6px var(--shadow-color);
  transition: all 0.2s ease;
}

button:hover {
  filter: brightness(1.1);
  transform: translateY(-1px);
}

button:active {
  transform: translateY(0);
  box-shadow: 0 1px 3px var(--shadow-color);
}

.theme-toggle {
  padding: clamp(3px, 0.8vw, 5px) clamp(6px, 1.5vw, 8px);
  font-size: clamp(0.9rem, 2vw, 1.1rem);
  background: var(--border-color);
  box-shadow: 0 2px 6px var(--shadow-color);
}

.theme-toggle:hover {
  background: var(--text-secondary);
  transform: rotate(20deg) translateY(-1px);
}

.theme-toggle:active {
  transform: translateY(0) rotate(20deg);
}

@media (max-width: 768px) {
  body {
    padding-top: 55px; /* Reduced for more compact top bar */
  }
  
  .top-bar {
    padding: 4px 6px;
  }
  
  .top-bar-content {
    flex-wrap: nowrap;
    align-items: center;
    gap: 4px;
  }
  
  .top-bar h1 {
    font-size: 0.85rem;
  }
  
  .top-bar-right {
    gap: 4px;
    flex-wrap: nowrap;
  }
  
  .modal-content {
    padding: 20px;
    width: 95%;
    margin: 8px;
  }
  
  .modal-content h2 {
    font-size: 1.4rem;
  }
}

@media (max-width: 480px) {
  body {
    padding-top: 50px;
  }
  
  .top-bar {
    padding: 3px 4px;
  }
  
  .top-bar h1 {
    font-size: 0.8rem;
  }
  
  .queue-label {
    display: none;
  }
  
  .top-bar-right {
    gap: 3px;
  }
  
  button {
    font-size: 0.65rem;
    padding: 4px 8px;
  }
  
  .modal-content {
    padding: 16px;
  }
  
  .instructions ul {
    padding-left: 20px;
  }
  
  .instructions li {
    font-size: 0.85rem;
  }
}

@media (max-width: 480px) {
  body {
    padding-top: 140px;
  }
  
  .top-bar h1 {
    font-size: 1rem;
  }
  
  .queue-label {
    display: none; /* Hide "Next:" label on very small screens */
  }
  
  .top-bar-right {
    gap: 6px;
  }
  
  button {
    font-size: 0.75rem;
    padding: 6px 10px;
  }
  
  .modal-content {
    padding: 16px;
  }
  
  .instructions ul {
    padding-left: 20px;
  }
  
  .instructions li {
    font-size: 0.85rem;
  }
}
