* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #241a14;
  font-family: 'Trebuchet MS', 'Segoe UI', system-ui, sans-serif;
  color: #fff5e6;
}

.hidden {
  display: none !important;
}

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

/* ---------------------------------------------------------------- HUD -- */

#hud {
  position: fixed;
  inset: 0;
  pointer-events: none;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}

#hud-top-left {
  position: absolute;
  top: 18px;
  left: 18px;
  display: flex;
  gap: 10px;
}

.hud-chip {
  background: rgba(46, 28, 18, 0.62);
  border: 2px solid rgba(255, 214, 158, 0.4);
  border-radius: 999px;
  padding: 7px 14px;
  font-size: 17px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 6px;
}

#hud-larder {
  gap: 10px;
}

.larder-item {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 15px;
}

.larder-swatch {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  border: 1.5px solid rgba(255, 240, 220, 0.8);
  display: inline-block;
}

#hud-clock {
  position: absolute;
  top: 18px;
  right: 20px;
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.4px;
  color: #ffeccd;
  background: linear-gradient(180deg, rgba(64, 38, 24, 0.82), rgba(38, 23, 15, 0.82));
  border: 2px solid rgba(255, 214, 158, 0.45);
  border-radius: 999px;
  padding: 7px 16px 7px 12px;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.35);
}

.clock-sep {
  width: 1px;
  height: 16px;
  background: rgba(255, 214, 158, 0.35);
}

.sky-icon {
  width: 20px;
  height: 20px;
  display: block;
}

.sky-icon .sky-fill {
  fill: #ffd98f;
}

.sky-icon .sky-stroke {
  stroke: #ffd98f;
  stroke-width: 1.7;
  stroke-linecap: round;
  fill: none;
}

.sky-icon .sky-faint {
  opacity: 0.45;
}

#hud-phase-icon,
#hud-weather {
  display: flex;
  align-items: center;
}

/* Stamina bar, just above the help line. */
#hud-stamina {
  position: absolute;
  left: 50%;
  bottom: 56px;
  transform: translateX(-50%);
  width: 220px;
  height: 10px;
  border-radius: 999px;
  background: rgba(46, 28, 18, 0.6);
  border: 2px solid rgba(255, 214, 158, 0.4);
  overflow: hidden;
}

#hud-stamina-fill {
  height: 100%;
  width: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #8fd14f, #d8e84a);
  transition: width 0.1s linear;
}

#hud-stamina.spent #hud-stamina-fill {
  background: linear-gradient(90deg, #d4553f, #e8883d);
}

/* Bottom-left minimap. */
#hud-minimap {
  position: absolute;
  left: calc(18px + env(safe-area-inset-left));
  bottom: calc(18px + env(safe-area-inset-bottom));
  width: 180px;
  height: 180px;
  border-radius: 50%;
  border: 3px solid rgba(255, 214, 158, 0.5);
  background: rgba(30, 20, 14, 0.55);
}

/* Aiming reticle with the tank count right under it. */
#hud-reticle {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: width 0.12s ease, height 0.12s ease;
  will-change: left, top;
}

#hud-reticle.locked {
  width: 54px;
  height: 54px;
}

/* Corner brackets that close in when a target is locked. */
#hud-reticle .bracket {
  position: absolute;
  width: 12px;
  height: 12px;
  border: 3px solid #ffd24a;
  opacity: 0;
  transition: opacity 0.12s ease;
}

#hud-reticle.locked .bracket {
  opacity: 1;
}

#hud-reticle .bracket.tl { top: 0; left: 0; border-right: none; border-bottom: none; }
#hud-reticle .bracket.tr { top: 0; right: 0; border-left: none; border-bottom: none; }
#hud-reticle .bracket.bl { bottom: 0; left: 0; border-right: none; border-top: none; }
#hud-reticle .bracket.br { bottom: 0; right: 0; border-left: none; border-top: none; }

#hud-reticle::before,
#hud-reticle::after {
  content: '';
  position: absolute;
  background: rgba(255, 246, 230, 0.9);
  box-shadow: 0 0 3px rgba(0, 0, 0, 0.6);
}

#hud-reticle::before {
  width: 2px;
  height: 14px;
}

