/* ── Reset & Base ──────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --dirt: #8B6340;
  --grass: #5D9E38;
  --stone: #888;
  --sky-day: #87CEEB;
  --sky-night: #0a0a1a;
  --ui-bg: rgba(0,0,0,0.72);
  --ui-border: rgba(255,255,255,0.12);
  --ui-text: #fff;
  --ui-accent: #5D9E38;
  --slot-bg: rgba(30,30,30,0.85);
  --slot-border: #555;
  --slot-selected: #fff;
  --font-game: 'Courier New', monospace;
}

html, body {
  width: 100%; height: 100%;
  overflow: hidden;
  background: #000;
  font-family: var(--font-game);
  color: var(--ui-text);
  user-select: none;
  -webkit-user-select: none;
}

.hidden { display: none !important; }

/* ── Main Menu ─────────────────────────────────────────────── */
#main-menu {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  z-index: 100;
}

.menu-bg {
  position: absolute; inset: 0;
  background:
    linear-gradient(180deg, #1a3a1a 0%, #0d1f0d 40%, #050d05 100%);
  overflow: hidden;
}

.menu-bg::before {
  content: '';
  position: absolute; inset: 0;
  background-image:
    repeating-linear-gradient(0deg, transparent, transparent 31px, rgba(255,255,255,0.015) 32px),
    repeating-linear-gradient(90deg, transparent, transparent 31px, rgba(255,255,255,0.015) 32px);
  background-size: 32px 32px;
}

.menu-bg::after {
  content: '';
  position: absolute; inset: 0;
  background: radial-gradient(ellipse at 50% 30%, rgba(93,158,56,0.18) 0%, transparent 65%);
}

.menu-content {
  position: relative; z-index: 1;
  display: flex; flex-direction: column; align-items: center;
  gap: 0;
  text-align: center;
  width: 100%; max-width: 460px;
  padding: 2rem;
}

.game-title {
  font-size: clamp(2.8rem, 8vw, 5rem);
  font-weight: 900;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #fff;
  text-shadow:
    4px 4px 0 #2d5a1a,
    8px 8px 0 #1a3a0d,
    0 0 60px rgba(93,158,56,0.5);
  margin-bottom: 0.4rem;
  line-height: 1;
}

.game-subtitle {
  font-size: 0.85rem;
  color: rgba(255,255,255,0.45);
  letter-spacing: 0.2em;
  text-transform: uppercase;
  margin-bottom: 2.5rem;
}

.menu-buttons {
  display: flex; flex-direction: column; gap: 0.7rem;
  width: 100%;
}

.menu-btn {
  display: block; width: 100%;
  padding: 0.7rem 1.5rem;
  background: rgba(0,0,0,0.6);
  border: 2px solid rgba(255,255,255,0.18);
  border-bottom-color: rgba(0,0,0,0.5);
  color: #fff;
  font-family: var(--font-game);
  font-size: 1rem;
  letter-spacing: 0.08em;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s, transform 0.08s;
  text-transform: uppercase;
}

.menu-btn:hover {
  background: rgba(93,158,56,0.25);
  border-color: rgba(93,158,56,0.7);
  transform: scale(1.01);
}

.menu-btn:active { transform: scale(0.99); }

.menu-btn.primary {
  background: rgba(93,158,56,0.35);
  border-color: rgba(93,158,56,0.8);
}

.menu-btn.primary:hover {
  background: rgba(93,158,56,0.55);
}

.menu-btn.small { font-size: 0.8rem; padding: 0.4rem 0.8rem; width: auto; }

.version-tag {
  margin-top: 2rem;
  font-size: 0.7rem;
  color: rgba(255,255,255,0.2);
  letter-spacing: 0.12em;
}

/* ── Modals ────────────────────────────────────────────────── */
.modal {
  position: fixed; inset: 0; z-index: 200;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,0.75);
}

.modal-box {
  background: #1a1a1a;
  border: 2px solid rgba(255,255,255,0.15);
  padding: 2rem;
  min-width: 340px;
  max-width: 480px;
  width: 90%;
}

.modal-box h2 {
  font-size: 1.4rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 1.5rem;
  color: var(--ui-accent);
}

.modal-box label {
  display: flex; flex-direction: column; gap: 0.4rem;
  font-size: 0.75rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.6);
  margin-bottom: 1rem;
}

.modal-box input[type="text"],
.modal-box input[type="number"] {
  background: rgba(255,255,255,0.07);
  border: 1px solid rgba(255,255,255,0.2);
  color: #fff;
  font-family: var(--font-game);
  font-size: 0.95rem;
  padding: 0.5rem 0.7rem;
  outline: none;
}

