:root {
  --primary: #E53E3E;
  --secondary: #4299E1;
  --background: #ffffff;
  --text: #2d3748;
  --card-bg: #f7fafc;
  --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.dark-mode {
  --primary: #FEB2B2;
  --secondary: #90CDF4;
  --background: #1a202c;
  --text: #e2e8f0;
  --card-bg: #2d3748;
  --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  transition: background-color 0.3s, color 0.3s, border-color 0.3s;
}

html {
  font-size: 16px;
}

body {
  font-family: 'Segoe UI', system-ui, sans-serif;
  background: var(--background);
  color: var(--text);
  line-height: 1.6;
  -webkit-tap-highlight-color: transparent;
}

.app {
  max-width: 600px;
  margin: 0 auto;
  min-height: 100vh;
  padding: 1rem;
  background: var(--background);
}

.hidden {
  display: none !important;
}

.screen {
  min-height: 100vh;
  padding: 20px;
  display: flex;
  flex-direction: column;
}

button {
  transition: transform 0.2s ease, opacity 0.2s ease;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

button:active {
  transform: scale(0.95);
}

.setup-content {
  text-align: center;
  padding: 20px;
}

h1 {
  margin-bottom: 30px;
  color: var(--text);
  font-size: 2.2em;
}

.player-selector {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-bottom: 20px;
}

.player-selector button {
  padding: 15px;
  border: none;
  background: var(--card-bg);
  border-radius: 12px;
  font-size: 16px;
  cursor: pointer;
  color: var(--text);
}

.player-selector button:hover {
  transform: translateY(-2px);
}

.game-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem;
  margin: 0.5rem;
  background: var(--card-bg);
  border-radius: 16px;
  box-shadow: var(--shadow);
}

.score {
  font-size: 2rem;
  font-weight: 700;
  color: var(--primary);
}

.throw-info {
  text-align: right;
  font-size: 0.8em;
  color: var(--text);
  opacity: 0.8;
}

.number-pad {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
  padding: 0.5rem;
}

.number-pad button {
  aspect-ratio: 1;
  border: none;
  background: var(--card-bg);
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
  padding: 8px;
}

.number-pad button:hover {
  transform: scale(1.05);
}

.number-pad button.bull {
  grid-column: span 2;
  aspect-ratio: 2;
  color: var(--primary);
  font-weight: 700;
}

.game-controls {
  display: grid;
  gap: 0.5rem;
  margin-top: auto;
}

.multiplier-toggle {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}

.multiplier-toggle button {
  padding: 12px;
  border: none;
  background: var(--card-bg);
  border-radius: 12px;
  font-size: 14px;
  cursor: pointer;
  color: var(--text);
}

.multiplier-toggle button.active {
  background: var(--primary) !important;
  color: white !important;
}

.action-buttons {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
}

.action-buttons button {
  padding: 12px;
  border: none;
  background: var(--card-bg);
  border-radius: 12px;
  font-size: 14px;
  cursor: pointer;
  color: var(--text);
}

.stats-card {
  background: var(--card-bg);
  border-radius: 16px;
  padding: 1rem;
  margin: 0.5rem 0;
  box-shadow: var(--shadow);
}

.stats-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.stat-badge {
  background: var(--primary);
  color: white;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 0.9em;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 0.5rem;
}

.stat-item {
  padding: 0.8rem;
  background: var(--background);
  border-radius: 12px;
}

.stat-label {
  color: var(--text);
  opacity: 0.8;
  font-size: 0.8em;
  margin-bottom: 0.3rem;
}

.stat-value {
  font-size: 1.2em;
  font-weight: 600;
  color: var(--text);
}

.progress-bar {
  height: 6px;
  background: var(--card-bg);
  border-radius: 4px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), #f56565);
}

.player-score-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  background: var(--card-bg);
  padding: 0.8rem;
  border-radius: 12px;
  margin: 0.3rem 0;
  box-shadow: var(--shadow);
  font-size: 0.9em;
}

.player-score-card.active {
  box-shadow: 0 0 0 2px var(--primary);
}

.player-score-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.player-score-value {
  flex-shrink: 0;
  font-weight: 700;
  color: var(--primary);
}

