/* DungeonCrawler browser adaptation */

.game-page {
  min-height: 100vh;
}

.game-header {
  position: sticky;
}

.game-nav {
  display: flex;
  gap: 6px;
}

.game-nav a {
  padding: 9px 12px;
  border-radius: 10px;
  color: var(--text-soft);
  font-size: 0.88rem;
  transition: color var(--transition), background var(--transition);
}

.game-nav a:hover {
  color: var(--text);
  background: rgba(255,255,255,.05);
}

.game-shell {
  width: min(calc(100% - 40px), 1180px);
  margin-inline: auto;
  padding: 72px 0 90px;
}

.game-intro {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(270px, 380px);
  gap: 60px;
  align-items: end;
  margin-bottom: 38px;
}

.game-intro h1 {
  margin: 0;
  font-size: clamp(3.4rem, 7vw, 6.6rem);
  line-height: .94;
  letter-spacing: -.065em;
}

.game-intro > div:first-child > p:last-child {
  max-width: 650px;
  margin: 24px 0 0;
  color: var(--text-soft);
}

.game-note {
  padding: 18px 20px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
}

.game-note span {
  color: var(--muted);
  font-size: .7rem;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
}

.game-note p {
  margin: 6px 0 0;
  color: var(--text-soft);
  font-size: .84rem;
}

.game-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 24px;
  align-items: start;
}

.game-frame {
  overflow: hidden;
  border: 1px solid var(--border-strong);
  border-radius: 22px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.game-toolbar {
  min-height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
}

.game-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
  color: var(--muted);
  font-size: .78rem;
}

.game-stats strong {
  color: var(--text);
  font-weight: 700;
}

.game-reset {
  padding: 7px 11px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: rgba(255,255,255,.03);
  color: var(--text-soft);
  cursor: pointer;
}

.game-reset:hover {
  border-color: var(--border-strong);
  color: var(--text);
}

.canvas-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 1;
  overflow: hidden;
  background: #090b0e;
}

#dungeon-canvas {
  width: 100%;
  height: 100%;
  display: block;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  background: #090b0e;
}

.game-overlay {
  position: absolute;
  inset: 0;
  z-index: 4;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(8,10,13,.78);
  backdrop-filter: blur(8px);
  opacity: 0;
  visibility: hidden;
  transition: opacity 180ms ease, visibility 180ms ease;
}

.game-overlay.is-visible {
  opacity: 1;
  visibility: visible;
}

.overlay-panel {
  width: min(100%, 490px);
  padding: 30px;
  border: 1px solid var(--border-strong);
  border-radius: 20px;
  background: rgba(18,22,27,.97);
  box-shadow: 0 28px 80px rgba(0,0,0,.45);
}

.overlay-panel.is-hidden {
  display: none;
}

.overlay-panel h2 {
  margin: 0;
  font-size: clamp(2rem, 5vw, 3rem);
  line-height: 1;
  letter-spacing: -.045em;
}

.overlay-panel > p:not(.section-kicker) {
  color: var(--text-soft);
}

.character-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin: 24px 0;
}

.character-card {
  display: grid;
  justify-items: center;
  gap: 8px;
  padding: 18px 14px;
  border: 1px solid var(--border);
  border-radius: 15px;
  background: rgba(255,255,255,.025);
  color: var(--text);
  cursor: pointer;
  transition: border-color 180ms ease, background 180ms ease, transform 180ms ease;
}

.character-card:hover {
  transform: translateY(-1px);
  border-color: var(--border-strong);
  background: rgba(255,255,255,.045);
}

.character-card.is-selected {
  border-color: rgba(139,184,255,.55);
  background: var(--accent-soft);
}

.character-card img {
  width: 80px;
  height: 80px;
  image-rendering: pixelated;
}

.character-card strong {
  font-size: .9rem;
}

.character-card span {
  color: var(--muted);
  font-size: .7rem;
}

.game-start {
  width: 100%;
}

.game-sidebar {
  display: grid;
  gap: 14px;
}

.sidebar-card {
  padding: 20px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: rgba(255,255,255,.018);
}

.sidebar-card p {
  margin: 0;
  color: var(--text-soft);
  font-size: .86rem;
}

.sidebar-card ul {
  margin: 0;
  padding-left: 18px;
  color: var(--text-soft);
  font-size: .82rem;
}

.sidebar-card li + li {
  margin-top: 7px;
}

