/* ============================================================
   HexaIslands — Steampunk Sky-Islands Theme
   ============================================================ */

/* --- Reset & Base --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg-deep: #0d0d1a;
  --bg-panel: #141420;
  --bg-surface: #1a1a2e;
  --brass: #d4a040;
  --brass-dim: rgba(212, 160, 64, 0.15);
  --brass-glow: rgba(212, 160, 64, 0.4);
  --copper: #b87333;
  --copper-dim: rgba(184, 115, 51, 0.25);
  --steel: #4080c0;
  --steel-dim: rgba(64, 128, 192, 0.15);
  --steel-glow: rgba(64, 128, 192, 0.4);
  --warm-white: #f0e6d2;
  --text: #c8bea8;
  --text-dim: #7a7060;
  --danger: #e04040;
  --success: #40c060;
  --sky-top: #0a0a1e;
  --sky-bottom: #1a1030;
  --font-display: 'Orbitron', sans-serif;
  --font-mono: 'Share Tech Mono', monospace;
}

html, body {
  width: 100%; height: 100%;
  overflow: hidden;
  background: var(--bg-deep);
  color: var(--text);
  font-family: var(--font-mono);
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

body {
  background: linear-gradient(175deg, var(--sky-top) 0%, var(--sky-bottom) 60%, #0d0818 100%);
}

/* Subtle gear-rivet texture overlay */
body::after {
  content: '';
  position: fixed; inset: 0;
  pointer-events: none;
  background: repeating-radial-gradient(circle at 50% 50%, transparent 0px, transparent 18px, rgba(184,115,51,0.012) 18px, rgba(184,115,51,0.012) 19px);
  z-index: 9999;
}

/* --- Screens --- */
.screen {
  display: none;
  position: fixed; inset: 0;
  justify-content: center; align-items: center;
  flex-direction: column;
  z-index: 10;
}
.screen.active { display: flex; }

/* --- Menu --- */
.menu-container {
  text-align: center;
  padding: 2rem;
}

.title {
  font-family: var(--font-display);
  font-size: 4rem;
  font-weight: 900;
  color: var(--brass);
  text-shadow: 0 0 40px var(--brass-glow), 0 2px 4px rgba(0,0,0,0.8);
  letter-spacing: 0.15em;
  line-height: 1.1;
  margin-bottom: 0.3rem;
}
.title-sub {
  font-size: 2rem;
  font-weight: 400;
  color: var(--copper);
  letter-spacing: 0.3em;
}
.subtitle {
  color: var(--text-dim);
  font-size: 0.85rem;
  letter-spacing: 0.2em;
  margin-bottom: 2.5rem;
}

.menu-buttons {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  align-items: center;
}

.menu-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-width: 260px;
  padding: 0.85rem 1.8rem;
  font-family: var(--font-display);
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--warm-white);
  background: linear-gradient(135deg, rgba(30,25,20,0.95), rgba(40,30,20,0.95));
  border: 1px solid var(--copper-dim);
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}
.menu-btn:hover {
  background: linear-gradient(135deg, rgba(50,40,25,0.95), rgba(60,45,25,0.95));
  border-color: var(--brass-glow);
  box-shadow: 0 0 20px var(--brass-dim), inset 0 0 20px rgba(212,160,64,0.05);
  color: var(--brass);
}
.menu-btn:active {
  transform: scale(0.98);
}
.menu-btn.secondary {
  background: transparent;
  border-color: rgba(184,115,51,0.15);
  color: var(--text-dim);
  font-size: 0.8rem;
  min-width: 180px;
  margin-top: 0.5rem;
}
.menu-btn.secondary:hover {
  border-color: var(--copper);
  color: var(--copper);
}
.menu-btn.small {
  min-width: auto;
  padding: 0.5rem 1rem;
  font-size: 0.75rem;
}

.btn-icon { font-size: 1.1rem; }

.footer-credit {
  margin-top: 3rem;
  color: var(--text-dim);
  font-size: 0.65rem;
  letter-spacing: 0.3em;
  opacity: 0.5;
}

/* --- Panels (lobby, difficulty, etc.) --- */
.panel {
  background: linear-gradient(180deg, var(--bg-panel) 0%, rgba(15,12,20,0.98) 100%);
  border: 1px solid var(--copper-dim);
  border-radius: 8px;
  padding: 2rem 2.5rem;
  text-align: center;
  max-width: 420px;
  width: 90%;
  box-shadow: 0 8px 40px rgba(0,0,0,0.6);
}
.panel h2 {
  font-family: var(--font-display);
  font-size: 1.4rem;
  color: var(--brass);
  margin-bottom: 1.5rem;
  letter-spacing: 0.1em;
}

