/* ── HEXSPOKETOWER — Styles ─────────────────────────────────── */
/* Daily Tower Gauntlet — Scarlet/Gold HexSpoke theme */

@import url('https://fonts.googleapis.com/css2?family=Cinzel:wght@400;600;700;900&family=Crimson+Text:ital,wght@0,400;0,600;1,400&family=Share+Tech+Mono&display=swap');

:root {
  --bg-dark: #0a0808;
  --bg-panel: #1c0e0e;
  --bg-hover: #2a1515;
  --text-primary: #e8dcd0;
  --text-secondary: #a88880;
  --text-dim: #684840;
  --accent: #c92020;
  --accent-glow: #e04040;
  --accent-rgb: 201, 32, 32;
  --accent-deep: #8b1515;
  --scarlet-mist: rgba(201, 32, 32, 0.08);
  --scarlet-border: rgba(201, 32, 32, 0.2);
  --scarlet-glow: rgba(224, 64, 64, 0.3);
  --gold: #c9a84c;
  --gold-dim: rgba(201, 168, 76, 0.55);
  --gold-glow: rgba(201, 168, 76, 0.3);
  --revealed: #e04040;
  --revealed-text: #ffffff;
  --unrevealed: #1a1210;
  --unrevealed-border: #2a2020;
  --center-hex: #c9a84c;
  --success: #4ade80;
  --danger: #ff2020;
  --cooldown: #c92020;
  --selected: #e0a020;
  --selected-glow: rgba(224, 160, 32, 0.4);
  --wrong: #ff4444;
  --border-radius: 8px;
  --transition: 0.2s ease;
}

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

body {
  font-family: 'Share Tech Mono', 'Courier New', monospace;
  background: var(--bg-dark);
  background-image:
    radial-gradient(ellipse at 50% 0%, rgba(201, 32, 32, 0.05) 0%, transparent 60%),
    radial-gradient(ellipse at 20% 80%, rgba(139, 21, 21, 0.04) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 60%, rgba(201, 168, 76, 0.02) 0%, transparent 40%);
  color: var(--text-primary);
  overflow: hidden;
  width: 100vw; height: 100vh;
  user-select: none; -webkit-user-select: none;
}

body::after {
  content: '';
  position: fixed; inset: 0;
  background:
    radial-gradient(1px 1px at 10% 20%, rgba(224, 64, 64, 0.25), transparent),
    radial-gradient(1px 1px at 30% 70%, rgba(201, 168, 76, 0.15), transparent),
    radial-gradient(1px 1px at 60% 15%, rgba(224, 64, 64, 0.2), transparent),
    radial-gradient(1px 1px at 80% 50%, rgba(201, 168, 76, 0.1), transparent),
    radial-gradient(1px 1px at 50% 90%, rgba(224, 64, 64, 0.15), transparent);
  pointer-events: none; z-index: 9999;
}

/* ── Screens ─────────────────────────────────────────────────── */

.screen { display: none; position: absolute; inset: 0; }
.screen.active { display: flex; align-items: center; justify-content: center; }
#game-screen.active { display: flex; flex-direction: column; }

/* ── Menu ─────────────────────────────────────────────────────── */

.menu-container {
  text-align: center; max-width: 480px; width: 90%;
  padding: 1.5rem 2rem;
  background: linear-gradient(135deg, rgba(28, 14, 14, 0.95), rgba(24, 10, 10, 0.95));
  border: 1px solid var(--scarlet-border); border-radius: var(--border-radius);
  box-shadow: 0 0 60px rgba(201, 32, 32, 0.06), inset 0 0 60px rgba(0, 0, 0, 0.3);
  position: relative; max-height: 95vh; overflow-y: auto;
}

.menu-container::before, .menu-container::after {
  content: ''; position: absolute; width: 20px; height: 20px;
  border-color: rgba(201, 32, 32, 0.35); border-style: solid;
}
.menu-container::before { top: -1px; left: -1px; border-width: 2px 0 0 2px; }
.menu-container::after { bottom: -1px; right: -1px; border-width: 0 2px 2px 0; }

.menu-sigil { font-size: 2.2rem; margin-bottom: 0.3rem; filter: drop-shadow(0 0 12px rgba(201, 32, 32, 0.5)); }

.title {
  font-family: 'Cinzel', serif; font-size: 2.6rem; font-weight: 900;
  letter-spacing: 0.08em; line-height: 1; margin-bottom: 0.3rem;
}

