/* --------------------
  Core Variables
-------------------- */
:root {
  /* Colors */
  --primary-color: rgb(108, 92, 231);
  --secondary-color: rgb(168, 129, 230);
  --accent-color: rgb(0, 210, 211);
  --background-color: #18192f;
  --surface-color: #242538;
  --text-color: #ffffff;
  --success-color: #00b894;
  --danger-color: #ff7675;
  --error-color: #ff4757;

  /* Theme Colors */
  --light-bg: #f0f2f5;
  --light-surface: #ffffff;
  --light-text: #1a1a1a;

  /* Special Effects */
  --input-bg: rgba(255, 255, 255, 0.1);
  --gradient-1: linear-gradient(
    135deg,
    var(--primary-color),
    var(--accent-color)
  );
  --gradient-2: linear-gradient(
    135deg,
    var(--success-color),
    var(--accent-color)
  );
  --glow: 0 0 20px rgba(108, 92, 231, 0.3);
}

/* --------------------
  Composition Layer
-------------------- */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  margin: 0;
  background-color: var(--background-color);
  font-family: "Inter", sans-serif;
}

.game-container {
  position: relative;
  width: 100%;
  max-width: 800px;
  background: var(--surface-color);
  padding: 20px 20px 40px;
  border-radius: 24px;
  text-align: center;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
}

.game-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 10px;
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  padding: 16px;
}

/* --------------------
  Utility Classes
-------------------- */
.flex-center {
  display: flex;
  align-items: center;
  justify-content: center;
}

.gradient-text {
  background: var(--gradient-1);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.icon {
  width: 24px;
  height: 24px;
  fill: var(--accent-color);
}

.icon-small {
  width: 16px;
  height: 16px;
  fill: var(--accent-color);
  transition: transform 0.3s ease;
}

.item {
  padding: 6px;
  border-radius: 6px;
  justify-content: center;
  font-size: 0.8rem;
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn {
  padding: 8px 16px;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.3s ease;
  text-align: center;
  background: var(--gradient-2);
  color: var(--text-color);
  font-weight: 700;
}

.btn:hover {
  transform: translateY(-2px);
  box-shadow: var(--glow);
}

.btn svg {
  fill: var(--text-color);
  width: 24px;
  height: 24px;
}

/* --------------------
  Block Components
-------------------- */
/* Game Title */
.game-container h1 {
  margin: 0 0 24px 0;
  font-size: clamp(24px, 6vw, 36px);
}

/* Score Display */
.score-display {
  color: var(--accent-color);
  font-weight: 700;
  justify-self: start;
}

/* Speed Display */
.speed-display {
  color: var(--accent-color);
  font-weight: 700;
}

#speedValue {
  font-family: monospace;
  font-size: 1.2em;
  color: var(--accent-color);
  text-shadow: 0 0 10px rgba(0, 210, 211, 0.3);
}

/* Controls Hint */
.controls-hint {
  color: rgba(0, 210, 211, 0.8);
  font-size: 0.7rem;
  gap: 8px;
  margin-bottom: 16px;
  line-height: 2;
}

.controls-hint span {
  background-color: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 4px;
  padding: 3px 5px;
  font-size: 0.5rem;
  margin: 0 3px;
  font-weight: 700;
}

/* Game Canvas */
canvas {
  width: 100%;
  max-width: 500px;
  height: auto;
  aspect-ratio: 1;
  border: 2px solid var(--secondary-color);
  border-radius: 16px;
  margin: 0 auto;
  display: block;
}

/* Dropdown Menu */
.dropdown {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.dropdown-trigger {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  transition: all 0.3s ease;
  border: none;
  background: none;
  color: var(--text-color);
  padding: 8px 16px;
}

.dropdown-content {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 200px;
  background-color: var(--surface-color);
  border-radius: 12px;
  padding: 12px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-10px) scale(0.95);
  transform-origin: top right;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 100;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 12px;
  border: none;
  background: none;
  color: var(--text-color);
  cursor: pointer;
  border-radius: 8px;
  transition: all 0.3s ease;
}

/* Modal Components */
.modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.8);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  z-index: 1000;
  justify-content: center;
  align-items: center;
}

.modal-content {
  background: var(--surface-color);
  padding: 32px;
  border-radius: 20px;
  width: 90%;
  max-width: 400px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
  transform: scale(0.95);
  transition: transform 0.3s ease;
  color: var(--text-color);
}

.modal-content h2 {
  font-size: 1.5rem;
  margin-bottom: 24px;
  text-align: center;
}

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

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

.form-group input {
  width: 100%;
  padding: 8px;
  border: 2px solid var(--input-bg);
  border-radius: 8px;
  background: var(--input-bg);
  color: var(--text-color);
}

