/* Root variables for theming */
:root {
  --primary-color: #3498DB;
  --secondary-color: #2ECC71;
  --danger-color: #E74C3C;
  --warning-color: #F39C12;
  --dark-color: #2C3E50;
  --light-color: #ECF0F1;
  --border-radius: 12px;
  --spacing: 16px;
  --transition: all 0.3s ease;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  background-attachment: fixed;
  min-height: 100vh;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  color: var(--dark-color);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Container */
.container {
  max-width: 480px;
  margin: 0 auto;
  padding: var(--spacing);
  min-height: 100vh;
}

/* Card component */
.card {
  background: white;
  border-radius: 14px;
  padding: 20px;
  margin-bottom: var(--spacing);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08), 0 2px 8px rgba(0, 0, 0, 0.06);
}

/* Typography */
h1 {
  font-size: 32px;
  font-weight: 700;
  margin-bottom: 8px;
  color: white;
  text-align: center;
  letter-spacing: -0.5px;
}

h2 {
  font-size: 24px;
  font-weight: 700;
  margin-bottom: var(--spacing);
  color: var(--dark-color);
  letter-spacing: -0.3px;
}

h3 {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--dark-color);
  letter-spacing: -0.2px;
}

p {
  line-height: 1.6;
  margin-bottom: 12px;
  color: #666;
}

/* Form elements */
.form-group {
  margin-bottom: var(--spacing);
}

label {
  display: block;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--dark-color);
  font-size: 14px;
}

input[type="text"],
input[type="number"],
textarea,
select {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid rgba(0, 0, 0, 0.1);
  border-radius: 10px;
  font-size: 16px;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  font-family: inherit;
  background: #F8F9FA;
}

input[type="text"]:focus,
input[type="number"]:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: var(--primary-color);
  background: white;
  box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
}

textarea {
  resize: vertical;
  min-height: 80px;
}

/* Checkbox and toggle */
.checkbox-group {
  display: flex;
  align-items: center;
  margin-bottom: var(--spacing);
}

.checkbox-group input[type="checkbox"] {
  width: 20px;
  height: 20px;
  margin-right: 12px;
  cursor: pointer;
}

.checkbox-group label {
  margin: 0;
  cursor: pointer;
}

/* Buttons */
.btn {
  display: inline-block;
  padding: 14px 20px;
  border: none;
  border-radius: 12px;
  font-size: 16px;
  font-weight: 600;
  text-align: center;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  text-decoration: none;
  width: 100%;
  margin-bottom: 12px;
  letter-spacing: -0.2px;
}

.btn-primary {
  background: var(--primary-color);
  color: white;
  box-shadow: 0 2px 6px rgba(52, 152, 219, 0.3);
}

.btn-primary:hover {
  background: #2980B9;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(52, 152, 219, 0.4);
}

.btn-success {
  background: var(--secondary-color);
  color: white;
  box-shadow: 0 2px 6px rgba(46, 204, 113, 0.3);
}

.btn-success:hover {
  background: #27AE60;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(46, 204, 113, 0.4);
}

.btn-danger {
  background: var(--danger-color);
  color: white;
  box-shadow: 0 2px 6px rgba(231, 76, 60, 0.3);
}

.btn-danger:hover {
  background: #C0392B;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(231, 76, 60, 0.4);
}

.btn-warning {
  background: var(--warning-color);
  color: white;
  box-shadow: 0 2px 6px rgba(243, 156, 18, 0.3);
}

.btn-warning:hover {
  background: #E67E22;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(243, 156, 18, 0.4);
}