#hud-reticle::after {
  width: 14px;
  height: 2px;
}

#hud-reticle.locked::before,
#hud-reticle.locked::after {
  background: #ffd24a;
}

#hud-reticle-count {
  position: absolute;
  top: 26px;
  font-size: 15px;
  font-weight: 800;
  color: #fff6e6;
  white-space: nowrap;
}

/* Big centered announcement when you catch something notable. */
#hud-catch {
  position: absolute;
  left: 50%;
  top: 27%;
  transform: translateX(-50%);
  text-align: center;
  font-size: 30px;
  font-weight: 800;
  color: var(--catch-color, #ffd24a);
  text-shadow: 0 3px 8px rgba(0, 0, 0, 0.6);
  opacity: 0;
  transition: opacity 0.25s ease;
  white-space: nowrap;
  pointer-events: none;
}

#hud-catch .catch-rarity {
  display: block;
  font-size: 15px;
  letter-spacing: 3px;
  text-transform: uppercase;
  opacity: 0.95;
}

#hud-prompt {
  position: absolute;
  left: 50%;
  bottom: 96px;
  transform: translateX(-50%);
  background: rgba(46, 28, 18, 0.78);
  border: 2px solid rgba(255, 214, 158, 0.45);
  border-radius: 12px;
  padding: 9px 18px;
  font-size: 17px;
  font-weight: 700;
  opacity: 0;
  transition: opacity 0.15s ease;
  max-width: calc(100vw - 32px);
  text-align: center;
}

#hud-toast {
  position: absolute;
  left: 50%;
  top: 92px;
  transform: translateX(-50%);
  background: rgba(46, 28, 18, 0.8);
  border: 2px solid var(--toast-color, #ffc233);
  color: var(--toast-color, #ffc233);
  border-radius: 12px;
  padding: 10px 20px;
  font-size: 18px;
  font-weight: 700;
  opacity: 0;
  transition: opacity 0.3s ease;
  white-space: nowrap;
}

#hud-help {
  position: absolute;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%);
  font-size: 13px;
  opacity: 0.8;
  text-align: center;
  max-width: calc(100vw - 32px);
}

.pulse {
  display: inline-block;
  animation: pulse 0.4s ease;
}

@keyframes pulse {
  0% { transform: scale(1); }
  40% { transform: scale(1.35); color: #ffe28a; }
  100% { transform: scale(1); }
}

/* -------------------------------------------------------- Home screen -- */

#home-screen {
  position: fixed;
  inset: 0;
  background: linear-gradient(170deg, #2b1c14 0%, #47281c 45%, #7d4a2b 100%);
  overflow-y: auto;
  display: flex;
  justify-content: center;
  padding: 24px 16px;
  z-index: 20;
}

.home-panel {
  width: 100%;
  max-width: 980px;
}

.home-title {
  margin: 8px 0 0;
  font-size: clamp(34px, 7vw, 60px);
  text-align: center;
  color: #ffd98f;
  letter-spacing: 1px;
  text-shadow: 0 4px 0 rgba(0, 0, 0, 0.35);
}

.home-subtitle {
  margin: 2px 0 20px;
  text-align: center;
  color: #ffc98f;
  opacity: 0.85;
  font-size: 16px;
}

.home-tabs {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin-bottom: 18px;
  flex-wrap: wrap;
}

.home-tab {
  background: rgba(255, 233, 200, 0.1);
  border: 2px solid rgba(255, 214, 158, 0.35);
  color: #ffe9cd;
  border-radius: 999px;
  padding: 9px 22px;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
}

.home-tab.active {
  background: #ffd08a;
  color: #46281a;
  border-color: #ffd08a;
}

.home-body {
  padding-bottom: 30px;
}

.home-heading {
  text-align: center;
  font-size: 20px;
  margin: 0 0 14px;
  color: #ffe3b0;
}

.home-stage {
  display: flex;
  justify-content: center;
  margin-bottom: 8px;
}

#home-preview {
  width: 220px;
  height: 300px;
  filter: drop-shadow(0 12px 18px rgba(0, 0, 0, 0.4));
}

.char-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 22px;
}

