:root {
  --bg: #07090b;
  --panel: rgba(15, 18, 22, 0.95);
  --text: #dcdedc;
  --muted: #8e959d;
  --accent: #8b9bb4;
  --danger: #9a3f3f;
  --shadow: rgba(0, 0, 0, 0.65);
  --gold: #b39b6b;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  background: radial-gradient(1200px 800px at 50% 0%, #161c22 0%, var(--bg) 60%, #030405 100%);
  color: var(--text);
  font-family: ui-serif, Georgia, Cambria, "Times New Roman", Times, serif;
  -webkit-tap-highlight-color: transparent;
}

.app {
  height: 100%;
  display: flex;
  flex-direction: column;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  background: rgba(0, 0, 0, 0.25);
  backdrop-filter: blur(10px);
}

.title {
  font-weight: 700;
  letter-spacing: 0.5px;
}

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

.btn {
  appearance: none;
  border: 1px solid rgba(179, 155, 107, 0.3);
  background: linear-gradient(to bottom, rgba(30, 30, 30, 0.8), rgba(15, 15, 15, 0.9));
  color: var(--text);
  padding: 8px 12px;
  border-radius: 4px;
  cursor: pointer;
  font-weight: 600;
  box-shadow: inset 0 0 4px rgba(0,0,0,0.5), 0 2px 4px var(--shadow);
  text-shadow: 0 1px 2px #000;
}

.btn:hover {
  background: linear-gradient(to bottom, rgba(40, 40, 40, 0.8), rgba(20, 20, 20, 0.9));
  border-color: rgba(179, 155, 107, 0.6);
}

.btn:active {
  transform: translateY(1px);
  box-shadow: inset 0 2px 6px rgba(0,0,0,0.8);
}

.btn.primary {
  border-color: rgba(179, 155, 107, 0.8);
  background: rgba(179, 155, 107, 0.15);
  color: var(--gold);
}

.btn.danger {
  border-color: rgba(154, 63, 63, 0.6);
  background: rgba(154, 63, 63, 0.15);
}

.stage {
  flex: 1;
  position: relative;
  display: grid;
  place-items: center;
  padding: 12px;
}

.fab {
  position: absolute;
  right: 18px;
  bottom: 18px;
  z-index: 20;
  border-radius: 999px;
  padding: 12px 14px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(0, 0, 0, 0.35);
  color: rgba(231, 235, 240, 0.92);
  cursor: pointer;
  font-weight: 900;
  letter-spacing: 0.3px;
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(10px);
}

.fab:hover {
  background: rgba(0, 0, 0, 0.42);
}

.sysgrid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}

.sysgrid .btn {
  width: 100%;
}

.canvas {
  width: min(980px, 100%);
  height: auto;
  border-radius: 16px;
  box-shadow: 0 14px 50px var(--shadow);
  border: 1px solid rgba(255, 255, 255, 0.06);
  background: #0a0f16;
  touch-action: manipulation;
}

.hud {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 12px;
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  pointer-events: none;
}

.message {
  background: var(--panel);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 14px;
  padding: 10px 12px;
  box-shadow: 0 10px 30px var(--shadow);
  pointer-events: none;
}

.message .label {
  color: var(--muted);
  font-weight: 700;
  margin-right: 6px;
}

.message .value {
  color: var(--text);
}

.inventory {
  background: var(--panel);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 14px;
  padding: 10px 12px;
  box-shadow: 0 10px 30px var(--shadow);
  pointer-events: auto;
}

.inventory .label {
  color: var(--muted);
  font-weight: 700;
  margin-bottom: 8px;
}

.inventory .list {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.item {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 6px;
  border: 1px solid rgba(179, 155, 107, 0.2);
  background: linear-gradient(to bottom, rgba(30, 30, 30, 0.8), rgba(15, 15, 15, 0.9));
  cursor: pointer;
  user-select: none;
  box-shadow: inset 0 0 4px rgba(0,0,0,0.5), 0 2px 4px var(--shadow);
}

.item:hover {
  background: linear-gradient(to bottom, rgba(40, 40, 40, 0.8), rgba(20, 20, 20, 0.9));
  border-color: rgba(179, 155, 107, 0.4);
}

.item.selected {
  border-color: rgba(179, 155, 107, 0.8);
  box-shadow: 0 0 10px rgba(179, 155, 107, 0.4) inset, 0 0 4px rgba(179, 155, 107, 0.2);
}

.item .badge {
  width: 32px;
  height: 32px;
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(179, 155, 107, 0.3);
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.8);
}

.modal {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  display: grid;
  place-items: center;
  padding: 16px;
}

.modal.hidden {
  display: none;
}

.modal-card {
  width: min(420px, 100%);
  border-radius: 18px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(12, 14, 18, 0.92);
  box-shadow: 0 16px 60px rgba(0, 0, 0, 0.55);
  padding: 14px 14px 16px;
}

.modal-title {
  font-weight: 800;
  letter-spacing: 0.8px;
  margin: 4px 4px 10px;
}

.keypad .display {
  padding: 10px 10px 8px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.05);
  margin-bottom: 10px;
}

.keypad .code {
  font-size: 24px;
  font-weight: 900;
  letter-spacing: 6px;
}

.keypad .hint {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 10px;
}

