:root {
  --bg-top: #96d6ff;
  --bg-mid: #95c9a5;
  --bg-low: #3d6a43;
  --panel: rgba(8, 17, 12, 0.72);
  --text: #ecf8ee;
  --accent: #f3ca59;
  --muted: #bbd6c0;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: radial-gradient(circle at 20% 20%, var(--bg-top), var(--bg-mid) 50%, var(--bg-low));
  color: var(--text);
  font-family: "Trebuchet MS", "Segoe UI", sans-serif;
}

body {
  overflow: hidden;
}

#game {
  display: block;
  width: 100vw;
  height: 100vh;
}

.hud-wrap {
  position: fixed;
  top: 10px;
  left: 10px;
  z-index: 4;
  max-width: 500px;
  display: grid;
  grid-template-columns: repeat(2, minmax(220px, 1fr));
  gap: 8px;
  pointer-events: none;
}

.panel {
  background: var(--panel);
  border: 1px solid rgba(236, 248, 238, 0.18);
  border-radius: 10px;
  padding: 8px 10px;
  backdrop-filter: blur(4px);
  font-size: 0.9rem;
}

.title,
.legend {
  grid-column: span 2;
}

.title h1 {
  margin: 0 0 4px;
  color: var(--accent);
}

.player-identity {
  display: grid;
  gap: 2px;
  margin: 0 0 6px;
}

.player-name {
  font-size: 0.82rem;
  color: #edf8f0;
  font-weight: 700;
}

.player-points {
  font-size: 0.76rem;
  color: #cfe3d5;
}

.title p,
.legend p {
  margin: 0;
  color: var(--muted);
  font-size: 0.82rem;
}

.equipped-tools {
  margin-top: 6px;
  min-height: 22px;
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
}

.equipped-tool {
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 8px;
  background: rgba(14, 26, 18, 0.85);
  color: #eaf6ef;
  padding: 2px 6px;
  font-size: 0.74rem;
}

kbd {
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-bottom-width: 2px;
  border-radius: 5px;
  padding: 1px 4px;
  font-size: 0.78rem;
  background: rgba(255, 255, 255, 0.08);
  margin-right: 2px;
}

.actions {
  display: none;
}

.actions.hidden {
  display: none;
}

