/* Omni Kage - Early Prototype Styles */
/* Cyberpunk iCY//VOiD shell, big tap targets, mobile friendly. */

@font-face {
  font-display: swap;
  font-family: "Audiowide";
  font-style: normal;
  font-weight: 400;
  src: url("assets/fonts/audiowide-regular.ttf") format("truetype");
}

@font-face {
  font-display: swap;
  font-family: "Rubik Glitch";
  font-style: normal;
  font-weight: 400;
  src: url("assets/fonts/rubik-glitch-regular.ttf") format("truetype");
}

:root {
  color-scheme: dark;
  --body-font: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --tech-font: "Audiowide", ui-sans-serif, system-ui, sans-serif;
  --glitch-font: "Rubik Glitch", var(--tech-font);
  --bg: #000000;
  --panel: #05080b;
  --panel-strong: #070d12;
  --surface: #020406;
  --text: #ffffff;
  --text-dim: #b8d8ed;
  --muted: #6ea4c4;
  --accent: #1793d1;
  --accent-strong: #48bfff;
  --accent-soft: rgba(23, 147, 209, 0.18);
  --border: #10283a;
  --health: #ff4d6d;
  --mana: #1793d1;
  --stamina: #58e6a4;
  --warning: #f5c451;
  --danger: #ff4d6d;
  --shadow: 0 18px 58px rgba(0, 0, 0, 0.56);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  line-height: 1.4;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

#app {
  width: 100%;
  max-width: 100%;
  margin: 0 auto;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
  min-height: 100vh;
  box-sizing: border-box;
}

/* === Resource Bars (top) === */
.resources {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  background: var(--panel);
  padding: 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
}

.resource {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.resource .label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-dim);
}

.resource .bar {
  height: 18px;
  background: #1a1a1e;
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid var(--border);
}

.resource .fill {
  height: 100%;
  transition: width 0.25s ease;
}

#health-fill { background: var(--health); }
#mana-fill { background: var(--mana); }
#stamina-fill { background: var(--stamina); }

.resource .value {
  font-size: 13px;
  font-weight: 600;
  text-align: right;
  color: var(--text);
}

/* === Main Game Area === */
.game-area {
  display: flex;
  flex-direction: column;
  gap: 12px;
  flex: 1;
}

/* Room View */
.room-view {
  background: var(--panel);
  border-radius: 12px;
  border: 1px solid var(--border);
  overflow: hidden;
}

.room-header {
  padding: 12px 16px 8px;
  background: #1a1a1e;
}

.room-header h1 {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
  color: var(--accent);
}

.room-image {
  height: 220px;
  background: #1f1f24;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  border-bottom: 1px solid var(--border);
}

.image-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 42px;
  color: #555;
  text-align: center;
  background-size: cover;
  background-position: center;
}

.room-desc {
  padding: 14px 16px;
  font-size: 15px;
  min-height: 60px;
  color: var(--text);
}

/* Log */
.log-section {
  background: var(--panel);
  border-radius: 12px;
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  min-height: 140px;
  max-height: 180px;
}

.log-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 12px;
  font-size: 12px;
  color: var(--text-dim);
  border-bottom: 1px solid var(--border);
  background: #1a1a1e;
}

.log {
  flex: 1;
  overflow-y: auto;
  padding: 10px 12px;
  font-size: 14px;
  line-height: 1.35;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.log-entry {
  padding: 2px 0;
  overflow-wrap: break-word;
}

.log-entry.move { color: #8ab4f8; }
.log-entry.combat { color: #f8a8a8; }
.log-entry.system { color: #a8d8a8; }
.log-entry.flavor { color: var(--text-dim); }

/* Directions */
.directions {
  background: var(--panel);
  border-radius: 12px;
  border: 1px solid var(--border);
  padding: 12px;
}

.dir-label {
  font-size: 12px;
  color: var(--text-dim);
  margin-bottom: 6px;
  text-align: center;
}

.dir-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  grid-template-rows: repeat(3, 1fr);
  gap: 6px;
  max-width: 100%;
  margin: 0 auto;
  /* Makes the D-pad form a clean, centered cross */
}

.dir-btn {
  background: #1f1f24;
  border: 2px solid var(--border);
  color: var(--text);
  border-radius: 10px;
  padding: 14px 8px;
  font-size: 22px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 72px;
  transition: transform 0.1s ease, background 0.1s ease;
}

.dir-btn:hover {
  background: #2a2a30;
  transform: scale(1.02);
}

.dir-btn:active {
  transform: scale(0.96);
}

.dir-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.dir-text {
  font-size: 11px;
  margin-top: 2px;
  color: var(--text-dim);
}

.dir-spacer, .dir-center {
  /* grid placeholders */
}

/* Action Bar (bottom) */
.action-bar {
  background: var(--panel);
  border-radius: 16px;
  border: 1px solid var(--border);
  padding: 10px 12px;
  margin-top: auto;
}

.action-label {
  font-size: 12px;
  color: var(--text-dim);
  text-align: center;
  margin-bottom: 6px;
}

.actions {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 8px;
}

.action-btn.is-hidden {
  display: none;
}

.action-btn.is-disabled {
  opacity: 0.58;
  border-color: #3a3a40;
}

.action-btn {
  background: #1f1f24;
  border: 2px solid var(--border);
  color: var(--text);
  border-radius: 12px;
  padding: 12px 6px;
  font-size: 20px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 68px;
  transition: all 0.1s ease;
}

.action-btn:hover {
  background: #2a2a30;
  border-color: var(--accent);
}

.action-btn:active {
  transform: scale(0.94);
}

.action-btn span {
  font-size: 10px;
  margin-top: 3px;
  color: var(--text-dim);
}

.action-btn .action-cooldown {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  margin-left: 6px;
  border-radius: 999px;
  background: rgba(201, 164, 106, 0.18);
  border: 1px solid rgba(201, 164, 106, 0.65);
  color: var(--accent);
  font-size: 12px;
}

/* Small utility */
.small-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-dim);
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 6px;
  cursor: pointer;
}

.small-btn:hover {
  color: var(--text);
  border-color: var(--accent);
}

.small-btn.danger {
  border-color: rgba(179, 58, 58, 0.65);
  color: #f8a8a8;
}

.small-btn.danger:hover {
  border-color: #f8a8a8;
  color: #ffd1d1;
}

/* Footer note */
.footer-note {
  text-align: center;
  font-size: 11px;
  color: #555;
  padding: 8px 0 16px;
  max-width: none;
  margin: 0 auto;
}

/* === Setup / Character Creation Screen === */
#setup-screen {
  max-width: 620px;
  margin: 0 auto;
  padding: 16px 12px 40px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.setup-header {
  text-align: center;
  margin-bottom: 4px;
}

.setup-header h1 {
  font-size: 28px;
  margin: 0 0 4px;
  color: var(--accent);
}

.setup-header .tagline {
  margin: 0;
  font-size: 14px;
  color: var(--text-dim);
  line-height: 1.3;
}

.version-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-top: 10px;
  padding: 4px 8px;
  border: 1px solid rgba(197, 164, 126, 0.25);
  border-radius: 6px;
  color: var(--text-dim);
  background: rgba(10, 10, 12, 0.32);
  font-size: 11px;
  line-height: 1.2;
}

.game-version {
  margin: -2px 0 6px;
  color: var(--text-dim);
  font-size: 10px;
  line-height: 1.2;
  text-align: right;
}

.setup-section {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.setup-section label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-dim);
  padding-left: 4px;
}

#player-name {
  width: 100%;
  background: #1a1a1e;
  border: 2px solid var(--border);
  color: var(--text);
  font-size: 18px;
  padding: 12px 14px;
  border-radius: 10px;
  outline: none;
}