.game-message {
  min-height: 3em;
}

.mobile-controls {
  display: none;
}

.control-button {
  min-height: 48px;
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  background: var(--surface-2);
  color: var(--text);
  font-size: 1rem;
  font-weight: 700;
}

.control-teleport {
  color: var(--accent);
}

.control-teleport.is-active {
  background: var(--accent-soft);
  border-color: rgba(139,184,255,.55);
}

@media (max-width: 980px) {
  .game-layout {
    grid-template-columns: 1fr;
  }

  .game-sidebar {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (max-width: 760px) {
  .game-shell {
    width: min(calc(100% - 28px), 1180px);
    padding-top: 52px;
  }

  .game-intro {
    grid-template-columns: 1fr;
    gap: 24px;
  }

  .game-nav a:first-child {
    display: none;
  }

  .game-sidebar {
    grid-template-columns: 1fr;
  }

  .mobile-controls {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    padding: 12px;
    border-top: 1px solid var(--border);
  }

  .control-up {
    grid-column: 2;
  }

  .control-left {
    grid-column: 1;
  }

  .control-down {
    grid-column: 2;
  }

  .control-right {
    grid-column: 3;
  }

  .control-teleport {
    grid-column: 1 / -1;
  }
}

@media (max-width: 520px) {
  .game-intro h1 {
    font-size: clamp(3rem, 15vw, 4.8rem);
  }

  .overlay-panel {
    padding: 22px 18px;
  }

  .character-grid {
    gap: 8px;
  }

  .character-card {
    padding: 14px 8px;
  }

  .character-card img {
    width: 62px;
    height: 62px;
  }

  .game-toolbar {
    align-items: flex-start;
  }

  .game-stats {
    gap: 10px 14px;
  }
}


/* ------------------------------
   Robust fullscreen game mode
------------------------------ */

.game-toolbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.game-fullscreen {
  padding: 7px 11px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: rgba(255,255,255,.03);
  color: var(--text);
  cursor: pointer;
}

.game-fullscreen:hover {
  border-color: var(--border-strong);
  background: rgba(255,255,255,.055);
}

body.game-fullscreen-active {
  overflow: hidden;
}

body.game-fullscreen-active .game-frame {
  position: fixed;
  inset: 0;
  z-index: 99999;
  width: 100vw;
  height: 100dvh;
  max-width: none;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  border: 0;
  border-radius: 0;
  background: #090b0e;
  box-shadow: none;
}

body.game-fullscreen-active .game-toolbar {
  min-height: 54px;
  padding: 10px 18px;
  background: var(--surface);
}

body.game-fullscreen-active .canvas-wrap {
  width: 100%;
  height: 100%;
  max-height: none;
  min-height: 0;
  aspect-ratio: auto;
  display: grid;
  place-items: center;
  background: #090b0e;
}

body.game-fullscreen-active #dungeon-canvas {
  width: min(calc(100vw - 24px), calc(100dvh - 78px));
  height: min(calc(100vw - 24px), calc(100dvh - 78px));
  max-width: none;
  max-height: none;
  margin: 0;
}

body.game-fullscreen-active .mobile-controls {
  display: none;
}

/* Also style native fullscreen directly as an extra safety net. */
:fullscreen body {
  overflow: hidden;
}

@media (min-width: 981px) {
  .game-shell {
    padding-top: 42px;
  }

  .game-intro {
    margin-bottom: 24px;
  }

  .game-intro h1 {
    font-size: clamp(3rem, 5.4vw, 5.3rem);
  }

  .game-intro > div:first-child > p:last-child {
    margin-top: 16px;
  }

  .canvas-wrap {
    max-height: calc(100vh - 245px);
    min-height: 500px;
  }

  #dungeon-canvas {
    width: min(100%, calc(100vh - 245px));
    height: auto;
    margin-inline: auto;
  }

  body.game-fullscreen-active .canvas-wrap {
    max-height: none;
    min-height: 0;
  }

  body.game-fullscreen-active #dungeon-canvas {
    width: min(calc(100vw - 24px), calc(100dvh - 78px));
    height: min(calc(100vw - 24px), calc(100dvh - 78px));
  }
}

@media (max-width: 760px) {
  .game-toolbar-actions {
    gap: 6px;
  }

  .game-fullscreen,
  .game-reset {
    padding-inline: 9px;
  }
}
