/* Reset and base styles */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --primary-color: #4CAF50;
  --primary-hover: #45a049;
  --secondary-color: #2196F3;
  --danger-color: #f44336;
  --warning-color: #ff9800;
  --bg-color: #f5f5f5;
  --card-bg: #ffffff;
  --text-color: #333333;
  --text-light: #666666;
  --border-color: #e0e0e0;
  --shadow: 0 2px 4px rgba(0,0,0,0.1);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background-color: var(--bg-color);
  color: var(--text-color);
  min-height: 100vh;
  padding-top: 60px;
}

/* Warning banner */
.warning-banner {
  background-color: #fff3cd;
  color: #856404;
  padding: 10px 15px;
  text-align: center;
  font-size: 14px;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1000;
}

.warning-banner.hidden {
  display: none;
}

body.has-warning {
  padding-top: 100px;
}

/* Tab bar */
.tab-bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  background: var(--card-bg);
  display: flex;
  justify-content: space-around;
  padding: 10px 0;
  box-shadow: var(--shadow);
  z-index: 100;
}

.tab-btn {
  background: none;
  border: none;
  padding: 12px 15px;
  font-size: 14px;
  color: var(--text-light);
  cursor: pointer;
  border-radius: 8px;
  transition: all 0.2s;
  min-width: 80px;
  min-height: 44px;
}

.tab-btn.active {
  color: var(--primary-color);
  background-color: rgba(76, 175, 80, 0.1);
  font-weight: 600;
}

/* Main content */
.main-content {
  padding: 15px;
  max-width: 800px;
  margin: 0 auto;
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

/* Form styles */
.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  margin-bottom: 8px;
  font-weight: 600;
  color: var(--text-color);
}

.form-group input[type="text"] {
  width: 100%;
  padding: 12px 15px;
  font-size: 16px;
  border: 2px solid var(--border-color);
  border-radius: 8px;
  transition: border-color 0.2s;
}

.form-group input[type="text"]:focus {
  outline: none;
  border-color: var(--primary-color);
}

.char-count {
  display: block;
  text-align: right;
  font-size: 12px;
  color: var(--text-light);
  margin-top: 4px;
}

/* Option rows */
#options-container {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.option-row {
  display: flex;
  gap: 10px;
}

.option-row input {
  flex: 1;
}

.remove-option-btn {
  width: 44px;
  height: 44px;
  background: none;
  border: 2px solid var(--border-color);
  border-radius: 8px;
  color: var(--text-light);
  font-size: 18px;
  cursor: pointer;
  transition: all 0.2s;
}

.remove-option-btn:not(:disabled):hover {
  border-color: var(--danger-color);
  color: var(--danger-color);
}

.remove-option-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.add-option-btn {
  width: 100%;
  padding: 12px;
  background: none;
  border: 2px dashed var(--border-color);
  border-radius: 8px;
  color: var(--text-light);
  font-size: 14px;
  cursor: pointer;
  margin-top: 10px;
  min-height: 44px;
  transition: all 0.2s;
}

.add-option-btn:hover {
  border-color: var(--primary-color);
  color: var(--primary-color);
}