#player-name:focus {
  border-color: var(--accent);
}

.choice-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

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

.choice-card {
  background: #1a1a1e;
  border: 2px solid var(--border);
  border-radius: 12px;
  padding: 12px 8px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.1s ease, transform 0.1s ease, box-shadow 0.1s ease;
  min-height: 118px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.choice-card:hover {
  border-color: #444;
  transform: translateY(-1px);
}

.choice-card.selected {
  border-color: var(--accent);
  background: #222226;
  box-shadow: 0 0 0 4px rgba(201, 164, 106, 0.15); /* "lights up" */
}

.choice-icon {
  font-size: 28px;
  line-height: 1;
  margin-bottom: 4px;
}

.choice-name {
  font-weight: 700;
  font-size: 15px;
  color: var(--text);
  margin-bottom: 2px;
}

.choice-desc {
  font-size: 11px;
  color: var(--text-dim);
  line-height: 1.25;
}

.setup-summary {
  background: #1a1a1e;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 14px;
  color: var(--text-dim);
  text-align: center;
  min-height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.play-btn {
  width: 100%;
  min-height: 56px;
  font-size: 18px;
  font-weight: 700;
  border-radius: 12px;
  border: 2px solid var(--border);
  background: #1f1f24;
  color: var(--text-dim);
  cursor: not-allowed;
  transition: all 0.15s ease;
}

.play-btn:not(:disabled) {
  background: var(--accent);
  color: #111;
  border-color: #d4b37a;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(201, 164, 106, 0.35); /* lights up */
}

.play-btn:not(:disabled):hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(201, 164, 106, 0.45);
}

.play-btn:not(:disabled):active {
  transform: scale(0.985);
}

.setup-note {
  text-align: center;
  font-size: 11px;
  color: #555;
  margin: 4px 0 0;
}

/* Stats row - clickable attributes for training (kept for legacy if used) */
.stats-row {
  display: flex;
  gap: 4px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 6px 8px;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
}

.stat {
  background: #1f1f24;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 6px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 42px;
  transition: all 0.1s ease;
}

.stat:hover {
  border-color: var(--accent);
  background: #2a2a30;
  transform: scale(1.05);
}

.stat:active {
  transform: scale(0.95);
}

.stat span {
  font-weight: 700;
  font-size: 13px;
  color: var(--text);
}

.training-points {
  font-size: 11px;
  color: var(--text-dim);
  background: #1a1a1e;
  padding: 2px 6px;
  border-radius: 4px;
  white-space: nowrap;
}

.char-attrs .attr-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 30px;
  align-items: center;
  gap: 6px;
  cursor: default;
  padding: 4px 6px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 4px;
  background: #1a1a1e;
  font-size: 12px;
  min-width: 0;
}

.char-attrs .attr-item:hover {
  border-color: rgba(201, 164, 106, 0.35);
}

.attr-copy {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.attr-label {
  color: var(--text-dim);
}

.attr-value {
  color: var(--text);
  font-weight: 700;
}

.attr-train-btn {
  width: 30px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #111114;
  border: 1px solid #6f3636;
  color: var(--text);
  border-radius: 4px;
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  padding: 0;
}

.attr-train-btn:hover {
  border-color: var(--accent);
  background: #2a2a30;
}

.char-attrs .attr-item.can-train .attr-train-btn {
  border-color: #3a9b3a;
  background: #142014;
}

.char-attrs .attr-item.can-train .attr-train-btn:hover {
  transform: scale(1.2);
}

.char-attrs .attr-item.is-capped .attr-train-btn {
  border-color: var(--border);
  opacity: 0.65;
}

.char-secondary {
  min-width: 0;
}

.char-subhead {
  color: var(--accent);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
  margin-bottom: 3px;
}

.secondary-stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 4px;
}

.secondary-stat {
  min-width: 0;
  display: flex;
  justify-content: space-between;
  gap: 6px;
  padding: 4px 6px;
  background: #1a1a1e;
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 4px;
  line-height: 1.2;
}

.secondary-stat-label {
  min-width: 0;
  color: var(--text-dim);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.secondary-stat-value {
  flex: 0 0 auto;
  color: var(--text);
  font-weight: 700;
}

/* Paperdoll for Equipment (UO / Project Zomboid style) */
.paperdoll {
  position: relative;
  width: 110px;
  height: 160px;
  margin: 0 auto 6px;
  background: linear-gradient(#555, #333);
  border: 2px solid var(--border);
  border-radius: 20px 20px 10px 10px;
  overflow: hidden;
}

.paperdoll .pd-body {
  position: relative;
  width: 100%;
  height: 100%;
}

.paperdoll .pd-head {
  position: absolute;
  top: 8px;
  left: 50%;
  transform: translateX(-50%);
  width: 28px;
  height: 28px;
  background: #222;
  border: 1px solid var(--accent);
  border-radius: 50%;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2;
}

.paperdoll .pd-torso {
  position: absolute;
  top: 38px;
  left: 50%;
  transform: translateX(-50%);
  width: 40px;
  height: 50px;
  background: #222;
  border: 1px solid var(--accent);
  border-radius: 4px;
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1;
}

.paperdoll .pd-left-arm {
  position: absolute;
  top: 42px;
  left: 12px;
  width: 18px;
  height: 40px;
  background: #222;
  border: 1px solid var(--accent);
  border-radius: 8px;
  font-size: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  transform: rotate(-15deg);
}

.paperdoll .pd-right-arm {
  position: absolute;
  top: 42px;
  right: 12px;
  width: 18px;
  height: 40px;
  background: #222;
  border: 1px solid var(--accent);
  border-radius: 8px;
  font-size: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  transform: rotate(15deg);
}

.paperdoll .pd-legs {
  position: absolute;
  bottom: 8px;
  left: 50%;
  transform: translateX(-50%);
  width: 36px;
  height: 45px;
  background: #222;
  border: 1px solid var(--accent);
  border-radius: 4px;
  font-size: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.equip-extra {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 2px;
  font-size: 9px;
  margin-top: 4px;
}

.equip-extra .slot.small {
  padding: 1px;
  min-height: 16px;
  font-size: 9px;
}

/* Improve direction grid alignment (D-pad cross) */
.dir-center {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  color: var(--text-dim);
  opacity: 0.5;
}

/* === Character Sheet (reactive, readable, panel style inspired by web MUDs like Mosshollow) === */
.character-sheet {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  margin-bottom: 12px;
  font-size: 14px;
  line-height: 1.4;
  color: var(--text);
}

.sheet-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 6px;
}

.sheet-header h2 {
  margin: 0;
  font-size: 16px;
  color: var(--accent);
}

.sheet-content > div {
  margin-bottom: 10px;
}

.sheet-basic, .sheet-progress {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 4px;
  font-size: 13px;
}

.sheet-attrs .attr-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(90px, 1fr));
  gap: 2px 8px;
  font-size: 13px;
}

.sheet-resources {
  font-size: 13px;
}

.sheet-equip .equip-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(70px, 1fr));
  gap: 4px;
  font-size: 11px;
}

.slot {
  background: #1a1a1e;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 4px;
  text-align: center;
  cursor: default;
  position: relative;
}

.slot:hover {
  border-color: var(--accent);
}

.equip-icon {
  font-size: 16px;
  display: block;
}

.sheet-buffs-debuffs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.icon-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  min-height: 24px;
}

.icon {
  font-size: 16px;
  cursor: help;
}

.empty {
  color: var(--text-dim);
  font-size: 11px;
}

.sheet-inv .inv-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 3px;
}