.modal-box input[type="text"]:focus {
  border-color: var(--ui-accent);
}

.modal-box input[type="range"] {
  accent-color: var(--ui-accent);
  width: 100%;
  margin-top: 0.3rem;
}

.checkbox-label {
  flex-direction: row !important;
  align-items: center;
  gap: 0.6rem !important;
  cursor: pointer;
}

.modal-buttons {
  display: flex; gap: 0.5rem; margin-top: 1.5rem;
}

.modal-buttons .menu-btn { flex: 1; }

/* ── Game Canvas ───────────────────────────────────────────── */
#game-ui {
  position: fixed; inset: 0; z-index: 10;
}

#game-canvas {
  display: block;
  width: 100%; height: 100%;
  outline: none;
}

/* ── Underwater Overlay ────────────────────────────────────── */
#underwater-overlay {
  position: fixed;
  inset: 0;
  z-index: 15;               /* above canvas, below crosshair */
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.4s ease;

  /* Deep blue vignette — darker baseline in center, dark at edges */
  background:
    radial-gradient(ellipse at center,
      rgba(10, 48, 128, 0.25)   0%,
      rgba(8, 38, 110, 0.45) 60%,
      rgba(3, 15,  80, 0.65) 100%
    );
}

#underwater-overlay.active {
  opacity: 1;
  /* Slow breathing pulse to simulate light filtering through water */
  animation: uw-pulse 3.5s ease-in-out infinite;
}

@keyframes uw-pulse {
  0%,  100% { opacity: 0.90; }
  50%        { opacity: 1.00; }
}

/* ── Crosshair ─────────────────────────────────────────────── */
#crosshair {
  position: fixed;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  z-index: 20;
  pointer-events: none;
}

.ch-h { width: 20px; height: 2px; background: rgba(255,255,255,0.85); }
.ch-v { width: 2px; height: 20px; background: rgba(255,255,255,0.85);
        position: absolute; top: -9px; left: 9px; }

/* ── HUD Stats ─────────────────────────────────────────────── */
#hud-stats {
  position: fixed; top: 10px; left: 10px;
  z-index: 20;
  display: flex; flex-direction: column; gap: 2px;
  font-size: 0.7rem;
  color: rgba(255,255,255,0.85);
  text-shadow: 1px 1px 2px #000;
  pointer-events: none;
}

/* ── Health Bar ────────────────────────────────────────────── */
#hud-health {
  position: fixed;
  bottom: 80px; left: 50%;
  transform: translateX(-50%);
  z-index: 20;
  display: flex; align-items: center; gap: 6px;
  pointer-events: none;
}

.bar-label { font-size: 1rem; }

.bar-track {
  width: 120px; height: 8px;
  background: rgba(0,0,0,0.5);
  border: 1px solid rgba(255,255,255,0.2);
}

.bar-fill { height: 100%; transition: width 0.2s; }
.health-fill { background: #e02020; width: 100%; }

/* ── Hotbar ────────────────────────────────────────────────── */
#hotbar {
  position: fixed;
  bottom: 10px; left: 50%;
  transform: translateX(-50%);
  z-index: 20;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
}

.hotbar-slots {
  display: flex; gap: 3px;
}

.hotbar-slot {
  width: 46px; height: 46px;
  background: var(--slot-bg);
  border: 2px solid var(--slot-border);
  display: flex; align-items: center; justify-content: center;
  position: relative;
  cursor: pointer;
}

.hotbar-slot.selected {
  border-color: var(--slot-selected);
  box-shadow: 0 0 6px rgba(255,255,255,0.35);
}

.hotbar-slot canvas {
  width: 36px; height: 36px;
  image-rendering: pixelated;
}

.hotbar-slot .slot-count {
  position: absolute; bottom: 1px; right: 3px;
  font-size: 0.62rem;
  text-shadow: 1px 1px 0 #000;
}

.hotbar-labels {
  display: flex; gap: 3px;
}

.hotbar-label {
  width: 46px;
  text-align: center;
  font-size: 0.5rem;
  color: rgba(255,255,255,0.5);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ── Inventory ─────────────────────────────────────────────── */
#inventory {
  position: fixed; inset: 0; z-index: 30;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,0.5);
}

.inventory-panel {
  background: rgba(20,20,20,0.97);
  border: 2px solid rgba(255,255,255,0.15);
  padding: 1.5rem;
  min-width: 380px;
}

.inventory-panel h3 {
  text-transform: uppercase;
  letter-spacing: 0.12em;
  margin-bottom: 1rem;
  font-size: 0.9rem;
  color: var(--ui-accent);
}

