* {
  box-sizing: border-box;
}

:root {
  color-scheme: dark;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
}

/* ---------- Landing ---------- */
.landing-body {
  min-height: 100vh;
  background: linear-gradient(160deg, #1a3a6e 0%, #3264b4 45%, #5a9fd4 100%);
  color: #fff;
}

.landing {
  max-width: 460px;
  margin: 0 auto;
  padding: 48px 20px 32px;
  text-align: center;
}

.landing h1 {
  margin: 0 0 8px;
  font-size: 2.6rem;
  letter-spacing: 0.5px;
}

.tagline {
  margin: 0 0 24px;
  opacity: 0.92;
}

.card {
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 16px;
  padding: 22px;
  text-align: left;
}

.card label {
  display: block;
  margin: 6px 0;
  font-weight: 600;
}

.card input[type="text"] {
  width: 100%;
  padding: 12px 14px;
  border: none;
  border-radius: 10px;
  font-size: 1rem;
}

.card small {
  display: block;
  margin-top: 6px;
  opacity: 0.8;
}

.char-pick {
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 12px;
  margin: 18px 0;
  padding: 12px;
  display: flex;
  gap: 12px;
  justify-content: center;
}

.char-pick legend {
  padding: 0 8px;
  font-weight: 600;
}

.char-option {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  padding: 8px 14px;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.15);
}

.char-preview {
  width: 32px;
  height: 32px;
  object-fit: none;
  object-position: 0 0;
  image-rendering: pixelated;
  transform: scale(1.75);
  transform-origin: center;
  margin: 8px 0;
  background: rgba(255, 255, 255, 0.15);
  border-radius: 6px;
}

.primary {
  width: 100%;
  padding: 14px;
  border: none;
  border-radius: 10px;
  background: #228b22;
  color: #fff;
  font-size: 1.1rem;
  font-weight: 700;
  cursor: pointer;
}

.primary:hover {
  background: #2aa32a;
}

.primary:disabled,
.secondary:disabled {
  opacity: 0.6;
  cursor: wait;
}

.secondary {
  width: 100%;
  padding: 12px;
  border: 1px solid rgba(255, 255, 255, 0.45);
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.2);
  color: #fff;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
}

.secondary:hover {
  background: rgba(0, 0, 0, 0.35);
}

.actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 8px;
}

.card label[for="pin"] {
  margin-top: 14px;
}

.remember-banner {
  background: rgba(255, 255, 255, 0.14);
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 14px;
  padding: 14px 18px;
  margin-bottom: 16px;
  text-align: left;
}

.remember-banner p {
  margin: 0 0 6px;
}

.remember-hint {
  opacity: 0.9;
  font-size: 0.9rem;
}

.linkish {
  margin-top: 4px;
  padding: 0;
  border: none;
  background: none;
  color: #ffe680;
  text-decoration: underline;
  cursor: pointer;
  font-size: 0.9rem;
}

.error {
  margin: 12px 0 0;
  color: #ffd0d0;
}

.admin-link {
  margin-top: 26px;
  font-size: 0.9rem;
}

.admin-link a {
  color: rgba(255, 255, 255, 0.85);
}

/* ---------- Game ---------- */
.game-body {
  margin: 0;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  background: #000;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

#game-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  image-rendering: pixelated;
  background: #101418;
}

#hud {
  position: fixed;
  top: 10px;
  left: 12px;
  z-index: 16;
  color: #fff;
  font-size: 0.85rem;
  text-shadow: 0 1px 2px #000;
  pointer-events: none;
  max-width: min(220px, 28vw);
}

.hud-meters {
  margin-top: 6px;
  min-width: 160px;
  padding: 6px 8px;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.45);
}

.meter-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
}

.meter-row:first-child {
  margin-top: 0;
}

.meter-row span {
  width: 48px;
  font-size: 0.75rem;
}