.inv-slot {
  background: #1a1a1e;
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 2px;
  text-align: center;
  font-size: 14px;
  min-height: 22px;
  cursor: help;
}

/* Reactive overall UI improvements */
#app {
  font-size: 16px;
  max-width: none;
}

.log, .room-desc-text {
  font-size: 14px;
  line-height: 1.4;
}

.dir-btn, .action-btn {
  font-size: 18px;
  min-height: 64px;
  padding: 6px 4px;
}

/* New 3-column + top/bottom layout - stretch to fill available viewport height */
.game-layout {
  display: grid;
  grid-template-columns: minmax(160px, 1fr) minmax(220px, 2fr) minmax(200px, 1fr);
  gap: 8px;
  flex: 1 1 auto;
  min-height: 0; /* allow flex children to shrink/grow properly */
  height: 100%;  /* fill the remaining space in the flex column (resources + layout + actions) */
}

.left-col, .middle-col, .right-col {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.left-col > section,
.middle-col > section,
.right-col > section {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 4px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.right-col > .char-info {
  flex: 1.6;
  min-height: 0; /* allow growth instead of hard floor */
  overflow: auto;
}

.right-col > .relics {
  flex: 0.9;
  min-height: 0;
  overflow: auto;
}

.right-col > .equipment {
  flex: 1.35;
  min-height: 0;
  overflow: auto;
}

.right-col > .inventory {
  flex: 0.85;
  min-height: 0;
  overflow: auto;
}

.left-col > section h3,
.middle-col > section h3,
.right-col > section h3 {
  font-size: 12px;
  margin: 0 0 4px;
  color: var(--accent);
  border-bottom: 1px solid var(--border);
  padding-bottom: 2px;
}

.room-desc-text {
  font-size: 12px;
  flex: 1;
  overflow: auto;
  white-space: pre-line; /* so name + \n\n + desc renders nicely as flavor text */
  padding: 2px 4px;
}

.map-display {
  font-family: inherit;
  font-size: 11px;
  background: #1a1a1e;
  padding: 4px;
  border-radius: 4px;
  flex: 1;
  overflow: auto;
}

.room-map {
  width: 100%;
  height: 100%;
  display: grid;
  gap: 4px;
  align-items: center;
  justify-items: center;
  padding: 6px;
}

.room-map.large {
  min-height: 420px;
  gap: 14px;
}

.map-room {
  width: 100%;
  height: 100%;
  max-width: 160px;
  max-height: 92px;
  min-height: 52px;
  background: #1f1f24;
  border: 2px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  cursor: default;
  text-align: center;
}

.room-map.large .map-room {
  max-width: 220px;
  max-height: 150px;
  min-height: 100px;
}

.map-room.available {
  border-color: var(--accent);
  cursor: pointer;
}

.map-room.locked {
  border-color: #8f6b39;
  background: #211d18;
}

.map-room.locked .map-room-dir {
  color: var(--accent);
}

.map-room.available:hover {
  background: #2a2a30;
  transform: translateY(-1px);
}

.map-room.current {
  border-color: var(--stamina);
  background: rgba(58, 155, 58, 0.14);
  opacity: 1;
}

.map-room:disabled:not(.current) {
  opacity: 0.55;
}

.map-room-icon {
  font-size: 20px;
  line-height: 1;
}

.room-map.large .map-room-icon {
  font-size: 34px;
}

.map-room-name {
  max-width: 100%;
  font-size: 11px;
  line-height: 1.15;
  overflow-wrap: anywhere;
}

.map-room-dir {
  font-size: 10px;
  line-height: 1.1;
  color: var(--text-dim);
}

.map-connector {
  color: #6a6252;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 18px;
  line-height: 1;
  pointer-events: none;
}

.local-actions {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 8px;
  align-content: start;
  overflow: auto;
  padding: 4px;
}

.local-action-btn {
  min-height: 74px;
  background: #1f1f24;
  border: 2px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 8px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  text-align: center;
}

.local-action-btn:hover {
  background: #2a2a30;
  border-color: var(--accent);
}

.local-action-btn.is-disabled {
  opacity: 0.55;
  border-color: #3a3a40;
}

.local-action-icon {
  font-size: 24px;
  line-height: 1;
}

.local-action-empty {
  color: var(--text-dim);
  font-size: 13px;
}

.log {
  flex: 1;
  overflow-y: auto;
  font-size: 11px;
  line-height: 1.3;
  background: #1a1a1e;
  padding: 4px;
  border-radius: 4px;
  margin-bottom: 4px;
}

/* Fixed proportions for middle logs per feedback (System 20%, Dialog 40%, Combat 40%).
   Scrollable, won't grow and push UI off bottom even with lots of training/combat text. */
.left-col > .room-objects-panel { flex: 0 0 30%; }
.middle-col > .journal { flex: 0 0 18%; }
.middle-col > .system-log { flex: 0 0 18%; }
.middle-col > .dialog { flex: 0 0 42%; }
.middle-col > .combat-log { flex: 0 0 22%; }

/* Instant custom tooltip (no browser delay on title=) */
#tooltip {
  position: fixed;
  background: #1a1a1e;
  color: var(--text);
  border: 1px solid var(--accent);
  padding: 3px 6px;
  font-size: 10px;
  line-height: 1.2;
  z-index: 99999;
  pointer-events: none;
  display: none;
  white-space: pre-wrap; /* preserve \n for structure (name/loc/stats/desc) but word-wrap long descriptions */
  word-break: break-word;
  overflow-wrap: break-word;
  box-shadow: 0 2px 6px rgba(0,0,0,0.6);
  max-width: 260px; /* a bit wider to accommodate wrapped lore descriptions */
}

/* Compact equipment list */
.equip-list {
  display: grid;
  gap: 3px;
  font-size: 10px;
  line-height: 1.25;
  padding: 2px;
}

.equip-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  gap: 4px;
  padding: 5px;
  border: 1px solid #222;
  border-radius: 4px;
  background: #1a1a1e;
}

.equip-row.empty {
  color: var(--text-dim);
}

.equip-main {
  min-width: 0;
  display: grid;
  gap: 4px;
}

.equip-name {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.equip-slot-label {
  color: var(--text-dim);
  font-size: 9px;
  text-transform: uppercase;
}

.equip-item-title {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text);
}

.equip-stat-chips,
.inv-compare-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  min-width: 0;
}

.stat-chip,
.compare-chip {
  border: 1px solid #33343a;
  border-radius: 999px;
  padding: 1px 5px;
  background: #151518;
  font-size: 9px;
  line-height: 1.25;
  color: var(--text-dim);
}

.stat-chip.positive,
.compare-chip.positive {
  border-color: rgba(168, 216, 168, 0.5);
  color: #a8d8a8;
}

.stat-chip.negative,
.compare-chip.negative {
  border-color: rgba(248, 168, 168, 0.5);
  color: #f8a8a8;
}

.stat-chip.muted,
.compare-chip.neutral {
  color: var(--text-dim);
}

.compare-chip.warning {
  border-color: rgba(201, 164, 106, 0.65);
  color: var(--accent);
}

.equip-unequip-btn {
  min-height: 22px;
  background: #151518;
  border: 1px solid var(--border);
  color: var(--text-dim);
  border-radius: 4px;
  font-size: 9px;
  cursor: pointer;
}

.equip-unequip-btn:hover {
  border-color: var(--accent);
  color: var(--text);
}

.log-entry {
  padding: 1px 0;
  border-bottom: 1px solid #222;
}