@media (max-width: 480px) {
  .game-header {
    padding: 0.8rem;
    margin: 0.3rem;
  }

  .number-pad {
    grid-template-columns: repeat(4, 1fr);
    gap: 4px;
    padding: 0.3rem;
  }

  .number-pad button {
    font-size: 0.9rem;
    padding: 6px;
  }

  .multiplier-toggle button {
    font-size: 12px;
    padding: 10px;
  }

  .action-buttons button {
    font-size: 12px;
    padding: 10px;
  }

  .score {
    font-size: 1.8rem;
  }
}

@media (min-width: 768px) {
  html {
    font-size: 16px;
  }

  .number-pad {
    grid-template-columns: repeat(6, 1fr);
    gap: 8px;
  }
}

@supports (-webkit-touch-callout: none) {
  button {
    min-height: 44px;
  }
  
  .number-pad button {
    aspect-ratio: unset;
    height: 60px;
  }
}

.theme-toggle {
  position: fixed;
  bottom: 20px;
  right: 20px;
  background: var(--background);
  border: 2px solid var(--text);
  width: 48px;
  height: 48px;
  border-radius: 50%;
  cursor: pointer;
  display: grid;
  place-items: center;
  box-shadow: var(--shadow);
  z-index: 1000;
}

.game-mode-box {
  background: var(--card-bg);
  padding: 1rem;
  border-radius: 12px;
  margin-bottom: 1.5rem;
}

.modern-select {
  width: 100%;
  padding: 12px;
  border: 2px solid var(--primary);
  border-radius: 8px;
  background: var(--background);
  color: var(--text);
}

.add-player-btn {
  width: 100%;
  margin-top: 10px;
  background: var(--secondary);
  color: white;
}

.chart-container {
  margin-top: 2rem;
  height: 300px;
}

.game-mode-container {
  background: var(--card-bg);
  padding: 1rem;
  border-radius: 12px;
  margin: 1rem 0;
}

.mode-toggle-group {
  display: flex;
  gap: 8px;
  margin-bottom: 1rem;
}

.mode-option {
  flex: 1;
  padding: 12px;
  border: 2px solid var(--primary);
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  transition: all 0.2s;
  font-size: 16px;
}

.mode-option.active {
  background: var(--primary);
  color: white;
}

.rules-toggle {
  display: flex;
  gap: 1rem;
  justify-content: center;
}

.player-name-input {
  width: 100%;
  padding: 12px;
  border: 2px solid var(--primary);
  border-radius: 8px;
  margin: 8px 0;
  background: var(--background);
  color: var(--text);
  font-size: 16px;
}

.add-player-btn {
  width: 100%;
  margin: 12px 0;
  padding: 12px;
  background: var(--secondary);
  color: white;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-size: 16px;
}

.stats-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 1.5rem;
}

.stats-tab {
  padding: 12px 24px;
  border: none;
  border-radius: 8px;
  background: var(--card-bg);
  color: var(--text);
  cursor: pointer;
  transition: all 0.2s;
}

.stats-tab.active {
  background: var(--primary);
  color: white;
}

.stats-container {
  display: grid;
  gap: 1.5rem;
}

.hidden {
  display: none;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  padding: 1rem;
}

.stat-item {
  background: var(--card-bg);
  padding: 1rem;
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.stat-label {
  font-size: 0.9em;
  color: var(--text);
  margin-bottom: 0.5rem;
}

.stat-value {
  font-size: 1.2em;
  font-weight: 600;
  color: var(--primary);
}

.progress-bar {
  height: 8px;
  background: var(--background);
  border-radius: 4px;
  overflow: hidden;
  margin-top: 0.5rem;
}

.progress-fill {
  height: 100%;
  background: var(--secondary);
  width: var(--progress-width);
}

/* Bestätigungsbutton Styling */
#confirm-turn {
  margin-top: 1rem;
  width: 100%;
  padding: 1rem;
  font-size: 1.1em;
  transition: opacity 0.3s;
}

#confirm-turn.hidden {
  opacity: 0;
  pointer-events: none;
}

/* Responsive Anpassungen */
@media (max-width: 480px) {
  #confirm-turn {
    font-size: 1em;
    padding: 0.8rem;
  }
}

/* Cloud Sync Warnhinweis */
.sync-warning {
  color: var(--primary);
  font-size: 0.8em;
  margin-top: 0.5rem;
  text-align: center;
}