.char-card {
  background: rgba(30, 18, 12, 0.5);
  border: 3px solid rgba(255, 214, 158, 0.25);
  border-radius: 16px;
  padding: 14px 10px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-family: inherit;
  color: #fff3df;
  transition: transform 0.12s ease, border-color 0.12s ease;
}

.char-card:hover {
  transform: translateY(-3px);
}

.char-card.selected {
  border-color: var(--accent);
  box-shadow: 0 0 22px -4px var(--accent);
  background: rgba(60, 36, 24, 0.75);
}

.char-name {
  font-size: 20px;
  font-weight: 700;
  color: var(--accent);
}

.char-net {
  font-size: 13px;
  opacity: 0.85;
}

.home-primary {
  display: block;
  width: 100%;
  max-width: 340px;
  margin: 0 auto;
  background: linear-gradient(180deg, #ffd98f, #f0a84e);
  color: #46281a;
  border: none;
  border-radius: 14px;
  padding: 16px;
  font-size: 22px;
  font-weight: 800;
  cursor: pointer;
  font-family: inherit;
  box-shadow: 0 5px 0 #b9762f;
}

.home-primary:active {
  transform: translateY(3px);
  box-shadow: 0 2px 0 #b9762f;
}

.home-hint {
  text-align: center;
  font-size: 13px;
  opacity: 0.7;
  margin-top: 14px;
}

/* -------------------------------------------------------- Slime guide -- */

.rarity-legend {
  display: flex;
  gap: 8px;
  justify-content: center;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.rarity-chip {
  border: 2px solid var(--rarity);
  color: var(--rarity);
  border-radius: 999px;
  padding: 4px 14px;
  font-size: 13px;
  font-weight: 700;
}

.combo-box {
  background: rgba(30, 18, 12, 0.55);
  border: 2px solid rgba(255, 214, 158, 0.28);
  border-radius: 16px;
  padding: 16px;
  margin-bottom: 20px;
}

.combo-title {
  margin: 0 0 6px;
  font-size: 18px;
  color: #ffd98f;
}

.combo-help {
  margin: 0 0 14px;
  font-size: 14px;
  opacity: 0.85;
  line-height: 1.45;
}

.combo-pickers {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
}

.combo-select {
  background: rgba(255, 240, 220, 0.94);
  border: 2px solid #b9762f;
  border-radius: 10px;
  padding: 8px 10px;
  font-size: 15px;
  font-family: inherit;
  color: #402318;
  max-width: 200px;
}

.combo-plus {
  font-size: 24px;
  font-weight: 800;
  color: #ffd98f;
}

.combo-result {
  text-align: center;
  margin-top: 14px;
}

.combo-imgs {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-bottom: 8px;
}

.combo-imgs img {
  width: 66px;
  height: 66px;
  object-fit: contain;
}

.combo-name {
  margin: 0;
  font-size: 19px;
  font-weight: 800;
  color: #ffd98f;
}

.combo-value {
  margin: 4px 0 0;
  font-size: 14px;
  opacity: 0.85;
}

.combo-warn {
  margin: 0;
  font-size: 14px;
  color: #ffb4a0;
}

.slime-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(124px, 1fr));
  gap: 12px;
}

.slime-card {
  background: rgba(30, 18, 12, 0.5);
  border: 3px solid var(--rarity);
  border-radius: 14px;
  padding: 10px 8px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
}

.slime-card.glowing {
  box-shadow: 0 0 18px -3px var(--rarity);
}

.slime-card img {
  width: 74px;
  height: 74px;
  object-fit: contain;
}

.slime-card-name {
  font-size: 13px;
  font-weight: 700;
  line-height: 1.2;
}