.form-group input[type="color"] {
  width: 60px;
  height: 60px;
}

.form-group input:focus {
  border-color: var(--primary-color);
  outline: none;
}

.form-group.checkbox {
  display: flex;
  align-items: center;
  gap: 8px;
}

.form-group.checkbox input[type="checkbox"] {
  width: auto;
  accent-color: var(--primary-color);
}

.form-group.checkbox label {
  margin: 0;
  font-size: 14px;
}

.form-actions {
  display: flex;
  margin-top: 48px;
  justify-content: space-between;
}

/* Settings Group */
.settings-group {
  display: flex;
  flex-direction: column;
  gap: 20px;
  margin-bottom: 24px;
}

.theme-switch {
  display: flex;
  align-items: center;
}

.switch-label {
  position: relative;
  display: inline-block;
  width: 60px;
  height: 34px;
  background: var(--gradient-1);
  border-radius: 17px;
  cursor: pointer;
  padding: 4px;
}

.switch-label .icon {
  width: 26px;
  height: 26px;
  fill: var(--text-color);
  transition: all 0.3s ease;
}

.switch-label .moon {
  display: none;
}

#themeToggle {
  display: none;
}

#themeToggle:checked + .switch-label {
  background: linear-gradient(135deg, #2c3e50, #3498db);
}

#themeToggle:checked + .switch-label .sun {
  display: none;
}

#themeToggle:checked + .switch-label .moon {
  display: block;
}

/* Game Over Screen */
.game-over {
  position: absolute;
  inset: 0;
  background: rgba(24, 25, 47, 0.9);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  border-radius: 24px;
  display: none;
}

.game-over-content {
  width: 400px;
  text-align: center;
  color: var(--text-color);
  padding: 32px;
  background: var(--surface-color);
  border-radius: 20px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
}

.game-over-content h2 {
  font-size: 2rem;
  margin-bottom: 16px;
}

.game-over-content p {
  margin-bottom: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.game-over-content #finalScore {
  font-size: 2rem;
  font-weight: 700;
  color: var(--accent-color);
  margin-left: 8px;
}
/* Rankings List */
.ranking-list {
  margin: 20px 0;
  padding: 16px;
  background: var(--input-bg);
  border-radius: 12px;
  max-height: 200px;
  overflow-y: auto;
}

.ranking-list h3 {
  font-size: 1.2rem;
  margin-bottom: 12px;
}

#topScores {
  list-style: none;
}

.ranking-list .no-scores {
  color: var(--accent-color);
  font-weight: 700;
  text-align: center;
}

.score-item {
  width: 100%;
  display: grid;
  grid-template-columns: 1fr 3fr 2fr 3fr;
  align-items: center;
  padding: 12px 0;
  color: var(--text-color);
}

.score-item:not(:last-child) {
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.score-item.top-three {
  background: rgba(108, 92, 231, 0.2);
  border-left: 3px solid var(--primary-color);
}

.score-item .rank {
  font-weight: 700;
  color: var(--accent-color);
}

.score-item .player-name {
  color: var(--text-color);
  text-align: left;
  font-size: 0.8rem;
  overflow: hidden;
  text-overflow: ellipsis;
}

.score-item .score-value {
  color: var(--success-color);
  font-weight: 700;
}

.score-item .date {
  color: var(--text-color);
  opacity: 0.7;
  font-size: 0.8rem;
}

#restartBtn {
  padding: 16px 32px;
  margin: auto;
  font-size: 18px;
  border-radius: 12px;
}

/* --------------------
  State Classes
-------------------- */
.dropdown.active .dropdown-content {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}

.dropdown.active .icon-small {
  transform: rotate(180deg);
}

.modal.active {
  display: flex !important;
}

.game-over.active {
  display: flex;
  justify-content: center;
  align-items: center;
}

#logoutBtn {
  display: none; 
}

#logoutBtn.show {
  display: flex;
}

/* --------------------
  Theme Variations
-------------------- */
body.light-theme {
  background-color: var(--light-bg);
}

body.light-theme .game-container {
  background: var(--light-surface);
}

body.light-theme .item {
  background: rgba(0, 0, 0, 0.05);
  color: var(--light-text);
}

/* --------------------
  Media Queries
-------------------- */
@media (max-width: 600px) {
  .game-header {
    flex-direction: column;
    align-items: stretch;
  }

  .dropdown-content {
    top: calc(100% + 16px);
    right: auto;
  }
}

/* --------------------
  Animations
-------------------- */
@keyframes slideUp {
  from {
    transform: translateY(20px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}
