:root {
  /* Light theme */
  --primary-color: #3b82f6;
  --secondary-color: #60a5fa;
  --accent-color: #f472b6;
  --win-color: #10b981;
  --lose-color: #ef4444;
  --draw-color: #f59e0b;
  --bg-color: #ffffff;
  --card-bg: #ffffff;
  --text-color: #1f2937;
  --border-color: #e5e7eb;
  --hover-color: #f9fafb;
  --shadow-color: rgba(0, 0, 0, 0.05);
}

.dark-theme {
  /* Dark theme */
  --primary-color: #3b82f6;
  --secondary-color: #60a5fa;
  --accent-color: #f472b6;
  --win-color: #10b981;
  --lose-color: #ef4444;
  --draw-color: #f59e0b;
  --bg-color: #111827;
  --card-bg: #1f2937;
  --text-color: #f9fafb;
  --border-color: #374151;
  --hover-color: #374151;
  --shadow-color: rgba(0, 0, 0, 0.2);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  transition: background-color 0.3s, color 0.3s, border-color 0.3s, box-shadow 0.3s;
}

body {
  background-color: var(--bg-color);
  color: var(--text-color);
  min-height: 100vh;
  overflow-x: hidden;
  line-height: 1.5;
}

#confetti-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 1000;
}

#game-container {
  max-width: 800px;
  margin: 0 auto;
  padding: 16px;
  position: relative;
  z-index: 1;
  width: 100%;
}

/* Header */
header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-color);
  flex-wrap: wrap;
  gap: 10px;
}

h1 {
  font-size: 1.75rem;
  color: var(--primary-color);
  font-weight: 700;
}

.controls {
  display: flex;
  gap: 8px;
}

.control-btn {
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 50%;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
  color: var(--primary-color);
  box-shadow: 0 1px 2px var(--shadow-color);
}

.control-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 2px 4px var(--shadow-color);
  border-color: var(--primary-color);
}

.control-btn:active {
  transform: translateY(0);
  box-shadow: 0 1px 2px var(--shadow-color);
}

/* Game Modes */
.game-modes {
  margin-bottom: 20px;
}

.mode-selector {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
  justify-content: center;
}

.mode-btn {
  padding: 6px 12px;
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  cursor: pointer;
  font-weight: 500;
  transition: all 0.2s ease;
  color: var(--text-color);
  font-size: 0.85rem;
  white-space: nowrap;
}

.mode-btn:hover {
  border-color: var(--primary-color);
  color: var(--primary-color);
}

.mode-btn.active {
  background: var(--primary-color);
  color: white;
  border-color: var(--primary-color);
}

/* Difficulty Selector */
.difficulty-selector {
  display: flex;
  gap: 8px;
  justify-content: center;
  flex-wrap: wrap;
}

.difficulty-btn {
  padding: 4px 10px;
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  cursor: pointer;
  font-weight: 500;
  transition: all 0.2s ease;
  color: var(--text-color);
  font-size: 0.75rem;
}

.difficulty-btn:hover {
  border-color: var(--primary-color);
  color: var(--primary-color);
}

.difficulty-btn.active {
  background: var(--primary-color);
  color: white;
  border-color: var(--primary-color);
}

/* Time Attack Mode */
#time-attack-container {
  margin-bottom: 20px;
}

.timer-container {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.timer-bar {
  flex-grow: 1;
  height: 6px;
  background-color: var(--border-color);
  border-radius: 3px;
  overflow: hidden;
}

.timer-progress {
  height: 100%;
  background-color: var(--primary-color);
  width: 100%;
  transition: width 1s linear;
}

.timer-text {
  font-weight: 600;
  min-width: 30px;
  text-align: right;
  font-size: 0.85rem;
}

.start-timer-btn {
  display: block;
  margin: 0 auto;
  padding: 6px 12px;
  background: var(--primary-color);
  color: white;
  border: none;
  border-radius: 16px;
  cursor: pointer;
  font-weight: 500;
  transition: all 0.2s ease;
  font-size: 0.85rem;
}

.start-timer-btn:hover {
  background: var(--secondary-color);
  transform: translateY(-2px);
  box-shadow: 0 2px 4px var(--shadow-color);
}

/* Scoreboard */
.scoreboard {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 20px;
}

.score-card {
  background: var(--card-bg);
  border-radius: 8px;
  padding: 10px;
  text-align: center;
  box-shadow: 0 2px 4px var(--shadow-color);
  border: 1px solid var(--border-color);
  position: relative;
}

.player-card {
  border-top: 2px solid var(--win-color);
}

.round-card {
  border-top: 2px solid var(--primary-color);
}

.computer-card {
  border-top: 2px solid var(--lose-color);
}

.score-title {
  font-size: 0.9rem;
  margin-bottom: 6px;
  color: var(--text-color);
  font-weight: 600;
}

.score {
  font-size: 2rem;
  font-weight: 700;
}

#player-score {
  color: var(--win-color);
}