.slime-card-rarity {
  font-size: 11px;
  font-weight: 700;
  color: var(--rarity);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.slime-card-value {
  font-size: 13px;
  opacity: 0.85;
}

/* ----------------------------------------------------------- Settings -- */

.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  background: rgba(30, 18, 12, 0.5);
  border: 2px solid rgba(255, 214, 158, 0.25);
  border-radius: 14px;
  padding: 14px 16px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.settings-label {
  font-size: 16px;
  font-weight: 700;
}

.settings-options {
  display: flex;
  gap: 8px;
}

.settings-option {
  background: rgba(255, 233, 200, 0.1);
  border: 2px solid rgba(255, 214, 158, 0.35);
  color: #ffe9cd;
  border-radius: 10px;
  padding: 8px 18px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
}

.settings-option.active {
  background: #ffd08a;
  color: #46281a;
}

.settings-danger {
  background: rgba(190, 70, 55, 0.85);
  border: 2px solid #e08070;
  color: #fff0ea;
  border-radius: 10px;
  padding: 9px 18px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
}

/* -------------------------------------------------------------- Pause -- */

#pause-screen {
  position: fixed;
  inset: 0;
  background: rgba(24, 14, 10, 0.72);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 15;
}

.pause-panel {
  background: rgba(46, 28, 18, 0.95);
  border: 3px solid rgba(255, 214, 158, 0.4);
  border-radius: 20px;
  padding: 28px 34px;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 260px;
}

.pause-panel h2 {
  margin: 0 0 6px;
  color: #ffd98f;
  font-size: 26px;
}

/* ------------------------------------------------------ Touch controls -- */

#touch-controls {
  position: fixed;
  inset: 0;
  pointer-events: none;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  z-index: 10;
}

#touch-controls > * {
  pointer-events: auto;
  touch-action: none;
}

#touch-joystick-base {
  position: absolute;
  left: calc(28px + env(safe-area-inset-left));
  bottom: calc(28px + env(safe-area-inset-bottom));
  width: 130px;
  height: 130px;
  border-radius: 50%;
  background: rgba(40, 22, 14, 0.35);
  border: 2px solid rgba(255, 217, 163, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
}

#touch-joystick-knob {
  width: 58px;
  height: 58px;
  border-radius: 50%;
  background: rgba(255, 223, 176, 0.75);
  border: 2px solid rgba(120, 70, 40, 0.5);
}

#touch-interact-btn,
#touch-sprint-btn {
  position: absolute;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  color: #4a2a17;
  background: rgba(255, 223, 176, 0.8);
  border: 2px solid rgba(120, 70, 40, 0.5);
}

#touch-interact-btn {
  right: calc(32px + env(safe-area-inset-right));
  bottom: calc(56px + env(safe-area-inset-bottom));
  width: 92px;
  height: 92px;
  font-size: 30px;
}

#touch-sprint-btn {
  right: calc(140px + env(safe-area-inset-right));
  bottom: calc(40px + env(safe-area-inset-bottom));
  width: 66px;
  height: 66px;
  font-size: 24px;
}

#touch-interact-btn:active,
#touch-sprint-btn:active {
  background: rgba(255, 238, 205, 0.95);
  transform: scale(0.94);
}

/* Jump / drop one / empty tank, stacked above the E button. */
.touch-small-btn {
  position: absolute;
  width: 54px;
  height: 54px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  font-weight: 800;
  color: #4a2a17;
  background: rgba(255, 223, 176, 0.72);
  border: 2px solid rgba(120, 70, 40, 0.5);
}

.touch-small-btn:active {
  background: rgba(255, 238, 205, 0.95);
  transform: scale(0.94);
}

#touch-jump-btn {
  right: calc(52px + env(safe-area-inset-right));
  bottom: calc(166px + env(safe-area-inset-bottom));
}

#touch-drop-btn {
  right: calc(118px + env(safe-area-inset-right));
  bottom: calc(130px + env(safe-area-inset-bottom));
}

#touch-empty-btn {
  right: calc(176px + env(safe-area-inset-right));
  bottom: calc(100px + env(safe-area-inset-bottom));
}

#touch-pause-btn {
  position: absolute;
  top: calc(16px + env(safe-area-inset-top));
  right: calc(16px + env(safe-area-inset-right));
  width: 46px;
  height: 46px;
  border-radius: 12px;
  background: rgba(46, 28, 18, 0.6);
  border: 2px solid rgba(255, 214, 158, 0.4);
  color: #ffe9cd;
  font-size: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
}

body.touch-active #hud-prompt {
  bottom: 240px;
}

body.touch-active #hud-help {
  top: calc(74px + env(safe-area-inset-top));
  bottom: auto;
  font-size: 12px;
}

