/* ===== Voxel Depths: Roguelike — styles ===== */

:root {
  --bg: #14091f;
  --bg-panel: #1e1233;
  --bg-panel-2: #271a42;
  --border: #4a3577;
  --border-light: #6b4fb0;
  --accent: #7dd3fc;
  --accent-2: #facc15;
  --accent-3: #4ade80;
  --danger: #f87171;
  --danger-dark: #7f1d1d;
  --text: #f2edff;
  --text-muted: #b7a9df;
  --font-pixel: "Press Start 2P", "Sen", monospace;
  --font-body: "Sen", system-ui, sans-serif;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
}

body {
  padding-left: var(--safe-left);
  padding-right: var(--safe-right);
  padding-bottom: var(--safe-bottom);
  background-image:
    linear-gradient(180deg, #1b0f2e 0%, #14091f 60%, #0d0616 100%);
  min-height: 100vh;
}

.site-header {
  text-align: center;
  padding: calc(1.2rem + var(--safe-top)) 1rem 0.8rem;
  border-bottom: 4px solid var(--border);
  background: repeating-linear-gradient(45deg, #201335, #201335 10px, #241639 10px, #241639 20px);
}

.site-header h1 {
  font-family: var(--font-pixel);
  font-size: clamp(1rem, 4.5vw, 1.6rem);
  margin: 0 0 0.5rem;
  color: var(--accent-2);
  text-shadow: 3px 3px 0 #4a2f00;
  line-height: 1.5;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.brand-icon {
  width: 1.5em;
  height: 1.5em;
  flex-shrink: 0;
}

.tagline {
  margin: 0 0 0.8rem;
  color: var(--text-muted);
  font-size: 0.95rem;
  letter-spacing: 0.03em;
}

main {
  max-width: 620px;
  margin: 0 auto;
  padding: 1rem;
}

.panel {
  background: var(--bg-panel);
  border: 3px solid var(--border);
  border-radius: 6px;
  padding: 1rem;
  margin-bottom: 1rem;
  box-shadow: 0 4px 0 rgba(0,0,0,0.35);
}

h2 {
  font-family: var(--font-pixel);
  font-size: 1.05rem;
  color: var(--accent);
  margin: 0 0 0.8rem;
  line-height: 1.6;
}

.info-panel { padding: 0; }
.info-panel summary {
  list-style: none;
  cursor: pointer;
  padding: 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  touch-action: manipulation;
}
.info-panel summary::-webkit-details-marker { display: none; }
.info-panel summary h2 { margin: 0; }
.info-panel summary::after {
  content: "+";
  font-family: var(--font-pixel);
  font-size: 1.1rem;
  color: var(--text-muted);
  flex-shrink: 0;
}
.info-panel[open] summary::after { content: "−"; }
.info-panel[open] summary { border-bottom: 2px solid var(--border); }

.info-panel .how-to-list {
  margin: 0;
  padding: 0.9rem 1rem 1rem 1.6rem;
  line-height: 1.7;
  font-size: 0.92rem;
  list-style: none;
}
.info-panel li {
  margin-bottom: 0.5rem;
  position: relative;
}
.info-panel li::before {
  content: "";
  position: absolute;
  left: -1.1rem;
  top: 0.5em;
  width: 6px;
  height: 6px;
  background: var(--accent);
}

.muted { color: var(--text-muted); font-size: 0.88rem; }

/* ===== Buttons ===== */
.btn {
  font-family: var(--font-body);
  font-weight: 800;
  font-size: 0.95rem;
  border: 3px solid var(--border-light);
  border-radius: 5px;
  padding: 0.7rem 1rem;
  min-height: 44px;
  cursor: pointer;
  background: var(--bg-panel-2);
  color: var(--text);
  box-shadow: 0 4px 0 #0d0616;
  transition: transform 0.06s ease, box-shadow 0.06s ease;
  touch-action: manipulation;
}
.btn:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 #0d0616;
}
.btn-primary {
  background: var(--accent-3);
  border-color: #166534;
  color: #052e13;
}
.btn-secondary {
  background: transparent;
  border-color: var(--border-light);
  color: var(--text);
}
.btn-big { width: 100%; font-size: 1.05rem; padding: 0.9rem 1rem; }

.menu-buttons { display: flex; flex-direction: column; gap: 0.7rem; margin-top: 1rem; }

/* ===== Menu / Upgrades screens ===== */
.screen-title { text-align: center; }

.stat-cards {
  display: flex;
  gap: 0.7rem;
  flex-wrap: wrap;
  justify-content: center;
}
.stat-card {
  background: var(--bg-panel-2);
  border: 2px solid var(--border);
  border-radius: 6px;
  padding: 0.7rem 1rem;
  text-align: center;
  flex: 1 1 140px;
}
.stat-label { display: block; font-size: 0.75rem; color: var(--text-muted); margin-bottom: 0.3rem; }
.stat-value { font-family: var(--font-pixel); font-size: 1.2rem; color: var(--accent-2); }
.stat-inline { font-size: 0.95rem; }

.upgrade-list { display: flex; flex-direction: column; gap: 0.6rem; margin: 0.8rem 0; }
.upgrade-card {
  background: var(--bg-panel-2);
  border: 2px solid var(--border);
  border-radius: 6px;
  padding: 0.7rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
}
.upgrade-info { flex: 1 1 160px; }
.upgrade-name { font-weight: 800; font-size: 0.92rem; }
.upgrade-desc { font-size: 0.8rem; color: var(--text-muted); }
.upgrade-level { font-size: 0.78rem; color: var(--accent-3); margin-top: 0.2rem; }
.upgrade-buy {
  min-height: 40px;
  padding: 0.5rem 0.8rem;
  font-size: 0.85rem;
}
.upgrade-buy:disabled { opacity: 0.45; cursor: not-allowed; }

/* ===== HUD ===== */
.hud { margin-bottom: 0.6rem; }
.hud-row { display: flex; gap: 0.6rem; margin-bottom: 0.4rem; flex-wrap: wrap; }
.hud-row-info { justify-content: space-between; font-size: 0.8rem; align-items: center; }

.bar-wrap { flex: 1 1 230px; display: flex; align-items: center; gap: 0.4rem; min-width: 0; }
.bar { min-width: 40px; }
.bar-label { font-size: 0.72rem; width: 4.6rem; flex-shrink: 0; }
.bar { flex: 1; height: 14px; background: #0d0616; border: 2px solid var(--border); border-radius: 6px; overflow: hidden; }
.bar-fill { height: 100%; width: 100%; transition: width 0.25s ease, background 0.25s ease; }
.bar-hp .bar-fill { background: linear-gradient(90deg, #f87171, #ef4444); }
.bar-hunger .bar-fill { background: linear-gradient(90deg, #fbbf24, #f59e0b); }
.bar-num { font-size: 0.7rem; width: 3.6rem; text-align: right; flex-shrink: 0; color: var(--text-muted); }

.depth-badge { font-weight: 800; color: var(--accent-2); }
.gear-badge { color: var(--text-muted); font-size: 0.72rem; text-align: right; }

.materials-row { gap: 0.4rem; font-size: 0.78rem; }
.material-chip {
  background: var(--bg-panel-2);
  border: 2px solid var(--border);
  border-radius: 6px;
  padding: 0.2rem 0.5rem;
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}

.log-line {
  min-height: 1.6em;
  font-size: 0.82rem;
  color: var(--accent);
  background: #0d0616;
  border: 2px solid var(--border);
  border-radius: 6px;
  padding: 0.4rem 0.6rem;
  margin: 0.4rem 0 0.6rem;
}

/* ===== Board ===== */
.board-wrap {
  display: flex;
  justify-content: center;
  margin-bottom: 0.8rem;
}

.board {
  display: grid;
  gap: 2px;
  background: #0d0616;
  border: 3px solid var(--border);
  border-radius: 6px;
  padding: 4px;
  width: 100%;
  max-width: 480px;
  aspect-ratio: 1 / 1;
}

.tile {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: clamp(0.7rem, 3.6vw, 1.3rem);
  border-radius: 3px;
  border: none;
  cursor: pointer;
  position: relative;
  padding: 0;
  min-width: 0;
  min-height: 0;
  touch-action: manipulation;
  color: var(--text);
}

.tile-tierra { background: #6b4a2f; }
.tile-roca { background: #4b4b58; }
.tile-mena { background: #574a7a; box-shadow: inset 0 0 0 2px rgba(255,255,255,0.15); }
.tile-suelo { background: #241639; }
.tile-suelo.tile-visited { background: #2a1a42; }
.tile-escaleras { background: #241639; color: var(--accent-2); }
.tile-cofre { background: #241639; }
.tile-comida { background: #241639; }
.tile-enemigo { background: #241639; }
.tile-player { box-shadow: inset 0 0 0 3px var(--accent-3); }

.tile-adjacent { box-shadow: inset 0 0 0 2px rgba(125, 211, 252, 0.7); }

.tile-hp-mini {
  position: absolute;
  bottom: 2px;
  left: 8%;
  right: 8%;
  height: 4px;
  background: #000;
  border-radius: 2px;
  overflow: hidden;
}
.tile-hp-mini-fill { height: 100%; background: #f87171; }

.tile-telegraph {
  animation: pulse-warn 0.5s infinite alternate;
}
@keyframes pulse-warn {
  from { box-shadow: inset 0 0 0 3px #facc15; }
  to { box-shadow: inset 0 0 0 3px #ef4444; }
}

/* ===== Action bar / dpad ===== */
.action-bar { display: flex; gap: 0.6rem; margin-bottom: 0.8rem; }
.action-bar .btn { flex: 1; }

.dpad {
  display: grid;
  grid-template-columns: 52px 52px 52px;
  grid-template-rows: 52px 52px;
  gap: 4px;
  justify-content: center;
  margin: 0 auto 0.5rem;
  width: max-content;
}
.dpad-btn {
  min-width: 44px;
  min-height: 44px;
  font-size: 1.1rem;
  border: 2px solid var(--border-light);
  border-radius: 5px;
  background: var(--bg-panel-2);
  color: var(--text);
  cursor: pointer;
  touch-action: manipulation;
}
.dpad-btn:active { transform: translateY(2px); }
.dpad-up { grid-column: 2; grid-row: 1; }
.dpad-left { grid-column: 1; grid-row: 2; }
.dpad-down { grid-column: 2; grid-row: 2; }
.dpad-right { grid-column: 3; grid-row: 2; }

/* ===== Modal ===== */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(5, 2, 12, 0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  z-index: 50;
}
.modal.hidden { display: none; }
.modal-box {
  background: var(--bg-panel);
  border: 3px solid var(--border-light);
  border-radius: 6px;
  padding: 1rem;
  max-width: 460px;
  width: 100%;
  max-height: 85vh;
  overflow-y: auto;
}
.craft-list { display: flex; flex-direction: column; gap: 0.6rem; margin-bottom: 0.8rem; }
.craft-card {
  background: var(--bg-panel-2);
  border: 2px solid var(--border);
  border-radius: 6px;
  padding: 0.6rem;
}
.craft-name { font-weight: 800; font-size: 0.9rem; margin-bottom: 0.2rem; }
.craft-desc { font-size: 0.78rem; color: var(--text-muted); margin-bottom: 0.4rem; }
.craft-cost { font-size: 0.78rem; margin-bottom: 0.5rem; }
.craft-cost.affordable { color: var(--accent-3); }
.craft-cost.expensive { color: var(--danger); }

/* ===== Summary ===== */
.summary-card {
  background: var(--bg-panel-2);
  border: 2px solid var(--border);
  border-radius: 6px;
  padding: 1rem;
  font-size: 0.92rem;
  line-height: 1.9;
}
.summary-card .big { font-family: var(--font-pixel); font-size: 1.1rem; color: var(--accent-2); }

.hidden { display: none !important; }

.site-footer {
  text-align: center;
  padding: 1rem;
  color: var(--text-muted);
  font-size: 0.78rem;
  border-top: 3px solid var(--border);
}

@media (min-width: 640px) {
  .dpad { display: none; }
}

@media (max-width: 380px) {
  .bar-label { width: 3.6rem; font-size: 0.65rem; }
  .gear-badge { font-size: 0.65rem; }
}
