/* mdungeon shared styles — dark fantasy theme */
:root {
  color-scheme: dark;
  --bg: #0a0a0f;
  --panel: #111118;
  --border: #2a2a3a;
  --text: #c8c8d8;
  --accent: #d4a44a;
  --accent2: #6a8ccc;
  --danger: #cc4444;
  --torch: #e8a020;
}

* { box-sizing: border-box; margin: 0; padding: 0;
    -webkit-user-select: none; user-select: none; }

html, body {
  height: 100%; background: var(--bg); color: var(--text);
  font: 16px/1.5 'Segoe UI', system-ui, sans-serif;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Splash / menu screens ── */
.screen {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; min-height: 100vh; padding: 24px; text-align: center;
}
.screen h1 {
  font-size: clamp(36px, 8vw, 72px); font-weight: 900;
  letter-spacing: .06em; color: var(--accent);
  text-shadow: 0 0 30px rgba(212,164,74,.35);
  margin-bottom: 8px;
}
.screen h2 {
  font-size: 20px; font-weight: 400; color: #888;
  margin-bottom: 32px;
}
.screen p { max-width: 600px; margin: 0 auto 16px; line-height: 1.7; }

.btn {
  display: inline-block; padding: 14px 32px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--panel);
  color: var(--text); font-size: 18px; font-weight: 700;
  cursor: pointer; transition: all .15s;
  text-decoration: none;
}
.btn:hover { background: #1a1a28; border-color: var(--accent); color: var(--accent); }
.btn.primary { background: var(--accent); color: #000; border-color: var(--accent); }
.btn.primary:hover { background: #e8b854; }

.btn-row { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; margin: 20px 0; }

/* ── Page layout ── */
.page {
  max-width: 800px; margin: 0 auto; padding: 40px 24px;
}
.page h1 { font-size: 32px; color: var(--accent); margin-bottom: 20px; }
.page h2 { font-size: 22px; color: var(--accent2); margin: 28px 0 12px; }
.page h3 { font-size: 18px; color: var(--accent); margin: 20px 0 8px; }
.page p, .page li { line-height: 1.7; margin-bottom: 8px; }
.page ul { padding-left: 24px; }
.page code { background: #1a1a28; padding: 2px 6px; border-radius: 4px; font-size: 14px; }
.page kbd {
  display: inline-block; background: #222; border: 1px solid #444;
  border-radius: 4px; padding: 2px 8px; font-family: monospace;
  font-size: 14px; color: var(--accent);
}
.page table { width: 100%; border-collapse: collapse; margin: 16px 0; }
.page th, .page td { padding: 8px 12px; border: 1px solid var(--border); text-align: left; }
.page th { background: var(--panel); color: var(--accent); }

.back-link { display: inline-block; margin-bottom: 20px; font-size: 14px; }

/* ── Game HUD ── */
.game-container {
  display: flex; flex-direction: column; height: 100vh; height: 100dvh; background: #000;
}
.game-top {
  display: flex; align-items: center; justify-content: space-between;
  padding: 6px 16px; background: var(--panel); border-bottom: 1px solid var(--border);
  font-size: 13px; flex: 0 0 auto;
}
.game-top .title { color: var(--accent); font-weight: 700; }
.game-top .players-count {
  color: #9fd8ff;
  font-weight: 700;
  white-space: nowrap;
  margin: 0 10px;
}
.game-top .stats span { margin-left: 12px; }
.game-top .stats b { color: var(--accent); margin-right: 4px; }

.viewport-wrap {
  flex: 1 1 auto; display: flex; align-items: center; justify-content: center;
  min-height: 0; padding: 0; background: #000;
}
#viewport {
  display: block; width: 100%; height: 100%;
  image-rendering: pixelated;
}

#inv-close-btn {
  position: fixed;
  top: 56px;
  left: 14px;
  z-index: 40;
  display: none;
  appearance: none;
  border: 1px solid #7a3030;
  border-radius: 8px;
  background: #2a0e0e;
  color: #ffb3b3;
  font-weight: 700;
  font-size: 13px;
  padding: 8px 10px;
  cursor: pointer;
}

.game-bottom {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 16px; background: var(--panel); border-top: 1px solid var(--border);
  font-size: 13px; flex: 0 0 auto;
}
.game-bottom .msg { color: var(--accent2); min-height: 1.4em; }
.game-bottom .controls { color: #666; }

.compass { color: var(--accent); font-weight: 700; font-size: 16px; }

/* ── Minimap overlay ── */
#minimap {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 35;
  border: 2px solid var(--border);
  border-radius: 6px;
  background: rgba(18,16,12,0.96);
  max-width: 94vw;
  max-height: 90vh;
  display: none;
}

.heal-target-modal {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(0,0,0,0.55);
  display: none;
  align-items: center;
  justify-content: center;
}

.heal-target-panel {
  width: min(520px, 92vw);
  max-height: 84vh;
  overflow: auto;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
}

.heal-target-title {
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 10px;
}

.heal-target-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.heal-target-btn,
.heal-target-close {
  appearance: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #0d0d18;
  color: var(--text);
  padding: 8px 10px;
  text-align: left;
  font-weight: 600;
  cursor: pointer;
}

.heal-target-close {
  margin-top: 10px;
  text-align: center;
}

/* ── Mobile controls ── */
.mobile-controls {
  display: none;
  flex: 0 0 auto;
  padding: 6px 8px 8px;
  justify-content: space-between;
  align-items: flex-end;
  background: var(--panel);
  border-top: 1px solid var(--border);
  gap: 10px;
}
.mobile-controls .m-btn {
  appearance: none; border: 1px solid var(--border); border-radius: 10px;
  padding: 12px 14px; font-size: 20px; font-weight: 700;
  color: var(--text); background: #0d0d18; min-width: 62px; min-height: 54px;
  touch-action: none; cursor: pointer;
}
.mobile-controls .m-btn.fight { background: #2b0d0d; border-color: #5a2424; color: #ff8888; }
body.mobile-ui .mobile-controls { display: flex; }

body.mobile-ui .game-container {
  height: 100svh;
}

body.mobile-ui .mobile-controls {
  display: grid;
  grid-template-columns: 1fr;
  justify-items: center;
  align-items: center;
  padding: 6px 8px calc(8px + env(safe-area-inset-bottom));
  gap: 8px;
}

.mobile-dpad {
  display: grid;
  grid-template-columns: 72px 72px 72px;
  grid-template-rows: 66px 66px;
  grid-template-areas:
    ". up ."
    "left down right";
  gap: 6px;
  align-items: center;
  justify-items: center;
  width: max-content;
}

.mobile-controls .m-btn.move {
  min-width: 72px;
  min-height: 66px;
  padding: 0;
  font-size: 30px;
}

.mobile-dpad .up { grid-area: up; }
.mobile-dpad .left { grid-area: left; }
.mobile-dpad .down { grid-area: down; }
.mobile-dpad .right { grid-area: right; }

.mobile-actions {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  flex-wrap: nowrap;
  gap: 6px;
  margin-left: 0;
}

.mobile-actions .m-btn {
  font-size: 20px;
  min-width: 62px;
  min-height: 54px;
  padding: 10px 14px;
}

body.mobile-ui .viewport-wrap {
  flex: 0 0 clamp(180px, 42svh, 320px);
  max-height: clamp(180px, 42svh, 320px);
}

body.mobile-ui .game-bottom {
  display: none;
}

body.mobile-ui .game-top {
  padding: 4px 10px;
  font-size: 12px;
}

body.mobile-ui .game-top .players-count {
  margin: 0 6px;
  font-size: 12px;
}

/* ── Door entry animation ── */
@keyframes doorPulse {
  0%, 100% { filter: brightness(1); }
  50% { filter: brightness(1.3); }
}