body.touch-active #hud-minimap {
  width: 120px;
  height: 120px;
  left: auto;
  right: calc(18px + env(safe-area-inset-right));
  bottom: calc(180px + env(safe-area-inset-bottom));
}

body.touch-active #hud-stamina {
  bottom: 160px;
}

body.touch-active #hud-larder {
  gap: 10px;
}

.larder-item {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 15px;
}

.larder-swatch {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  border: 1.5px solid rgba(255, 240, 220, 0.8);
  display: inline-block;
}

#hud-clock {
  right: 74px;
}

/* Narrow/portrait screens: drop the decorative title, tighten the chips. */
@media (max-width: 760px) {
  #hud-larder {
  gap: 10px;
}

.larder-item {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 15px;
}

.larder-swatch {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  border: 1.5px solid rgba(255, 240, 220, 0.8);
  display: inline-block;
}

#hud-clock {
    font-size: 15px;
    padding: 4px 10px;
  }

  #hud-top-left {
    gap: 6px;
    top: 12px;
    left: 12px;
  }

  .hud-chip {
    padding: 6px 10px;
    font-size: 15px;
  }
}

/* ------------------------------------------------------ Loading screen -- */

#loading-screen {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at 50% 40%, #4a2c1e 0%, #1e130d 75%);
}

.loading-panel {
  width: min(420px, calc(100vw - 48px));
  text-align: center;
}

.loading-kicker {
  font-size: 14px;
  letter-spacing: 4px;
  text-transform: uppercase;
  color: #ffe3b0;
  opacity: 0.75;
}

.loading-title {
  margin: 8px 0 22px;
  font-size: clamp(30px, 6vw, 46px);
  font-weight: 800;
  text-shadow: 0 4px 0 rgba(0, 0, 0, 0.35);
}

.loading-bar {
  height: 12px;
  border-radius: 999px;
  background: rgba(255, 214, 158, 0.18);
  border: 2px solid rgba(255, 214, 158, 0.35);
  overflow: hidden;
}

.loading-fill {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, #ffd98f, #f0a84e);
  transition: width 0.25s ease;
}

.loading-tip {
  margin-top: 16px;
  font-size: 14px;
  color: #ffe9cd;
  opacity: 0.8;
}

/* ------------------------------------------------------- Guide details -- */

.combo-rules {
  margin: 0 0 14px;
  padding-left: 18px;
  font-size: 14px;
  line-height: 1.6;
  opacity: 0.92;
}

.combo-out {
  border-radius: 50%;
  box-shadow: 0 0 18px -2px var(--rarity);
}

.slime-card-meta {
  font-size: 11px;
  opacity: 0.85;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.slime-card-family {
  opacity: 0.6;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* ---------------------------------------------------------- achievements */
#hud-achievement {
  position: absolute;
  top: 150px;
  left: 50%;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 18px 10px 12px;
  background: linear-gradient(180deg, rgba(70, 44, 16, 0.94), rgba(46, 28, 12, 0.94));
  border: 2px solid #ffc233;
  border-radius: 14px;
  box-shadow: 0 6px 24px rgba(255, 194, 51, 0.35);
  transform: translate(-50%, -30px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.35s cubic-bezier(0.2, 1.4, 0.4, 1);
}
#hud-achievement.show {
  opacity: 1;
  transform: translate(-50%, 0);
}
#hud-achievement .ach-icon { font-size: 30px; }
#hud-achievement .ach-text { display: flex; flex-direction: column; }
#hud-achievement .ach-kicker {
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #ffd98f;
}
#hud-achievement .ach-name { font-size: 19px; font-weight: 800; color: #fff4d6; }
#hud-achievement .ach-reward { font-size: 17px; font-weight: 800; color: #8fe36a; margin-left: 6px; }