.btn-secondary {
  background: var(--light-color);
  color: var(--dark-color);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.btn-secondary:hover {
  background: #BDC3C7;
  transform: translateY(-1px);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

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

.btn:disabled:hover {
  transform: none;
  box-shadow: none;
}

/* Button group */
.btn-group {
  display: flex;
  gap: 12px;
  margin-bottom: var(--spacing);
}

.btn-group .btn {
  flex: 1;
  margin-bottom: 0;
}

/* Lists */
.participant-list {
  list-style: none;
}

.participant-item {
  background: #F8F9FA;
  padding: 14px 16px;
  border-radius: 12px;
  margin-bottom: 8px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: all 0.2s ease;
  border: 1px solid rgba(0, 0, 0, 0.05);
}

.participant-item:hover {
  background: #E9ECEF;
  transform: translateX(2px);
}

.participant-item strong {
  color: var(--dark-color);
  font-weight: 600;
}

.participant-item span {
  color: #666;
  font-size: 14px;
}

/* Leaderboard */
.leaderboard-item {
  background: white;
  border: 1px solid rgba(0, 0, 0, 0.06);
  padding: 16px;
  border-radius: 12px;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
  transition: all 0.2s ease;
}

.leaderboard-item:hover {
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
  transform: translateY(-1px);
}

.leaderboard-item.winner {
  background: linear-gradient(135deg, #F39C12 0%, #E67E22 100%);
  color: white;
  border: none;
  box-shadow: 0 4px 12px rgba(243, 156, 18, 0.3);
}

.leaderboard-rank {
  font-size: 24px;
  font-weight: 700;
  min-width: 40px;
  text-align: center;
}

.leaderboard-info {
  flex: 1;
}

.leaderboard-name {
  font-weight: 600;
  font-size: 16px;
  margin-bottom: 4px;
}

.leaderboard-item {
  font-size: 14px;
  opacity: 0.8;
}

.leaderboard-score {
  font-size: 28px;
  font-weight: 700;
}

/* QR Code */
.qr-container {
  text-align: center;
  padding: var(--spacing);
}

.qr-container img {
  max-width: 250px;
  width: 100%;
  height: auto;
  margin: 0 auto;
}

/* Status badges */
.badge {
  display: inline-block;
  padding: 6px 14px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.badge-setup {
  background: var(--warning-color);
  color: white;
}

.badge-active {
  background: var(--secondary-color);
  color: white;
}

.badge-finished {
  background: var(--dark-color);
  color: white;
}

.badge-locked {
  background: var(--danger-color);
  color: white;
}

/* Loading spinner */
.spinner {
  border: 3px solid var(--light-color);
  border-top: 3px solid var(--primary-color);
  border-radius: 50%;
  width: 40px;
  height: 40px;
  animation: spin 1s linear infinite;
  margin: 20px auto;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* Alert messages */
.alert {
  padding: 14px 16px;
  border-radius: 12px;
  margin-bottom: var(--spacing);
  font-size: 15px;
  font-weight: 500;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.alert-success {
  background: #D4EDDA;
  color: #155724;
  border: none;
}

.alert-error {
  background: #F8D7DA;
  color: #721C24;
  border: none;
}

.alert-info {
  background: #D1ECF1;
  color: #0C5460;
  border: none;
}

/* Voting interface */
.voting-card {
  background: white;
  border-radius: 14px;
  padding: 24px;
  margin-bottom: var(--spacing);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08), 0 2px 8px rgba(0, 0, 0, 0.06);
  text-align: center;
}

.current-item {
  font-size: 26px;
  font-weight: 700;
  color: var(--primary-color);
  margin: 16px 0;
  letter-spacing: -0.5px;
}

.score-selector {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-top: 12px;
}

.score-btn {
  flex: 1;
  padding: 16px;
  border: 1px solid rgba(0, 0, 0, 0.1);
  border-radius: 12px;
  background: #F8F9FA;
  font-size: 18px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.score-btn:hover {
  background: #E9ECEF;
  transform: scale(1.05);
}

.score-btn.selected {
  background: var(--primary-color);
  color: white;
  border-color: var(--primary-color);
  box-shadow: 0 2px 8px rgba(52, 152, 219, 0.3);
  transform: scale(1.05);
}

/* iOS-style Segmented Control Tabs */
.tabs {
  display: flex;
  background: rgba(255, 255, 255, 0.15);
  border-radius: 10px;
  padding: 3px;
  margin-bottom: 20px;
  gap: 4px;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.tab {
  flex: 1;
  padding: 10px 12px;
  background: transparent;
  border: none;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.8);
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  z-index: 1;
}

.tab:hover {
  color: rgba(255, 255, 255, 0.95);
}

.tab.active {
  background: white;
  color: var(--primary-color);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.tab-content {
  display: none;
  animation: fadeIn 0.3s ease-in-out;
}

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

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(5px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Category list */
.category-list {
  margin-top: 16px;
}

.category-item {
  background: #F8F9FA;
  padding: 14px 16px;
  border-radius: 12px;
  margin-bottom: 8px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border: 1px solid rgba(0, 0, 0, 0.05);
  transition: all 0.2s ease;
}

.category-item:hover {
  background: #E9ECEF;
}

.category-item button {
  background: var(--danger-color);
  color: white;
  border: none;
  padding: 6px 14px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.category-item button:hover {
  transform: scale(1.05);
  box-shadow: 0 2px 6px rgba(231, 76, 60, 0.3);
}

/* Utility classes */
.text-center {
  text-align: center;
}

.mt-1 {
  margin-top: 8px;
}

.mt-2 {
  margin-top: 16px;
}

.mb-1 {
  margin-bottom: 8px;
}

.mb-2 {
  margin-bottom: 16px;
}

.hidden {
  display: none !important;
}

/* iOS specific fixes */
@supports (-webkit-touch-callout: none) {
  body {
    min-height: -webkit-fill-available;
  }
}

/* iOS-style Info Sections */
.info-section {
  margin-bottom: 24px;
}

.info-section-title {
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: rgba(255, 255, 255, 0.85);
  margin: 0 0 8px 12px;
}

.info-card {
  padding: 16px;
  margin-bottom: 0;
}

.info-card p {
  margin: 0;
  line-height: 1.5;
  color: var(--dark-color);
}

.info-card p:last-child {
  margin-bottom: 0;
}

/* Responsive adjustments */
@media (max-width: 375px) {
  .container {
    padding: 12px;
  }

  .card {
    padding: 16px;
  }

  h1 {
    font-size: 24px;
  }

  h2 {
    font-size: 20px;
  }

  .info-section-title {
    font-size: 12px;
    margin-left: 8px;
  }
}

/* Winner Animation */
@keyframes bounce-in {
  0% {
    transform: scale(0.3);
    opacity: 0;
  }
  50% {
    transform: scale(1.05);
  }
  70% {
    transform: scale(0.9);
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

@keyframes confetti {
  0% {
    transform: translateY(0) rotate(0deg);
  }
  100% {
    transform: translateY(100vh) rotate(360deg);
  }
}

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

#winnerAnimation {
  animation: bounce-in 0.6s ease-out;
}

#winnerAnimation h1 {
  animation: pulse 2s ease-in-out infinite;
}

#winnerName {
  animation: bounce-in 0.8s ease-out 0.2s both;
}

#winnerItem {
  animation: bounce-in 0.8s ease-out 0.4s both;
}

/* Password Gate - iOS Style */
#passwordGate .card {
  padding: 32px 24px;
  text-align: center;
}

#passwordGate h2 {
  font-size: 28px;
  margin-bottom: 8px;
}

#passwordGate p {
  margin-bottom: 32px;
  font-size: 15px;
}

#passwordForm {
  max-width: 320px;
  margin: 0 auto;
}

#passwordForm .form-group {
  margin-bottom: 24px;
}

#passwordForm label {
  text-align: left;
  font-size: 15px;
  margin-bottom: 10px;
  color: #666;
}

/* iOS-style password input */
input[type="password"] {
  width: 100%;
  padding: 16px 18px;
  border: 1px solid rgba(0, 0, 0, 0.1);
  border-radius: 12px;
  font-size: 18px;
  font-family: inherit;
  background: #F8F9FA;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  text-align: center;
  letter-spacing: 0.5px;
}

input[type="password"]:focus {
  outline: none;
  border-color: var(--primary-color);
  background: white;
  box-shadow: 0 0 0 4px rgba(52, 152, 219, 0.12);
}

input[type="password"]::placeholder {
  color: #999;
  text-align: center;
}

#passwordForm .btn {
  width: 100%;
  padding: 16px;
  font-size: 18px;
  font-weight: 600;
  margin-top: 8px;
}