.log-entry.system { color: #a8d8a8; }
.log-entry.combat { color: #f8a8a8; }
.log-entry.dialog { color: #8ab4f8; }

.room-objects-list {
  flex: 1;
  min-height: 0;
  overflow: auto;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 8px;
  padding: 4px;
  background: #1a1a1e;
  border-radius: 4px;
}

.room-object-card {
  min-width: 0;
  background: #1f1f24;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 8px;
  align-content: start;
}

.room-object-card.hostile {
  border-color: rgba(179, 58, 58, 0.8);
  background: #241b1d;
}

.room-object-card.item {
  border-color: rgba(201, 164, 106, 0.65);
}

.room-object-card.npc {
  border-color: rgba(138, 180, 248, 0.65);
}

.room-object-icon {
  font-size: 24px;
  line-height: 1;
}

.room-object-main {
  min-width: 0;
}

.room-object-title {
  font-size: 13px;
  color: var(--text);
  font-weight: 700;
  line-height: 1.2;
}

.room-object-status {
  font-size: 10px;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0;
  margin-top: 1px;
}

.room-object-desc {
  font-size: 11px;
  color: var(--text-dim);
  line-height: 1.25;
  margin-top: 4px;
  overflow-wrap: anywhere;
}

.room-object-actions {
  grid-column: 1 / -1;
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.room-object-actions button {
  flex: 1 1 70px;
  min-height: 28px;
  background: #1a1a1e;
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 4px;
  cursor: pointer;
}

.room-object-actions button:hover {
  border-color: var(--accent);
  background: #2a2a30;
}

.room-object-actions button.is-disabled {
  opacity: 0.55;
}

.room-object-bar {
  height: 6px;
  background: #1a1a1e;
  border: 1px solid #5b2222;
  border-radius: 999px;
  overflow: hidden;
  margin-top: 6px;
}

.room-object-bar > div {
  height: 100%;
  background: var(--health);
}

.room-object-empty {
  color: var(--text-dim);
  font-size: 13px;
}

.journal-list {
  flex: 1;
  min-height: 0;
  overflow: auto;
  display: grid;
  gap: 8px;
  padding: 4px;
  background: #1a1a1e;
  border-radius: 4px;
}

.objective-card {
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #1f1f24;
  padding: 8px;
}

.objective-card.complete {
  background: #1a1f1b;
  border-color: rgba(168, 216, 168, 0.35);
}

.objective-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  color: var(--text);
  font-size: 13px;
  font-weight: 700;
  line-height: 1.2;
}

.objective-badge {
  flex: 0 0 auto;
  color: var(--accent);
  font-size: 10px;
  text-transform: uppercase;
}

.objective-summary {
  color: var(--text-dim);
  font-size: 11px;
  line-height: 1.25;
  margin-top: 4px;
}

.objective-steps {
  display: grid;
  gap: 3px;
  margin-top: 7px;
}

.objective-step {
  display: flex;
  gap: 6px;
  align-items: baseline;
  color: var(--text-dim);
  font-size: 11px;
  line-height: 1.25;
}

.objective-step-copy {
  min-width: 0;
}

.objective-step-source,
.objective-step-note,
.objective-hidden-step {
  margin-top: 2px;
  color: var(--text-dim);
  font-size: 10px;
  line-height: 1.2;
}

.objective-step-note {
  color: #b7c7a8;
}

.objective-hidden-step {
  padding-left: 20px;
  font-style: italic;
}

.objective-step.complete {
  color: #a8d8a8;
}

.objective-step.active {
  color: var(--text);
  font-weight: 700;
}

.objective-step-marker {
  width: 14px;
  text-align: center;
  color: var(--accent);
}

.objective-step.active .objective-step-marker {
  color: #f1c56f;
}

.char-basic, .char-progress, .char-attrs, .char-secondary, .char-res, .char-state {
  font-size: 11px;
  margin-bottom: 4px;
}

.save-controls {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  margin-top: 4px;
  margin-bottom: 6px;
}

.character-list-panel {
  display: grid;
  gap: 8px;
  background: #141417;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px;
}

.character-list-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  color: var(--text);
  font-size: 13px;
  font-weight: 800;
}

.character-list {
  display: grid;
  gap: 7px;
  max-height: 270px;
  overflow: auto;
  padding-right: 2px;
}

.character-empty {
  color: var(--text-dim);
  font-size: 12px;
  text-align: center;
  padding: 12px 8px;
  border: 1px dashed var(--border);
  border-radius: 6px;
}

.character-card {
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  background: #1a1a1e;
  border: 1px solid #282830;
  border-radius: 6px;
  padding: 8px;
}

.character-card.ended {
  border-color: rgba(179, 58, 58, 0.55);
}

.character-card-main {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.character-card-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  color: var(--text);
  font-size: 13px;
  font-weight: 800;
  line-height: 1.2;
}

.character-card-state {
  flex: 0 0 auto;
  color: var(--accent);
  font-size: 10px;
  text-transform: uppercase;
}

.character-card-meta {
  min-width: 0;
  color: var(--text-dim);
  font-size: 11px;
  line-height: 1.25;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.character-card-actions,
.character-list-actions {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

@media (max-width: 520px) {
  .character-card {
    grid-template-columns: 1fr;
  }

  .character-card-actions {
    justify-content: stretch;
  }

  .character-card-actions .small-btn {
    flex: 1 1 72px;
  }
}

.relic-wheel {
  flex: 1;
  min-height: 0;
  position: relative;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  grid-template-rows: repeat(3, minmax(34px, 1fr));
  gap: 4px;
  overflow: auto;
}

.relic-slot {
  min-width: 0;
  min-height: 34px;
  background: #1a1a1e;
  border: 1px solid var(--border);
  border-radius: 5px;
  color: var(--text);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  padding: 3px;
  text-align: center;
}

.relic-slot.center {
  position: absolute;
  z-index: 2;
  left: 50%;
  top: 50%;
  width: 26%;
  height: 26%;
  transform: translate(-50%, -50%);
  border-color: rgba(201, 164, 106, 0.7);
  background: #201d19;
}

.relic-slot.center .relic-label {
  display: none;
}

.relic-slot.locked {
  opacity: 0.62;
}

.relic-slot.unlocked {
  border-color: rgba(168, 216, 168, 0.7);
  background: #1a241d;
  opacity: 1;
}

.relic-icon {
  font-size: 17px;
  line-height: 1;
}

.relic-label {
  max-width: 100%;
  font-size: 9px;
  line-height: 1.05;
  overflow-wrap: anywhere;
  color: var(--text-dim);
}

.reward-stack {
  position: fixed;
  top: 14px;
  right: 14px;
  z-index: 10050;
  display: grid;
  gap: 8px;
  width: min(340px, calc(100vw - 28px));
  pointer-events: none;
}

.reward-toast {
  border: 1px solid rgba(201, 164, 106, 0.55);
  border-radius: 6px;
  background: rgba(18, 18, 20, 0.96);
  color: var(--text);
  padding: 10px 12px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
  animation: reward-in 180ms ease-out;
}

.reward-toast.objective {
  border-color: rgba(168, 216, 168, 0.55);
}

.reward-toast.leaving {
  opacity: 0;
  transform: translateY(-6px);
  transition: opacity 180ms ease, transform 180ms ease;
}

.reward-toast-title {
  font-size: 13px;
  font-weight: 800;
  color: var(--accent);
  line-height: 1.2;
}

.reward-toast-body {
  margin-top: 3px;
  color: var(--text-dim);
  font-size: 11px;
  line-height: 1.25;
}

.reward-modal {
  position: fixed;
  inset: 0;
  z-index: 10060;
  align-items: center;
  justify-content: center;
  padding: 18px;
  background: rgba(0, 0, 0, 0.68);
}

.reward-modal-panel {
  width: min(560px, 100%);
  border: 1px solid rgba(201, 164, 106, 0.75);
  border-radius: 8px;
  background: #121214;
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.65);
  padding: 18px;
}

.reward-modal-kicker {
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0;
}

.reward-modal h2 {
  margin: 6px 0 8px;
  color: var(--text);
  font-size: 24px;
  line-height: 1.15;
}

.reward-modal-body {
  color: var(--text-dim);
  font-size: 14px;
  line-height: 1.45;
}

.reward-modal-close {
  width: 100%;
  min-height: 42px;
  margin-top: 16px;
  border: 1px solid rgba(201, 164, 106, 0.75);
  border-radius: 6px;
  background: #211d18;
  color: var(--text);
  font-weight: 700;
  cursor: pointer;
}

.reward-modal-close:hover {
  background: #2a241c;
}

@keyframes reward-in {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.equip-grid, .inv-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(56px, 1fr));
  gap: 4px;
  font-size: 10px;
}

.slot, .inv-slot {
  background: #1a1a1e;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 4px;
  text-align: center;
  cursor: help;
  min-height: 42px;
}

.inv-slot.has-item {
  display: grid;
  grid-template-rows: auto auto auto auto auto;
  gap: 2px;
  align-content: start;
}

.inv-slot.equippable {
  border-color: rgba(201, 164, 106, 0.45);
}

.inv-icon {
  font-size: 16px;
  line-height: 1;
}

.inv-name {
  display: block;
  color: var(--text-dim);
  font-size: 9px;
  line-height: 1.1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.inv-compare {
  min-width: 0;
  color: var(--accent);
  font-size: 8px;
  line-height: 1.15;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.inv-compare-chips {
  justify-content: center;
}

.inv-compare-chips .compare-chip {
  padding: 0 4px;
  font-size: 8px;
}

.inv-actions {
  display: flex;
  justify-content: center;
  gap: 2px;
  flex-wrap: wrap;
}

.inv-actions button {
  min-height: 18px;
  background: #151518;
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 3px;
  padding: 1px 4px;
  font-size: 9px;
  cursor: pointer;
}

.inv-actions button:hover {
  border-color: var(--accent);
}

.stat-bonus {
  color: var(--accent);
  font-size: 10px;
}

.resources.full-width {
  width: 100%;
  max-width: none;
  margin: 0;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.resource .label {
  font-size: 11px;
}

.bar-wrapper {
  position: relative;
  height: 16px;
}

.bar-wrapper .num {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  text-align: center;
  font-size: 10px;
  line-height: 16px;
  color: #fff;
  text-shadow: 0 0 2px #000;
  pointer-events: none;
}

/* Color coded resources */
.resource:has(#health-fill) .bar-wrapper { background: rgba(179, 58, 58, 0.25); }
.resource:has(#mana-fill) .bar-wrapper { background: rgba(58, 111, 179, 0.25); }
.resource:has(#stamina-fill) .bar-wrapper { background: rgba(58, 155, 58, 0.25); }

.action-bar.full-width {
  width: 100%;
  max-width: none;
  margin: 0;
  padding: 6px;
}

/* Combat / resting state backgrounds per feedback (red in combat, green resting, default black) */
#game-screen.combat {
  box-shadow: inset 0 0 30px rgba(180, 50, 50, 0.25);
}
#game-screen.resting {
  box-shadow: inset 0 0 30px rgba(50, 150, 50, 0.2);
}
.game-layout.combat .middle-col > section {
  border-color: #b33a3a;
}
.game-layout.resting .middle-col > section {
  border-color: #3a9b3a;
}

.action-bar .actions {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 6px;
}

/* Make sure top and bottom span - drive full viewport usage + prevent logs pushing content out (100% box) */
#game-screen {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  height: 100%;
  max-height: 100vh;
  overflow: hidden;
}

.game-layout {
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
  overflow: hidden;
}

.middle-col {
  height: 100%;
  max-height: 100%;
  overflow: hidden;
}

/* Help the overall chain fill the browser viewport (html/body/#app must cooperate) */
html, body {
  height: 100%;
}
#app {
  min-height: 100vh; /* fallback */
  display: flex;
  flex-direction: column;
}

/* Reactive adjustments */
@media (max-width: 900px) {
  .game-layout {
    grid-template-columns: 1fr;
    grid-template-rows: auto;
  }
  .left-col, .middle-col, .right-col {
    flex-direction: row;
    flex-wrap: wrap;
  }
  .left-col > section, .middle-col > section, .right-col > section {
    flex: 1 1 30%;
    min-width: 120px;
  }
}

@media (max-width: 480px) {
  .resources {
    gap: 6px;
    padding: 8px;
  }
  .room-image {
    height: 120px;
  }
  .action-btn {
    font-size: 12px;
    min-height: 48px;
  }
  .game-layout {
    gap: 4px;
  }
}

/* === Full-screen game shell ===
   This section intentionally overrides the older centered-page prototype rules.
   The game screen should behave like a viewport-filling app, not a document column. */
html,
body {
  width: 100%;
  height: 100%;
  overflow: hidden;
}

body {
  min-height: 100dvh;
}

#app {
  width: 100vw;
  max-width: none;
  height: 100dvh;
  min-height: 0;
  margin: 0;
  padding: 10px;
  gap: 10px;
  overflow: hidden;
}

#setup-screen {
  max-height: 100%;
  overflow: auto;
}

#game-screen {
  width: 100%;
  height: 100%;
  max-height: none;
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow: hidden;
}

.game-layout {
  width: 100%;
  height: auto;
  flex: 1 1 0;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(230px, 1fr) minmax(360px, 2fr) minmax(230px, 1fr);
  gap: 10px;
  overflow: hidden;
}

.left-col,
.middle-col,
.right-col {
  min-width: 0;
  min-height: 0;
  height: 100%;
  overflow: hidden;
  gap: 10px;
}

.left-col > section,
.middle-col > section,
.right-col > section {
  min-width: 0;
  min-height: 0;
  padding: 8px;
  border-radius: 6px;
}

.left-col > .room-desc { flex: 1.3 1 24%; }
.left-col > .known-map { flex: 1.3 1 21%; }
.left-col > .navigation { flex: 1.3 1 20%; }
.left-col > .room-objects-panel { flex: 2.1 1 35%; }

.middle-col > .journal { flex: 1 1 18%; }
.middle-col > .system-log { flex: 1 1 17%; }
.middle-col > .dialog { flex: 3 1 43%; }
.middle-col > .combat-log { flex: 1 1 22%; }

.right-col > .char-info { flex: 0 1 30%; overflow: auto; }
.right-col > .relics { flex: 0 1 20%; overflow: auto; }
.right-col > .equipment { flex: 1 1 34%; overflow: auto; }
.right-col > .inventory { flex: 0 1 16%; overflow: auto; }

.left-col > section h3,
.middle-col > section h3,
.right-col > section h3 {
  font-size: 14px;
  line-height: 1.2;
  margin-bottom: 8px;
}

.room-desc-text,
.map-display,
.log,
.equip-list,
.local-actions,
.room-objects-list,
.journal-list,
.relic-wheel,
.char-basic,
.char-progress,
.char-attrs,
.char-secondary,
.char-res,
.char-state {
  font-size: 14px;
}

.room-desc-text,
.map-display,
.log,
.equip-list,
.local-actions,
.room-objects-list,
.journal-list,
.relic-wheel,
.inv-grid {
  min-height: 0;
  overflow: auto;
}

.log {
  padding: 8px;
  margin-bottom: 6px;
  overflow-x: hidden;
}

.dir-grid {
  width: min(100%, 360px);
  height: min(100%, 360px);
  max-width: none;
  align-self: center;
  margin: auto;
  align-content: center;
  justify-content: center;
}

.dir-btn {
  width: 100%;
  min-height: 0;
  height: 100%;
  aspect-ratio: 1;
  font-size: 24px;
}

.dir-text {
  font-size: 13px;
}

.resources.full-width {
  flex: 0 0 auto;
  padding: 8px;
}

.resource .label,
.bar-wrapper .num {
  font-size: 13px;
}

.bar-wrapper {
  height: 22px;
}

.bar-wrapper .num {
  line-height: 22px;
}

.action-bar.full-width {
  flex: 0 0 auto;
  padding: 8px;
}

.action-btn {
  min-height: 72px;
  font-size: 20px;
}

.footer-note {
  display: none;
}

@media (max-width: 900px) {
  html {
    height: auto;
    min-height: 100%;
    overflow: auto;
  }

  body {
    height: auto;
    min-height: 100dvh;
    overflow: visible;
  }

  #app {
    display: block;
    height: auto;
    min-height: 100dvh;
    overflow: visible;
  }

  #game-screen {
    flex: none;
    height: auto;
    min-height: 0;
    overflow: visible;
  }

  .game-layout {
    flex: 0 0 auto;
    grid-template-columns: 1fr;
    grid-template-rows: auto;
    height: auto;
    overflow: visible;
  }

  .left-col,
  .middle-col,
  .right-col {
    flex-direction: column;
    flex-wrap: nowrap;
    height: auto;
    overflow: visible;
  }

  .left-col > section,
  .middle-col > section,
  .right-col > section {
    min-width: 0;
    min-height: 180px;
  }

  .middle-col > .system-log,
  .middle-col > .journal,
  .middle-col > .dialog,
  .middle-col > .combat-log,
  .left-col > .room-desc,
  .left-col > .known-map,
  .left-col > .navigation,
  .left-col > .room-objects-panel,
  .right-col > .char-info,
  .right-col > .relics,
  .right-col > .equipment,
  .right-col > .inventory {
    flex: 0 0 auto;
  }

  .dir-grid {
    width: min(100%, 300px);
    height: 300px;
  }
}

