/* KeyQuest - Stylesheet */

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

body {
  background: #1a1a2e;
  color: #e0e0e0;
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  overflow: hidden;
  width: 100vw;
  height: 100vh;
}

#game-canvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
}

/* ─── Overlays ─── */

.overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(10, 10, 30, 0.92);
  backdrop-filter: blur(4px);
}

/* ─── Lobby ─── */

.lobby-container {
  background: #16213e;
  border: 1px solid #2a3a5c;
  border-radius: 12px;
  padding: 40px;
  width: 420px;
  max-width: 95vw;
  max-height: 90vh;
  overflow-y: auto;
}

.game-title {
  font-size: 48px;
  font-weight: 800;
  text-align: center;
  color: #e0e0e0;
  letter-spacing: 4px;
  margin-bottom: 4px;
}

.game-title .accent {
  color: #f39c12;
}

.subtitle {
  text-align: center;
  color: #888;
  font-size: 14px;
  margin-bottom: 28px;
  letter-spacing: 2px;
  text-transform: uppercase;
}

.lobby-section {
  margin-bottom: 20px;
}

.lobby-section h3 {
  font-size: 14px;
  color: #888;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 10px;
}

.lobby-section label {
  display: block;
  font-size: 12px;
  color: #888;
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 1px;
}

input[type="text"] {
  width: 100%;
  padding: 10px 14px;
  background: #0f1629;
  border: 1px solid #2a3a5c;
  border-radius: 6px;
  color: #e0e0e0;
  font-size: 15px;
  outline: none;
  transition: border-color 0.2s;
}

input[type="text"]:focus {
  border-color: #f39c12;
}

select {
  padding: 8px 12px;
  background: #0f1629;
  border: 1px solid #2a3a5c;
  border-radius: 6px;
  color: #e0e0e0;
  font-size: 14px;
  outline: none;
  cursor: pointer;
}

select:focus {
  border-color: #f39c12;
}

/* ─── Buttons ─── */

.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 12px 20px;
  border: none;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  letter-spacing: 0.5px;
}

.btn:hover {
  transform: translateY(-1px);
  filter: brightness(1.1);
}

.btn:active {
  transform: translateY(0);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.btn-primary {
  background: #f39c12;
  color: #1a1a2e;
}

.btn-secondary {
  background: #2a3a5c;
  color: #e0e0e0;
}

.btn-accent {
  background: #3498db;
  color: #fff;
}

.btn-danger {
  background: #e74c3c;
  color: #fff;
}

.btn-small {
  padding: 8px 16px;
  font-size: 13px;
}

.btn-icon {
  font-size: 18px;
}

.mode-buttons {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 10px;
}

.join-row {
  display: flex;
  gap: 8px;
}

.join-row input {
  flex: 1;
}

.join-row .btn {
  width: auto;
  white-space: nowrap;
}

.option-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.option-row label {
  margin-bottom: 0;
}

.solo-options {
  background: #0f1629;
  padding: 16px;
  border-radius: 8px;
  border: 1px solid #2a3a5c;
}

.lobby-status {
  text-align: center;
  padding: 12px;
  background: #2a3a5c;
  border-radius: 6px;
  color: #3498db;
  font-size: 14px;
  animation: pulse 1.5s ease infinite;
}

.lobby-error {
  text-align: center;
  padding: 12px;
  background: rgba(231, 76, 60, 0.2);
  border: 1px solid #e74c3c;
  border-radius: 6px;
  color: #e74c3c;
  font-size: 14px;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

/* ─── Room Screen ─── */

.room-code-section {
  text-align: center;
  margin: 16px 0;
}

.room-code-label {
  color: #888;
  font-size: 14px;
}

.room-code {
  font-size: 32px;
  font-weight: 800;
  letter-spacing: 6px;
  color: #f39c12;
  font-family: monospace;
}

.share-section {
  margin-bottom: 16px;
}

.share-section label {
  font-size: 12px;
  color: #888;
  margin-bottom: 4px;
  display: block;
}

.share-section input {
  font-size: 12px;
  cursor: pointer;
}

.room-player-list {
  margin: 16px 0;
  min-height: 60px;
}

.room-player {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: #0f1629;
  border-radius: 6px;
  margin-bottom: 6px;
  font-size: 14px;
}

.host-badge {
  margin-left: auto;
  font-size: 10px;
  background: #f39c12;
  color: #1a1a2e;
  padding: 2px 8px;
  border-radius: 3px;
  font-weight: 700;
}

.host-controls {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 16px 0;
  padding: 16px;
  background: #0f1629;
  border-radius: 8px;
  border: 1px solid #2a3a5c;
}

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

#game-hud {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 10;
  pointer-events: none;
  display: flex;
  flex-direction: column;
}

#game-hud > * {
  pointer-events: auto;
}