.add-option-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Radio group */
.radio-group {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.radio-label {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 15px;
  background: var(--card-bg);
  border: 2px solid var(--border-color);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
  min-height: 44px;
}

.radio-label:hover {
  border-color: var(--primary-color);
}

.radio-label input:checked + span {
  color: var(--primary-color);
  font-weight: 600;
}

.radio-label:has(input:checked) {
  border-color: var(--primary-color);
  background-color: rgba(76, 175, 80, 0.05);
}

/* Buttons */
.primary-btn {
  width: 100%;
  padding: 15px;
  background-color: var(--primary-color);
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 18px;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.2s;
  min-height: 50px;
}

.primary-btn:hover:not(:disabled) {
  background-color: var(--primary-hover);
}

.primary-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.secondary-btn {
  width: 100%;
  padding: 12px;
  background-color: var(--card-bg);
  color: var(--text-color);
  border: 2px solid var(--border-color);
  border-radius: 8px;
  font-size: 16px;
  cursor: pointer;
  transition: all 0.2s;
  min-height: 44px;
}

.secondary-btn:hover {
  border-color: var(--primary-color);
  color: var(--primary-color);
}

.danger-btn {
  width: 100%;
  padding: 12px;
  background-color: var(--danger-color);
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 16px;
  cursor: pointer;
  transition: opacity 0.2s;
  min-height: 44px;
}

.danger-btn:hover {
  opacity: 0.9;
}

/* Loading */
.loading {
  text-align: center;
  padding: 40px 20px;
}

.loading.hidden {
  display: none;
}

.dice-spinner {
  font-size: 60px;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* Result area */
.result {
  margin-top: 25px;
  background: var(--card-bg);
  border-radius: 12px;
  padding: 20px;
  box-shadow: var(--shadow);
}

.result.hidden {
  display: none;
}

.server-hint {
  text-align: center;
  color: var(--text-light);
  font-size: 13px;
  padding: 8px;
  background: #f0f7f0;
  border-radius: 6px;
  margin-bottom: 15px;
}

.result-round {
  margin-bottom: 20px;
  padding: 15px;
  background: var(--bg-color);
  border-radius: 8px;
}

.round-title {
  font-weight: 600;
  font-size: 16px;
  margin-bottom: 12px;
  color: var(--primary-color);
}

.series-card {
  background: var(--card-bg);
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 10px;
  border: 1px solid var(--border-color);
}

.series-players {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
  font-weight: 600;
}

.series-score {
  text-align: center;
  padding: 5px 15px;
  background: var(--bg-color);
  border-radius: 4px;
  font-size: 14px;
}

.games-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.game-item {
  padding: 5px 12px;
  background: var(--bg-color);
  border-radius: 4px;
  font-size: 13px;
}

.winner-highlight {
  background: var(--primary-color);
  color: white;
  font-weight: 600;
  padding: 15px;
  border-radius: 8px;
  text-align: center;
  font-size: 18px;
  margin-top: 15px;
}

/* Toast */
.toast {
  position: fixed;
  bottom: 20px;
  left: 20px;
  right: 20px;
  padding: 15px;
  background-color: var(--danger-color);
  color: white;
  border-radius: 8px;
  text-align: center;
  z-index: 1001;
  animation: slideUp 0.3s ease;
}

/* Universal hidden class */
.hidden {
  display: none !important;
}

.toast.hidden {
  display: none;
}

@keyframes slideUp {
  from {
    transform: translateY(100%);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

/* History list */
#history-list {
  display: flex;
  flex-direction: column;
  gap: 15px;
}

.history-card {
  background: var(--card-bg);
  border-radius: 12px;
  padding: 15px;
  box-shadow: var(--shadow);
}

.history-title {
  font-weight: 600;
  font-size: 16px;
  margin-bottom: 8px;
}

.history-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  font-size: 13px;
  color: var(--text-light);
  margin-bottom: 10px;
}

.history-winner {
  background: rgba(76, 175, 80, 0.1);
  color: var(--primary-color);
  padding: 5px 10px;
  border-radius: 4px;
  font-weight: 600;
}

.history-actions {
  display: flex;
  gap: 10px;
  margin-top: 10px;
}

.history-actions button {
  flex: 1;
  padding: 10px;
  font-size: 13px;
  min-height: 40px;
}

.loading-more {
  text-align: center;
  padding: 20px;
  color: var(--text-light);
}

.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-light);
}

/* Settings */
.settings-card {
  background: var(--card-bg);
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 15px;
  box-shadow: var(--shadow);
}

.settings-card h3 {
  margin-bottom: 15px;
  font-size: 16px;
}

.settings-card.danger {
  border: 2px solid var(--danger-color);
}

.user-id-label {
  font-size: 12px;
  color: var(--text-light);
}

.user-id-value {
  font-family: monospace;
  font-size: 12px;
  word-break: break-all;
  background: var(--bg-color);
  padding: 8px;
  border-radius: 4px;
  margin-top: 5px;
}

/* Modal */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal.hidden {
  display: none;
}

.modal-content {
  background: var(--card-bg);
  border-radius: 12px;
  width: 100%;
  max-width: 500px;
  max-height: 80vh;
  overflow-y: auto;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 15px 20px;
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  background: var(--card-bg);
}

.modal-header h2 {
  font-size: 18px;
}

.close-btn {
  width: 36px;
  height: 36px;
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
  color: var(--text-light);
}

.modal-body {
  padding: 20px;
}

.confirm-dialog {
  padding: 25px;
  text-align: center;
}

.confirm-dialog p {
  margin-bottom: 20px;
  font-size: 16px;
}

.confirm-btns {
  display: flex;
  gap: 15px;
}

.confirm-btns button {
  flex: 1;
}

/* Responsive */
@media (min-width: 481px) {
  .main-content {
    padding: 25px;
  }

  .radio-group {
    flex-direction: row;
    flex-wrap: wrap;
  }

  .radio-label {
    flex: 1;
    min-width: 120px;
  }
}

@media (min-width: 769px) {
  .main-content {
    padding: 30px 40px;
  }

  .tab-bar {
    max-width: 800px;
    left: 50%;
    transform: translateX(-50%);
    border-radius: 0 0 12px 12px;
  }

  .history-card {
    padding: 20px;
  }

  .history-actions {
    justify-content: flex-end;
  }

  .history-actions button {
    flex: none;
    width: auto;
    padding: 10px 20px;
  }
}