.inv-grid {
  display: grid;
  grid-template-columns: repeat(9, 44px);
  gap: 3px;
  margin-bottom: 1rem;
}

.inv-slot {
  width: 44px; height: 44px;
  background: var(--slot-bg);
  border: 1px solid var(--slot-border);
  display: flex; align-items: center; justify-content: center;
  position: relative;
  cursor: pointer;
  transition: border-color 0.1s;
}

.inv-slot:hover { border-color: rgba(255,255,255,0.5); }
.inv-slot.dragging { opacity: 0.4; }

.inv-slot canvas {
  width: 32px; height: 32px;
  image-rendering: pixelated;
}

/* ── Pause Menu ────────────────────────────────────────────── */
#pause-menu {
  position: fixed; inset: 0; z-index: 40;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,0.6);
}

.pause-panel {
  background: rgba(20,20,20,0.97);
  border: 2px solid rgba(255,255,255,0.15);
  padding: 2rem;
  min-width: 300px;
  display: flex; flex-direction: column; gap: 0.7rem;
  text-align: center;
}

.pause-panel h2 {
  text-transform: uppercase;
  letter-spacing: 0.15em;
  font-size: 1.4rem;
  margin-bottom: 0.5rem;
  color: #fff;
}

/* ── Block Tooltip ─────────────────────────────────────────── */
#block-tooltip {
  position: fixed;
  top: 50%; left: 50%;
  transform: translate(-50%, calc(-50% - 48px));
  z-index: 25;
  background: rgba(0,0,0,0.7);
  border: 1px solid rgba(255,255,255,0.2);
  padding: 0.25rem 0.6rem;
  font-size: 0.7rem;
  letter-spacing: 0.05em;
  pointer-events: none;
}

/* ── Time Indicator ────────────────────────────────────────── */
#time-indicator {
  position: fixed; top: 12px; right: 12px; z-index: 20;
  display: flex; align-items: center; gap: 5px;
  font-size: 0.75rem;
  pointer-events: none;
}

#time-bar {
  width: 80px; height: 6px;
  background: rgba(255,255,255,0.15);
  border: 1px solid rgba(255,255,255,0.2);
  position: relative;
}

#time-dot {
  position: absolute; top: -2px;
  width: 10px; height: 10px;
  background: #ffe066;
  border-radius: 50%;
  left: 0%;
  box-shadow: 0 0 6px #ffe066;
  transition: left 2s linear;
}

/* ── Notifications ─────────────────────────────────────────── */
#notifications {
  position: fixed; top: 50px; left: 50%;
  transform: translateX(-50%);
  z-index: 50;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  pointer-events: none;
}

.notif {
  background: rgba(0,0,0,0.75);
  border: 1px solid rgba(255,255,255,0.15);
  padding: 0.3rem 0.8rem;
  font-size: 0.75rem;
  letter-spacing: 0.05em;
  animation: notif-in 0.2s ease, notif-out 0.3s ease 2s forwards;
}

@keyframes notif-in  { from { opacity:0; transform:translateY(-8px); } to { opacity:1; transform:translateY(0); } }
@keyframes notif-out { to   { opacity:0; transform:translateY(-8px); } }

/* ── Loading Screen ────────────────────────────────────────── */
#loading-screen {
  position: fixed; inset: 0; z-index: 200;
  background: #0a1a0a;
  display: flex; align-items: center; justify-content: center;
}

.loading-content {
  text-align: center;
  display: flex; flex-direction: column; align-items: center; gap: 1rem;
}

.loading-content h2 {
  font-size: 1.4rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--ui-accent);
}

.loading-bar-track {
  width: 300px; height: 10px;
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.2);
}

.loading-bar-fill {
  height: 100%;
  background: var(--ui-accent);
  width: 0%;
  transition: width 0.15s ease;
}

#loading-msg {
  font-size: 0.75rem;
  color: rgba(255,255,255,0.45);
  letter-spacing: 0.1em;
}

/* ── Block Icon Canvases ───────────────────────────────────── */
.block-icon {
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

/* ── Settings Screen (Minecraft-style) ────────────────────── */
.settings-box {
  width: min(640px, 95vw);
  max-height: 88vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: 1.5rem 1.5rem 1.2rem;
}

.settings-box h2 {
  text-align: center;
  margin-bottom: 1rem;
  font-size: 1.1rem;
  letter-spacing: 0.1em;
  color: var(--ui-accent);
}

.settings-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 0.8rem;
  border-bottom: 2px solid rgba(255,255,255,0.1);
  padding-bottom: 4px;
}

