:root {
  --primary: #4361ee;
  --light: #f8f9fa;
  --dark: #212529;
  --gray: #6c757d;
  --shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

/* Reset & Base Styles */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
}

body {
  background: #f5f7ff;
  color: var(--dark);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 20px;
}

.container {
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
}

/* App Card */
.app-card {
  background: white;
  border-radius: 16px;
  box-shadow: var(--shadow);
  overflow: hidden;
  padding: 30px;
  transition: all 0.3s ease;
  border: 1px solid #e9ecef;
}

/* Header */
.app-header {
  text-align: center;
  margin-bottom: 30px;
  padding-bottom: 20px;
  border-bottom: 2px solid var(--primary);
}

.app-header h1 {
  font-size: 2.2rem;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.app-header h1 i {
  color: var(--primary);
}

.subtitle {
  font-size: 1rem;
  color: var(--gray);
  font-weight: 400;
}

/* Tabs */
.tabs {
  display: flex;
  background: var(--light);
  border-radius: 12px;
  padding: 6px;
  margin-bottom: 30px;
  max-width: 400px;
  margin-left: auto;
  margin-right: auto;
}

.tab {
  flex: 1;
  padding: 16px 24px;
  border: none;
  background: transparent;
  border-radius: 8px;
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--gray);
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.tab.active {
  background: white;
  color: var(--primary);
  box-shadow: 0 4px 12px rgba(67, 97, 238, 0.15);
}

.tab:hover:not(.active) {
  color: var(--primary);
  background: rgba(67, 97, 238, 0.05);
}

/* Sections */
.section {
  display: none;
}

.section.active {
  display: block;
  animation: fadeIn 0.5s ease;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

/* Dice Roller Section */
.dice-controls {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 30px;
  gap: 20px;
}

.control-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.control-group label {
  font-weight: 600;
  color: var(--dark);
  font-size: 1rem;
}

.number-selector {
  display: flex;
  align-items: center;
  background: var(--light);
  border-radius: 8px;
  overflow: hidden;
  width: 140px;
  border: 1px solid #dee2e6;
}

.selector-btn {
  background: var(--primary);
  color: white;
  border: none;
  width: 40px;
  height: 40px;
  font-size: 1.2rem;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.selector-btn:hover {
  background: var(--primary);
}

.selector-btn.minus {
  border-radius: 8px 0 0 8px;
}

.selector-btn.plus {
  border-radius: 0 8px 8px 0;
}

#diceCount {
  width: 60px;
  height: 40px;
  border: none;
  background: var(--light);
  text-align: center;
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--dark);
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
}

/* Action Buttons */
.action-btn {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary) 100%);
  color: white;
  border: none;
  border-radius: 8px;
  padding: 16px 32px;
  font-size: 1.1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 4px 15px rgba(67, 97, 238, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.action-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(67, 97, 238, 0.3);
}

.action-btn:active {
  transform: translateY(0);
}

.spin-btn {
  background: var(--primary);
  box-shadow: 0 0 0 3px rgba(67, 97, 238, 0.2);
}

.spin-btn:hover {
  box-shadow: 0 0 0 3px rgba(67, 97, 238, 0.2);
}

/* Dice Container */
.dice-container {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 20px;
  margin-bottom: 40px;
  min-height: 180px;
}

.dice {
  width: 100px;
  height: 100px;
  background: white;
  border-radius: 12px;
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 3rem;
  font-weight: 700;
  color: var(--primary);
  box-shadow: var(--shadow);
  border: 2px solid #e9ecef;
  position: relative;
  transform-style: preserve-3d;
  transition: transform 0.5s ease;
}

.dice.rolling {
  animation: rollDice 0.8s ease-out;
}

@keyframes rollDice {
  0% {
    transform: rotateX(0) rotateY(0);
  }
  25% {
    transform: rotateX(180deg) rotateY(90deg);
  }
  50% {
    transform: rotateX(360deg) rotateY(180deg);
  }
  75% {
    transform: rotateX(540deg) rotateY(270deg);
  }
  100% {
    transform: rotateX(720deg) rotateY(360deg);
  }
}

/* Result Display */
.result-display {
  background: var(--light);
  border-radius: 12px;
  padding: 24px;
  margin-top: 20px;
  border: 1px solid #e9ecef;
}

.result-display h3 {
  font-size: 1.5rem;
  color: var(--dark);
  margin-bottom: 16px;
  font-weight: 600;
}

.result-display h3 span {
  color: var(--primary);
  font-weight: 700;
}

.history-label {
  font-weight: 600;
  margin-bottom: 10px;
  color: var(--gray);
}