.meter-track {
  flex: 1;
  height: 10px;
  border-radius: 5px;
  background: rgba(0, 0, 0, 0.45);
  overflow: hidden;
}

.meter-bar {
  height: 100%;
  width: 100%;
  transition: width 0.12s linear;
}

.meter-bar.health {
  background: linear-gradient(90deg, #1e8449, #2ecc71);
}

.meter-bar.health.low {
  background: linear-gradient(90deg, #922b21, #e74c3c);
}

.meter-bar.hunger {
  background: linear-gradient(90deg, #d35400, #f39c12);
}

.meter-bar.hunger.low {
  background: linear-gradient(90deg, #922b21, #e74c3c);
}

.meter-bar.hunger.empty,
.meter-bar.health.empty {
  width: 0% !important;
}

.time-phase {
  margin-top: 4px;
  font-size: 0.75rem;
  opacity: 0.85;
  text-transform: capitalize;
}

.time-phase.night {
  color: #c8b0ff;
  font-weight: 700;
}

.hunger-warning {
  position: fixed;
  left: 50%;
  top: 20%;
  transform: translateX(-50%);
  z-index: 24;
  padding: 16px 20px;
  border-radius: 12px;
  background: rgba(80, 10, 10, 0.92);
  border: 2px solid rgba(255, 100, 100, 0.7);
  color: #fff;
  text-align: center;
  pointer-events: auto;
}

.hunger-warning button {
  margin-top: 8px;
  padding: 8px 14px;
  border: none;
  border-radius: 8px;
  background: #f39c12;
  color: #111;
  font-weight: 700;
  cursor: pointer;
}

#hud .scene-name {
  font-weight: 700;
  font-size: 1rem;
}

#conn-status {
  position: fixed;
  top: 10px;
  right: 12px;
  z-index: 5;
  font-size: 0.8rem;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.5);
  color: #fff;
}

#conn-status.online {
  background: rgba(34, 139, 34, 0.85);
}

#conn-status.offline {
  background: rgba(178, 34, 34, 0.85);
}

/* Touch joystick */
#touch-controls {
  position: fixed;
  inset: 0;
  z-index: 4;
  pointer-events: none;
}

#joystick {
  position: absolute;
  left: 24px;
  bottom: 28px;
  width: 132px;
  height: 132px;
  border-radius: 50%;
  border: 3px solid rgba(200, 200, 200, 0.5);
  background: rgba(40, 40, 40, 0.45);
  pointer-events: auto;
}

#joystick-knob {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 56px;
  height: 56px;
  margin: -28px 0 0 -28px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.85);
  background: rgba(180, 180, 190, 0.9);
}

.action-btn {
  position: absolute;
  right: 28px;
  bottom: 40px;
  width: 84px;
  height: 84px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.85);
  background: rgba(50, 100, 55, 0.85);
  color: #fff;
  font-size: 1.4rem;
  font-weight: 700;
  pointer-events: auto;
}

.block-btn {
  position: absolute;
  right: 120px;
  bottom: 48px;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.35);
  background: rgba(60, 90, 160, 0.35);
  color: rgba(255, 255, 255, 0.45);
  font-size: 1.2rem;
  font-weight: 700;
  pointer-events: auto;
  transition: background 0.15s, opacity 0.15s, box-shadow 0.15s, color 0.15s;
}

.block-btn.m-available,
.block-btn.m-mining,
body.in-combat .block-btn {
  border-color: rgba(255, 255, 255, 0.9);
  background: rgba(60, 110, 200, 0.95);
  color: #fff;
  box-shadow: 0 0 14px rgba(120, 180, 255, 0.85);
}

.block-btn.m-mining {
  background: rgba(140, 100, 200, 0.95);
  box-shadow: 0 0 14px rgba(200, 160, 255, 0.9);
}

/* Always show N/M action buttons; joystick only on touch. */
@media (pointer: fine) {
  #joystick {
    display: none;
  }
}