#computer-score {
  color: var(--lose-color);
}

.round-number {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--primary-color);
}

.draw-text {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--draw-color);
  transform: scale(0);
  position: absolute;
  bottom: 8px;
  left: 0;
  right: 0;
}

.draw-animation {
  animation: drawPulse 0.5s ease forwards;
}

@keyframes drawPulse {
  0% {
    transform: scale(0);
  }
  50% {
    transform: scale(1.1);
  }
  100% {
    transform: scale(1);
  }
}

.best-of-container {
  margin-top: 8px;
}

.best-of-progress {
  height: 6px;
  background-color: var(--border-color);
  border-radius: 3px;
  position: relative;
  overflow: hidden;
}

.player-progress,
.computer-progress {
  position: absolute;
  height: 100%;
  transition: width 0.3s ease;
}

.player-progress {
  left: 0;
  background-color: var(--win-color);
  width: 0%;
}

.computer-progress {
  right: 0;
  background-color: var(--lose-color);
  width: 0%;
}

/* Countdown */
.countdown-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  background-color: rgba(0, 0, 0, 0.2);
  z-index: 100;
  backdrop-filter: blur(2px);
}

.countdown {
  font-size: 4rem;
  font-weight: 700;
  color: white;
  text-shadow: 0 0 8px var(--primary-color);
}

/* Result Display */
.result-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  background-color: rgba(0, 0, 0, 0.2);
  z-index: 100;
  backdrop-filter: blur(2px);
}

.result-text {
  font-size: 3rem;
  font-weight: 700;
  color: white;
  text-shadow: 0 0 8px var(--primary-color);
  animation: resultPulse 0.5s ease-in-out;
}