.stab {
  flex: 1;
  padding: 0.4rem 0.5rem;
  background: rgba(0,0,0,0.4);
  border: 1px solid rgba(255,255,255,0.1);
  color: rgba(255,255,255,0.55);
  font-size: 0.72rem;
  font-family: inherit;
  letter-spacing: 0.06em;
  cursor: pointer;
  text-transform: uppercase;
  transition: all 0.12s;
}
.stab:hover { background: rgba(255,255,255,0.08); color: #fff; }
.stab.active {
  background: rgba(255,255,255,0.15);
  color: #fff;
  border-color: rgba(255,255,255,0.3);
}

.stab-content {
  flex: 1;
  overflow: visible;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.2) transparent;
  padding-right: 0;
  max-height: none;
}

.settings-grid {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.45rem 0.6rem;
  background: rgba(0,0,0,0.25);
  border: 1px solid rgba(255,255,255,0.05);
}
.setting-row:hover { background: rgba(255,255,255,0.05); }

.setting-label {
  font-size: 0.78rem;
  color: rgba(255,255,255,0.85);
  letter-spacing: 0.04em;
  white-space: nowrap;
  min-width: 140px;
}

.setting-control {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex: 1;
  justify-content: flex-end;
}

.setting-control input[type="range"] {
  flex: 1;
  max-width: 200px;
  accent-color: var(--ui-accent);
  cursor: pointer;
}

.setting-value {
  font-size: 0.72rem;
  color: rgba(255,255,255,0.6);
  min-width: 60px;
  text-align: right;
  letter-spacing: 0.04em;
}

/* ON/OFF toggle buttons */
.toggle-btn {
  padding: 0.25rem 0.7rem;
  min-width: 52px;
  font-size: 0.7rem;
  font-family: inherit;
  letter-spacing: 0.08em;
  cursor: pointer;
  border: 1px solid rgba(255,255,255,0.2);
  background: rgba(180,40,40,0.4);
  color: rgba(255,255,255,0.7);
  transition: all 0.1s;
}
.toggle-btn.tog-on {
  background: rgba(40,140,40,0.45);
  color: #fff;
  border-color: rgba(80,200,80,0.4);
}
.toggle-btn:hover { filter: brightness(1.2); }

/* Cycle buttons (e.g. difficulty) */
.cycle-btn {
  padding: 0.25rem 0.7rem;
  min-width: 80px;
  font-size: 0.7rem;
  font-family: inherit;
  letter-spacing: 0.06em;
  cursor: pointer;
  border: 1px solid rgba(255,255,255,0.2);
  background: rgba(255,255,255,0.1);
  color: #fff;
  transition: all 0.1s;
}
.cycle-btn:hover { background: rgba(255,255,255,0.18); }

/* Key bindings table */
.keybind-section {
  margin-top: 1rem;
}
.keybind-section h3 {
  font-size: 0.72rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.4);
  margin-bottom: 0.4rem;
  padding-bottom: 0.2rem;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.keybind-grid {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 2px 1rem;
}
.keybind-grid span {
  font-size: 0.74rem;
  color: rgba(255,255,255,0.7);
  padding: 0.2rem 0.5rem;
  display: flex;
  align-items: center;
}
.keybind-grid span:nth-child(odd) { background: rgba(0,0,0,0.2); }
.keybind-key {
  background: rgba(0,0,0,0.5) !important;
  border: 1px solid rgba(255,255,255,0.2);
  font-size: 0.68rem !important;
  letter-spacing: 0.05em;
  padding: 0.15rem 0.5rem !important;
  justify-content: center;
  min-width: 60px;
  text-align: center;
  color: rgba(255,255,255,0.9) !important;
}

/* Pause panel - update for new button */
.pause-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  min-width: 220px;
}

/* ── Minimap HUD ────────────────────────────────────────────── */
#minimap-container {
  position: fixed;
  top: 20px;
  right: 20px;
  width: 120px;
  height: 120px;
  border-radius: 50%;
  border: 3px solid rgba(0, 0, 0, 0.7);
  outline: 1.5px solid rgba(255, 255, 255, 0.15);
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.6);
  background: #111;
  overflow: hidden;
  z-index: 12;
  pointer-events: none;
}

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

#minimap-marker {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 10px;
  height: 10px;
  color: #ef4444;
  font-size: 10px;
  line-height: 10px;
  text-align: center;
  font-family: monospace;
  text-shadow: 0 0 3px rgba(0,0,0,1);
  pointer-events: none;
  transform-origin: center;
}

/* ── Full-screen map overlay ────────────────────────────────── */
#map-view-overlay {
  position: fixed;
  inset: 0;
  z-index: 90;
  background: #0a0a0c;
  /* Establish containing block for absolute children */
  overflow: hidden;
}