@media (min-width: 901px) and (max-width: 1200px) {
  .left-col > .room-desc {
    flex: 1 1 22%;
  }

  .left-col > .known-map {
    flex: 1 1 30%;
  }

  .left-col > .navigation {
    flex: 1 1 22%;
  }

  .left-col > .room-objects-panel {
    flex: 1 1 26%;
  }

  .map-room {
    padding: 4px;
    min-height: 46px;
  }

  .map-room-name {
    display: none;
  }

  .map-room-dir {
    font-size: 9px;
  }

  .map-room-icon {
    font-size: 18px;
  }

  .local-action-btn {
    min-height: 54px;
  }

  .action-bar .actions {
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  }

  .action-btn {
    min-height: 64px;
    font-size: 18px;
  }
}

@media (max-width: 700px) {
  #app {
    padding: 6px;
    gap: 8px;
  }

  #game-screen {
    min-height: calc(100dvh - 12px);
    gap: 8px;
  }

  .game-layout {
    gap: 8px;
  }

  .left-col,
  .middle-col,
  .right-col {
    gap: 8px;
  }

  .left-col > section,
  .middle-col > section,
  .right-col > section {
    min-height: 150px;
  }

  .left-col > .navigation {
    min-height: 170px;
  }

  .dir-grid {
    width: min(100%, 270px);
    height: 270px;
  }

  .resources.full-width {
    grid-template-columns: 1fr;
  }

  .action-bar .actions {
    grid-template-columns: repeat(3, 1fr);
  }

  .action-btn {
    min-height: 64px;
  }
}