.home-achievements { display: flex; flex-direction: column; gap: 10px; }
.ach-summary { margin: 0; color: #ffd98f; font-weight: 700; }
.ach-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 10px;
  max-height: 56vh;
  overflow-y: auto;
  padding-right: 4px;
}
.ach-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.06);
  border: 2px solid rgba(255, 255, 255, 0.08);
  opacity: 0.75;
}
.ach-card.unlocked {
  opacity: 1;
  border-color: rgba(255, 194, 51, 0.7);
  background: rgba(255, 194, 51, 0.12);
}
.ach-card-icon { font-size: 24px; }
.ach-card-text { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 0; }
.ach-card-name { font-weight: 800; }
.ach-card-desc { font-size: 13px; opacity: 0.8; }
.ach-card-count { font-size: 11px; opacity: 0.7; }
.ach-card-reward { font-weight: 800; color: #8fe36a; }
.ach-bar { height: 5px; border-radius: 3px; background: rgba(255, 255, 255, 0.12); overflow: hidden; margin-top: 3px; }
.ach-bar-fill { height: 100%; background: #ffc233; }

#touch-feed-btn {
  right: calc(110px + env(safe-area-inset-right));
  bottom: calc(206px + env(safe-area-inset-bottom));
}

/* ---------------------------------------------------------- level + shop */
.hud-level-chip { flex-direction: column; align-items: stretch; gap: 3px; min-width: 64px; }
.hud-level { font-weight: 800; color: #ffd98f; text-align: center; }
.hud-xp { height: 5px; border-radius: 3px; background: rgba(255, 255, 255, 0.15); overflow: hidden; }
.hud-xp-fill { height: 100%; width: 0; background: linear-gradient(90deg, #8fe36a, #ffd24a); transition: width 0.3s ease; }

#hud-reticle.cooling { opacity: 0.4; }

#shop-screen {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(20, 12, 6, 0.55);
  backdrop-filter: blur(3px);
  color: #ffe9cd;
}
#shop-screen.hidden { display: none; }
.shop-panel {
  width: min(980px, 100%);
  max-height: calc(100vh - 32px);
  overflow-y: auto;
  background: linear-gradient(180deg, rgba(58, 36, 22, 0.97), rgba(40, 24, 14, 0.97));
  border: 3px solid rgba(63, 169, 255, 0.6);
  border-radius: 20px;
  padding: 18px 20px 14px;
  box-shadow: 0 16px 50px rgba(0, 0, 0, 0.45);
}
.shop-header { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 12px; }
.shop-title-wrap { flex: 1; min-width: 0; }
.shop-title { margin: 0; font-size: 26px; color: #9fdcff; }
.shop-greeting { margin: 4px 0 0; opacity: 0.8; font-size: 14px; }
.shop-wallet { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; font-weight: 800; }
.shop-level { color: #ffd98f; }
.shop-money { font-size: 20px; }
.shop-close {
  background: rgba(255, 255, 255, 0.1);
  border: 2px solid rgba(255, 214, 158, 0.35);
  color: inherit;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  font-size: 18px;
  cursor: pointer;
}
.shop-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 12px; }
.shop-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 12px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.06);
  border: 2px solid rgba(255, 255, 255, 0.08);
}
.shop-card.state-ok { border-color: rgba(63, 169, 255, 0.7); }
.shop-card.state-level { opacity: 0.6; }
.shop-card.state-max { border-color: rgba(143, 227, 106, 0.6); }
.shop-card-top { display: flex; align-items: center; gap: 8px; }
.shop-icon { font-size: 24px; }
.shop-swatch { width: 20px; height: 20px; border-radius: 50%; border: 2px solid rgba(0, 0, 0, 0.3); }
.shop-name { font-weight: 800; font-size: 16px; }
.shop-desc { margin: 0; font-size: 13px; opacity: 0.8; flex: 1; }
.shop-pips { display: flex; gap: 4px; }
.shop-pip { width: 18px; height: 6px; border-radius: 3px; background: rgba(255, 255, 255, 0.15); }
.shop-pip.on { background: #3fa9ff; }
.shop-values { margin: 0; font-weight: 700; color: #9fdcff; font-size: 14px; }
.shop-buy {
  margin-top: 4px;
  padding: 9px;
  border-radius: 10px;
  border: none;
  font: inherit;
  font-weight: 800;
  font-size: 16px;
  cursor: pointer;
  background: #3fa9ff;
  color: #0e2336;
}
.shop-buy:disabled { background: rgba(255, 255, 255, 0.12); color: rgba(255, 233, 205, 0.7); cursor: default; }
.shop-xp { margin: 12px 0 0; text-align: center; font-size: 13px; opacity: 0.75; }

/* --------------------------------------------------------------- quests */
#hud-quests {
  position: absolute;
  top: 70px;
  right: 20px;
  width: 250px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  pointer-events: none;
}
#hud-quests:empty { display: none; }
.quests-title {
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #ffd98f;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6);
  text-align: right;
}
.quest-row {
  background: rgba(46, 28, 18, 0.78);
  border: 2px solid rgba(255, 214, 158, 0.35);
  border-left: 4px solid #ffd24a;
  border-radius: 10px;
  padding: 7px 10px;
}
.quest-row.done { border-left-color: #8fe36a; }
.quest-text { font-weight: 700; font-size: 14px; color: #fff4d6; }
.quest-meta { font-size: 11px; opacity: 0.75; margin-top: 2px; }
.quest-bar { height: 4px; border-radius: 2px; background: rgba(255, 255, 255, 0.12); margin-top: 5px; overflow: hidden; }
.quest-bar-fill { height: 100%; background: #ffd24a; }
.quest-row.done .quest-bar-fill { background: #8fe36a; }
body.touch-active #hud-quests { top: calc(74px + env(safe-area-inset-top)); width: 200px; }
body.touch-active .quest-text { font-size: 12px; }
@media (max-width: 760px) {
  #hud-quests { width: 170px; right: 10px; }
  .quest-meta { display: none; }
}

#hud-phase { font-variant-numeric: tabular-nums; min-width: 4.2em; text-align: center; }

.lime-icon { width: 1.05em; height: 1.05em; vertical-align: -0.16em; display: inline-block; }

#touch-blow-btn {
  right: calc(170px + env(safe-area-inset-right));
  bottom: calc(176px + env(safe-area-inset-bottom));
}

/* ----------------------------------------------------------- build mode */
#build-menu {
  position: fixed;
  left: 50%;
  bottom: 140px;
  transform: translateX(-50%);
  z-index: 30;
  width: min(640px, calc(100vw - 32px));
  background: linear-gradient(180deg, rgba(58, 36, 22, 0.95), rgba(40, 24, 14, 0.95));
  border: 3px solid rgba(110, 224, 106, 0.6);
  border-radius: 16px;
  padding: 10px 12px;
  color: #ffe9cd;
}
#build-menu.hidden { display: none; }
.build-title { font-weight: 800; color: #b8ffb0; margin-bottom: 8px; text-align: center; }
.build-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.build-option {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 8px 4px;
  border-radius: 12px;
  border: 2px solid rgba(255, 214, 158, 0.3);
  background: rgba(255, 255, 255, 0.06);
  color: inherit;
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}
.build-option.active { border-color: #6ee06a; background: rgba(110, 224, 106, 0.18); }
.build-icon { font-size: 24px; }
.build-cost { font-size: 12px; opacity: 0.85; }
.build-actions { display: flex; gap: 8px; margin-top: 8px; }
.build-place, .build-close {
  flex: 1;
  padding: 9px;
  border-radius: 10px;
  border: none;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}
.build-place { background: #6ee06a; color: #12301a; }
.build-place:disabled { background: rgba(255, 255, 255, 0.12); color: rgba(255, 233, 205, 0.6); }
.build-close { background: rgba(255, 255, 255, 0.14); color: #ffe9cd; }
#touch-build-btn {
  right: calc(230px + env(safe-area-inset-right));
  bottom: calc(60px + env(safe-area-inset-bottom));
}
body.touch-active #build-menu { bottom: 250px; }

/* ------------------------------------------------------ character creator */
.home-create { display: flex; flex-direction: column; gap: 10px; max-height: 60vh; overflow-y: auto; padding-right: 4px; }
.create-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.create-label { min-width: 110px; font-weight: 700; color: #ffd98f; font-size: 14px; }
.create-options { display: flex; gap: 6px; flex-wrap: wrap; flex: 1; }
.create-option {
  position: relative;
  padding: 6px 12px;
  border-radius: 999px;
  border: 2px solid rgba(255, 214, 158, 0.3);
  background: rgba(255, 255, 255, 0.06);
  color: #ffe9cd;
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}
.create-option.active { border-color: #ffd24a; background: rgba(255, 210, 74, 0.18); }
.create-option.locked { opacity: 0.55; cursor: not-allowed; }
.create-lock { font-size: 10px; margin-left: 6px; opacity: 0.85; }
.create-swatch {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 2px solid rgba(0, 0, 0, 0.35);
  cursor: pointer;
  padding: 0;
}
.create-swatch.active { border-color: #fff; box-shadow: 0 0 0 2px #ffd24a; }
.create-name {
  flex: 1;
  min-width: 140px;
  padding: 7px 10px;
  border-radius: 10px;
  border: 2px solid rgba(255, 214, 158, 0.35);
  background: rgba(255, 255, 255, 0.08);
  color: #ffe9cd;
  font: inherit;
  font-weight: 700;
}
.home-secondary {
  align-self: center;
  padding: 8px 18px;
  border-radius: 999px;
  border: 2px solid rgba(255, 214, 158, 0.45);
  background: rgba(255, 255, 255, 0.08);
  color: #ffe9cd;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}
.home-secondary.hidden { display: none; }

/* --------------------------------------------------------- price board */
#hud-market {
  position: absolute;
  left: 20px;
  top: 96px;
  width: 235px;
  background: linear-gradient(180deg, rgba(58, 36, 22, 0.92), rgba(40, 24, 14, 0.92));
  border: 2px solid rgba(255, 214, 158, 0.45);
  border-radius: 12px;
  padding: 8px 10px;
  pointer-events: none;
}
#hud-market.hidden { display: none; }
.market-title {
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #ffd98f;
  margin-bottom: 5px;
}
.market-row { display: flex; align-items: center; gap: 6px; font-size: 13px; padding: 1px 0; }
.market-row.carried { color: #fff4d6; font-weight: 800; }
.market-swatch { width: 10px; height: 10px; border-radius: 50%; flex: none; border: 1px solid rgba(0,0,0,0.4); }
.market-name { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.market-price { font-variant-numeric: tabular-nums; font-weight: 700; }
.market-price.up { color: #8fe36a; }
.market-price.down { color: #ff8a5c; }
.market-price.flat { color: #ffe9cd; }
.market-flooded { font-size: 10px; color: #ff8a5c; text-transform: uppercase; }
body.touch-active #hud-market { top: 120px; width: 190px; }

.build-upgrades { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-top: 8px; }
.build-upgrade {
  display: grid;
  grid-template-columns: auto 1fr auto;
  grid-template-areas: "icon name cost" "icon desc desc";
  gap: 2px 8px;
  text-align: left;
  padding: 7px 9px;
  border-radius: 10px;
  border: 2px solid rgba(255, 214, 158, 0.3);
  background: rgba(255, 255, 255, 0.06);
  color: #ffe9cd;
  font: inherit;
  cursor: pointer;
}
.build-upgrade .build-icon { grid-area: icon; align-self: center; font-size: 20px; }
.build-up-name { grid-area: name; font-weight: 800; font-size: 13px; }
.build-up-desc { grid-area: desc; font-size: 11px; opacity: 0.75; }
.build-upgrade .build-cost { grid-area: cost; }
.build-upgrade.owned { border-color: rgba(143, 227, 106, 0.7); background: rgba(143, 227, 106, 0.12); }
.build-upgrade:disabled { opacity: 0.6; cursor: default; }
.build-hint { margin: 6px 0 0; font-size: 13px; opacity: 0.8; text-align: center; }

.ui-icon { width: 1.15em; height: 1.15em; vertical-align: -0.2em; display: inline-block; }
.build-icon .ui-icon, .shop-icon .ui-icon { width: 1.5em; height: 1.5em; }
.ach-icon .ui-icon { width: 1.6em; height: 1.6em; }
.hud-glyph .ui-icon { width: 1.05em; height: 1.05em; opacity: 0.9; }
#touch-blow-btn, #touch-feed-btn, #touch-build-btn, #touch-sprint-btn { font-size: 12px; font-weight: 800; letter-spacing: 0.04em; }