#map-view-overlay.hidden {
  display: none;
}

#map-view-canvas {
  display: block;
  width: 100%;
  height: 100%;
  cursor: grab;
  image-rendering: pixelated;
}

#map-close-hint {
  position: absolute;
  bottom: 14px;
  left: 50%;
  transform: translateX(-50%);
  font-family: monospace;
  font-size: 0.78rem;
  color: rgba(255,255,255,0.45);
  pointer-events: none;
  z-index: 91;
  white-space: nowrap;
  letter-spacing: 0.04em;
}

/* ── Storage Tab ────────────────────────────────────────────── */

/* Remove hover effect from storage mode row — it has its own styling */
.storage-mode-row { flex-direction: column; align-items: stretch !important; gap: 0.7rem; background: transparent !important; border: none !important; padding: 0.5rem 0 !important; }
.storage-mode-row:hover { background: transparent !important; }

/* Storage pills — big clickable card buttons */
.storage-mode-pills {
  display: flex;
  gap: 0.5rem;
}

.storage-pill {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.2rem;
  padding: 0.75rem 0.9rem;
  background: rgba(0,0,0,0.4);
  border: 2px solid rgba(255,255,255,0.12);
  color: rgba(255,255,255,0.65);
  font-family: var(--font-game);
  cursor: pointer;
  text-align: left;
  transition: all 0.15s;
}

.storage-pill:hover {
  background: rgba(255,255,255,0.07);
  border-color: rgba(255,255,255,0.25);
  color: #fff;
}

.storage-pill.active {
  background: rgba(93,158,56,0.18);
  border-color: rgba(93,158,56,0.7);
  color: #fff;
  box-shadow: 0 0 12px rgba(93,158,56,0.15) inset;
}

.pill-icon { font-size: 1.3rem; line-height: 1; }

.pill-title {
  font-size: 0.78rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: inherit;
}

.pill-desc {
  font-size: 0.66rem;
  color: rgba(255,255,255,0.4);
  line-height: 1.4;
  letter-spacing: 0;
  text-transform: none;
}

.storage-pill.active .pill-desc { color: rgba(255,255,255,0.6); }

/* Folder status panel */
.storage-folder-panel,
.storage-browser-panel {
  flex-direction: column !important;
  align-items: stretch !important;
  gap: 0.6rem;
  padding: 0.6rem !important;
  background: rgba(0,0,0,0.3) !important;
  border: 1px solid rgba(255,255,255,0.08) !important;
}

.folder-status-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.folder-status-icon {
  font-size: 1.5rem;
  flex-shrink: 0;
  width: 2rem;
  text-align: center;
}

.folder-status-text {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  flex: 1;
  font-size: 0.78rem;
  color: rgba(255,255,255,0.85);
  letter-spacing: 0.03em;
  overflow: hidden;
}

.folder-perm-label {
  font-size: 0.68rem;
  color: rgba(255,255,255,0.4);
  letter-spacing: 0.02em;
}

.folder-action-row {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.folder-action-row .menu-btn {
  flex: 0;
  white-space: nowrap;
  font-size: 0.72rem;
  padding: 0.4rem 0.9rem;
  width: auto;
}

.storage-hint {
  font-size: 0.66rem;
  color: rgba(255,255,255,0.35);
  line-height: 1.6;
  letter-spacing: 0.02em;
  padding-top: 0.2rem;
  border-top: 1px solid rgba(255,255,255,0.06);
}

.storage-hint code {
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.12);
  padding: 0.05em 0.3em;
  font-family: var(--font-game);
  font-size: 0.92em;
  color: rgba(255,255,255,0.65);
}

/* Danger button (Disconnect, Delete) */
.danger-btn {
  background: rgba(180,40,40,0.35) !important;
  border-color: rgba(200,60,60,0.4) !important;
  color: rgba(255,160,160,0.9) !important;
}
.danger-btn:hover {
  background: rgba(200,50,50,0.55) !important;
  border-color: rgba(220,80,80,0.6) !important;
}

/* ── Upgraded settings sidebar layout ── */
.settings-box {
  display: grid;
  grid-template-columns: 200px 1fr;
  grid-template-rows: 1fr auto;
  height: 80vh;
  max-height: 580px;
  width: 90vw;
  max-width: 820px;
  padding: 0 !important;
  overflow: hidden;
}

.settings-sidebar {
  grid-column: 1;
  grid-row: 1;
  background: #141414;
  border-right: 1px solid rgba(255,255,255,0.08);
  display: flex;
  flex-direction: column;
  padding: 1.2rem 0.8rem;
}