/* --- Lobby --- */
.lobby-section { margin: 1rem 0; }
.lobby-divider {
  color: var(--text-dim);
  font-size: 0.8rem;
  margin: 1rem 0;
}
.room-code { margin-top: 1rem; }
.code-text {
  display: inline-block;
  font-family: var(--font-display);
  font-size: 2.5rem;
  font-weight: 900;
  color: var(--brass);
  letter-spacing: 0.3em;
  padding: 0.3rem 0;
  text-shadow: 0 0 20px var(--brass-glow);
}
.input-label {
  display: block;
  color: var(--text-dim);
  font-size: 0.75rem;
  margin-bottom: 0.4rem;
  letter-spacing: 0.1em;
}
.code-input {
  display: block;
  width: 100%;
  max-width: 200px;
  margin: 0 auto 0.8rem;
  padding: 0.6rem 1rem;
  font-family: var(--font-display);
  font-size: 1.4rem;
  font-weight: 700;
  text-align: center;
  text-transform: uppercase;
  letter-spacing: 0.3em;
  color: var(--warm-white);
  background: rgba(0,0,0,0.3);
  border: 1px solid var(--copper-dim);
  border-radius: 4px;
  outline: none;
}
.code-input:focus {
  border-color: var(--brass);
  box-shadow: 0 0 15px var(--brass-dim);
}
.hint {
  color: var(--text-dim);
  font-size: 0.75rem;
  margin-top: 0.3rem;
}

/* --- Matchmaking spinner --- */
.spinner {
  width: 40px; height: 40px;
  margin: 1rem auto;
  border: 3px solid var(--copper-dim);
  border-top-color: var(--brass);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* --- Tutorial --- */
.tutorial-panel {
  max-width: 520px;
  max-height: 85vh;
  overflow-y: auto;
}
.tutorial-content {
  text-align: left;
  font-size: 0.85rem;
  line-height: 1.6;
  color: var(--text);
  margin: 1rem 0;
  min-height: 200px;
}
.tutorial-content h3 {
  font-family: var(--font-display);
  color: var(--brass);
  font-size: 1rem;
  margin: 1rem 0 0.5rem;
}
.tutorial-content .unit-icon { color: var(--brass); font-weight: bold; }
.tutorial-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 1rem 0;
}

/* --- HUD (in-game) --- */
.hud {
  position: fixed;
  z-index: 20;
  pointer-events: auto;
  font-family: var(--font-mono);
}

.hud-top {
  top: 0; left: 0; right: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 1rem;
  background: linear-gradient(180deg, rgba(13,13,26,0.92) 0%, rgba(13,13,26,0.7) 100%);
  border-bottom: 1px solid var(--copper-dim);
  backdrop-filter: blur(6px);
}

.hud-resources {
  display: flex;
  gap: 1rem;
  font-size: 0.9rem;
}
.res-brass { color: var(--brass); }
.res-gusts { color: #a0c8e0; }

.hud-turn-info {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  font-size: 0.85rem;
}
.phase-badge {
  display: inline-block;
  padding: 0.15rem 0.6rem;
  background: var(--brass-dim);
  border: 1px solid var(--brass-glow);
  border-radius: 3px;
  color: var(--brass);
  font-family: var(--font-display);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.1em;
}

.hud-wind {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.8rem;
  color: var(--text-dim);
}
.wind-arrow {
  font-size: 1.2rem;
  color: #a0c8e0;
  transition: transform 0.5s ease;
}

.hud-bottom {
  bottom: 0; left: 0; right: 0;
  padding: 0.5rem 1rem;
  background: linear-gradient(0deg, rgba(13,13,26,0.92) 0%, rgba(13,13,26,0.7) 100%);
  border-top: 1px solid var(--copper-dim);
  backdrop-filter: blur(6px);
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.action-panel {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  justify-content: center;
}

.action-btn {
  padding: 0.5rem 0.8rem;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--warm-white);
  background: rgba(30,25,20,0.9);
  border: 1px solid var(--copper-dim);
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s;
  text-align: center;
  line-height: 1.3;
}
.action-btn:hover {
  border-color: var(--brass);
  background: rgba(50,40,25,0.9);
  color: var(--brass);
}
.action-btn:disabled {
  opacity: 0.35;
  cursor: default;
}
.action-btn.active {
  border-color: var(--brass);
  background: rgba(212,160,64,0.25);
  color: var(--brass);
  box-shadow: 0 0 10px rgba(212,160,64,0.25), inset 0 0 8px rgba(212,160,64,0.1);
}
.action-btn small {
  color: var(--text-dim);
  font-size: 0.65rem;
}

/* --- Selection Panel --- */
.hud-selection {
  top: 60px; left: 8px;
  width: 180px;
  padding: 0.8rem;
  background: rgba(13,13,26,0.92);
  border: 1px solid var(--copper-dim);
  border-radius: 6px;
  backdrop-filter: blur(6px);
  font-size: 0.75rem;
}
.sel-title {
  font-family: var(--font-display);
  font-size: 0.8rem;
  color: var(--brass);
  margin-bottom: 0.4rem;
}
.sel-stats { color: var(--text); line-height: 1.5; }

/* --- Notifications --- */
.notifications {
  position: fixed;
  top: 55px; right: 10px;
  z-index: 30;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  pointer-events: none;
}
.notif {
  padding: 0.5rem 1rem;
  background: rgba(13,13,26,0.9);
  border: 1px solid var(--copper-dim);
  border-radius: 4px;
  color: var(--warm-white);
  font-size: 0.75rem;
  animation: notif-in 0.3s ease, notif-out 0.5s ease 2.5s forwards;
}
@keyframes notif-in { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: translateX(0); } }
@keyframes notif-out { to { opacity: 0; transform: translateY(-10px); } }