/* Small-screen app shell: keep global controls docked and scroll only the game panels. */
@media (max-width: 900px) {
  html,
  body {
    width: 100%;
    height: 100%;
    overflow: hidden;
  }

  body {
    min-height: 100dvh;
  }

  #app {
    display: flex;
    flex-direction: column;
    width: 100vw;
    height: 100dvh;
    min-height: 0;
    padding: 6px;
    gap: 6px;
    overflow: hidden;
  }

  #game-screen {
    flex: 1 1 auto;
    min-height: 0;
    height: 100%;
    gap: 6px;
    overflow: hidden;
  }

  .game-layout {
    flex: 1 1 0;
    min-height: 0;
    height: auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding-right: 2px;
  }

  .left-col,
  .middle-col,
  .right-col {
    display: contents;
  }

  .left-col > section,
  .middle-col > section,
  .right-col > section {
    flex: 0 0 auto;
    width: 100%;
    min-height: 138px;
    overflow: hidden;
  }

  .left-col > .room-desc { order: 1; }
  .left-col > .known-map { order: 2; }
  .left-col > .navigation { order: 3; }
  .left-col > .room-objects-panel { order: 4; }
  .middle-col > .journal { order: 5; }
  .middle-col > .system-log { order: 6; }
  .middle-col > .dialog { order: 7; }
  .middle-col > .combat-log { order: 8; }
  .right-col > .char-info { order: 9; }
  .right-col > .relics { order: 10; }
  .right-col > .equipment { order: 11; }
  .right-col > .inventory { order: 12; }

  .left-col > .room-desc {
    min-height: 112px;
  }

  .left-col > .known-map,
  .left-col > .room-objects-panel {
    min-height: 220px;
  }

  .left-col > .navigation {
    min-height: 160px;
  }

  .middle-col > .dialog {
    min-height: 240px;
  }

  .right-col > .char-info,
  .right-col > .equipment,
  .right-col > .inventory,
  .right-col > .relics {
    overflow: hidden;
  }

  .local-actions {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .local-action-btn {
    min-height: 58px;
  }

  .room-objects-list {
    grid-template-columns: 1fr;
  }

  .resources.full-width {
    flex: 0 0 auto;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 4px;
    padding: 5px;
    border-radius: 8px;
  }

  .resource {
    min-width: 0;
    gap: 2px;
  }

  .resource .label {
    font-size: 10px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .bar-wrapper {
    height: 16px;
  }

  .bar-wrapper .num {
    font-size: 10px;
    line-height: 16px;
  }

  .action-bar.full-width {
    flex: 0 0 auto;
    padding: 5px;
    border-radius: 8px;
  }

  .action-bar .actions {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 4px;
  }

  .action-btn {
    min-height: 44px;
    border-width: 1px;
    border-radius: 8px;
    padding: 3px 2px;
    font-size: 11px;
    line-height: 1.1;
    overflow-wrap: anywhere;
  }

  .action-btn span {
    margin-top: 1px;
    font-size: 9px;
  }

  .action-btn .action-cooldown {
    width: 16px;
    height: 16px;
    margin-left: 3px;
    font-size: 10px;
  }
}

@media (max-width: 480px) {
  #app {
    padding: 5px;
    gap: 5px;
  }

  #game-screen {
    gap: 5px;
  }

  .game-layout {
    gap: 6px;
  }

  .left-col,
  .middle-col,
  .right-col {
    gap: 6px;
  }

  .left-col > section,
  .middle-col > section,
  .right-col > section {
    padding: 6px;
    border-radius: 6px;
  }

  .left-col > section h3,
  .middle-col > section h3,
  .right-col > section h3 {
    font-size: 12px;
    margin-bottom: 6px;
  }

  .room-desc-text,
  .map-display,
  .log,
  .equip-list,
  .local-actions,
  .room-objects-list,
  .journal-list,
  .relic-wheel,
  .char-basic,
  .char-progress,
  .char-attrs,
  .char-secondary,
  .char-res,
  .char-state {
    font-size: 12px;
  }

  .char-attrs .attr-item {
    grid-template-columns: minmax(0, 1fr) 28px;
    padding: 4px;
  }

  .attr-train-btn {
    width: 28px;
    height: 26px;
  }

  .resources.full-width {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    padding: 4px;
  }

  .action-bar.full-width {
    padding: 4px;
  }

  .action-btn {
    min-height: 42px;
    font-size: 10px;
  }
}