/* ---------- Craft bubble + panel ---------- */
/* Bag / Stats / Craft cluster (tablet + desktop) */
.menu-cluster {
  position: fixed;
  right: 16px;
  bottom: 180px;
  z-index: 16;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 10px;
  pointer-events: none;
}

.menu-cluster > * {
  pointer-events: auto;
}

.menu-btn,
.craft-bubble {
  min-width: 72px;
  min-height: 44px;
  padding: 12px 18px;
  border-radius: 999px;
  border: 2px solid rgba(255, 255, 255, 0.85);
  color: #fff;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

.menu-btn-bag {
  background: rgba(50, 80, 140, 0.92);
  border-color: rgba(160, 190, 255, 0.9);
}

.menu-btn-bag:hover,
.menu-btn-bag.active {
  background: rgba(70, 110, 180, 0.95);
}

.menu-btn-stats {
  background: rgba(120, 50, 90, 0.92);
  border-color: rgba(255, 180, 210, 0.9);
}

.menu-btn-stats:hover,
.menu-btn-stats.active {
  background: rgba(150, 70, 110, 0.95);
}

.craft-bubble {
  border-color: rgba(255, 220, 160, 0.9);
  background: rgba(140, 90, 40, 0.92);
}

.craft-bubble:hover {
  background: rgba(170, 110, 50, 0.95);
}

.hotbar-bag {
  width: 52px;
  height: 52px;
  border-radius: 8px;
  border: 2px solid rgba(160, 190, 255, 0.85);
  background: rgba(50, 80, 140, 0.92);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
  cursor: pointer;
  margin-right: 4px;
  flex-shrink: 0;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.panel-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  background: rgba(0, 0, 0, 0.45);
  touch-action: none;
}

.panel-backdrop[hidden] {
  display: none !important;
}

body.panel-open #touch-controls {
  pointer-events: none;
}

.craft-backdrop {
  position: fixed;
  inset: 0;
  z-index: 22;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(0, 0, 0, 0.55);
}

.craft-backdrop[hidden] {
  display: none !important;
}

.craft-window {
  width: min(720px, calc(100vw - 24px));
  max-height: min(80vh, 560px);
  overflow: auto;
  padding: 16px;
  border-radius: 14px;
  background: rgba(28, 24, 20, 0.98);
  border: 2px solid rgba(200, 160, 90, 0.75);
  color: #fff;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
}

.craft-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.craft-panel-header h2 {
  margin: 0;
  font-size: 1.25rem;
  color: #ffd27a;
}

.craft-close {
  padding: 6px 12px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.3);
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  cursor: pointer;
}

.craft-help {
  margin: 0 0 12px;
  font-size: 0.9rem;
  opacity: 0.9;
}

.craft-columns {
  display: grid;
  grid-template-columns: 1fr 1.4fr;
  gap: 14px;
}

@media (max-width: 640px) {
  .craft-columns {
    grid-template-columns: 1fr;
  }
}

.craft-col h3 {
  margin: 0 0 8px;
  font-size: 0.95rem;
  color: #e8c98a;
}

.craft-inventory,
.craft-list {
  min-height: 120px;
  max-height: 340px;
  overflow: auto;
  padding: 8px;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.28);
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.craft-inv-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.craft-inv-list li {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 8px;
  margin-bottom: 4px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.06);
}

.craft-inv-count {
  font-weight: 700;
  color: #9fd4ff;
}

.craft-empty {
  margin: 8px;
  opacity: 0.75;
  font-size: 0.85rem;
}

.craft-recipe-card {
  display: block;
  width: 100%;
  text-align: left;
  padding: 10px 12px;
  margin-bottom: 8px;
  border-radius: 10px;
  border: 2px solid rgba(255, 255, 255, 0.15);
  background: rgba(255, 255, 255, 0.05);
  color: #bbb;
  cursor: pointer;
}