.history {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.history-item {
  background: white;
  padding: 8px 16px;
  border-radius: 6px;
  font-weight: 500;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
  border: 1px solid #dee2e6;
  color: var(--dark);
}

/* Spin Wheel Section */
.wheel-controls {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 30px;
  gap: 30px;
}

.options-editor {
  flex: 1;
  min-width: 300px;
  background: var(--light);
  border-radius: 12px;
  padding: 24px;
  border: 1px solid #e9ecef;
}

.options-editor h3 {
  margin-bottom: 20px;
  color: var(--primary);
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
}

.options-list {
  margin-bottom: 20px;
  max-height: 200px;
  overflow-y: auto;
}

.option-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: white;
  padding: 12px 16px;
  border-radius: 8px;
  margin-bottom: 10px;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
  border: 1px solid #dee2e6;
}

.option-item span {
  flex: 1;
  color: var(--dark);
}

.option-actions {
  display: flex;
  gap: 8px;
}

.option-btn {
  background: none;
  border: none;
  color: var(--gray);
  cursor: pointer;
  font-size: 0.9rem;
  padding: 4px;
  border-radius: 4px;
  transition: all 0.2s ease;
}

.option-btn:hover {
  color: var(--primary);
  background: rgba(67, 97, 238, 0.1);
}

.add-option {
  display: flex;
  gap: 10px;
}

#newOption {
  flex: 1;
  padding: 14px 18px;
  border: 2px solid #dee2e6;
  border-radius: 8px;
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  font-size: 1rem;
  transition: all 0.3s ease;
  color: var(--dark);
}

#newOption:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(67, 97, 238, 0.2);
}

.add-btn {
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 8px;
  width: 50px;
  font-size: 1.2rem;
  cursor: pointer;
  transition: all 0.3s ease;
}

.add-btn:hover {
  background: var(--primary);
}

/* Wheel Container */
.wheel-wrapper {
  display: flex;
  flex-wrap: wrap;
  gap: 40px;
  align-items: center;
  justify-content: center;
}

.wheel-container {
  position: relative;
  width: 400px;
  height: 400px;
}

#wheelCanvas {
  border-radius: 50%;
  box-shadow: var(--shadow);
  border: 3px solid white;
}

.wheel-pointer {
  position: absolute;
  top: -20px;
  left: 50%;
  transform: translateX(-50%);
  width: 40px;
  height: 40px;
  background: #e63946;
  clip-path: polygon(50% 0%, 0% 100%, 100% 100%);
  z-index: 10;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.2));
}

.wheel-spinning {
  animation: spin 3s cubic-bezier(0.2, 0.8, 0.3, 1) forwards;
}

@keyframes spin {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(var(--final-rotation));
  }
}

/* Footer */
.app-footer {
  margin-top: 40px;
  padding-top: 20px;
  border-top: 1px solid #dee2e6;
  text-align: center;
  color: var(--gray);
  font-size: 0.9rem;
}

/* Updated Color Palette for Wheel */
.wheelColors {
  --color-1: #4361ee;
  --color-2: #3a0ca3;
  --color-3: #4cc9f0;
  --color-4: #20c997;
  --color-5: #ff9e00;
  --color-6: #ff6b6b;
  --color-7: #9d4edd;
  --color-8: #f72585;
  --color-9: #4a4e69;
  --color-10: #38b000;
  --color-11: #f8961e;
  --color-12: #277da1;
}

/* Responsive Design */
@media (max-width: 768px) {
  .app-card {
    padding: 20px;
  }

  .app-header h1 {
    font-size: 1.8rem;
    flex-direction: column;
    gap: 5px;
  }

  .dice-controls,
  .wheel-controls {
    flex-direction: column;
    align-items: stretch;
  }

  .wheel-wrapper {
    flex-direction: column;
  }

  .wheel-container {
    width: 300px;
    height: 300px;
  }

  #wheelCanvas {
    width: 300px;
    height: 300px;
  }

  .dice {
    width: 80px;
    height: 80px;
    font-size: 2.5rem;
  }

  .options-editor {
    min-width: 100%;
  }
}

@media (max-width: 480px) {
  body {
    padding: 10px;
  }

  .app-header h1 {
    font-size: 1.5rem;
  }

  .tab {
    padding: 12px 16px;
    font-size: 1rem;
  }

  .dice {
    width: 70px;
    height: 70px;
    font-size: 2rem;
  }

  .wheel-container {
    width: 250px;
    height: 250px;
  }

  #wheelCanvas {
    width: 250px;
    height: 250px;
  }

  .action-btn {
    padding: 14px 24px;
    font-size: 1rem;
  }

  .action-btn:hover {
    box-shadow: 0 0 0 3px rgba(67, 97, 238, 0.2);
  }
}
