.game-page {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.game-shell {
  flex: 1;
  max-width: 960px;
  margin: 0 auto;
  padding: 24px 20px 40px;
  width: 100%;
}

.game-header {
  text-align: center;
  margin-bottom: 16px;
}

.game-header h1 {
  margin: 0 0 6px;
  font-family: 'Cinzel', Georgia, serif;
  font-size: clamp(1.4rem, 4vw, 2rem);
  letter-spacing: 0.06em;
  background: linear-gradient(90deg, #d4af37, #f4e4bc 45%, #c46960);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.game-subtitle {
  margin: 0;
  font-size: 0.9rem;
}

.game-menu {
  max-width: 520px;
  margin: 0 auto 20px;
  padding: 24px 20px 28px;
  background: #1a2030;
  border: 1px solid #405060;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.game-menu.hidden {
  display: none;
}

.hero-card {
  display: flex;
  align-items: center;
  gap: 18px;
  margin-bottom: 20px;
  padding: 16px;
  background: #0a1018;
  border: 2px solid #506070;
  border-radius: 12px;
}

.game-menu-title {
  margin: 0 0 6px;
  font-family: 'Cinzel', Georgia, serif;
  font-size: 1.35rem;
  color: #ff8080;
}

.hero-desc {
  margin: 0 0 8px;
  font-size: 0.9rem;
  color: #88aacc;
  line-height: 1.4;
}

.hero-stats {
  margin: 0;
  font-size: 0.8rem;
  color: #607080;
}

.class-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 16px 10px;
  background: #1a2030;
  border: 2px solid #3a3028;
  border-radius: 12px;
  color: #f4e4bc;
  cursor: pointer;
  font-family: inherit;
  transition: border-color 0.15s, background 0.15s;
}

.class-btn:hover {
  background: #261c14;
  border-color: #6a6050;
}

.class-btn.selected {
  background: #3a2a18;
  border-color: #d4af37;
}

.class-btn strong {
  font-family: 'Cinzel', Georgia, serif;
  font-size: 0.95rem;
}

.class-btn small {
  color: #a89070;
  font-size: 0.75rem;
}

.class-dot {
  width: 28px;
  height: 28px;
  border-radius: 50%;
}

.class-dot.warrior { background: #c46960; }
.class-dot.rogue { background: #6bd46b; }
.class-dot.sorcerer { background: #5b8cff; }
.class-dot.bard { background: #d4af37; }

.selected-label {
  text-align: center;
  margin: 18px 0 14px;
  font-family: 'Cinzel', Georgia, serif;
  color: #807060;
}

.selected-label.ready {
  color: #f4e4bc;
}

.enter-btn {
  display: block;
  width: 100%;
  max-width: 280px;
  margin: 0 auto;
  padding: 14px 24px;
  font-family: 'Cinzel', Georgia, serif;
  font-size: 1.2rem;
  font-weight: 700;
  color: #f4e4bc;
  background: linear-gradient(135deg, #c46960, #a05048);
  border: 2px solid #d4af37;
  border-radius: 12px;
  cursor: pointer;
  transition: filter 0.15s, transform 0.15s;
}

.enter-btn:hover:not(:disabled) {
  filter: brightness(1.08);
  transform: translateY(-1px);
}

.enter-btn:disabled {
  background: #2a2118;
  border-color: #5a5040;
  color: #5a5040;
  cursor: not-allowed;
}

.menu-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: center;
}

.secondary-btn {
  display: inline-block;
  padding: 10px 18px;
  font-family: 'Cinzel', Georgia, serif;
  font-size: 0.95rem;
  color: #d4af37;
  background: #0a1018;
  border: 1px solid #506070;
  border-radius: 10px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.secondary-btn:hover {
  background: #141c28;
  border-color: #8090a0;
}

a.secondary-btn {
  display: inline-block;
  text-align: center;
  text-decoration: none;
}

.download-source-btn {
  font-size: 0.88rem;
}

.kc-modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(8, 12, 18, 0.82);
}

.kc-modal.is-open {
  display: flex;
}

.kc-modal-panel {
  width: min(100%, 420px);
  max-height: min(80vh, 560px);
  overflow: auto;
  padding: 20px;
  background: #1a2030;
  border: 1px solid #506070;
  border-radius: 14px;
  box-shadow: var(--shadow);
}

.kc-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.kc-modal-header h2 {
  margin: 0;
  font-family: 'Cinzel', Georgia, serif;
  font-size: 1.2rem;
  color: #f4e4bc;
}

.kc-modal-subtitle {
  margin: 0 0 14px;
  font-size: 0.88rem;
  color: #88aacc;
}

.kc-leaderboard-list {
  margin: 0;
  padding-left: 1.2rem;
  color: #f0d0a0;
  font-size: 0.92rem;
  line-height: 1.6;
}

.kc-leaderboard-empty {
  margin: 0;
  font-size: 0.88rem;
  color: #607080;
}

.kc-name-label {
  display: block;
  margin-bottom: 6px;
  font-size: 0.85rem;
  color: #88aacc;
}

.kc-name-input {
  width: 100%;
  margin-bottom: 14px;
  padding: 10px 12px;
  font-size: 1rem;
  color: #f4e4bc;
  background: #0a1018;
  border: 1px solid #506070;
  border-radius: 8px;
}

.kc-modal-actions {
  display: flex;
  gap: 10px;
}

.kc-modal-actions .enter-btn,
.kc-modal-actions .secondary-btn {
  flex: 1;
  max-width: none;
  width: auto;
}

.game-play-wrap {
  width: 100%;
  max-width: 800px;
  margin: 0 auto;
  border: 1px solid #405060;
  box-shadow: var(--shadow);
  background: #1a2030;
}

.game-play-wrap.game-hidden {
  display: none;
}

.game-hud {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px 20px;
  margin: 0;
  padding: 10px 14px;
  background:
    linear-gradient(180deg, rgba(64, 80, 96, 0.35) 0%, rgba(64, 80, 96, 0) 100%),
    repeating-linear-gradient(
      90deg,
      #223040 0,
      #223040 16px,
      #283848 16px,
      #283848 32px
    );
  border-bottom: 1px solid #405060;
}

.game-hud-stat {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-size: 0.92rem;
  white-space: nowrap;
  padding: 2px 6px;
  background: rgba(10, 16, 24, 0.55);
  border: 1px solid rgba(64, 80, 96, 0.8);
}

.game-hud-label {
  font-family: 'Cinzel', Georgia, serif;
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  color: #8090a0;
  text-transform: uppercase;
}

#hud-hp { color: #ff8080; font-family: Georgia, serif; }
#hud-score { color: #d4af37; font-family: Georgia, serif; }
#hud-kills { color: #88aacc; }
#hud-cellar { color: #f0d0a0; font-family: 'Cinzel', Georgia, serif; }

.game-hud-fullscreen {
  margin-left: auto;
  align-self: center;
  padding: 6px 12px;
  font-family: 'Cinzel', Georgia, serif;
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #d4af37;
  background: rgba(10, 16, 24, 0.55);
  border: 1px solid rgba(64, 80, 96, 0.8);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, color 0.15s;
}

.game-hud-fullscreen:hover {
  background: rgba(20, 28, 40, 0.85);
  border-color: #8090a0;
  color: #f4e4bc;
}

.game-play-wrap:fullscreen,
.game-play-wrap:-webkit-full-screen {
  display: grid;
  grid-template-rows: auto 1fr;
  width: 100vw;
  height: 100vh;
  max-width: none;
  margin: 0;
  border: none;
  box-shadow: none;
  background: #1a2030;
}

.game-play-wrap:fullscreen .game-hud,
.game-play-wrap:-webkit-full-screen .game-hud {
  padding: 12px 20px;
  gap: 10px 24px;
  border-bottom: 1px solid #506070;
}

.game-play-wrap:fullscreen .game-hud-stat,
.game-play-wrap:-webkit-full-screen .game-hud-stat {
  font-size: 1rem;
  padding: 4px 10px;
}

.game-play-wrap:fullscreen .game-hud-label,
.game-play-wrap:-webkit-full-screen .game-hud-label {
  font-size: 0.78rem;
}

.game-play-wrap:fullscreen .game-hud-fullscreen,
.game-play-wrap:-webkit-full-screen .game-hud-fullscreen {
  font-size: 0.78rem;
  padding: 8px 14px;
}

.game-viewport {
  width: 100%;
}

.game-play-wrap:fullscreen .game-viewport,
.game-play-wrap:-webkit-full-screen .game-viewport {
  container-type: size;
  display: grid;
  place-items: center;
  min-height: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: #304050;
  background-image:
    linear-gradient(#253040 1px, transparent 1px),
    linear-gradient(90deg, #253040 1px, transparent 1px),
    repeating-conic-gradient(#405060 0% 25%, #465668 0% 50%) 0 0 / 32px 32px;
}

.game-play-wrap:fullscreen #game-container,
.game-play-wrap:-webkit-full-screen #game-container {
  width: min(100cqw, calc(100cqh * 800 / 600));
  height: min(100cqh, calc(100cqw * 600 / 800));
  aspect-ratio: 800 / 600;
  max-width: 100%;
  max-height: 100%;
  box-shadow: 0 0 0 2px #506070;
}

#game-container {
  margin: 0;
  width: 100%;
  aspect-ratio: 800 / 600;
  border-radius: 0;
  overflow: hidden;
  background: #1a2030;
}

#game-container canvas {
  display: block;
  width: 100% !important;
  height: 100% !important;
}

.game-hint {
  text-align: center;
  margin: 14px 0 0;
  font-size: 0.85rem;
}

.game-page footer {
  margin-top: auto;
}

@media (max-width: 640px) {
  .game-shell {
    padding: 16px 12px 28px;
  }

  .game-header h1 {
    font-size: 1.25rem;
  }
}