.hex-accent {
  background: linear-gradient(135deg, #c92020, #c9a84c);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text; filter: drop-shadow(0 0 10px rgba(201, 32, 32, 0.4));
}

.tower-accent {
  font-size: 1.8rem;
  background: linear-gradient(135deg, #c9a84c, #f0d060);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text; filter: drop-shadow(0 0 10px rgba(201, 168, 76, 0.5));
  letter-spacing: 0.15em;
}

.tagline {
  font-family: 'Crimson Text', serif; font-style: italic;
  color: var(--gold); font-size: 0.85rem; margin-bottom: 0.2rem; opacity: 0.8;
}

.subtitle {
  color: rgba(201, 32, 32, 0.5); font-size: 0.7rem;
  margin-bottom: 1rem; letter-spacing: 0.1em; text-transform: uppercase;
}

/* Tower Info */
.tower-info { margin-bottom: 1rem; text-align: left; }

.info-row {
  display: flex; align-items: center; gap: 0.5rem;
  padding: 0.3rem 0.5rem; font-size: 0.78rem; color: var(--text-secondary);
}
.info-row span:first-child { font-size: 0.9rem; flex-shrink: 0; }

/* Attempt info */
.attempt-info {
  background: rgba(201, 32, 32, 0.1); border: 1px solid var(--scarlet-border);
  border-radius: var(--border-radius); padding: 0.6rem; margin-bottom: 0.8rem;
  font-size: 0.8rem; color: var(--accent-glow);
}

/* ── Buttons ─────────────────────────────────────────────────── */

.menu-buttons { display: flex; flex-direction: column; gap: 0.5rem; }

.btn {
  padding: 0.7rem 1.5rem; border: none; border-radius: var(--border-radius);
  font-size: 0.95rem; font-weight: 600; cursor: pointer;
  transition: all var(--transition); font-family: 'Share Tech Mono', monospace;
}

.btn-primary { background: var(--accent); color: white; }
.btn-primary:hover { background: var(--accent-glow); box-shadow: 0 0 25px rgba(var(--accent-rgb), 0.35); }

.btn-outline { background: transparent; color: var(--text-secondary); border: 1px solid var(--unrevealed-border); }
.btn-outline:hover { border-color: var(--accent); color: var(--text-primary); }

.btn-small { padding: 0.4rem 0.8rem; font-size: 0.8rem; }
.btn:disabled { opacity: 0.3; cursor: not-allowed; }
.btn.attempted { background: var(--bg-panel); color: var(--text-dim); }

/* Countdown */
.countdown-section { margin-top: 1rem; }
.countdown-label { font-size: 0.7rem; color: var(--text-dim); }
.countdown-value { font-size: 0.85rem; color: var(--gold); font-weight: 600; }
.result-countdown { margin-top: 0.8rem; }

/* ── Tutorial ─────────────────────────────────────────────────── */

.tutorial-container {
  max-width: 600px; width: 90%; max-height: 90vh; overflow-y: auto; padding: 2rem;
}
.tutorial-container h2 {
  font-family: 'Cinzel', serif; color: var(--accent-glow);
  margin-bottom: 1.5rem; text-align: center; font-size: 1.6rem;
}
.tutorial-step {
  margin-bottom: 1rem; padding: 0.8rem 1rem;
  background: var(--bg-panel); border-radius: var(--border-radius);
  border-left: 3px solid var(--accent);
}
.tutorial-step h3 { color: var(--gold); margin-bottom: 0.3rem; font-size: 0.95rem; }
.tutorial-step p { color: var(--text-secondary); font-size: 0.85rem; line-height: 1.5; }
.tutorial-step strong { color: var(--text-primary); }

/* ── Game HUD ─────────────────────────────────────────────────── */

.hud {
  position: relative; z-index: 10;
  padding: 0.4rem 0.8rem;
  background: rgba(10, 8, 8, 0.95); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--scarlet-border); flex-shrink: 0;
}

.tower-hud-row {
  display: flex; align-items: center; justify-content: space-between; gap: 0.5rem;
  flex-wrap: wrap;
}

.stat-group { display: flex; align-items: center; gap: 0.25rem; }
.stat-icon { font-size: 0.8rem; }
.stat-value { font-size: 1rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat-label { font-size: 0.6rem; color: var(--text-dim); text-transform: uppercase; }

.tower-timer { font-size: 1.3rem; color: var(--gold); }
.timer-group { flex-shrink: 0; }

/* Phase indicator */
.phase-indicator {
  font-size: 0.6rem; color: var(--accent-glow); text-transform: uppercase;
  letter-spacing: 0.08em; padding: 2px 6px;
  border: 1px solid var(--scarlet-border); border-radius: 4px;
  background: rgba(201, 32, 32, 0.1);
}
.phase-indicator.deduction {
  color: var(--gold); border-color: rgba(201, 168, 76, 0.3);
  background: rgba(201, 168, 76, 0.1);
}

/* Floor Progress Dots */
.floor-progress {
  display: flex; justify-content: center; gap: 4px;
  padding: 4px 0 2px;
}
.floor-dot {
  width: 22px; height: 22px; border-radius: 3px;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.6rem; font-weight: 700;
  transition: all 0.3s ease;
}
.floor-dot.cleared {
  background: var(--success); color: #000; box-shadow: 0 0 6px rgba(74, 222, 128, 0.4);
}
.floor-dot.current {
  background: var(--accent); color: white; box-shadow: 0 0 8px rgba(var(--accent-rgb), 0.5);
  animation: currentFloorPulse 1.5s ease-in-out infinite;
}
.floor-dot.locked {
  background: var(--bg-panel); color: var(--text-dim); border: 1px solid var(--unrevealed-border);
}

@keyframes currentFloorPulse {
  0%, 100% { box-shadow: 0 0 8px rgba(var(--accent-rgb), 0.5); }
  50% { box-shadow: 0 0 16px rgba(var(--accent-rgb), 0.8); }
}

/* ── Hex Grid ─────────────────────────────────────────────────── */

#hex-container {
  flex: 1; display: flex; align-items: center; justify-content: center;
  overflow: hidden; min-height: 0;
}
#hex-grid { width: 100%; height: 100%; }

.hex-cell { cursor: default; }
.hex-cell.selectable { cursor: pointer; }

.hex-bg { transition: fill 0.3s ease, stroke 0.3s ease; }
.hex-bg.unrevealed { fill: var(--unrevealed); stroke: var(--unrevealed-border); stroke-width: 1.5; }
.hex-bg.revealed { fill: rgba(201, 32, 32, 0.25); stroke: var(--accent); stroke-width: 1.5; }
.hex-bg.center { fill: rgba(201, 168, 76, 0.2); stroke: var(--gold); stroke-width: 2; }
.hex-bg.selected {
  fill: rgba(224, 160, 32, 0.25); stroke: var(--selected); stroke-width: 2.5;
  filter: drop-shadow(0 0 6px var(--selected-glow));
}
.hex-bg.wrong-flash { fill: rgba(255, 68, 68, 0.35); stroke: var(--wrong); stroke-width: 2; }

.hex-letter {
  font-family: 'Cinzel', serif; font-weight: 700; fill: var(--text-primary);
  text-anchor: middle; dominant-baseline: central; pointer-events: none;
}
.hex-letter.hidden-letter { fill: var(--text-dim); }
.hex-letter.revealed-letter { fill: #ffffff; filter: drop-shadow(0 0 4px rgba(224, 64, 64, 0.6)); }
.hex-letter.center-letter { fill: var(--gold); filter: drop-shadow(0 0 6px rgba(201, 168, 76, 0.5)); }

@keyframes hexRevealGlow {
  0% { filter: drop-shadow(0 0 0px rgba(224, 64, 64, 0)); }
  50% { filter: drop-shadow(0 0 12px rgba(224, 64, 64, 0.8)); }
  100% { filter: drop-shadow(0 0 4px rgba(224, 64, 64, 0.3)); }
}
.hex-reveal-anim { animation: hexRevealGlow 0.6s ease-out; }

@keyframes hexWrongFlash {
  0% { opacity: 1; } 25% { opacity: 0.5; } 50% { opacity: 1; } 75% { opacity: 0.5; } 100% { opacity: 1; }
}
.hex-wrong-anim { animation: hexWrongFlash 0.5s ease-out; }

/* ── Letter Picker ────────────────────────────────────────────── */

#letter-picker {
  display: flex; flex-wrap: wrap; justify-content: center; gap: 4px;
  padding: 0.5rem 0.6rem;
  background: rgba(10, 8, 8, 0.95); border-top: 1px solid var(--scarlet-border);
  flex-shrink: 0;
}
.letter-btn {
  width: 38px; height: 38px; display: flex; align-items: center; justify-content: center;
  background: var(--bg-panel); border: 1px solid var(--unrevealed-border); border-radius: 5px;
  color: var(--text-primary); font-family: 'Cinzel', serif; font-size: 0.95rem; font-weight: 700;
  cursor: pointer; transition: all 0.15s ease;
}
.letter-btn:hover:not(.used):not(.disabled) {
  background: rgba(201, 32, 32, 0.2); border-color: var(--accent);
  color: var(--accent-glow); box-shadow: 0 0 10px rgba(201, 32, 32, 0.2);
}
.letter-btn.disabled { opacity: 0.3; cursor: not-allowed; pointer-events: none; }
.letter-btn.used { opacity: 0; transform: scale(0.5); pointer-events: none; transition: opacity 0.4s, transform 0.4s; }

/* ── Cooldown Bar ─────────────────────────────────────────────── */

#cooldown-bar-container { height: 4px; background: rgba(10, 8, 8, 0.9); flex-shrink: 0; overflow: hidden; }
#cooldown-bar {
  height: 100%; width: 0%;
  background: linear-gradient(90deg, var(--accent), var(--gold));
  transition: width 0.1s linear; border-radius: 0 2px 2px 0;
  box-shadow: 0 0 8px rgba(201, 32, 32, 0.4);
}