.craft-recipe-card.ready {
  background: rgba(70, 120, 45, 0.45);
  border-color: rgba(150, 220, 90, 0.85);
  color: #fff;
}

.craft-recipe-card.ready:hover {
  background: rgba(90, 150, 55, 0.55);
}

.craft-recipe-card.locked {
  cursor: not-allowed;
  opacity: 0.85;
}

.craft-recipe-card.selected {
  box-shadow: 0 0 0 2px rgba(255, 210, 120, 0.6);
}

.craft-recipe-out {
  font-weight: 700;
  font-size: 1rem;
  margin-bottom: 4px;
}

.craft-recipe-ings {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 4px;
}

.craft-recipe-ings .ing {
  font-size: 0.8rem;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.25);
}

.craft-recipe-ings .ing.have {
  color: #b6f5b6;
}

.craft-recipe-ings .ing.lack {
  color: #ffb0b0;
}

.craft-recipe-action {
  font-size: 0.78rem;
  opacity: 0.85;
}

.craft-recipe-card.ready .craft-recipe-action {
  color: #d8ffb0;
  font-weight: 700;
}

.craft-status {
  min-height: 1.2em;
  margin: 12px 0 0;
  font-weight: 700;
  text-align: center;
}

.craft-status.ok {
  color: #9dff9d;
}

.craft-status.err {
  color: #ffb0b0;
}

/* ---------- Dialogue ---------- */
.dialogue-box {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%);
  width: min(900px, calc(100vw - 24px));
  padding: 18px 22px 14px;
  border-radius: 10px;
  border: 3px solid rgba(255, 255, 255, 0.9);
  background: rgba(30, 30, 40, 0.94);
  color: #f5f5f5;
  z-index: 20;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.55);
}

.dialogue-name {
  font-size: 1.15rem;
  font-weight: 700;
  color: #ffd700;
  margin-bottom: 8px;
}

.dialogue-text {
  margin: 0 0 14px;
  font-size: 1.05rem;
  line-height: 1.45;
  white-space: pre-wrap;
}

.dialogue-options {
  list-style: none;
  margin: 0;
  padding: 0;
}

.dialogue-options li {
  margin: 4px 0;
}

.dialogue-options button {
  width: 100%;
  text-align: left;
  padding: 8px 12px;
  border: none;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.08);
  color: #ccc;
  font-size: 0.95rem;
  cursor: pointer;
}

.dialogue-options button:hover,
.dialogue-options button:focus {
  background: rgba(255, 255, 0, 0.18);
  color: #fff;
}

.dialogue-actions {
  margin-top: 8px;
  display: flex;
  justify-content: flex-end;
}

.dialogue-give {
  padding: 8px 16px;
  border: 2px solid #fff;
  border-radius: 10px;
  background: #e68c28;
  color: #fff;
  font-weight: 700;
  cursor: pointer;
}

.dialogue-give:hover {
  background: #f0a040;
}

.dialogue-hint {
  margin: 10px 0 0;
  font-size: 0.75rem;
  opacity: 0.65;
  text-align: right;
}

