@import url('https://fonts.googleapis.com/css2?family=Oxanium:wght@300;500;700&display=swap');

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

body {
  background: #050a12;
  color: #c8dce8;
  font-family: 'Oxanium', sans-serif;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 100vh;
  overflow-x: hidden;
}

#game-wrapper {
  width: 100%;
  max-width: 960px;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 8px;
  position: relative;
}

#hud {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 16px;
  background: linear-gradient(180deg, #0c1a2a 0%, #081220 100%);
  border: 1px solid rgba(40, 120, 200, 0.25);
  border-bottom: none;
  border-radius: 6px 6px 0 0;
  font-size: 11px;
  font-weight: 500;
  color: #00e5ff;
  text-shadow: 0 0 8px rgba(0,229,255,0.3);
  flex-wrap: wrap;
  gap: 6px;
  letter-spacing: 0.5px;
}

#main-area {
  display: flex;
  width: 100%;
  border: 1px solid rgba(40, 120, 200, 0.25);
  background: #060e1a;
  position: relative;
}

#canvas {
  flex: 1;
  display: block;
  background: #060e1a;
  cursor: crosshair;
  transition: transform 0.05s linear;
}

#palette {
  width: 90px;
  background: linear-gradient(180deg, #0a1525 0%, #060e18 100%);
  border-left: 1px solid rgba(40, 120, 200, 0.2);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 10px 6px;
  gap: 8px;
  flex-shrink: 0;
}

.palette-title {
  font-size: 9px;
  font-weight: 700;
  color: rgba(100, 180, 255, 0.6);
  letter-spacing: 3px;
  text-transform: uppercase;
}

.token-slot {
  width: 74px;
  background: linear-gradient(135deg, #0d1e30 0%, #081520 100%);
  border: 1.5px solid rgba(40, 100, 180, 0.3);
  border-radius: 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 5px;
  cursor: pointer;
  transition: all 0.2s ease;
  gap: 3px;
}

.token-slot:hover {
  border-color: rgba(0, 229, 255, 0.6);
  background: linear-gradient(135deg, #122a40 0%, #0c1e30 100%);
  transform: scale(1.04);
  box-shadow: 0 0 12px rgba(0, 229, 255, 0.15);
}

.token-slot:active {
  transform: scale(0.96);
}

.token-slot.selected {
  border-color: #ffcc00;
  background: linear-gradient(135deg, #1a2800 0%, #0d1a00 100%);
  box-shadow: 0 0 14px rgba(255, 204, 0, 0.25), inset 0 0 8px rgba(255, 204, 0, 0.08);
  transform: scale(1.06);
}

.token-slot.selected span {
  color: #ffcc00;
}

.token-slot span {
  font-size: 9px;
  font-weight: 500;
  color: rgba(150, 200, 255, 0.7);
}

.token-preview {
  width: 48px;
  height: 48px;
}

.palette-divider {
  width: 50px;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(40, 120, 200, 0.3), transparent);
  margin: 2px 0;
}

.palette-info {
  font-size: 8px;
  color: rgba(100, 160, 220, 0.5);
  font-weight: 300;
}

#controls {
  width: 100%;
  display: flex;
  justify-content: center;
  gap: 8px;
  padding: 10px 16px;
  background: linear-gradient(180deg, #081220 0%, #0c1a2a 100%);
  border: 1px solid rgba(40, 120, 200, 0.25);
  border-top: none;
  border-radius: 0 0 6px 6px;
  flex-wrap: wrap;
}

.ctrl-btn {
  font-family: 'Oxanium', sans-serif;
  font-size: 10px;
  font-weight: 500;
  padding: 8px 14px;
  background: linear-gradient(135deg, #0d1e30 0%, #081520 100%);
  color: #00e5ff;
  border: 1px solid rgba(0, 229, 255, 0.3);
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.15s ease;
  letter-spacing: 0.5px;
}

.ctrl-btn:hover:not(:disabled) {
  background: linear-gradient(135deg, #122a40 0%, #0e2030 100%);
  border-color: #00e5ff;
  box-shadow: 0 0 10px rgba(0, 229, 255, 0.2);
  color: #ffffff;
}

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

.ctrl-btn:active:not(:disabled) {
  transform: scale(0.95);
}

#overlay {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(3, 6, 12, 0.85);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  border-radius: 6px;
  animation: overlayFadeIn 0.3s ease;
}

#overlay.gameover-overlay {
  background: rgba(3, 6, 12, 0.35);
  backdrop-filter: blur(1px);
  align-items: flex-end;
  padding-bottom: 40px;
}

@keyframes overlayFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

#overlay.hidden {
  display: none;
}

#overlay-content {
  text-align: center;
  padding: 30px;
  max-width: 400px;
}

#overlay-content h1 {
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 16px;
  letter-spacing: 2px;
}

#overlay-content p {
  font-size: 9px;
  line-height: 2;
  margin-bottom: 16px;
  font-weight: 300;
  color: rgba(180, 210, 240, 0.8);
}

#overlay-content button {
  font-family: 'Oxanium', sans-serif;
  font-size: 11px;
  font-weight: 500;
  padding: 12px 24px;
  margin: 6px;
  background: linear-gradient(135deg, #0d1e30 0%, #081520 100%);
  color: #00e5ff;
  border: 1.5px solid rgba(0, 229, 255, 0.5);
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s ease;
  letter-spacing: 1px;
}

#overlay-content button:hover {
  background: #00e5ff;
  color: #050a12;
  box-shadow: 0 0 20px rgba(0, 229, 255, 0.3);
}

.gameover-title {
  color: #ff1744;
  text-shadow: 0 0 20px rgba(255, 23, 68, 0.6), 0 0 40px rgba(255, 23, 68, 0.3);
  animation: gameOverPulse 1s ease-in-out infinite alternate;
}

@keyframes gameOverPulse {
  from { text-shadow: 0 0 20px rgba(255, 23, 68, 0.6), 0 0 40px rgba(255, 23, 68, 0.3); }
  to { text-shadow: 0 0 30px rgba(255, 23, 68, 0.9), 0 0 60px rgba(255, 23, 68, 0.5); }
}

.gameover-reason {
  color: #ff6d00 !important;
  font-size: 12px !important;
  font-weight: 700 !important;
  letter-spacing: 2px;
  margin-bottom: 8px !important;
  text-transform: uppercase;
}

.levelcomplete-title {
  color: #00e676;
  text-shadow: 0 0 20px rgba(0, 230, 118, 0.4);
}

footer {
  padding: 16px;
  font-size: 10px;
}

footer a {
  color: rgba(100, 160, 220, 0.5);
  text-decoration: none;
  font-family: 'Oxanium', sans-serif;
  transition: color 0.2s;
}

footer a:hover {
  color: #00e5ff;
}

@media (max-width: 640px) {
  #palette {
    width: 72px;
    padding: 6px 4px;
  }
  .token-slot {
    width: 62px;
  }
  .token-preview {
    width: 40px;
    height: 40px;
  }
  #hud {
    font-size: 9px;
    padding: 8px 10px;
  }
  .ctrl-btn {
    font-size: 9px;
    padding: 6px 10px;
  }
  #overlay-content h1 {
    font-size: 16px;
  }
  #overlay-content p {
    font-size: 8px;
  }
  #overlay-content button {
    font-size: 9px;
    padding: 10px 16px;
  }
}