#hud-top {
  display: flex;
  justify-content: center;
  padding: 12px;
}

.hud-timer {
  background: rgba(0, 0, 0, 0.7);
  padding: 8px 20px;
  border-radius: 20px;
  font-family: monospace;
  font-size: 24px;
  font-weight: 700;
  color: #f39c12;
  letter-spacing: 2px;
}

#hud-left {
  position: fixed;
  top: 60px;
  left: 12px;
  width: 220px;
}

.player-list {
  background: rgba(0, 0, 0, 0.7);
  border-radius: 8px;
  padding: 10px;
  backdrop-filter: blur(4px);
}

.player-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 4px;
  font-size: 13px;
  margin-bottom: 2px;
}

.player-row.me {
  background: rgba(255, 255, 255, 0.08);
}

.player-row.dead {
  opacity: 0.4;
}

.player-color {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  flex-shrink: 0;
}

.player-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.player-stats {
  font-size: 11px;
  color: #888;
  white-space: nowrap;
}

/* ─── Right-side HUD ─── */

#hud-right {
  position: fixed;
  top: 60px;
  right: 12px;
  width: 200px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.hud-panel {
  background: rgba(0, 0, 0, 0.7);
  border-radius: 8px;
  padding: 10px 12px;
  backdrop-filter: blur(4px);
}

.hud-panel-title {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: #888;
  margin-bottom: 6px;
  font-weight: 600;
}

/* Gauge (troop pool & momentum) */

.gauge-container {
  position: relative;
  height: 20px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 4px;
  overflow: hidden;
}

.gauge-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.3s ease;
}

