@import url('https://fonts.googleapis.com/css2?family=Special+Elite&family=Major+Mono+Display&display=swap');

:root {
  --bg: #2a1a0e;
  --bg2: #3d2817;
  --text: #e8d5b7;
  --text-dim: #9a8a7a;
  --accent: #d4a056;
  --accent2: #7a4a2a;
  --danger: #c04040;
  --success: #5a9a5a;
  --glow: rgba(212, 160, 86, 0.3);
  --cardboard: #b8956a;
  --paint-warm: #c4a882;
  --font-title: 'Major Mono Display', monospace;
  --font-body: 'Special Elite', serif, monospace;
}

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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  font-family: var(--font-body);
  color: var(--text);
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
  background: var(--bg);
}

#ui-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 10;
}

#ui-overlay > * {
  pointer-events: auto;
}

.screen {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse at center, rgba(42,26,14,0.92) 0%, rgba(20,10,5,0.96) 100%);
  z-index: 20;
}

.hidden { display: none !important; }

.title {
  font-family: var(--font-title);
  font-size: clamp(1.8rem, 6vw, 4rem);
  color: var(--accent);
  text-shadow: 0 0 20px var(--glow), 0 0 60px rgba(212,160,86,0.15);
  letter-spacing: 0.3em;
  margin-bottom: 0.5rem;
  text-align: center;
}

.subtitle {
  font-family: var(--font-body);
  font-size: clamp(0.7rem, 2vw, 1rem);
  color: var(--text-dim);
  letter-spacing: 0.15em;
  margin-bottom: 2.5rem;
  text-transform: lowercase;
}

.menu-items {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.menu-btn {
  font-family: var(--font-body);
  font-size: clamp(0.9rem, 2.5vw, 1.1rem);
  letter-spacing: 0.2em;
  color: var(--text);
  background: none;
  border: 1px solid var(--accent2);
  padding: 0.5rem 2rem;
  cursor: pointer;
  transition: all 0.2s;
  text-transform: uppercase;
  min-width: 200px;
  position: relative;
}

.menu-btn:hover, .menu-btn:focus {
  color: var(--accent);
  border-color: var(--accent);
  background: rgba(212,160,86,0.08);
  outline: none;
}

.menu-btn.small {
  font-size: clamp(0.7rem, 2vw, 0.85rem);
  padding: 0.35rem 1.2rem;
  min-width: auto;
}

.menu-footer {
  position: absolute;
  bottom: 1rem;
  left: 0;
  right: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 1rem;
}

.icon-btn {
  font-family: var(--font-body);
  font-size: 1.2rem;
  color: var(--text-dim);
  background: none;
  border: 1px solid var(--accent2);
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
}

.icon-btn:hover {
  color: var(--accent);
  border-color: var(--accent);
}

.version {
  font-size: 0.7rem;
  color: var(--text-dim);
  opacity: 0.5;
}

/* Tutorial */
.tutorial-content {
  max-width: 500px;
  width: 90%;
  padding: 1.5rem;
}

.tutorial-content h2 {
  font-family: var(--font-title);
  font-size: clamp(1.2rem, 3vw, 1.8rem);
  color: var(--accent);
  text-align: center;
  margin-bottom: 1.5rem;
  letter-spacing: 0.2em;
}

.tutorial-step {
  display: none;
  font-size: clamp(0.8rem, 2vw, 0.95rem);
  line-height: 1.6;
  color: var(--text);
  text-align: center;
}

.tutorial-step.active { display: block; }

.tutorial-step p { margin-bottom: 0.8rem; }

.tutorial-nav {
  display: flex;
  justify-content: center;
  gap: 0.5rem;
  margin-top: 1.5rem;
  align-items: center;
  flex-wrap: wrap;
}

#tutorial-dots {
  display: flex;
  gap: 0.3rem;
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent2);
  display: inline-block;
}

.dot.active { background: var(--accent); }

/* Leaderboard */
#leaderboard-screen h2 {
  font-family: var(--font-title);
  font-size: clamp(1.2rem, 3vw, 1.8rem);
  color: var(--accent);
  margin-bottom: 1.5rem;
  letter-spacing: 0.2em;
}

#leaderboard-entries {
  width: 90%;
  max-width: 400px;
  margin-bottom: 1rem;
}