.settings-sidebar-title {
  font-size: 0.95rem;
  font-weight: bold;
  text-transform: uppercase;
  color: var(--ui-accent);
  margin-bottom: 1.2rem;
  padding-left: 0.8rem;
  letter-spacing: 0.08em;
  font-family: Courier New, monospace;
}

.settings-nav {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.snav {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  background: transparent;
  border: none;
  color: rgba(255,255,255,0.6);
  text-align: left;
  padding: 0.6rem 0.8rem;
  font-family: var(--font-game);
  font-size: 0.82rem;
  cursor: pointer;
  transition: all 0.15s;
  border-radius: 4px;
}

.snav:hover {
  background: rgba(255,255,255,0.04);
  color: #fff;
}

.snav.active {
  background: rgba(93, 158, 56, 0.18);
  color: var(--ui-accent);
  font-weight: bold;
}

.snav-icon {
  font-size: 1rem;
}

.settings-main {
  grid-column: 2;
  grid-row: 1;
  overflow-y: auto;
  min-height: 0;
  padding: 1.5rem;
  background: #1a1a1a;
}

.settings-footer {
  grid-column: 1 / span 2;
  grid-row: 2;
  display: flex;
  justify-content: flex-end;
  gap: 0.6rem;
  padding: 0.9rem 1.5rem;
  border-top: 1px solid rgba(255,255,255,0.08);
  background: #151515;
}

.settings-footer .menu-btn {
  width: auto;
  min-width: 100px;
  padding: 0.5rem 1.2rem;
  font-size: 0.85rem;
}

.stab-content {
  display: flex;
  flex-direction: column;
  gap: 1.2rem;
  overflow: visible;
  max-height: none;
  padding-right: 0;
}

.stab-content.hidden {
  display: none !important;
}

.stab-heading {
  font-size: 1.1rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ui-accent);
  border-bottom: 1px solid rgba(255,255,255,0.08);
  padding-bottom: 0.4rem;
  margin-bottom: 0.2rem;
  font-family: Courier New, monospace;
}

.settings-grid {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.setting-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 0.8rem;
  background: rgba(0,0,0,0.2);
  border: 1px solid rgba(255,255,255,0.05);
  border-radius: 4px;
}

.setting-label {
  font-size: 0.82rem;
  color: rgba(255,255,255,0.85);
}

.setting-control {
  display: flex;
  align-items: center;
  gap: 0.8rem;
}

.setting-value {
  font-size: 0.78rem;
  color: rgba(255,255,255,0.45);
  min-width: 65px;
  text-align: right;
}

/* ── Upgraded Packs Tab styling ── */
.pack-active-card {
  display: flex;
  gap: 1.2rem;
  background: rgba(0,0,0,0.2);
  border: 1px solid rgba(255,255,255,0.06);
  padding: 1rem;
  border-radius: 6px;
}

.pack-preview-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
  flex-shrink: 0;
}

.atlas-preview-wrap {
  position: relative;
  border: 2px solid rgba(255,255,255,0.12);
  border-radius: 6px;
  width: 128px;
  height: 128px;
  cursor: crosshair;
  background: #050505;
  overflow: hidden;
}

.atlas-preview-wrap canvas {
  width: 100%;
  height: 100%;
  display: block;
  image-rendering: pixelated;
}

.atlas-tooltip {
  position: absolute;
  pointer-events: none;
  background: rgba(0,0,0,0.95);
  border: 1px solid rgba(255,255,255,0.25);
  padding: 0.25rem 0.5rem;
  font-size: 0.65rem;
  color: #fff;
  font-family: Courier New, monospace;
  border-radius: 4px;
  display: none;
  z-index: 100;
  white-space: nowrap;
  box-shadow: 0 2px 8px rgba(0,0,0,0.6);
}

.atlas-caption {
  font-size: 0.6rem;
  color: rgba(255,255,255,0.35);
  margin: 0;
  text-align: center;
  max-width: 150px;
  line-height: 1.3;
}

.pack-info-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 0.4rem;
}

.pack-active-badge {
  font-size: 0.58rem;
  font-weight: bold;
  background: var(--ui-accent);
  color: #fff;
  padding: 0.15rem 0.45rem;
  border-radius: 3px;
  width: max-content;
  letter-spacing: 0.06em;
}

.pack-name-display {
  font-size: 0.95rem;
  font-weight: bold;
  color: #fff;
}

.pack-desc-text {
  font-size: 0.72rem;
  color: rgba(255,255,255,0.5);
  line-height: 1.4;
  margin: 0;
}