@keyframes resultPulse {
  0% {
    transform: scale(0);
    opacity: 0;
  }
  50% {
    transform: scale(1.1);
    opacity: 1;
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

/* Battle Arena */
.battle-arena {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  height: 90px;
}

.player-side,
.computer-side {
  flex: 1;
  display: flex;
  justify-content: center;
  align-items: center;
}

.vs-container {
  width: 40px;
  display: flex;
  justify-content: center;
  align-items: center;
}

.vs-text {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--primary-color);
}

.choice-display {
  width: 70px;
  height: 70px;
  background: var(--card-bg);
  border-radius: 50%;
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 2rem;
  box-shadow: 0 2px 4px var(--shadow-color);
  transition: all 0.3s ease;
  border: 1px solid var(--border-color);
}

.choice-display.flip {
  animation: flip 0.5s ease forwards;
}

@keyframes flip {
  0% {
    transform: rotateY(0deg);
  }
  100% {
    transform: rotateY(360deg);
  }
}

/* Game Options */
.options-container {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 20px;
  max-width: 500px;
  margin-left: auto;
  margin-right: auto;
}

.option {
  perspective: 1000px;
  cursor: pointer;
}

.option-inner {
  position: relative;
  width: 100%;
  height: 0;
  padding-bottom: 100%;
  transition: transform 0.3s;
}

.option:hover .option-inner {
  transform: translateY(-5px);
}

.option-front {
  position: absolute;
  width: 100%;
  height: 100%;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 2px 4px var(--shadow-color);
  background: var(--card-bg);
  border: 1px solid var(--border-color);
}

.option-content {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.emoji {
  font-size: 2.5rem;
}

.option-label {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(0, 0, 0, 0.5);
  color: white;
  padding: 6px;
  text-align: center;
  text-transform: capitalize;
  font-size: 0.85rem;
}

.option.player-win .option-front {
  border-color: var(--win-color);
  box-shadow: 0 0 8px var(--win-color);
}

.option.computer-win .option-front {
  border-color: var(--lose-color);
  box-shadow: 0 0 8px var(--lose-color);
}

.option.draw .option-front {
  border-color: var(--draw-color);
  box-shadow: 0 0 8px var(--draw-color);
}

/* Special Moves */
.special-moves {
  display: flex;
  justify-content: center;
  margin-bottom: 20px;
}

.special-move-btn {
  padding: 8px 16px;
  background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
  color: white;
  border: none;
  border-radius: 16px;
  cursor: pointer;
  font-weight: 600;
  transition: all 0.2s ease;
  box-shadow: 0 2px 4px var(--shadow-color);
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
}

.special-move-btn:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 3px 6px var(--shadow-color);
}

.special-move-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.special-move-counter {
  background-color: rgba(255, 255, 255, 0.3);
  padding: 2px 6px;
  border-radius: 8px;
  font-size: 0.75rem;
}

/* Tabs */
.tabs {
  background: var(--card-bg);
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 2px 4px var(--shadow-color);
  margin-bottom: 20px;
  border: 1px solid var(--border-color);
}

.tab-buttons {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
}

.tab-button {
  padding: 10px;
  background: var(--card-bg);
  border: none;
  border-bottom: 1px solid var(--border-color);
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 500;
  transition: all 0.2s ease;
  color: var(--text-color);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
}

.tab-button:hover {
  background: var(--hover-color);
}

.tab-button.active {
  border-bottom: 2px solid var(--primary-color);
  color: var(--primary-color);
}

.tab-panel {
  display: none;
  padding: 12px;
}

.tab-panel.active {
  display: block;
}

/* History Tab */
.history-container {
  max-height: 200px;
  overflow-y: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 6px;
  text-align: left;
  border-bottom: 1px solid var(--border-color);
  font-size: 0.85rem;
}

th {
  font-weight: 600;
  color: var(--text-color);
}

.result-badge {
  display: inline-block;
  padding: 2px 5px;
  border-radius: 10px;
  font-size: 0.7rem;
  font-weight: 500;
}

.win-badge {
  background-color: rgba(16, 185, 129, 0.2);
  color: var(--win-color);
}

.lose-badge {
  background-color: rgba(239, 68, 68, 0.2);
  color: var(--lose-color);
}

.draw-badge {
  background-color: rgba(245, 158, 11, 0.2);
  color: var(--draw-color);
}

.empty-message {
  text-align: center;
  padding: 12px;
  color: #6b7280;
  font-size: 0.85rem;
}

/* Stats Tab */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
}

.stats-card {
  background: var(--card-bg);
  border-radius: 6px;
  padding: 12px;
  box-shadow: 0 1px 3px var(--shadow-color);
  border: 1px solid var(--border-color);
}

.stats-card h3 {
  margin-bottom: 10px;
  font-size: 0.95rem;
  color: var(--primary-color);
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 4px;
}

.stats-item {
  display: flex;
  justify-content: space-between;
  margin-bottom: 6px;
  font-size: 0.85rem;
}

.distribution-item {
  margin-bottom: 10px;
}

.distribution-label {
  display: flex;
  justify-content: space-between;
  margin-bottom: 3px;
  font-size: 0.85rem;
}

.progress-bar {
  height: 5px;
  background-color: var(--border-color);
  border-radius: 2px;
  overflow: hidden;
}

.progress {
  height: 100%;
  background-color: var(--primary-color);
  border-radius: 2px;
  transition: width 0.3s ease;
}

/* Achievements Tab */
.achievements-header {
  text-align: center;
  margin-bottom: 12px;
}

#achievements-count {
  font-size: 0.85rem;
  background-color: var(--primary-color);
  color: white;
  padding: 2px 8px;
  border-radius: 10px;
}

.achievements-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 10px;
}

