@import url('https://fonts.googleapis.com/css2?family=Press+Start+2P&display=swap');

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

body {
  background: #1a0a00;
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  min-height: 100dvh;
  font-family: 'Press Start 2P', monospace;
  -webkit-user-select: none;
  user-select: none;
  overflow: hidden;
}

.scene {
  width: 100%;
  max-width: 480px;
  padding: 16px 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

.scene.hidden {
  display: none;
}

/* ── Event Header ── */
.event-header,
.saloon-header {
  text-align: center;
  margin-bottom: 14px;
  flex-shrink: 0;
  padding-top: 8px;
}

.event-header h1 {
  font-size: 22px;
  color: #e8a630;
  text-shadow: 3px 3px 0 #5a2d00, 0 0 12px rgba(232, 166, 48, 0.15);
  letter-spacing: 3px;
  line-height: 1.4;
  margin-bottom: 8px;
  animation: glowFlicker 6s ease-in-out infinite;
}

.saloon-header h1 {
  font-size: 18px;
  color: #e8a630;
  text-shadow: 2px 2px 0 #5a2d00;
  letter-spacing: 2px;
  margin-bottom: 6px;
}

@keyframes glowFlicker {
  0%, 100% { text-shadow: 3px 3px 0 #5a2d00, 0 0 10px rgba(232, 166, 48, 0.12); }
  30% { text-shadow: 3px 3px 0 #5a2d00, 0 0 18px rgba(232, 166, 48, 0.28); }
  55% { text-shadow: 3px 3px 0 #5a2d00, 0 0 12px rgba(232, 166, 48, 0.15); }
  80% { text-shadow: 3px 3px 0 #5a2d00, 0 0 20px rgba(232, 166, 48, 0.32); }
}

.event-header .subtitle,
.saloon-header .subtitle {
  font-size: 7px;
  color: #c87830;
  letter-spacing: 1px;
  line-height: 1.6;
}

/* ── Preview Canvas ── */
.preview-wrap {
  width: 100%;
  max-width: 400px;
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
  margin-bottom: 14px;
}

#lobby-canvas,
#saloon-canvas {
  width: 100%;
  max-height: 100%;
  display: block;
  border: 2px solid #5a2d00;
  background: #1a0a00;
  image-rendering: pixelated;
  cursor: crosshair;
  touch-action: manipulation;
}

.preview-hint {
  font-size: 6px;
  color: #5a2d00;
  letter-spacing: 1px;
  margin-top: 6px;
  animation: blink 2s step-end infinite;
}

/* ── Lobby Buttons ── */
.lobby-buttons {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
  max-width: 320px;
  flex-shrink: 0;
  padding-bottom: 8px;
}

.lobby-btn {
  font-family: 'Press Start 2P', monospace;
  font-size: 11px;
  color: #f5d88e;
  background: rgba(40, 18, 0, 0.9);
  border: 2px solid #5a2d00;
  padding: 12px 16px;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition: border-color 0.15s, background 0.15s, color 0.15s;
  letter-spacing: 1px;
  text-decoration: none;
  text-align: center;
  display: block;
  width: 100%;
}

.lobby-btn:hover {
  border-color: #e8a630;
  background: rgba(60, 25, 0, 0.95);
  color: #ffee44;
}

.lobby-btn:active {
  background: #e8a630;
  color: #1a0a00;
}

.lobby-btn-release {
  font-size: 9px;
  color: #c87830;
  border-color: #3a1800;
}

.lobby-btn-release:hover {
  color: #e8a630;
}

/* ── Modal ── */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.85);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 100;
  padding: 16px;
}

.modal.hidden {
  display: none;
}

.modal-content {
  background: #1a0a00;
  border: 2px solid #5a2d00;
  padding: 20px 16px;
  width: 100%;
  max-width: 320px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
}

.modal-content h2 {
  font-size: 14px;
  color: #e8a630;
  text-shadow: 2px 2px 0 #5a2d00;
  text-align: center;
  margin-bottom: 14px;
  letter-spacing: 2px;
}

/* ── Leaderboard List ── */
.leaderboard-list {
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid #5a2d00;
  padding: 8px;
  overflow-y: auto;
  flex: 1 1 auto;
  min-height: 0;
  max-height: 50vh;
  margin-bottom: 14px;
  -webkit-overflow-scrolling: touch;
}

.leaderboard-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 5px 4px;
  font-size: 8px;
  color: #d4a860;
}

.leaderboard-row:not(:last-child) {
  border-bottom: 1px solid rgba(90, 45, 0, 0.4);
}

.leaderboard-row .rank {
  color: #e8a630;
  width: 20px;
  text-align: left;
}

.leaderboard-row .lb-name {
  flex: 1;
  text-align: left;
  margin-left: 4px;
  color: #f5d88e;
}

.leaderboard-row .lb-score {
  text-align: right;
  color: #e8a630;
  min-width: 50px;
}

.leaderboard-row .lb-wave {
  text-align: right;
  color: #888;
  min-width: 30px;
  margin-left: 6px;
  font-size: 7px;
}

.leaderboard-row:first-child .lb-name {
  color: #ffee44;
}

.leaderboard-empty {
  font-size: 7px;
  color: #666;
  padding: 10px;
  text-align: center;
}

/* ── Profile Modal ── */
.profile-field {
  margin-bottom: 14px;
}

.profile-label {
  font-size: 7px;
  color: #c87830;
  letter-spacing: 1px;
  margin-bottom: 6px;
}

.profile-value {
  font-size: 11px;
  color: #ffee44;
  text-shadow: 1px 1px 0 #5a2d00;
}

.profile-email-input {
  font-family: 'Press Start 2P', monospace;
  font-size: 9px;
  color: #ffee44;
  background: rgba(0, 0, 0, 0.5);
  border: 2px solid #5a2d00;
  padding: 10px 12px;
  width: 100%;
  text-align: center;
  outline: none;
  box-sizing: border-box;
}

.profile-email-input:focus {
  border-color: #e8a630;
}

.profile-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 14px;
}