#debug-toggle {
  display: none !important;
}

/* === iCY//VOiD Cyberpunk Theme Layer === */
html,
body {
  background: #000000;
}

body {
  color: var(--text);
  font-family: var(--body-font);
  background-color: #000000;
  background-image:
    linear-gradient(rgba(0, 0, 0, 0.88), rgba(0, 0, 0, 0.96)),
    url("assets/syntos-check-bg.png"),
    repeating-linear-gradient(0deg, rgba(23, 147, 209, 0.055) 0 1px, transparent 1px 5px);
  background-position: center, center, top left;
  background-repeat: repeat;
  background-size: auto, 188px 188px, auto;
}

body::selection {
  background: var(--accent);
  color: #000000;
}

#app {
  background: transparent;
}

#setup-screen {
  max-width: 660px;
  padding-top: 26px;
}

.setup-header h1 {
  color: var(--text);
  font-family: var(--glitch-font);
  font-size: 42px;
  font-weight: 400;
  line-height: 1;
  text-shadow:
    2px 0 0 rgba(23, 147, 209, 0.88),
    -2px 0 0 rgba(72, 191, 255, 0.44),
    0 0 32px rgba(23, 147, 209, 0.5);
}

.setup-header .tagline,
.setup-note,
.footer-note,
.empty,
.local-action-empty {
  color: var(--muted);
}

.version-badge,
.game-version {
  color: var(--muted);
  border-color: rgba(23, 147, 209, 0.36);
  background: rgba(2, 8, 12, 0.78);
}

.resources,
.action-bar,
.room-view,
.directions,
.log-section,
.character-list-panel,
.setup-summary,
.left-col > section,
.middle-col > section,
.right-col > section,
.reward-modal-panel,
.reward-toast {
  border: 1px solid rgba(23, 147, 209, 0.28);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(7, 13, 18, 0.985), rgba(2, 4, 6, 0.99));
  box-shadow:
    inset 0 1px 0 rgba(72, 191, 255, 0.08),
    0 14px 40px rgba(0, 0, 0, 0.36);
}

.room-header,
.log-header,
.map-display,
.log,
.room-objects-list,
.journal-list,
.choice-card,
#player-name,
.character-card,
.char-attrs .attr-item,
.secondary-stat,
.equip-row,
.slot,
.inv-slot,
.objective-card,
.relic-slot,
.room-object-card,
.stat,
.training-points {
  border-color: rgba(23, 147, 209, 0.22);
  background: rgba(2, 8, 12, 0.88);
}

.left-col > section h3,
.middle-col > section h3,
.right-col > section h3,
.sheet-header h2,
.room-header h1,
.char-subhead,
.objective-badge,
.reward-toast-title,
.reward-modal-kicker,
.stat-bonus,
.inv-compare,
.room-object-status {
  color: var(--accent-strong);
  font-family: var(--tech-font);
  font-weight: 400;
  letter-spacing: 0;
  text-shadow: 0 0 16px rgba(23, 147, 209, 0.45);
}

.left-col > section h3,
.middle-col > section h3,
.right-col > section h3 {
  border-bottom-color: rgba(23, 147, 209, 0.28);
  text-transform: uppercase;
}

.choice-name,
.character-list-header,
.character-card-title,
.room-object-title,
.objective-title,
.equip-item-title,
.attr-value,
.secondary-stat-value,
.resource .value,
.bar-wrapper .num {
  color: var(--text);
}

.choice-desc,
.setup-section label,
.attr-label,
.secondary-stat-label,
.equip-slot-label,
.room-object-desc,
.objective-summary,
.objective-step,
.objective-step-source,
.objective-step-note,
.objective-hidden-step,
.character-card-meta,
.inv-name,
.relic-label,
.reward-toast-body,
.reward-modal-body,
.map-room-dir,
.resource .label {
  color: var(--text-dim);
}

button,
input {
  font-family: var(--body-font);
}

.small-btn,
.action-btn,
.local-action-btn,
.dir-btn,
.map-room,
.room-object-actions button,
.equip-unequip-btn,
.inv-actions button,
.attr-train-btn,
.play-btn,
.reward-modal-close,
.filter-button {
  border-color: rgba(23, 147, 209, 0.42);
  border-radius: 8px;
  background: #02080c;
  color: var(--text);
  box-shadow: inset 0 1px 0 rgba(72, 191, 255, 0.08);
}

.small-btn:hover,
.action-btn:hover,
.local-action-btn:hover,
.dir-btn:hover,
.map-room.available:hover,
.room-object-actions button:hover,
.equip-unequip-btn:hover,
.inv-actions button:hover,
.attr-train-btn:hover,
.choice-card:hover,
#player-name:focus {
  border-color: rgba(72, 191, 255, 0.82);
  background: rgba(23, 147, 209, 0.13);
  color: var(--text);
  box-shadow:
    inset 0 1px 0 rgba(72, 191, 255, 0.12),
    0 0 0 1px rgba(23, 147, 209, 0.18),
    0 0 24px rgba(23, 147, 209, 0.16);
}

.action-btn.is-disabled,
.local-action-btn.is-disabled,
.dir-btn:disabled {
  border-color: rgba(110, 164, 196, 0.22);
  color: rgba(184, 216, 237, 0.55);
  background: rgba(2, 8, 12, 0.58);
  box-shadow: none;
}

.choice-card.selected {
  border-color: var(--accent-strong);
  background: rgba(23, 147, 209, 0.16);
  box-shadow:
    0 0 0 1px rgba(23, 147, 209, 0.32),
    0 0 30px rgba(23, 147, 209, 0.22);
}

.play-btn:not(:disabled),
.reward-modal-close {
  border-color: var(--accent-strong);
  background: var(--accent);
  color: #000000;
  box-shadow:
    0 0 0 1px rgba(72, 191, 255, 0.34),
    0 0 28px rgba(23, 147, 209, 0.32);
}

.play-btn:not(:disabled):hover,
.reward-modal-close:hover {
  background: var(--accent-strong);
  box-shadow:
    0 0 0 1px rgba(72, 191, 255, 0.5),
    0 0 36px rgba(23, 147, 209, 0.42);
}

.action-btn .action-cooldown,
.stat-chip,
.compare-chip,
.project-meta span {
  border-color: rgba(23, 147, 209, 0.35);
  background: rgba(23, 147, 209, 0.09);
  color: var(--text-dim);
}

.compare-chip.warning {
  border-color: rgba(245, 196, 81, 0.62);
  color: var(--warning);
}

.stat-chip.positive,
.compare-chip.positive,
.objective-step.complete,
.room-object-card.npc {
  border-color: rgba(88, 230, 164, 0.44);
  color: #9ff4c8;
}

.stat-chip.negative,
.compare-chip.negative,
.room-object-card.hostile,
.character-card.ended,
.small-btn.danger {
  border-color: rgba(255, 77, 109, 0.58);
  color: #ff9aad;
}

.small-btn.danger:hover {
  border-color: rgba(255, 154, 173, 0.88);
  color: #ffd7de;
}

.room-object-card.item,
.inv-slot.equippable,
.relic-slot.center {
  border-color: rgba(72, 191, 255, 0.58);
}

.relic-slot.unlocked,
.objective-card.complete,
.char-attrs .attr-item.can-train .attr-train-btn,
.map-room.current {
  border-color: rgba(88, 230, 164, 0.62);
  background: rgba(13, 38, 29, 0.74);
}