.pack-toolbar {
  display: flex;
  gap: 0.4rem;
  margin-top: 0.4rem;
}

.pack-toolbar .menu-btn {
  font-size: 0.7rem;
  padding: 0.35rem 0.75rem;
  flex: 1;
  white-space: nowrap;
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
}

.pack-status-text {
  font-size: 0.68rem;
  color: rgba(255,255,255,0.45);
  margin: 0.2rem 0 0;
  min-height: 1.1em;
}

.pack-drop-zone {
  border: 2px dashed rgba(255,255,255,0.18);
  border-radius: 6px;
  padding: 1.2rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  color: rgba(255,255,255,0.4);
  font-size: 0.78rem;
  cursor: pointer;
  transition: all 0.15s;
}

.pack-drop-zone:hover, .pack-drop-zone.dragover {
  border-color: var(--ui-accent);
  background: rgba(93,158,56,0.05);
  color: #fff;
}

.drop-zone-icon {
  font-size: 1.4rem;
}

.skin-debug-panel {
  display: grid;
  grid-template-columns: minmax(220px, 320px) 1fr;
  gap: 1rem;
  align-items: stretch;
}

.skin-preview-wrap {
  min-height: 300px;
  height: min(42vh, 360px);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 6px;
  background:
    linear-gradient(180deg, rgba(135,206,235,0.18), rgba(12,18,24,0.3)),
    repeating-linear-gradient(0deg, rgba(255,255,255,0.04), rgba(255,255,255,0.04) 1px, transparent 1px, transparent 16px),
    repeating-linear-gradient(90deg, rgba(255,255,255,0.04), rgba(255,255,255,0.04) 1px, transparent 1px, transparent 16px);
  overflow: hidden;
  cursor: grab;
  touch-action: none;
}

.skin-preview-wrap:active {
  cursor: grabbing;
}

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

.skin-debug-controls {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  min-width: 0;
}

.skin-segment-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.4rem;
}

.skin-segment-row .menu-btn {
  width: 100%;
  min-width: 0;
  padding: 0.55rem 0.35rem;
  font-size: 0.72rem;
  letter-spacing: 0.04em;
}

.skin-segment-row .menu-btn.active {
  background: rgba(93,158,56,0.35);
  border-color: rgba(93,158,56,0.75);
}

@media (max-width: 760px) {
  .skin-debug-panel {
    grid-template-columns: 1fr;
  }

  .skin-preview-wrap {
    min-height: 260px;
    height: 320px;
  }
}

/* ── Storage Tab Tree ── */
.folder-tree-wrap {
  margin-top: 0.8rem;
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 4px;
  overflow: hidden;
  background: rgba(0,0,0,0.15);
}

.folder-tree-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.45rem 0.7rem;
  background: rgba(255,255,255,0.04);
  font-size: 0.75rem;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  font-weight: bold;
}

.tree-refresh-btn {
  background: transparent;
  border: none;
  color: rgba(255,255,255,0.4);
  cursor: pointer;
  font-size: 0.8rem;
  padding: 0.15rem;
  transition: color 0.15s;
}

.tree-refresh-btn:hover {
  color: #fff;
}

.folder-tree {
  padding: 0.5rem;
  font-family: Courier New, monospace;
  font-size: 0.7rem;
  max-height: 180px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  color: rgba(255,255,255,0.65);
}

.tree-node {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.15rem 0.25rem;
  border-radius: 3px;
}

.tree-node:hover {
  background: rgba(255,255,255,0.03);
}

.tree-node-info {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tree-node-actions {
  display: flex;
  gap: 0.2rem;
  opacity: 0;
  transition: opacity 0.15s;
}

.tree-node:hover .tree-node-actions {
  opacity: 1;
}

.tree-action-btn {
  background: transparent;
  border: 1px solid rgba(255,255,255,0.12);
  color: rgba(255,255,255,0.55);
  padding: 0.1rem 0.25rem;
  font-size: 0.58rem;
  border-radius: 2px;
  cursor: pointer;
}

.tree-action-btn:hover {
  background: rgba(255,255,255,0.08);
  color: #fff;
}

.db-world-list {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  max-height: 160px;
  overflow-y: auto;
  margin-bottom: 0.5rem;
}

.db-empty-hint {
  font-size: 0.72rem;
  color: rgba(255,255,255,0.35);
  text-align: center;
  padding: 0.8rem;
}

.db-world-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.4rem 0.6rem;
  background: rgba(255,255,255,0.02);
  border: 1px solid rgba(255,255,255,0.04);
  border-radius: 4px;
}

.db-world-info {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  font-size: 0.75rem;
}

.db-world-meta {
  font-size: 0.64rem;
  color: rgba(255,255,255,0.4);
}