.lb-entry {
  display: flex;
  justify-content: space-between;
  padding: 0.3rem 0.5rem;
  border-bottom: 1px solid rgba(212,160,86,0.1);
  font-size: clamp(0.75rem, 2vw, 0.9rem);
}

.lb-entry.highlight {
  color: var(--accent);
  background: rgba(212,160,86,0.08);
}

.lb-rank { color: var(--text-dim); min-width: 2rem; }
.lb-name { flex: 1; text-align: center; }
.lb-score { min-width: 4rem; text-align: right; color: var(--accent); }
.lb-date { min-width: 5rem; text-align: right; color: var(--text-dim); font-size: 0.8em; }

#lb-back { margin-top: 0.5rem; }

/* Settings */
#settings-screen h2 {
  font-family: var(--font-title);
  font-size: clamp(1.2rem, 3vw, 1.8rem);
  color: var(--accent);
  margin-bottom: 1.5rem;
  letter-spacing: 0.2em;
}

.setting-row {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
  width: 90%;
  max-width: 300px;
}

.setting-row label {
  font-size: 0.9rem;
  min-width: 5rem;
  color: var(--text);
}

.setting-row input[type="range"] {
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  height: 4px;
  background: var(--accent2);
  border-radius: 2px;
  outline: none;
}

.setting-row input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
}

#settings-back { margin-top: 0.5rem; }

/* HUD */
#hud {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 0.5rem 0.8rem;
  z-index: 15;
}

#turn-indicator {
  font-family: var(--font-title);
  font-size: clamp(0.6rem, 1.8vw, 0.85rem);
  color: var(--accent);
  letter-spacing: 0.2em;
  text-shadow: 0 0 10px var(--glow);
}

#unit-info {
  display: flex;
  gap: 0.8rem;
  font-size: clamp(0.55rem, 1.5vw, 0.75rem);
  color: var(--text);
  background: rgba(42,26,14,0.85);
  padding: 0.3rem 0.6rem;
  border: 1px solid var(--accent2);
}

#wave-indicator {
  font-family: var(--font-title);
  font-size: clamp(0.55rem, 1.5vw, 0.75rem);
  color: var(--text-dim);
  letter-spacing: 0.15em;
}

#end-turn-btn {
  position: absolute;
  bottom: 1rem;
  right: 1rem;
}

/* Game Over */
#gameover-screen h2 {
  font-family: var(--font-title);
  font-size: clamp(2rem, 6vw, 3.5rem);
  color: var(--danger);
  text-shadow: 0 0 30px rgba(192,64,64,0.3);
  margin-bottom: 1rem;
}

#gameover-screen p {
  font-size: clamp(0.8rem, 2vw, 1rem);
  margin-bottom: 0.5rem;
  color: var(--text);
}

#name-entry {
  margin: 0.8rem 0;
  text-align: center;
}

#name-entry p:first-child {
  color: var(--accent);
  font-family: var(--font-title);
  font-size: clamp(0.7rem, 2vw, 0.85rem);
  letter-spacing: 0.15em;
  margin-bottom: 0.3rem;
}

#initials-input {
  font-family: var(--font-title);
  font-size: 1.5rem;
  width: 80px;
  text-align: center;
  background: rgba(42,26,14,0.9);
  border: 1px solid var(--accent);
  color: var(--accent);
  padding: 0.3rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
}

#gameover-screen .menu-btn {
  margin: 0.2rem;
}

/* Demo overlay */
#demo-overlay {
  position: absolute;
  bottom: 20%;
  left: 0;
  right: 0;
  text-align: center;
  z-index: 25;
  animation: pulse-text 2s ease-in-out infinite;
}

#demo-overlay p {
  font-family: var(--font-title);
  font-size: clamp(0.8rem, 2.5vw, 1.2rem);
  color: var(--accent);
  letter-spacing: 0.2em;
  text-shadow: 0 0 20px var(--glow);
}

/* Glitch text effect */
.glitch {
  position: relative;
}

.glitch::before,
.glitch::after {
  content: attr(data-text);
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
}

.glitch::before {
  color: #ff4080;
  z-index: -1;
}

.glitch::after {
  color: #00e5ff;
  z-index: -2;
}

/* Animations */
@keyframes pulse-text {
  0%, 100% { opacity: 0.6; }
  50% { opacity: 1; }
}

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

.screen:not(.hidden) {
  animation: fadeIn 0.3s ease;
}