/* --- Game Over --- */
.game-over-stats {
  margin: 1rem 0;
  font-size: 0.8rem;
  line-height: 1.8;
  text-align: left;
}

/* --- Canvas --- */
#game-canvas {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  z-index: 1;
  display: block;
}

/* --- Mobile --- */
@media (max-width: 600px) {
  .title { font-size: 2.5rem; }
  .title-sub { font-size: 1.3rem; }
  .menu-btn { min-width: 220px; padding: 0.7rem 1.2rem; font-size: 0.85rem; }
  .panel { padding: 1.5rem 1.2rem; }
  .hud-top { padding: 0.4rem 0.6rem; font-size: 0.8rem; }
  .hud-bottom { padding: 0.4rem 0.6rem; }
  .action-btn { padding: 0.4rem 0.6rem; font-size: 0.7rem; }
  .hud-selection { width: 150px; font-size: 0.7rem; }
  .hud-resources { gap: 0.5rem; font-size: 0.8rem; }
}

@media (max-width: 380px) {
  .title { font-size: 2rem; }
  .title-sub { font-size: 1rem; }
  .menu-btn { min-width: 180px; font-size: 0.8rem; }
}

/* --- Footer --- */
.site-footer {
  position: fixed; bottom: 0; left: 0; right: 0;
  display: flex; justify-content: center; align-items: center; gap: 1.5em;
  padding: 8px 16px;
  font-size: 0.72rem; letter-spacing: 0.5px;
  color: rgba(200,190,168,0.35);
  background: linear-gradient(0deg, rgba(13,13,26,0.95) 0%, rgba(13,13,26,0) 100%);
  pointer-events: none;
  z-index: 50;
}
.site-footer a { color: var(--brass); text-decoration: none; pointer-events: auto; transition: color 0.2s; }
.site-footer a:hover { color: var(--warm-white); text-decoration: underline; }
.footer-brand { pointer-events: auto; }
.footer-cross { pointer-events: auto; }
.footer-divider { opacity: 0.3; }
/* Hide footer during gameplay */
#game-screen.active ~ .site-footer { display: none; }

/* --- Music Toggle --- */
#btn-music {
  position: fixed;
  top: 16px; right: 16px;
  z-index: 100;
  padding: 8px 16px;
  border: 1px solid var(--copper-dim);
  border-radius: 4px;
  background: rgba(184,115,51,0.06);
  color: rgba(184,115,51,0.5);
  font-family: var(--font-mono);
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.2s;
}
#btn-music:hover {
  background: rgba(184,115,51,0.12);
  color: var(--brass);
  border-color: var(--brass-glow);
  box-shadow: 0 0 10px var(--brass-dim);
}
#btn-music.muted {
  opacity: 0.4;
  color: var(--text-dim);
  border-color: rgba(255,255,255,0.08);
  background: rgba(255,255,255,0.03);
}
/* Hide music btn during gameplay */
#game-screen.active ~ #btn-music { display: none; }

/* Share */
.share-section { margin-top: 16px; padding-top: 12px; border-top: 1px solid rgba(184,115,59,0.2); }
.share-label { font-size: 11px; color: rgba(184,115,59,0.5); letter-spacing: 1px; margin-bottom: 8px; text-transform: uppercase; }
.share-buttons { display: flex; justify-content: center; gap: 6px; flex-wrap: wrap; }
.btn-share { padding: 6px 14px; background: rgba(13,13,26,0.6); border: 1px solid rgba(184,115,59,0.2); border-radius: 4px; color: rgba(184,115,59,0.6); font-family: 'Share Tech Mono', monospace; font-size: 12px; cursor: pointer; transition: all 0.2s; }
.btn-share:hover { border-color: rgba(184,115,59,0.5); color: #d4a040; background: rgba(184,115,59,0.08); }
.btn-share.copied { border-color: #4ade80; color: #4ade80; }
.share-flavor { font-size: 13px; color: rgba(200,200,220,0.5); margin-bottom: 12px; }