.gauge-fill.high {
  background: linear-gradient(90deg, #2ecc71, #27ae60);
}

.gauge-fill.medium {
  background: linear-gradient(90deg, #f39c12, #e67e22);
}

.gauge-fill.low {
  background: linear-gradient(90deg, #e74c3c, #c0392b);
}

.gauge-fill.momentum {
  background: linear-gradient(90deg, #3498db, #9b59b6);
}

.gauge-text {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  color: #fff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6);
  font-family: monospace;
}

.momentum-gauge {
  height: 14px;
}

/* Specials list */

.specials-list {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.special-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 6px;
  border-radius: 4px;
  font-size: 11px;
  font-family: monospace;
}

.special-item.available {
  background: rgba(46, 204, 113, 0.15);
  color: #4ade80;
  border: 1px solid rgba(46, 204, 113, 0.3);
}

.special-item.unavailable {
  background: rgba(255, 255, 255, 0.03);
  color: #555;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.special-item.cooldown {
  background: rgba(52, 152, 219, 0.1);
  color: #5a8ab5;
  border: 1px solid rgba(52, 152, 219, 0.2);
}

.special-name {
  font-weight: 700;
  flex: 1;
}

.special-cost {
  font-size: 10px;
  opacity: 0.7;
}

.special-status {
  font-size: 10px;
  font-weight: 600;
}

/* Active effects */

.effects-list {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.effect-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-family: monospace;
  animation: effectPulse 2s ease infinite;
}

.effect-item.effect-blitz {
  background: rgba(243, 156, 18, 0.2);
  color: #f39c12;
  border: 1px solid rgba(243, 156, 18, 0.4);
}

.effect-item.effect-rally {
  background: rgba(46, 204, 113, 0.2);
  color: #2ecc71;
  border: 1px solid rgba(46, 204, 113, 0.4);
}

.effect-item.effect-fortify {
  background: rgba(74, 158, 255, 0.2);
  color: #4a9eff;
  border: 1px solid rgba(74, 158, 255, 0.4);
}

.effect-name {
  font-weight: 700;
}

.effect-detail {
  font-size: 10px;
  opacity: 0.8;
}

@keyframes effectPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.8; }
}

/* ─── Bottom HUD ─── */

#hud-bottom {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 12px;
  pointer-events: none;
}

.typing-container {
  display: flex;
  align-items: center;
  background: rgba(0, 0, 0, 0.8);
  padding: 12px 24px;
  border-radius: 12px;
  border: 2px solid #2a3a5c;
  min-width: 320px;
  font-family: monospace;
  font-size: 22px;
  backdrop-filter: blur(4px);
  pointer-events: auto;
}

.typing-prompt {
  color: #f39c12;
  margin-right: 8px;
  font-weight: 700;
}

.typing-input {
  color: #fff;
  letter-spacing: 2px;
  min-width: 20px;
}

.typing-input.has-text {
  color: #4ade80;
}

.typing-cursor {
  color: #f39c12;
  animation: blink 1s step-end infinite;
}

.typing-input.flash-success {
  animation: flashGreen 0.3s ease;
}

.typing-input.flash-error {
  animation: flashRed 0.3s ease;
}

.typing-input.flash-special {
  animation: flashSpecial 0.5s ease;
}

@keyframes blink {
  50% { opacity: 0; }
}

@keyframes flashGreen {
  0% { color: #4ade80; text-shadow: 0 0 10px #4ade80; }
  100% { color: #fff; text-shadow: none; }
}

@keyframes flashRed {
  0% { color: #e74c3c; text-shadow: 0 0 10px #e74c3c; }
  100% { color: #fff; text-shadow: none; }
}

@keyframes flashSpecial {
  0% { color: #f39c12; text-shadow: 0 0 20px #f39c12, 0 0 40px #f39c12; }
  50% { color: #ffd700; text-shadow: 0 0 15px #ffd700; }
  100% { color: #fff; text-shadow: none; }
}

.typing-hint {
  color: #555;
  font-size: 12px;
  margin-top: 6px;
  text-align: center;
}

.target-selection-hint {
  color: #f39c12;
  font-size: 14px;
  font-weight: 600;
  margin-top: 8px;
  text-align: center;
  padding: 8px 16px;
  background: rgba(243, 156, 18, 0.15);
  border: 1px solid rgba(243, 156, 18, 0.4);
  border-radius: 8px;
  animation: pulse 1s ease infinite;
}

/* ─── Notifications ─── */

.notification-container {
  position: fixed;
  top: 50px;
  right: 220px;
  width: 280px;
  z-index: 20;
  display: flex;
  flex-direction: column;
  gap: 6px;
  pointer-events: none;
}

.notification {
  padding: 10px 16px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  animation: slideIn 0.3s ease;
  pointer-events: auto;
}

.notification-info {
  background: rgba(52, 152, 219, 0.85);
  color: #fff;
  border: 1px solid rgba(52, 152, 219, 0.5);
}

.notification-error {
  background: rgba(231, 76, 60, 0.85);
  color: #fff;
  border: 1px solid rgba(231, 76, 60, 0.5);
}

.notification-special {
  background: rgba(243, 156, 18, 0.9);
  color: #1a1a2e;
  border: 1px solid rgba(243, 156, 18, 0.6);
}

.notification.fade-out {
  animation: slideOut 0.3s ease forwards;
}

@keyframes slideIn {
  from { transform: translateX(30px); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

@keyframes slideOut {
  from { transform: translateX(0); opacity: 1; }
  to { transform: translateX(30px); opacity: 0; }
}

/* ─── Game Over ─── */

.game-over-container {
  background: #16213e;
  border: 1px solid #2a3a5c;
  border-radius: 12px;
  padding: 48px;
  text-align: center;
  min-width: 340px;
}

.game-over-title {
  font-size: 48px;
  font-weight: 800;
  margin-bottom: 12px;
}

.game-over-title.winner {
  color: #f39c12;
}

.game-over-title.loser {
  color: #e74c3c;
}

.game-over-details {
  color: #aaa;
  font-size: 16px;
  margin-bottom: 24px;
}

.game-over-stats {
  text-align: left;
  margin: 0 auto 28px;
  max-width: 250px;
}

.stat-row {
  display: flex;
  justify-content: space-between;
  padding: 6px 0;
  border-bottom: 1px solid #2a3a5c;
  font-size: 14px;
}

/* ─── Scrollbar ─── */

::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: #2a3a5c;
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: #3a4a6c;
}