.actions button {
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 8px;
  background: linear-gradient(180deg, #345035, #22361f);
  color: var(--text);
  padding: 5px 7px;
  font-size: 0.8rem;
  cursor: pointer;
}

.action-row {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.action-row.locked {
  display: none;
}

.action-buttons {
  display: flex;
  gap: 6px;
}

.action-buttons button:first-child {
  flex: 1;
}

.vial-btn {
  width: 36px;
  min-width: 36px;
  padding: 0;
  font-size: 1rem;
}

.cost-line {
  font-size: 0.72rem;
  color: rgba(224, 242, 230, 0.86);
  padding-left: 2px;
}

.actions button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  filter: grayscale(0.35);
}

.actions button:hover {
  filter: brightness(1.1);
}

.quest-log {
  position: fixed;
  top: 10px;
  right: 10px;
  z-index: 5;
  width: min(340px, calc(100vw - 20px));
  pointer-events: auto;
}

.quest-log h2 {
  margin: 0;
  font-size: 0.9rem;
  color: var(--accent);
}

.quest-focus {
  margin: 6px 0 4px;
  color: #edf6ef;
  font-size: 0.8rem;
}

.quest-items {
  margin: 0;
  padding-left: 18px;
  display: grid;
  gap: 4px;
  font-size: 0.76rem;
  color: var(--muted);
}

.resource-bar {
  position: fixed;
  bottom: 76px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 6;
  display: flex;
  gap: 10px;
}

.resource-slot {
  min-width: 64px;
  padding: 6px 10px;
  border-radius: 10px;
  background: rgba(9, 16, 12, 0.8);
  border: 1px solid rgba(255, 255, 255, 0.18);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-weight: 700;
}

.resource-slot.hidden-empty {
  display: none;
}

.resource-slot .icon {
  font-size: 1rem;
}

.book-toggle {
  cursor: pointer;
  font-weight: 700;
  color: #f2f8f4;
  background: linear-gradient(180deg, #4f6537, #334727);
}

.book-toggle:hover {
  filter: brightness(1.08);
}

.map-toggle {
  cursor: pointer;
  font-weight: 700;
  color: #f2f8f4;
  background: linear-gradient(180deg, #5d6933, #404d27);
}

.map-toggle:hover {
  filter: brightness(1.08);
}

.map-toggle.active {
  border-color: rgba(243, 202, 89, 0.9);
  box-shadow: inset 0 0 0 1px rgba(243, 202, 89, 0.35);
}

.progress-toggle {
  cursor: pointer;
  font-weight: 700;
  color: #f2f8f4;
  background: linear-gradient(180deg, #5c4e2d, #40351d);
}

.progress-toggle:hover {
  filter: brightness(1.08);
}

.progress-toggle.active {
  border-color: rgba(243, 202, 89, 0.9);
  box-shadow: inset 0 0 0 1px rgba(243, 202, 89, 0.35);
}

.potion-book {
  position: fixed;
  bottom: 116px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 8;
  width: min(900px, calc(100vw - 20px));
  max-height: min(54vh, 470px);
  background: rgba(7, 13, 9, 0.93);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 12px;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: auto;
}

.world-resource-panel {
  position: fixed;
  bottom: 116px;
  right: 10px;
  z-index: 8;
  width: min(360px, calc(100vw - 20px));
  max-height: min(54vh, 470px);
  background: rgba(7, 13, 9, 0.93);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 12px;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: auto;
}

.world-resource-panel.hidden {
  display: none;
}

.progress-panel {
  position: fixed;
  bottom: 116px;
  right: 10px;
  z-index: 8;
  width: min(420px, calc(100vw - 20px));
  max-height: min(62vh, 560px);
  background: rgba(7, 13, 9, 0.94);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 12px;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: auto;
  overflow: hidden;
}

.progress-panel.hidden {
  display: none;
}

.progress-player {
  border: 1px solid rgba(255, 255, 255, 0.13);
  border-radius: 10px;
  background: rgba(17, 28, 20, 0.82);
  padding: 7px 8px;
  display: grid;
  gap: 2px;
}

.progress-player-name {
  font-size: 0.82rem;
  color: #edf7ef;
  font-weight: 700;
}

.progress-player-points {
  font-size: 0.75rem;
  color: #c5dccd;
}

.progress-section {
  border: 1px solid rgba(255, 255, 255, 0.13);
  border-radius: 10px;
  background: rgba(17, 28, 20, 0.8);
  padding: 7px 8px;
  display: grid;
  gap: 5px;
}

.progress-section h3 {
  margin: 0;
  font-size: 0.8rem;
  color: var(--accent);
}

.progress-focus {
  margin: 0;
  font-size: 0.76rem;
  color: #e7f5ea;
}

.progress-list {
  margin: 0;
  padding-left: 18px;
  display: grid;
  gap: 4px;
  font-size: 0.73rem;
  color: #bdd1c2;
  overflow: auto;
}

.resource-guide-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.resource-guide-head h2 {
  margin: 0;
  font-size: 0.95rem;
  color: var(--accent);
}

.resource-guide-points {
  font-size: 0.74rem;
  color: #d6e9db;
}

.world-resource-list {
  overflow: auto;
  display: grid;
  gap: 6px;
  padding-right: 2px;
}

.world-resource-entry {
  border: 1px solid rgba(255, 255, 255, 0.13);
  border-radius: 10px;
  padding: 7px 8px;
  background: rgba(18, 28, 20, 0.8);
  display: grid;
  gap: 3px;
}

.world-resource-title {
  font-weight: 700;
  color: #edf8f0;
  font-size: 0.8rem;
}

.world-resource-line {
  font-size: 0.74rem;
  color: #b9d2bf;
}

.potion-book.hidden {
  display: none;
}

.book-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.book-head h2 {
  margin: 0;
  font-size: 0.95rem;
  color: var(--accent);
}

.book-close {
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 8px;
  background: rgba(35, 52, 31, 0.9);
  color: var(--text);
  width: 32px;
  height: 28px;
  cursor: pointer;
}

.book-tabs {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.book-tabs button {
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 8px;
  background: rgba(33, 48, 29, 0.9);
  color: var(--text);
  padding: 4px 8px;
  font-size: 0.76rem;
  cursor: pointer;
}

.book-tabs button.active {
  border-color: rgba(243, 202, 89, 0.9);
  box-shadow: inset 0 0 0 1px rgba(243, 202, 89, 0.4);
  color: #fff3c7;
}

.book-filters {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.book-filters button {
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 8px;
  background: rgba(33, 48, 29, 0.9);
  color: var(--text);
  padding: 4px 8px;
  font-size: 0.76rem;
  cursor: pointer;
}

.book-filters button.active {
  border-color: rgba(243, 202, 89, 0.9);
  box-shadow: inset 0 0 0 1px rgba(243, 202, 89, 0.4);
  color: #fff3c7;
}

.book-list {
  overflow: auto;
  display: grid;
  gap: 6px;
  padding-right: 2px;
}

.book-entry {
  border: 1px solid rgba(255, 255, 255, 0.13);
  border-radius: 10px;
  padding: 7px 8px;
  background: rgba(18, 28, 20, 0.8);
  display: grid;
  gap: 4px;
}

.book-entry-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
}

.book-entry-title {
  font-weight: 700;
  color: #edf8f0;
  font-size: 0.8rem;
}

.book-entry-state {
  font-size: 0.72rem;
  color: #c3d9c8;
}

.book-entry-line {
  font-size: 0.74rem;
  color: #b9d2bf;
}

.book-entry-cast {
  height: 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.18);
  overflow: hidden;
  margin-top: 2px;
}

.book-entry-cast-fill {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, #d9f18f 0%, #f3c95f 100%);
}

.book-entry-actions {
  display: flex;
  gap: 6px;
  margin-top: 2px;
}

.book-entry-actions button {
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 8px;
  background: rgba(37, 54, 32, 0.92);
  color: #edf8f0;
  padding: 4px 8px;
  font-size: 0.88rem;
  cursor: pointer;
  min-width: 38px;
}

.book-entry-actions button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  filter: grayscale(0.35);
}

.book-workshop {
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 10px;
  background: rgba(14, 22, 16, 0.82);
  padding: 8px;
  display: grid;
  gap: 6px;
}

.book-workshop h3 {
  margin: 0;
  font-size: 0.82rem;
  color: var(--accent);
}

.book-workshop-grid {
  display: grid;
  gap: 6px;
}

.book-workshop-row {
  border: 1px solid rgba(255, 255, 255, 0.11);
  border-radius: 8px;
  background: rgba(19, 30, 22, 0.82);
  padding: 6px 7px;
  display: grid;
  gap: 4px;
}

.book-workshop-row-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
}

.book-workshop-row-title {
  font-size: 0.78rem;
  font-weight: 700;
  color: #eef8f1;
}

.book-workshop-row-state {
  font-size: 0.7rem;
  color: #b6d0bd;
}

.book-workshop-row-line {
  font-size: 0.72rem;
  color: #b2ccb9;
}

.book-workshop-row button {
  justify-self: start;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 8px;
  background: rgba(36, 52, 33, 0.9);
  color: #edf8f0;
  padding: 4px 8px;
  font-size: 0.8rem;
  cursor: pointer;
}

.book-workshop-row button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  filter: grayscale(0.35);
}

.book-entry.muted .book-entry-title,
.book-entry.muted .book-entry-state,
.book-entry.muted .book-entry-line {
  color: #92a99a;
}

.vial-bar {
  position: fixed;
  bottom: 8px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 6;
  background: rgba(9, 16, 12, 0.84);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 10px;
  padding: 6px 8px;
}

.vial-bar.hidden {
  display: none;
}

.vial-slots {
  display: flex;
  gap: 6px;
}

.action-slot {
  width: 62px;
  min-height: 44px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  background: rgba(17, 28, 20, 0.9);
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.76rem;
}

.action-slot .key {
  position: absolute;
  top: 2px;
  left: 4px;
  color: rgba(206, 227, 213, 0.85);
  font-size: 0.64rem;
}

.action-slot .slot-content {
  font-weight: 700;
  color: #edf8f0;
  text-align: center;
  user-select: none;
}

.fixed-slot .slot-content {
  font-size: 0.7rem;
}

.action-slot.disabled {
  opacity: 0.45;
  filter: grayscale(0.35);
}

.vial-slot.filled .slot-content {
  cursor: grab;
}

.vial-slot.drag-over {
  outline: 2px solid rgba(142, 226, 167, 0.95);
}

.cauldron-menu {
  position: fixed;
  z-index: 7;
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: rgba(7, 12, 8, 0.88);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 10px;
  padding: 8px;
  min-width: 170px;
  pointer-events: auto;
}

.cauldron-menu.hidden {
  display: none;
}

.cauldron-menu button {
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 8px;
  background: linear-gradient(180deg, #345035, #22361f);
  color: var(--text);
  padding: 6px 8px;
  font-size: 0.8rem;
  cursor: pointer;
}

.cauldron-menu button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.help-tooltip {
  position: fixed;
  z-index: 20;
  max-width: 320px;
  padding: 6px 8px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  background: rgba(8, 14, 10, 0.94);
  color: #edf8f0;
  font-size: 0.78rem;
  line-height: 1.3;
  pointer-events: none;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35);
}

.help-tooltip.hidden {
  display: none;
}

.profile-overlay {
  position: fixed;
  inset: 0;
  z-index: 30;
  background: rgba(6, 11, 8, 0.84);
  display: grid;
  place-items: center;
  pointer-events: auto;
}

.profile-overlay.hidden {
  display: none;
}

.profile-card {
  width: min(520px, calc(100vw - 28px));
  max-height: min(84vh, 720px);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 12px;
  background: rgba(9, 16, 12, 0.94);
  padding: 12px;
  display: grid;
  gap: 10px;
}

.profile-card h2 {
  margin: 0;
  color: var(--accent);
  font-size: 1rem;
}

.profile-card p {
  margin: 0;
  color: #d7e8db;
  font-size: 0.8rem;
}

.profile-list {
  display: grid;
  gap: 8px;
  overflow: auto;
  max-height: min(48vh, 360px);
  padding-right: 2px;
}

.profile-entry {
  border: 1px solid rgba(255, 255, 255, 0.17);
  border-radius: 10px;
  background: rgba(21, 32, 24, 0.86);
  padding: 8px;
  display: grid;
  gap: 4px;
}

.profile-entry button {
  justify-self: start;
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 8px;
  background: linear-gradient(180deg, #3f5b34, #2b4223);
  color: #edf8f0;
  padding: 5px 9px;
  font-size: 0.8rem;
  cursor: pointer;
}

.profile-name {
  font-size: 0.86rem;
  font-weight: 700;
  color: #eff8f1;
}

.profile-meta {
  font-size: 0.74rem;
  color: #bfd5c5;
}

.profile-empty {
  border: 1px dashed rgba(255, 255, 255, 0.2);
  border-radius: 10px;
  padding: 10px;
  color: #bfd7c6;
  font-size: 0.78rem;
  background: rgba(16, 25, 18, 0.82);
}

.profile-create {
  display: flex;
  gap: 8px;
}

.profile-create input {
  flex: 1;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.24);
  background: rgba(12, 22, 15, 0.92);
  color: #eef8f1;
  padding: 7px 9px;
  font-size: 0.82rem;
}

.profile-create button {
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 8px;
  background: linear-gradient(180deg, #4f6537, #334727);
  color: #edf8f0;
  padding: 7px 10px;
  font-size: 0.8rem;
  cursor: pointer;
}

@media (max-width: 900px) {
  .hud-wrap {
    max-width: calc(100vw - 20px);
    grid-template-columns: 1fr;
  }

  .quest-log {
    top: auto;
    bottom: 128px;
    right: 10px;
    width: min(360px, calc(100vw - 20px));
  }

  .resource-bar {
    width: calc(100vw - 18px);
    left: 9px;
    transform: none;
    overflow-x: auto;
    padding-bottom: 2px;
  }

  .potion-book {
    left: 10px;
    transform: none;
    width: calc(100vw - 20px);
    bottom: 116px;
  }

  .progress-panel {
    width: calc(100vw - 20px);
    max-height: min(56vh, 520px);
    right: 10px;
  }

  .title,
  .legend {
    grid-column: span 1;
  }
}