.map-room.available {
  border-color: rgba(72, 191, 255, 0.72);
}

.map-room.locked {
  border-color: rgba(245, 196, 81, 0.5);
  background: rgba(37, 28, 8, 0.72);
}

.map-connector {
  color: rgba(72, 191, 255, 0.45);
}

.resource .bar,
.bar-wrapper,
.room-object-bar {
  border-color: rgba(23, 147, 209, 0.28);
  background: rgba(2, 8, 12, 0.9);
}

#health-fill {
  background: linear-gradient(90deg, #ff4d6d, #ff8ea0);
}

#mana-fill {
  background: linear-gradient(90deg, #1793d1, #48bfff);
}

#stamina-fill {
  background: linear-gradient(90deg, #29bf7f, #74f7ba);
}

.resource:has(#health-fill) .bar-wrapper {
  background: rgba(255, 77, 109, 0.13);
}

.resource:has(#mana-fill) .bar-wrapper {
  background: rgba(23, 147, 209, 0.16);
}

.resource:has(#stamina-fill) .bar-wrapper {
  background: rgba(88, 230, 164, 0.13);
}

.log-entry {
  border-bottom-color: rgba(23, 147, 209, 0.16);
}

.log-entry.move,
.log-entry.dialog {
  color: #8fd6ff;
}

.log-entry.system {
  color: #9ff4c8;
}

.log-entry.combat {
  color: #ff9aad;
}

#game-screen.combat {
  box-shadow:
    inset 0 0 34px rgba(255, 77, 109, 0.16),
    inset 0 0 72px rgba(23, 147, 209, 0.06);
}

#game-screen.resting {
  box-shadow:
    inset 0 0 34px rgba(88, 230, 164, 0.12),
    inset 0 0 72px rgba(23, 147, 209, 0.06);
}

.game-layout.combat .middle-col > section {
  border-color: rgba(255, 77, 109, 0.58);
}

.game-layout.resting .middle-col > section {
  border-color: rgba(88, 230, 164, 0.58);
}

#tooltip {
  border-color: rgba(72, 191, 255, 0.78);
  background: rgba(2, 8, 12, 0.98);
  color: var(--text);
  box-shadow: 0 10px 36px rgba(0, 0, 0, 0.58), 0 0 22px rgba(23, 147, 209, 0.22);
}

::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-track {
  background: #020406;
}

::-webkit-scrollbar-thumb {
  border: 2px solid #020406;
  border-radius: 8px;
  background: rgba(23, 147, 209, 0.62);
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(72, 191, 255, 0.78);
}

@media (max-width: 700px) {
  .setup-header h1 {
    font-size: 34px;
  }
}

/* === Workspace Layout + Inventory Modal Adjustments === */
.game-layout {
  grid-template-columns: minmax(300px, 1fr) minmax(420px, 1.42fr) minmax(300px, 1fr);
}

.left-col > .journal { flex: 1.1 1 19%; }
.left-col > .system-log { flex: 1 1 18%; }
.left-col > .dialog { flex: 2.25 1 41%; }
.left-col > .combat-log { flex: 1.25 1 22%; }

.middle-col > .room-objects-panel { flex: 2.15 1 38%; }
.middle-col > .navigation { flex: 0.9 1 16%; }
.middle-col > .known-map { flex: 1.55 1 27%; }
.middle-col > .room-desc { flex: 1.05 1 19%; }

.inventory h3 {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.inventory-summary,
.inventory-modal-summary {
  margin-bottom: 6px;
  color: var(--text-dim);
  font-size: 11px;
  line-height: 1.2;
}

.inventory {
  cursor: pointer;
}

.inventory .inv-grid {
  grid-template-columns: repeat(auto-fit, minmax(44px, 1fr));
}

.inventory .inv-slot {
  min-height: 54px;
  align-content: center;
}

.inventory .inv-slot.has-item {
  grid-template-rows: auto auto auto;
}

.inventory .inv-actions,
.inventory .inv-compare-chips {
  display: none;
}

.inventory-modal {
  position: fixed;
  inset: 0;
  z-index: 10058;
  align-items: center;
  justify-content: center;
  padding: 18px;
  background: rgba(0, 0, 0, 0.72);
}

.inventory-modal-panel {
  width: min(880px, 100%);
  max-height: min(760px, calc(100dvh - 36px));
  display: flex;
  flex-direction: column;
  gap: 10px;
  border: 1px solid rgba(23, 147, 209, 0.48);
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(7, 13, 18, 0.99), rgba(2, 4, 6, 0.995));
  box-shadow: 0 26px 80px rgba(0, 0, 0, 0.72), 0 0 44px rgba(23, 147, 209, 0.18);
  padding: 14px;
}

.inventory-modal-header {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid rgba(23, 147, 209, 0.24);
  padding-bottom: 10px;
}

.inventory-modal-kicker {
  color: var(--accent-strong);
  font-family: var(--tech-font);
  font-size: 12px;
  line-height: 1.2;
  text-transform: uppercase;
}

.inventory-modal h2 {
  margin: 4px 0 0;
  color: var(--text);
  font-size: 24px;
  line-height: 1.15;
}

.inventory-modal-list {
  min-height: 0;
  overflow: auto;
  display: grid;
  gap: 8px;
  padding-right: 4px;
}

.inventory-modal-empty {
  border: 1px dashed rgba(23, 147, 209, 0.38);
  border-radius: 8px;
  padding: 24px;
  color: var(--text-dim);
  text-align: center;
}

.inventory-modal-item {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: start;
  border: 1px solid rgba(23, 147, 209, 0.28);
  border-radius: 8px;
  background: rgba(2, 8, 12, 0.88);
  padding: 10px;
}

.inventory-modal-item.protected {
  border-color: rgba(245, 196, 81, 0.44);
}

.inventory-modal-icon {
  display: grid;
  min-height: 42px;
  place-items: center;
  border: 1px solid rgba(23, 147, 209, 0.22);
  border-radius: 8px;
  background: rgba(23, 147, 209, 0.08);
  font-size: 22px;
}

.inventory-modal-body {
  min-width: 0;
  display: grid;
  gap: 5px;
}

.inventory-modal-name {
  color: var(--text);
  font-weight: 800;
}

.inventory-modal-details {
  margin: 0;
  color: var(--text-dim);
  white-space: pre-wrap;
  font: inherit;
  font-size: 11px;
  line-height: 1.25;
}

.inventory-modal-desc {
  color: var(--text-dim);
  font-size: 12px;
  line-height: 1.35;
}

.inventory-modal-note {
  width: fit-content;
  border: 1px solid rgba(245, 196, 81, 0.48);
  border-radius: 999px;
  padding: 2px 7px;
  color: var(--warning);
  background: rgba(245, 196, 81, 0.08);
  font-size: 10px;
  line-height: 1.2;
}

.inventory-modal-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(70px, 1fr));
  gap: 6px;
}

.inventory-modal-actions button {
  min-height: 30px;
  border: 1px solid rgba(23, 147, 209, 0.42);
  border-radius: 6px;
  background: #02080c;
  color: var(--text);
  cursor: pointer;
}

.inventory-modal-actions button:hover:not(:disabled) {
  border-color: rgba(72, 191, 255, 0.82);
  background: rgba(23, 147, 209, 0.13);
}

.inventory-modal-actions button:disabled {
  opacity: 0.42;
  cursor: not-allowed;
}

@media (max-width: 900px) {
  .inventory-modal-item {
    grid-template-columns: 36px minmax(0, 1fr);
  }

  .inventory-modal-actions {
    grid-column: 1 / -1;
  }
}