/* ---------- Hotbar ---------- */
.hotbar {
  position: fixed;
  left: 50%;
  bottom: max(12px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 15;
  pointer-events: auto;
  padding-bottom: env(safe-area-inset-bottom);
}

.hotbar-slots {
  display: flex;
  gap: 6px;
  padding: 8px;
  border-radius: 12px;
  background: rgba(20, 20, 28, 0.88);
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.hotbar-slot {
  position: relative;
  width: 52px;
  height: 52px;
  border-radius: 8px;
  border: 2px solid rgba(255, 255, 255, 0.25);
  background: rgba(50, 50, 60, 0.9);
  color: #fff;
  cursor: pointer;
  padding: 0;
  overflow: hidden;
}

.hotbar-slot.selected {
  border-color: #6af;
  box-shadow: 0 0 10px rgba(100, 170, 255, 0.7);
}

.hotbar-slot.empty {
  opacity: 0.45;
  cursor: default;
}

.hotbar-icon {
  width: 100%;
  height: 100%;
  object-fit: contain;
  image-rendering: pixelated;
}

.hotbar-name {
  font-size: 0.55rem;
  display: block;
  padding: 4px 2px;
  line-height: 1.1;
}

.hotbar-count {
  position: absolute;
  right: 3px;
  bottom: 2px;
  font-size: 0.7rem;
  font-weight: 700;
  text-shadow: 0 1px 2px #000;
}

.hotbar-key {
  position: absolute;
  left: 3px;
  top: 1px;
  font-size: 0.6rem;
  opacity: 0.7;
}

/* ---------- Side panels (I / E) ---------- */
.side-panel {
  position: fixed;
  right: 12px;
  top: 56px;
  z-index: 21;
  width: min(300px, calc(100vw - 24px));
  max-height: min(70vh, 480px);
  overflow: auto;
  padding: 14px;
  border-radius: 12px;
  background: rgba(22, 24, 34, 0.96);
  border: 1px solid rgba(255, 255, 255, 0.25);
  color: #fff;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.panel-header h2 {
  margin: 0;
  font-size: 1.1rem;
}

.panel-header button,
.panel-close,
.give-panel .panel-header button {
  min-height: 40px;
  min-width: 64px;
  padding: 8px 14px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.3);
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  cursor: pointer;
  touch-action: manipulation;
  font-size: 0.95rem;
  font-weight: 600;
}

.panel-claim {
  min-height: 44px;
  width: 100%;
  margin-top: 8px;
  touch-action: manipulation;
}

.panel-meta {
  margin: 0 0 8px;
  color: #ffb6c1;
}

.panel-hint {
  margin: 10px 0 0;
  font-size: 0.72rem;
  opacity: 0.65;
}

.inv-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.inv-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  min-height: 44px;
  padding: 10px 12px;
  margin-bottom: 6px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
  cursor: pointer;
  touch-action: manipulation;
}

.inv-row.selected {
  outline: 2px solid #6af;
}

.inv-empty {
  opacity: 0.7;
  padding: 8px;
}

.stats-grid {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 6px 12px;
  margin: 0 0 12px;
}

.stats-grid dt {
  opacity: 0.7;
}

.stats-grid dd {
  margin: 0;
  font-weight: 700;
}

.give-panel {
  position: fixed;
  left: 50%;
  top: 40%;
  transform: translate(-50%, -50%);
  z-index: 23;
  width: min(360px, calc(100vw - 24px));
  max-height: 50vh;
  overflow: auto;
  padding: 14px;
  border-radius: 12px;
  background: rgba(30, 30, 40, 0.97);
  border: 2px solid rgba(230, 140, 40, 0.8);
  color: #fff;
}

.give-list {
  list-style: none;
  margin: 0 0 10px;
  padding: 0;
}

.give-item {
  width: 100%;
  text-align: left;
  padding: 8px 10px;
  margin-bottom: 4px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  cursor: pointer;
}

.give-item.selected {
  background: rgba(70, 100, 70, 0.8);
  border-color: #8c8;
}

.give-confirm {
  width: 100%;
  padding: 10px;
  border: none;
  border-radius: 8px;
  background: #e68c28;
  color: #fff;
  font-weight: 700;
  cursor: pointer;
}

/* Lift action buttons above hotbar on touch */
#touch-controls .action-btn {
  bottom: 100px;
}
#touch-controls .block-btn {
  bottom: 108px;
}