/* ── Music Toggle ─────────────────────────────────────────────── */

.hud-music-btn {
  position: absolute; top: 6px; right: 10px; z-index: 20;
  padding: 3px 10px; border: 1px solid rgba(201, 168, 76, 0.2); border-radius: 4px;
  background: rgba(201, 168, 76, 0.06); color: rgba(201, 168, 76, 0.5);
  font-family: 'Share Tech Mono', monospace; font-size: 0.7rem; cursor: pointer;
}
.hud-music-btn:hover { background: rgba(201, 168, 76, 0.12); color: var(--gold); }
.hud-music-btn.muted { opacity: 0.4; color: #556; border-color: rgba(255, 255, 255, 0.08); }

/* Timer States */
.timer-warning { color: var(--danger) !important; animation: timerFlash 0.8s infinite; }
.timer-overtime { color: var(--danger) !important; }
@keyframes timerFlash { 0%, 100% { opacity: 1; } 50% { opacity: 0.3; } }

/* ── Phase Banner ─────────────────────────────────────────────── */

#phase-banner {
  position: fixed; top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  z-index: 100; text-align: center; pointer-events: none; opacity: 0;
}
#phase-banner.show { animation: phaseBannerAnim 2.5s ease-out forwards; }

@keyframes phaseBannerAnim {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(0.8); }
  15% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  70% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -50%) scale(1.1); }
}