.db-world-actions {
  display: flex;
  gap: 0.25rem;
}

.db-world-actions .menu-btn {
  padding: 0.2rem 0.45rem;
  font-size: 0.65rem;
  width: auto;
}

.storage-autosave-section {
  border-top: 1px dashed rgba(255,255,255,0.08);
  padding-top: 0.8rem;
  margin-top: 0.5rem;
}

.storage-section-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ui-accent);
  margin-bottom: 0.5rem;
  font-family: Courier New, monospace;
}

/* ── Autosave Recovery Dialog ── */
.autosave-dialog {
  max-width: 420px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
}

.autosave-dialog-icon {
  font-size: 2.2rem;
  line-height: 1;
}

.autosave-dialog-desc {
  font-size: 0.78rem;
  color: rgba(255,255,255,0.6);
  line-height: 1.4;
  margin: 0 0 0.4rem;
}

.autosave-comparison {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  width: 100%;
  margin: 0.4rem 0;
}

.autosave-option {
  flex: 1;
  background: rgba(0,0,0,0.25);
  border: 1px solid rgba(255,255,255,0.08);
  padding: 0.8rem 0.6rem;
  border-radius: 6px;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  align-items: center;
}

.autosave-option-recommended {
  border-color: rgba(93,158,56,0.45);
  background: rgba(93,158,56,0.06);
}

.autosave-opt-label {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: rgba(255,255,255,0.45);
}

.autosave-option-recommended .autosave-opt-label {
  color: var(--ui-accent);
  font-weight: bold;
}

.autosave-opt-time {
  font-size: 0.8rem;
  font-weight: bold;
  color: #fff;
}

.autosave-vs {
  font-size: 0.68rem;
  color: rgba(255,255,255,0.25);
  font-weight: bold;
  text-transform: uppercase;
}

.autosave-option .menu-btn {
  font-size: 0.72rem;
  padding: 0.35rem 0.5rem;
  width: 100%;
}

/* ── Storage Setup Wizard ─────────────────────────────── */
.wizard-box {
  max-width: 520px;
  padding: 2rem 1.8rem;
}

.wizard-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
}

.wizard-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  width: 100%;
  gap: 0;
}

.wizard-step.hidden {
  display: none !important;
}

.wizard-icon {
  font-size: 2.8rem;
  margin-bottom: 0.6rem;
  line-height: 1;
}

.wizard-heading {
  font-size: 1.3rem;
  font-weight: bold;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #fff;
  margin-bottom: 0.5rem;
}

.wizard-desc {
  font-size: 0.78rem;
  color: rgba(255,255,255,0.6);
  line-height: 1.5;
  margin-bottom: 1.2rem;
  max-width: 400px;
}

.wizard-note {
  font-size: 0.7rem;
  color: rgba(255,200,100,0.75);
  line-height: 1.4;
  padding: 0.6rem 0.8rem;
  background: rgba(255,200,100,0.06);
  border: 1px solid rgba(255,200,100,0.15);
  border-radius: 4px;
  max-width: 400px;
}

/* Choice cards */
.wizard-cards {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  width: 100%;
  max-width: 420px;
}

.wizard-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  padding: 1rem 1.2rem;
  background: rgba(0,0,0,0.3);
  border: 2px solid rgba(255,255,255,0.1);
  border-radius: 6px;
  color: #fff;
  font-family: var(--font-game);
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s, transform 0.08s;
  text-align: center;
}

.wizard-card:hover {
  background: rgba(93,158,56,0.12);
  border-color: rgba(93,158,56,0.5);
  transform: scale(1.015);
}

.wizard-card:active {
  transform: scale(0.99);
}

.wizard-card-icon {
  font-size: 1.6rem;
  margin-bottom: 0.2rem;
}

.wizard-card-title {
  font-size: 0.85rem;
  font-weight: bold;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #fff;
}

.wizard-card-desc {
  font-size: 0.68rem;
  color: rgba(255,255,255,0.5);
  line-height: 1.4;
}

/* Folder selection area */
.wizard-folder-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.7rem;
  margin-bottom: 1rem;
  width: 100%;
}

.wizard-folder-status {
  font-size: 0.75rem;
  color: rgba(255,255,255,0.55);
  min-height: 1.2rem;
}

.wizard-folder-status.success {
  color: var(--ui-accent);
}

.wizard-folder-status.error {
  color: #ff6666;
}

/* Wizard bottom buttons */
.wizard-buttons {
  display: flex;
  gap: 0.6rem;
  justify-content: center;
  margin-top: 0.5rem;
  width: 100%;
}