/* ── Dialog Overlay ── */
.dialog-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.85);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 100;
  padding: 16px;
}

.dialog-overlay.hidden {
  display: none;
}

.dialog-box {
  background: #1a0a00;
  border: 2px solid #5a2d00;
  padding: 20px 16px;
  width: 100%;
  max-width: 320px;
}

.dialog-name {
  font-size: 11px;
  color: #e8a630;
  letter-spacing: 2px;
  margin-bottom: 12px;
  text-align: center;
  text-shadow: 1px 1px 0 #5a2d00;
}

.dialog-text {
  font-size: 9px;
  color: #f5d88e;
  line-height: 1.8;
  margin-bottom: 18px;
  letter-spacing: 0.5px;
  text-align: center;
}

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

/* ── Fade Overlay ── */
.fade-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: #1a0a00;
  z-index: 9999;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.4s ease;
}

.fade-overlay.active {
  opacity: 1;
  pointer-events: all;
}

/* ── Music Toggle ── */
.music-toggle {
  position: fixed;
  bottom: 10px;
  right: 10px;
  font-family: 'Press Start 2P', monospace;
  font-size: 7px;
  color: #c87830;
  background: rgba(26, 10, 0, 0.9);
  border: 1px solid #5a2d00;
  padding: 4px 6px;
  cursor: pointer;
  z-index: 20;
}

.music-toggle:hover {
  color: #e8a630;
  border-color: #e8a630;
}

/* ── Responsive ── */
@media (max-height: 650px) {
  .event-header h1 { font-size: 18px; margin-bottom: 4px; }
  .event-header { margin-bottom: 8px; padding-top: 4px; }
  .lobby-btn { font-size: 9px; padding: 9px 12px; }
  .lobby-btn-release { font-size: 8px; }
  .lobby-buttons { gap: 6px; }
}

@supports (padding-top: env(safe-area-inset-top)) {
  .scene {
    padding-top: calc(16px + env(safe-area-inset-top));
    padding-bottom: calc(16px + env(safe-area-inset-bottom));
  }
}