.achievement {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--card-bg);
  border-radius: 6px;
  padding: 10px;
  box-shadow: 0 1px 3px var(--shadow-color);
  transition: all 0.2s ease;
  border: 1px solid var(--border-color);
  position: relative;
  overflow: hidden;
}

.achievement:hover {
  transform: translateY(-2px);
  box-shadow: 0 2px 4px var(--shadow-color);
}

.achievement.unlocked {
  border-color: var(--win-color);
}

.achievement.unlocked::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.1), transparent);
  z-index: 0;
}

.achievement-icon {
  font-size: 1.25rem;
  background: var(--primary-color);
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: flex;
  justify-content: center;
  align-items: center;
  box-shadow: 0 1px 2px var(--shadow-color);
  position: relative;
  z-index: 1;
}

.achievement.unlocked .achievement-icon {
  background: var(--win-color);
}

.achievement-info {
  flex-grow: 1;
  position: relative;
  z-index: 1;
}

.achievement-name {
  font-weight: 600;
  font-size: 0.85rem;
  margin-bottom: 4px;
}

.achievement-progress {
  margin-top: 4px;
}

.achievement-progress .progress-bar {
  height: 4px;
  background-color: var(--border-color);
  border-radius: 2px;
  overflow: hidden;
}

.achievement-progress .progress {
  height: 100%;
  background-color: var(--primary-color);
  border-radius: 2px;
  transition: width 0.3s ease;
}

.achievement.unlocked .achievement-progress .progress {
  background-color: var(--win-color);
  width: 100% !important;
}

/* Animation for unlocking achievements */
@keyframes achievementUnlock {
  0% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.03);
  }
  100% {
    transform: scale(1);
  }
}

.achievement.just-unlocked {
  animation: achievementUnlock 0.5s ease;
}

/* Toast */
.toast {
  position: fixed;
  bottom: 16px;
  right: 16px;
  background: var(--card-bg);
  border-radius: 6px;
  padding: 10px 14px;
  box-shadow: 0 2px 5px var(--shadow-color);
  transform: translateY(150%);
  transition: transform 0.3s ease;
  z-index: 1000;
  max-width: 250px;
  border: 1px solid var(--border-color);
}

.toast.show {
  transform: translateY(0);
}

.toast-title {
  font-weight: 600;
  margin-bottom: 3px;
  color: var(--primary-color);
  font-size: 0.85rem;
}

.toast-message {
  color: var(--text-color);
  font-size: 0.8rem;
}

.toast.success {
  border-left: 2px solid var(--win-color);
}

.toast.error {
  border-left: 2px solid var(--lose-color);
}

.toast.warning {
  border-left: 2px solid var(--draw-color);
}

.toast.info {
  border-left: 2px solid var(--primary-color);
}

/* Modal */
.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.4);
  z-index: 1000;
  justify-content: center;
  align-items: center;
  backdrop-filter: blur(2px);
}

.modal.show {
  display: flex;
}

.modal-content {
  background: var(--card-bg);
  border-radius: 8px;
  width: 90%;
  max-width: 400px;
  box-shadow: 0 4px 8px var(--shadow-color);
  animation: modalFadeIn 0.3s ease;
  border: 1px solid var(--border-color);
}

@keyframes modalFadeIn {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px;
  border-bottom: 1px solid var(--border-color);
}

.modal-header h2 {
  font-size: 1.25rem;
  color: var(--primary-color);
  margin: 0;
  font-weight: 600;
}

.close-modal {
  background: none;
  border: none;
  font-size: 1.25rem;
  cursor: pointer;
  color: var(--text-color);
  transition: color 0.2s ease;
}

.close-modal:hover {
  color: var(--primary-color);
}

.modal-body {
  padding: 12px;
  max-height: 70vh;
  overflow-y: auto;
}

.modal-body h3 {
  color: var(--primary-color);
  margin: 10px 0 6px;
  font-size: 1rem;
  font-weight: 600;
}

.modal-body ul {
  margin-left: 16px;
  margin-bottom: 10px;
}

.modal-body li {
  margin-bottom: 4px;
  font-size: 0.85rem;
}

.modal-body p {
  margin-bottom: 10px;
  line-height: 1.4;
  font-size: 0.85rem;
}

