:root {
  /* Default Light Mode */
  --bg-color: #f3f4f6;
  --card-bg: #ffffff;
  --primary-color: #1f2937;
  --accent-blue: #3b82f6;
  --accent-red: #ef4444;
  --text-main: #1f2937;
  --text-muted: #6b7280;
  --border-color: #e5e7eb;
  --font-stack: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;

  /* Visibility Fixes */
  --button-active-bg: #e5e7eb;
  /* Light gray for active button in light mode */
  --button-hover-bg: #e5e7eb;
  --gradient-start: #1f2937;
  /* Dark text for gradient start */
  --gradient-end: #6b7280;
  /* Gray text for gradient end */
}

body.dark-mode {
  --bg-color: #0d0d0d;
  --card-bg: #1a1a1a;
  --primary-color: #ffffff;
  --text-main: #ffffff;
  --text-muted: #a1a1aa;
  --border-color: #27272a;

  /* Visibility Fixes */
  --button-active-bg: #27272a;
  --button-hover-bg: #27272a;
  --gradient-start: #ffffff;
  --gradient-end: #a1a1aa;
}

* {
  box-sizing: border-box;
}

body {
  background-color: var(--bg-color);
  color: var(--text-main);
  font-family: var(--font-stack);
  margin: 0;
  padding: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  /* Center vertically on desktop */
  align-items: center;
  overflow-x: hidden;
}

header {
  text-align: center;
  margin-bottom: 2rem;
  padding-top: 2rem;
  position: relative;
  /* For absolute positioning of toggle if needed */
}

.theme-toggle {
  position: absolute;
  top: 1rem;
  right: 1rem;
  background: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 8px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 1.2rem;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
}

.theme-toggle:hover {
  background: var(--border-color);
  transform: scale(1.1);
}

.title {
  font-size: 2rem;
  font-weight: 700;
  margin: 0 0 0.5rem 0;
  letter-spacing: -0.02em;
}

.subtitle {
  color: var(--text-muted);
  font-size: 0.95rem;
  margin: 0;
}

.game-container {
  width: 100%;
  max-width: 500px;
  /* Restrict width for mobile app feel */
  background: var(--card-bg);
  border-radius: 24px;
  padding: 2rem;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
  border: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* Game Elements */
.game-mode-selector {
  background: var(--bg-color);
  padding: 4px;
  border-radius: 12px;
  display: flex;
  gap: 4px;
  margin-bottom: 2rem;
  width: 100%;
}

.game-mode-button {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 10px;
  border-radius: 8px;
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.game-mode-button.active {
  background: var(--button-active-bg);
  color: var(--text-main);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.choices-container {
  display: flex;
  justify-content: center;
  gap: 1.5rem;
  margin-bottom: 2.5rem;
  width: 100%;
}

.move-button {
  background: var(--bg-color);
  border: 1px solid var(--border-color);
  width: 100px;
  height: 100px;
  border-radius: 50%;
  /* Perfect circles */
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  justify-content: center;
  align-items: center;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.move-button:hover {
  transform: translateY(-4px);
  border-color: var(--text-muted);
}

.move-button:active {
  transform: scale(0.95);
}

.move-icon {
  height: 50px;
  width: auto;
}

/* Results & Score */
.result-container {
  text-align: center;
  margin-bottom: 2rem;
  min-height: 80px;
}

.result {
  font-size: 1.75rem;
  font-weight: 700;
  margin: 0 0 0.5rem 0;
  background: linear-gradient(to right, var(--gradient-start), var(--gradient-end));
  background-clip: text;
  /* Standard property */
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.moves {
  font-size: 0.9rem;
  color: var(--text-muted);
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 1rem;
}

.score-container {
  width: 100%;
  background: var(--bg-color);
  border-radius: 16px;
  padding: 1.5rem;
  margin-bottom: 2rem;
  text-align: center;
  border: 1px solid var(--border-color);
}

.js-score {
  font-size: 1rem;
  font-weight: 500;
  color: var(--text-muted);
  margin: 0;
}

.js-series-score {
  display: block;
  margin-top: 0.5rem;
  font-weight: 600;
  color: var(--accent-blue);
}

/* Controls */
.controls-container {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  width: 100%;
}

.auto-play-button {
  grid-column: span 2;
  /* Full width for auto play */
}

.control-button {
  background: var(--bg-color);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 14px;
  border-radius: 12px;
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  transition: background 0.2s;
}

.control-button:hover {
  background: var(--button-hover-bg);
}

.auto-play-button.playing {
  background: rgba(59, 130, 246, 0.15);
  /* Tinted blue */
  color: var(--accent-blue);
  border-color: rgba(59, 130, 246, 0.3);
}

/* History - Hidden by default or styled minimally */
.history-container {
  margin-top: 2rem;
  width: 100%;
  border-top: 1px solid var(--border-color);
  padding-top: 1.5rem;
}

.history-title {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  text-align: center;
  margin-bottom: 1rem;
}

.history-list {
  padding: 0;
  list-style: none;
  max-height: 150px;
  overflow-y: auto;
}

.history-item {
  display: flex;
  justify-content: space-between;
  padding: 8px 12px;
  font-size: 0.85rem;
  border-bottom: 1px solid var(--border-color);
}

.history-item.win {
  color: #4ade80;
}

.history-item.loss {
  color: #f87171;
}

.history-item.tie {
  color: var(--text-muted);
}

.app-footer {
  margin-top: 3rem;
  color: #52525b;
  font-size: 0.8rem;
  text-align: center;
  /* Ensure alignment */
}

.app-footer a {
  color: #71717a;
  text-decoration: none;
}

/* Mobile Optimization */
@media (max-width: 600px) {
  body {
    display: block;
    /* Allow natural flow */
    padding: 1rem;
    height: 100vh;
    /* Fill screen */
    background: var(--bg-color);
    /* Match card bg for seamless look */
  }

  header {
    margin-bottom: 1.5rem;
    padding-top: 1rem;
  }

  .game-container {
    box-shadow: none;
    background: transparent;
    border: none;
    padding: 0;
    max-width: 100%;
  }

  .title {
    font-size: 1.75rem;
  }

  .move-button {
    width: 85px;
    height: 85px;
  }

  .move-icon {
    height: 40px;
  }

  .controls-container {
    margin-bottom: 2rem;
    /* Spacing at bottom for thumb reach */
  }
}