/* Bottom-sheet panels on phones / short landscape tablets */
@media (max-width: 900px), (max-height: 560px) {
  .side-panel {
    left: 0;
    right: 0;
    top: auto;
    bottom: 0;
    width: 100%;
    max-width: none;
    max-height: min(70vh, 520px);
    border-radius: 16px 16px 0 0;
    padding: 16px 16px max(16px, env(safe-area-inset-bottom));
    box-shadow: 0 -8px 28px rgba(0, 0, 0, 0.45);
  }

  .menu-cluster {
    bottom: 200px;
  }

  .hotbar-bag {
    width: 56px;
    height: 56px;
    font-size: 0.75rem;
  }
}

#interact-prompt {
  position: fixed;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -80px);
  z-index: 6;
  padding: 6px 14px;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.55);
  color: #ffff00;
  font-size: 0.9rem;
  pointer-events: none;
  text-shadow: 0 1px 2px #000;
}

/* ---------- Debug HUD (Phase 2 game state) ---------- */
.debug-hud {
  position: fixed;
  top: 42px;
  right: 12px;
  left: auto;
  bottom: auto;
  z-index: 15;
  max-width: min(360px, calc(100vw - 24px));
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #e8e8e8;
  font-size: 0.78rem;
  line-height: 1.4;
  pointer-events: auto;
  text-align: left;
}

.debug-hud .debug-title {
  font-weight: 700;
  margin-bottom: 6px;
  color: #9fd4ff;
}

.debug-hud .debug-phase {
  font-weight: 500;
  opacity: 0.7;
  font-size: 0.7rem;
}

.debug-hud strong {
  color: #bbb;
}

.debug-actions {
  margin-top: 8px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.debug-actions button {
  padding: 4px 10px;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.35);
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  font-size: 0.75rem;
  cursor: pointer;
}

.debug-actions button:hover {
  background: rgba(255, 255, 255, 0.2);
}

/* ---------- Combat HUD ---------- */
.combat-hud {
  position: fixed;
  left: 50%;
  top: 16px;
  transform: translateX(-50%);
  z-index: 18;
  width: min(420px, calc(100vw - 24px));
  padding: 12px 16px;
  border-radius: 12px;
  background: rgba(20, 10, 10, 0.88);
  border: 2px solid rgba(255, 80, 80, 0.55);
  color: #fff;
  text-align: left;
}

.combat-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 6px 0;
}

.combat-label {
  width: 88px;
  font-size: 0.85rem;
  font-weight: 700;
  flex-shrink: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.combat-bar-track {
  flex: 1;
  height: 14px;
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.15);
  overflow: hidden;
}

.combat-bar {
  height: 100%;
  width: 100%;
  border-radius: 7px;
  transition: width 0.12s linear;
}