#game-result {
  font-size: 1.5rem;
  font-weight: 700;
  text-align: center;
  margin: 12px 0;
  color: var(--primary-color);
}

.final-score {
  display: flex;
  justify-content: space-around;
  margin: 16px 0;
}

.final-score-item {
  text-align: center;
}

.final-score-item span:first-child {
  font-size: 0.9rem;
  display: block;
  margin-bottom: 3px;
}

.final-score-item span:last-child {
  font-size: 1.5rem;
  font-weight: 700;
}

.play-again-btn {
  display: block;
  margin: 0 auto;
  padding: 8px 16px;
  background: var(--primary-color);
  color: white;
  border: none;
  border-radius: 16px;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 600;
  transition: all 0.2s ease;
  box-shadow: 0 1px 3px var(--shadow-color);
}

.play-again-btn:hover {
  background: var(--secondary-color);
  transform: translateY(-2px);
  box-shadow: 0 2px 4px var(--shadow-color);
}

/* Utility Classes */
.hidden {
  display: none !important;
}

/* Responsive Design */
@media (max-width: 768px) {
  h1 {
    font-size: 1.5rem;
  }

  .scoreboard {
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
  }

  .score-card {
    padding: 8px;
  }

  .score {
    font-size: 1.75rem;
  }

  .round-number {
    font-size: 1rem;
  }

  .battle-arena {
    height: 80px;
  }

  .choice-display {
    width: 60px;
    height: 60px;
    font-size: 1.75rem;
  }

  .emoji {
    font-size: 2rem;
  }

  .achievements-grid {
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  }

  .achievement {
    padding: 8px;
  }

  .achievement-icon {
    width: 25px;
    height: 25px;
    font-size: 1rem;
  }

  .achievement-name {
    font-size: 0.8rem;
  }

  .result-text {
    font-size: 2.5rem;
  }

  .countdown {
    font-size: 3.5rem;
  }
}

@media (max-width: 576px) {
  #game-container {
    padding: 12px;
  }

  header {
    flex-direction: column;
    align-items: flex-start;
  }

  .controls {
    align-self: flex-end;
    margin-top: 8px;
  }

  .mode-selector {
    gap: 6px;
  }

  .mode-btn {
    padding: 5px 10px;
    font-size: 0.8rem;
  }

  .difficulty-btn {
    padding: 4px 8px;
    font-size: 0.7rem;
  }

  .scoreboard {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .score-card {
    padding: 8px;
  }

  .battle-arena {
    height: auto;
    flex-direction: column;
    gap: 10px;
  }

  .vs-container {
    height: 20px;
  }

  .vs-text {
    font-size: 1rem;
  }

  .choice-display {
    width: 50px;
    height: 50px;
    font-size: 1.5rem;
  }

  .options-container {
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
  }

  .emoji {
    font-size: 1.75rem;
  }

  .option-label {
    padding: 4px;
    font-size: 0.75rem;
  }

  .tab-buttons {
    display: flex;
    overflow-x: auto;
  }

  .tab-button {
    flex: 1;
    white-space: nowrap;
    padding: 8px;
    font-size: 0.8rem;
  }

  .achievements-grid {
    grid-template-columns: repeat(auto-fill, minmax(100%, 1fr));
  }

  .result-text {
    font-size: 2rem;
  }

  .countdown {
    font-size: 3rem;
  }

  .modal-content {
    width: 95%;
  }

  .modal-body {
    padding: 10px;
  }

  #game-result {
    font-size: 1.25rem;
  }

  .final-score-item span:last-child {
    font-size: 1.25rem;
  }
}

@media (max-width: 360px) {
  h1 {
    font-size: 1.25rem;
  }

  .controls {
    gap: 5px;
  }

  .control-btn {
    width: 32px;
    height: 32px;
  }

  .options-container {
    gap: 5px;
  }

  .emoji {
    font-size: 1.5rem;
  }

  .choice-display {
    width: 45px;
    height: 45px;
    font-size: 1.25rem;
  }

  .special-move-btn {
    padding: 6px 12px;
    font-size: 0.8rem;
  }

  .toast {
    max-width: 200px;
  }
}