.phase-banner-title {
  font-family: 'Cinzel', serif; font-size: 1.8rem; font-weight: 900;
  color: var(--accent-glow); text-shadow: 0 0 20px rgba(201, 32, 32, 0.5);
}
.phase-banner-sub {
  font-family: 'Crimson Text', serif; font-style: italic;
  font-size: 0.9rem; color: var(--gold); margin-top: 0.3rem;
}

/* ── Overlays ─────────────────────────────────────────────────── */

.overlay {
  position: fixed; inset: 0;
  background: rgba(6, 4, 4, 0.88);
  display: flex; align-items: center; justify-content: center;
  z-index: 50; animation: fadeIn 0.5s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.overlay-content {
  text-align: center; padding: 1.5rem;
  background: linear-gradient(135deg, rgba(28, 14, 14, 0.97), rgba(24, 10, 10, 0.97));
  border-radius: var(--border-radius); border: 1px solid var(--scarlet-border);
  max-width: 440px; width: 90%;
  box-shadow: 0 0 40px rgba(201, 32, 32, 0.1);
  max-height: 90vh; overflow-y: auto;
}

/* Floor Transition */
.transition-content { padding: 2rem; }
.transition-sigil { font-size: 2.5rem; margin-bottom: 0.3rem; }
.transition-time { color: var(--text-dim); font-size: 0.8rem; margin-top: 0.5rem; }

/* Results */
.results-sigil { font-size: 2.5rem; margin-bottom: 0.3rem; }
.overlay-content h2 {
  font-family: 'Cinzel', serif; font-size: 1.6rem; margin-bottom: 0.3rem; color: var(--gold);
}
.results-flavor {
  font-family: 'Crimson Text', serif; font-style: italic;
  color: var(--text-secondary); margin-bottom: 1rem; font-size: 0.85rem;
}

.results-stats { display: flex; justify-content: center; gap: 1.5rem; margin-bottom: 1rem; }
.result-stat { display: flex; flex-direction: column; align-items: center; gap: 0.1rem; }
.result-label { font-size: 0.65rem; color: var(--text-dim); text-transform: uppercase; }
.result-value { font-family: 'Cinzel', serif; font-size: 1.6rem; font-weight: 700; color: var(--accent-glow); }
.result-percentile-text { color: var(--gold); font-size: 0.85rem; margin-bottom: 0.8rem; }

.lb-prompt-text {
  color: var(--gold); font-family: 'Crimson Text', serif; font-size: 0.95rem; margin-bottom: 0.4rem;
}
.lb-name-input { display: flex; gap: 0.5rem; justify-content: center; margin-bottom: 0.8rem; }
.lb-name-input input {
  background: var(--bg-panel); border: 1px solid var(--unrevealed-border);
  border-radius: var(--border-radius); color: var(--text-primary);
  font-family: 'Share Tech Mono', monospace; font-size: 1rem;
  padding: 0.4rem 0.6rem; width: 180px; text-align: center;
}
.lb-name-input input:focus { outline: none; border-color: var(--accent); }

.results-buttons { display: flex; gap: 0.5rem; justify-content: center; flex-wrap: wrap; }

/* ── Leaderboard ──────────────────────────────────────────────── */

.leaderboard-content { max-width: 500px; }
.lb-total { font-size: 0.75rem; color: var(--text-dim); margin-bottom: 0.5rem; }

.lb-table-wrap { margin-bottom: 1rem; max-height: 400px; overflow-y: auto; }

.lb-table { width: 100%; border-collapse: collapse; font-size: 0.75rem; }
.lb-table thead th {
  color: var(--text-dim); text-transform: uppercase; font-size: 0.6rem;
  letter-spacing: 0.08em; padding: 0.35rem 0.4rem;
  border-bottom: 1px solid var(--unrevealed-border); text-align: left;
}
.lb-table thead th:first-child { text-align: center; width: 30px; }

.lb-table tbody td {
  padding: 0.35rem 0.4rem; border-bottom: 1px solid rgba(42, 32, 32, 0.4);
  color: var(--text-secondary);
}
.lb-table tbody td:first-child { text-align: center; color: var(--gold); font-weight: 700; }
.lb-table tbody tr:nth-child(-n+3) td:first-child { font-size: 0.9rem; }
.lb-table tbody tr.lb-highlight td { color: var(--accent-glow); background: rgba(201, 32, 32, 0.08); }

/* ── Share ─────────────────────────────────────────────────────── */

.share-section { margin-top: 1rem; padding-top: 0.8rem; border-top: 1px solid var(--scarlet-border); }
.share-label { font-family: 'Crimson Text', serif; font-style: italic; color: var(--text-dim); font-size: 0.7rem; margin-bottom: 0.4rem; }
.share-buttons { display: flex; justify-content: center; gap: 0.4rem; flex-wrap: wrap; }
.btn-share {
  padding: 0.3rem 0.7rem; background: var(--bg-panel);
  border: 1px solid var(--unrevealed-border); border-radius: var(--border-radius);
  color: var(--text-secondary); font-family: 'Share Tech Mono', monospace;
  font-size: 0.65rem; cursor: pointer; transition: all var(--transition);
}
.btn-share:hover { border-color: var(--accent); color: var(--accent-glow); }
.btn-share.copied { border-color: var(--success); color: var(--success); }

/* ── Footer ───────────────────────────────────────────────────── */

.footer-brand {
  display: block; margin-top: 1.2rem; font-size: 0.65rem; color: var(--gold-dim);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}
.footer-brand a { color: var(--gold); text-decoration: none; }
.footer-brand a:hover { color: #f1d27a; text-decoration: underline; }

.footer-cross {
  display: block; margin-top: 0.3rem; font-size: 0.55rem; color: var(--text-dim);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}
.footer-cross a { color: var(--text-secondary); text-decoration: none; }
.footer-cross a:hover { color: var(--accent-glow); text-decoration: underline; }

/* ── Responsive ───────────────────────────────────────────────── */

@media (max-width: 420px) {
  .title { font-size: 2.2rem; }
  .tower-accent { font-size: 1.5rem; }
  .menu-container { padding: 1.2rem 1rem; }
  .letter-btn { width: 32px; height: 32px; font-size: 0.85rem; }
  .floor-dot { width: 20px; height: 20px; font-size: 0.55rem; }
  .result-value { font-size: 1.3rem; }
  .info-row { font-size: 0.7rem; }
  .phase-indicator { font-size: 0.55rem; }
}

@media (max-width: 360px) {
  .title { font-size: 1.9rem; }
  .letter-btn { width: 28px; height: 28px; font-size: 0.8rem; }
  #letter-picker { gap: 3px; padding: 0.3rem; }
}

@media (min-width: 768px) {
  .letter-btn { width: 42px; height: 42px; font-size: 1rem; }
}