.combat-bar.enemy {
  background: linear-gradient(90deg, #c0392b, #e74c3c);
}

.combat-bar.player {
  background: linear-gradient(90deg, #27ae60, #2ecc71);
}

.combat-flash {
  margin: 8px 0 0;
  text-align: center;
  color: #ffe680;
  font-weight: 700;
  min-height: 1.2em;
}

.combat-hint {
  margin: 6px 0 0;
  text-align: center;
  font-size: 0.8rem;
  opacity: 0.85;
}

/* ---------- Death screen ---------- */
.death-screen {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(120, 0, 0, 0.82);
  color: #fff;
  text-align: center;
  gap: 12px;
}

.death-screen[hidden] {
  display: none !important;
}

.death-screen h2 {
  margin: 0;
  font-size: 2rem;
}

.death-screen button {
  margin-top: 8px;
  padding: 12px 28px;
  border: none;
  border-radius: 10px;
  background: #fff;
  color: #800;
  font-size: 1.1rem;
  font-weight: 700;
  cursor: pointer;
}

/* ---------- Mission HUD ---------- */
.mission-hud {
  position: fixed;
  left: 12px;
  /* Sit below scene name + health/hunger meters, not over the playfield center */
  top: 148px;
  z-index: 14;
  width: min(240px, 32vw);
  max-height: min(200px, 28vh);
  overflow: auto;
  padding: 8px 10px;
  border-radius: 10px;
  background: rgba(20, 24, 40, 0.88);
  border: 1px solid rgba(255, 215, 0, 0.45);
  color: #f5f5f5;
  font-size: 0.75rem;
  line-height: 1.3;
  pointer-events: auto;
}

.mission-hud.has-gate {
  max-height: min(260px, 36vh);
  border-color: rgba(255, 140, 80, 0.75);
}

.mission-title {
  font-weight: 700;
  color: #ffd700;
  margin-bottom: 2px;
  font-size: 0.78rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mission-instructions {
  margin: 0 0 6px;
  opacity: 0.92;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.mission-gate {
  margin: 0 0 6px;
  padding: 5px 7px;
  border-radius: 6px;
  background: rgba(120, 40, 20, 0.55);
  border: 1px solid rgba(255, 140, 80, 0.7);
  color: #ffd0a8;
  font-size: 0.72rem;
  font-weight: 600;
  line-height: 1.25;
}

.mission-gate.ready {
  background: rgba(30, 90, 40, 0.55);
  border-color: rgba(120, 220, 120, 0.75);
  color: #c8f5c8;
}

.mission-gate[hidden] {
  display: none !important;
}

.mission-pending {
  font-size: 0.72rem;
  color: #ffb6c1;
  margin-bottom: 4px;
}

.mission-claim {
  display: block;
  width: 100%;
  padding: 6px 8px;
  border: none;
  border-radius: 8px;
  background: #c0392b;
  color: #fff;
  font-weight: 700;
  font-size: 0.75rem;
  cursor: pointer;
}

.mission-claim:hover:not(:disabled) {
  background: #e74c3c;
}

.mission-claim:disabled {
  background: rgba(80, 80, 90, 0.7);
  color: rgba(255, 255, 255, 0.4);
  cursor: not-allowed;
  box-shadow: none;
}

.mission-hint {
  margin: 4px 0 0;
  font-size: 0.65rem;
  opacity: 0.65;
}

.mission-toast {
  position: fixed;
  left: 50%;
  top: 72px;
  transform: translateX(-50%);
  z-index: 25;
  max-width: min(480px, calc(100vw - 24px));
  padding: 12px 18px;
  border-radius: 10px;
  background: rgba(20, 60, 30, 0.94);
  border: 2px solid rgba(100, 220, 120, 0.7);
  color: #fff;
  font-weight: 700;
  text-align: center;
  pointer-events: none;
}

.location-toast {
  position: fixed;
  left: 50%;
  bottom: 96px;
  transform: translateX(-50%);
  z-index: 24;
  max-width: min(520px, calc(100vw - 24px));
  padding: 12px 16px;
  border-radius: 10px;
  background: rgba(20, 24, 40, 0.94);
  border: 2px solid rgba(255, 215, 100, 0.65);
  color: #fff;
  font-size: 0.95rem;
  text-align: center;
  pointer-events: none;
  padding-bottom: max(12px, env(safe-area-inset-bottom));
}

/* ---------- Mining progress ---------- */
.mining-hud {
  position: fixed;
  left: 50%;
  bottom: 120px;
  transform: translateX(-50%);
  z-index: 17;
  width: min(280px, calc(100vw - 40px));
  padding: 10px 14px;
  border-radius: 10px;
  background: rgba(20, 20, 30, 0.88);
  border: 2px solid rgba(200, 180, 255, 0.55);
  color: #fff;
  text-align: center;
}

.mining-label {
  font-size: 0.9rem;
  font-weight: 700;
  margin-bottom: 8px;
  color: #d2bee0;
}

.mining-bar-track {
  height: 12px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.15);
  overflow: hidden;
}

.mining-bar {
  height: 100%;
  width: 0%;
  border-radius: 6px;
  background: linear-gradient(90deg, #8e6bb8, #d2bee0);
  transition: width 0.08s linear;
}

.chop-bar {
  background: linear-gradient(90deg, #6b4226, #c4a06a);
}
