:root {
  --bg: #f6f3e9;
  --ink: #24303f;
  --panel: #ffffff;
  --accent: #2e8b57;
  --accent-2: #1f5f8b;
  --danger: #c94b4b;
  --gold: #d2a94a;
  --line: #d9d2bf;
}

html,
body {
  height: 100%;
  overflow: hidden;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Trebuchet MS", "Segoe UI", sans-serif;
  background: radial-gradient(circle at top, #fff8e8, var(--bg));
  color: var(--ink);
}

.rpg-shell {
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 4px;
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 6px;
}

.hud-bar {
  display: grid;
  grid-template-columns: repeat(3, 1fr) auto;
  gap: 10px;
  background: var(--panel);
  border: 2px solid var(--line);
  border-radius: 12px;
  padding: 8px;
}

.bar-group {
  display: grid;
  grid-template-columns: 40px 1fr auto;
  align-items: center;
  gap: 8px;
  font-size: 0.9rem;
}

.bar {
  height: 14px;
  background: #ece7d8;
  border-radius: 99px;
  overflow: hidden;
  border: 1px solid #ccbfa0;
}

.bar-fill {
  height: 100%;
  width: 0;
  transition: width 120ms linear;
}

.bar-fill.hp { background: linear-gradient(90deg, #ca4a4a, #f06f6f); }
.bar-fill.mp { background: linear-gradient(90deg, #3f78c0, #64a1ef); }
.bar-fill.xp { background: linear-gradient(90deg, #be8a2e, #e3bf62); }

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

button {
  border: 1px solid #887f67;
  background: #fff8de;
  color: #2e2b23;
  border-radius: 8px;
  padding: 8px 10px;
  cursor: pointer;
}

button:hover {
  background: #fff0c2;
}

.game-layout {
  display: grid;
  grid-template-columns: minmax(175px, 220px) minmax(420px, 760px) minmax(210px, 260px);
  gap: 6px;
  margin-top: 0;
  align-items: start;
  min-height: 0;
  height: 100%;
  justify-content: center;
}

.canvas-wrap {
  position: relative;
  display: flex;
  align-items: stretch;
  justify-self: center;
  width: 100%;
  max-width: 760px;
  background: #111;
  border: 3px solid #343434;
  border-radius: 12px;
  overflow: hidden;
  min-height: 0;
  height: 100%;
}

#game-canvas {
  display: block;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
}

.sidebar {
  display: grid;
  gap: 10px;
  align-content: start;
  min-height: 0;
  overflow: hidden;
  height: 100%;
}

.sidebar-left {
  grid-template-rows: auto auto 1fr;
}

.sidebar-right {
  grid-template-rows: auto 1fr;
}

.sidebar-right .panel {
  padding: 8px;
}

.sidebar-right .panel h2 {
  margin-bottom: 8px;
  font-size: 1rem;
}

.panel {
  background: var(--panel);
  border: 2px solid var(--line);
  border-radius: 12px;
  padding: 8px;
}

.panel h2 {
  margin: 0 0 8px;
  font-size: 1rem;
}

#stats-list {
  margin: 0;
  padding-left: 18px;
  line-height: 1.4;
}

.inventory-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
}

.inventory-slot {
  min-height: 38px;
  border: 1px solid #cbbf9f;
  border-radius: 8px;
  background: #f9f5e7;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-size: 0.66rem;
  line-height: 1.1;
  padding: 3px;
  cursor: pointer;
}

.equipment-slot {
  min-height: 40px;
  border: 1px solid #cbbf9f;
  border-radius: 8px;
  background: #f9f5e7;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-size: 0.66rem;
  line-height: 1.1;
  padding: 3px;
  cursor: pointer;
}

.slot-dragging {
  opacity: 0.45;
}

.slot-drop-target {
  outline: 2px dashed #2f7f42;
  outline-offset: -2px;
}

.equipment-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.hint {
  margin: 0 0 8px;
  font-size: 0.8rem;
  opacity: 0.85;
}

.sidebar-right .hint {
  margin-bottom: 4px;
  font-size: 0.78rem;
}

.event-log {
  max-height: 96px;
  height: auto;
  overflow: hidden;
  font-size: 0.82rem;
  line-height: 1.3;
}

.quest-list {
  display: grid;
  gap: 8px;
  font-size: 0.84rem;
}

.quest-entry {
  background: #f7f2e2;
  border: 1px solid #dacda9;
  border-radius: 8px;
  padding: 8px;
}

.quest-title {
  font-weight: 700;
  margin-bottom: 4px;
}

.quest-meta {
  opacity: 0.88;
}

.minimap-panel {
  overflow: hidden;
}

#minimap-canvas {
  width: 100%;
  max-width: 190px;
  aspect-ratio: 1 / 1;
  display: block;
  margin: 0 auto;
  border: 1px solid #cbbf9f;
  border-radius: 8px;
  background: #f4efe0;
  image-rendering: pixelated;
}

.log-line {
  margin-bottom: 6px;
}

.dialogue,
.combat,
.shop {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 12px;
  background: rgba(255, 252, 243, 0.96);
  border: 2px solid #b59f75;
}

.dialogue-options,
.combat-actions,
.shop-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.hidden {
  display: none;
}

.help-bar {
  margin-top: 0;
  padding: 8px;
  background: #fff;
  border: 2px solid var(--line);
  border-radius: 10px;
  font-size: 0.82rem;
}

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

  .canvas-wrap {
    min-height: 0;
  }

  .inventory-grid {
    grid-template-columns: repeat(6, 1fr);
  }

  .sidebar {
    grid-template-rows: none;
    max-height: none;
    overflow: hidden;
  }
}