.kbtn {
  border-radius: 14px;
  padding: 12px 10px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  font-weight: 800;
  cursor: pointer;
}

.kbtn:hover {
  background: rgba(255, 255, 255, 0.1);
}

.kbtn.alt {
  color: var(--muted);
  font-weight: 800;
}

.row {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

@media (max-width: 460px) {
  .topbar {
    flex-direction: column;
    align-items: flex-start;
  }

  .row {
    justify-content: stretch;
  }

  .row .btn {
    flex: 1;
  }
}

.statusbar {
  position: absolute;
  left: 12px;
  right: 12px;
  top: 12px;
  display: grid;
  grid-template-columns: 1fr 1fr auto auto;
  gap: 10px;
  pointer-events: none;
}

.stat {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  background: rgba(20, 24, 30, 0.72);
  backdrop-filter: blur(10px);
  box-shadow: 0 10px 30px var(--shadow);
}

.stat.compact {
  grid-template-columns: auto auto;
  gap: 8px;
  pointer-events: none;
}

.stat-label {
  color: var(--muted);
  font-weight: 850;
  letter-spacing: 0.4px;
  font-size: 12px;
}

.stat-text {
  color: rgba(231, 235, 240, 0.92);
  font-weight: 900;
  font-size: 12px;
}

.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
}

.bar {
  height: 12px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.06);
  overflow: hidden;
  position: relative;
}

.bar-fill {
  height: 100%;
  width: 0%;
  border-radius: 999px;
}

.bar-fill.hp {
  background: linear-gradient(90deg, rgba(123, 255, 179, 0.85) 0%, rgba(127, 209, 255, 0.72) 50%, rgba(255, 209, 102, 0.72) 100%);
}

.bar-fill.inf {
  background: linear-gradient(90deg, rgba(127, 209, 255, 0.55) 0%, rgba(255, 107, 107, 0.82) 100%);
}

.bar-fill.danger {
  background: linear-gradient(90deg, rgba(255, 209, 102, 0.55) 0%, rgba(255, 107, 107, 0.85) 100%);
}

.modal-card.wide {
  width: min(860px, 100%);
}

.modal-card.parchment {
  background: rgba(12, 14, 18, 0.92);
  border-color: rgba(255, 255, 255, 0.08);
  background-image: url("./assets/art/ui_parchment_panel.svg");
  background-repeat: no-repeat;
  background-position: center;
  background-size: cover;
  color: rgba(12, 14, 18, 0.92);
}

.modal-card.parchment .modal-title {
  color: rgba(12, 14, 18, 0.92);
}

.dlg-body {
  color: rgba(12, 14, 18, 0.9);
  font-weight: 850;
  line-height: 1.6;
  padding: 4px 6px 8px;
}

.modal-card.parchment .btn {
  color: rgba(12, 14, 18, 0.92);
  border-color: rgba(0, 0, 0, 0.16);
  background: rgba(255, 255, 255, 0.35);
}

.modal-card.parchment .btn:hover {
  background: rgba(255, 255, 255, 0.5);
}

.modal-card.parchment .btn.primary {
  border-color: rgba(0, 0, 0, 0.16);
  background: rgba(255, 209, 102, 0.58);
}

.panel {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 14px;
  align-items: center;
}

.sigil {
  width: 220px;
  height: 220px;
  display: block;
  filter: drop-shadow(0 18px 30px rgba(0, 0, 0, 0.35));
}

.panel-text {
  color: rgba(231, 235, 240, 0.88);
  font-weight: 750;
  line-height: 1.6;
  margin-bottom: 12px;
}

.encounter {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 14px;
  align-items: stretch;
}

.enemy {
  border: 1px solid rgba(255, 255, 255, 0.10);
  background: rgba(0, 0, 0, 0.22);
  border-radius: 16px;
  padding: 12px;
}

.enemy-name {
  font-weight: 950;
  letter-spacing: 0.6px;
  margin-bottom: 10px;
}

.combatlog {
  border: 1px solid rgba(255, 255, 255, 0.10);
  background: rgba(0, 0, 0, 0.22);
  border-radius: 16px;
  padding: 12px;
  display: grid;
  grid-template-rows: 1fr auto;
  gap: 12px;
}

.combat-log {
  overflow: auto;
  border: 1px solid rgba(255, 255, 255, 0.10);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.04);
  padding: 10px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 12px;
  color: rgba(231, 235, 240, 0.88);
  line-height: 1.45;
}

.journal {
  max-height: 420px;
  overflow: auto;
  padding: 10px 6px 4px;
  color: rgba(12, 14, 18, 0.9);
  font-weight: 800;
  line-height: 1.6;
}

.jitem {
  padding: 10px 10px;
  border-radius: 14px;
  border: 1px solid rgba(0, 0, 0, 0.14);
  background: rgba(255, 255, 255, 0.28);
  margin-bottom: 10px;
}

.jtime {
  font-size: 12px;
  color: rgba(12, 14, 18, 0.70);
  font-weight: 900;
  letter-spacing: 0.2px;
  margin-bottom: 6px;
}

@media (max-width: 860px) {
  .statusbar {
    grid-template-columns: 1fr 1fr;
  }
  .encounter {
    grid-template-columns: 1fr;
  }
  .panel {
    grid-template-columns: 1fr;
  }
  .sigil {
    width: 160px;
    height: 160px;
  }
}
