* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: #0d0c11;
  color: #e8e4f0;
  font: 15px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
}

#game {
  display: flex;
  flex-direction: column;
  height: 100%;
  max-width: 720px;
  margin: 0 auto;
  padding: env(safe-area-inset-top) 8px env(safe-area-inset-bottom);
}

#hud {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 14px;
  padding: 8px 4px;
  font-variant-numeric: tabular-nums;
}
#hud-timer.urgent { color: #ff6b5e; font-weight: 700; }

#board {
  position: relative;
  flex: 1 1 auto;
  min-height: 200px;
  border-radius: 8px;
  overflow: hidden;
  background: #000;
}
#map { display: block; width: 100%; height: 100%; }

#log {
  list-style: none;
  margin: 6px 0 0;
  padding: 0 4px;
  height: 7.5em;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  font-size: 13px;
}
#log li { color: #a9a3b8; }
#log li.combat { color: #e8e4f0; }
#log li.system { color: #ffcf4a; font-weight: 600; }
#log li.danger { color: #ff6b5e; font-weight: 600; }
#log li.good   { color: #7ee08a; }

#controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 0 12px;
}

#pad {
  display: grid;
  grid-template-columns: repeat(3, 56px);
  grid-template-rows: repeat(3, 56px);
  gap: 6px;
}

#actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex: 1;
  max-width: 220px;
}

button {
  min-height: 48px;
  border: 0;
  border-radius: 10px;
  background: #2a2733;
  color: inherit;
  font: inherit;
  font-size: 18px;
  cursor: pointer;
}
button:active { background: #3d3948; }
button:disabled { opacity: 0.4; }
#btn-descend { background: #6b4f12; color: #fff1c9; font-weight: 700; }

#overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(5, 4, 8, 0.88);
}
#overlay[hidden] { display: none; }
.card {
  max-width: 420px;
  padding: 24px;
  border-radius: 14px;
  background: #1a1822;
  text-align: center;
}
.card h1 { margin: 0 0 12px; color: #ffcf4a; }
.card p { color: #c9c3d6; }
.card button { width: 100%; margin-top: 12px; background: #6b4f12; color: #fff1c9; font-weight: 700; }

/* Banners over the map */
.toast {
  position: absolute;
  top: 10px;
  left: 10px;
  right: 10px;
  padding: 12px 14px;
  border-radius: 12px;
  border: 2px solid #8a8399;
  background: rgba(22, 20, 30, 0.96);
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.6);
  text-align: center;
  cursor: pointer;
  animation: drop-in 0.25s ease-out;
}
.toast[hidden] { display: none; }
.toast-title { font-weight: 800; font-size: 17px; }
.toast-body { margin-top: 4px; color: #e8e4f0; }
.toast-note { margin-top: 4px; font-size: 13px; color: #a9a3b8; }
.toast-note:empty { display: none; }
.toast.achievement { border-color: #ffcf4a; }
.toast.achievement .toast-title { color: #ffcf4a; font-size: 18px; }
.toast.box.bronze    { border-color: #b87333; }
.toast.box.silver    { border-color: #c0c6d0; }
.toast.box.gold      { border-color: #ffcf4a; }
.toast.box.legendary { border-color: #c77dff; }
@keyframes drop-in {
  from { transform: translateY(-16px); opacity: 0; }
  to   { transform: none; opacity: 1; }
}

/* Gear panel */
#sheet {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(5, 4, 8, 0.88);
}
#sheet[hidden] { display: none; }
.sheet-card {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-height: 100%;
  text-align: left;
}
#sheet-body { overflow-y: auto; min-height: 0; }
.sheet-card h2 { margin: 18px 0 8px; font-size: 15px; color: #ffcf4a; }
.sheet-card h2:first-child { margin-top: 0; }
.sheet-card ul { list-style: none; margin: 0; padding: 0; }
.stats li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 7px 0;
  border-bottom: 1px solid #2a2733;
}
.stats li span:last-child { color: #c9c3d6; white-space: nowrap; }
.stats li.empty { color: #8a8399; }
.stats li.tier-silver    span:first-child { color: #d9dee6; }
.stats li.tier-gold      span:first-child { color: #ffcf4a; }
.stats li.tier-legendary span:first-child { color: #c77dff; }
.achievements li { padding: 7px 0; border-bottom: 1px solid #2a2733; }
.achievements li span { display: block; font-size: 13px; color: #a9a3b8; }
.achievements li.locked { color: #6b6578; }
#sheet-close { flex: none; }
