:root {
  --bg-deep: #090c10;
  --bg-base: #0e1116;
  --bg-raised: #141922;
  --bg-surface: #1b2230;
  --border-dim: #23304a;
  --border-bright: #2e3a55;
  --accent: #8ef;
  --accent-warm: #ffee88;
  --accent-blue: #5a9aff;
  --text-primary: #eee;
  --text-dim: #8895a7;
  --sprout-dark: #4a2810;
  --sprout-mid: #6b3f1c;
  --sprout-text: #6b3a14;
  --sprout-text-bright: #4a2810;
  --sprout-text-on-warm: #4a2810;
  --sprout-text-soft: #6b3a14;
  --sprout-light: #d1ba9e;
  --sprout-border: #8c643c;
  --sprout-cream: #f3deb6;
  --panel-radius: 10px;
  --transition-fast: .08s ease;
  --transition-med: .18s ease;
  --transition-slow: .3s ease;
}

*, *::before, *::after {
  box-sizing: border-box;
}

@font-face {
  font-family: 'SproutPixel';
  src: url('../assets/SproutLands-UI/fonts/pixelFont-7-8x14-sproutLands.ttf') format('truetype');
  font-display: block;
}

html, body {
  margin: 0; padding: 0;
  background: var(--bg-deep);
  color: var(--text-primary);
  font-family: ui-monospace, monospace;
  letter-spacing: 0.5px;
}

/* ─── Cursor: patita de gato (tema SproutLands) ───
   Tres estados (hotspot 8 2 = toe superior-izquierdo, igual en todos para que
   no "salte" al cambiar de imagen):
     1. Default (nada interactivo)  → huella normal
     2. Hover sobre algo clickeable → patita que apunta
     3. Presionando (body.mouse-held, ver src/ui/index.js) → patita que sostiene */
* {
  cursor: url('../assets/SproutLands-UI/Sprite sheets/Mouse sprites/catpaw-cursor.png') 8 2, auto !important;
}
button, a, select, summary, label, [role="button"], [draggable="true"],
input[type="button"], input[type="submit"], input[type="checkbox"], input[type="radio"], input[type="range"],
[data-dir], [data-target], [data-jdir] {
  cursor: url('../assets/SproutLands-UI/Sprite sheets/Mouse sprites/catpaw-cursor-point.png') 8 2, auto !important;
}
/* Botones dibujados por Phaser (menu, seleccion de niveles): no son DOM, asi que
   las escenas togglean body.cursor-point al pasar por un objeto interactivo. */
body.cursor-point canvas {
  cursor: url('../assets/SproutLands-UI/Sprite sheets/Mouse sprites/catpaw-cursor-point.png') 8 2, auto !important;
}
body.mouse-held *,
body.mouse-held canvas {
  cursor: url('../assets/SproutLands-UI/Sprite sheets/Mouse sprites/catpaw-cursor-hold.png') 8 2, auto !important;
}
/* Mantener el cursor de texto en campos editables */
input:not([type="button"]):not([type="submit"]):not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="color"]),
textarea, [contenteditable="true"] {
  cursor: text !important;
}

/* ─── Mobile-first: base = portrait (≤767px), flexbox column ─── */
body {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: center;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  padding: 2px 0;
  gap: 2px;
  box-sizing: border-box;
  background:
    radial-gradient(ellipse 80% 60% at 50% 50%, rgba(20, 30, 52, .6) 0%, transparent 70%),
    repeating-conic-gradient(rgba(255,255,255,.008) 0% 25%, transparent 0% 50%) 0 0 / 4px 4px,
    var(--bg-deep);
}

body.app-loading canvas,
body.app-loading #hud {
  visibility: hidden;
}

#boot-splash {
  display: none;
}

body.app-loading #boot-splash {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(circle at 50% 35%, rgba(38, 59, 96, .32), transparent 38%),
    linear-gradient(180deg, rgba(8, 11, 16, .88), rgba(8, 11, 16, .96)),
    var(--bg-deep);
}

.boot-card {
  width: min(460px, calc(100vw - 48px));
  padding: 28px 26px 24px;
  border-radius: 18px;
  border: 1px solid rgba(140, 100, 60, .55);
  background:
    linear-gradient(180deg, rgba(24, 31, 43, .98), rgba(14, 18, 27, .98)),
    var(--bg-raised);
  box-shadow:
    0 18px 60px rgba(0, 0, 0, .45),
    inset 0 1px 0 rgba(255,255,255,.06),
    0 0 0 1px rgba(46,58,85,.45);
  position: relative;
  overflow: hidden;
}

.boot-card::before {
  content: '';
  position: absolute;
  inset: 10px;
  border: 1px solid rgba(142, 238, 255, .08);
  border-radius: 12px;
  pointer-events: none;
}

.boot-badge {
  width: 72px;
  height: 72px;
  border-radius: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 18px;
  background: linear-gradient(180deg, #f8d27a, #c78d39);
  border: 2px solid rgba(255, 238, 136, .32);
  box-shadow:
    0 10px 22px rgba(199,141,57,.22),
    inset 0 1px 0 rgba(255,255,255,.35);
  overflow: hidden;
  position: relative;
}

.boot-badge::before {
  content: '';
  width: 48px;
  height: 48px;
  background-image: url('../assets/SproutLands-Sprites/Characters/Premium Charakter Spritesheet.png');
  background-repeat: no-repeat;
  background-size: 384px 1152px;
  background-position: 0 -192px;
  image-rendering: pixelated;
  transform: scale(3);
  transform-origin: center;
  animation: boot-cat-walk .72s steps(8) infinite;
}

@keyframes boot-cat-walk {
  from {
    background-position: 0 -192px;
  }
  to {
    background-position: -384px -192px;
  }
}

.boot-kicker,
.boot-title {
  font-family: 'Press Start 2P', 'SproutPixel', monospace;
}

.boot-kicker {
  font-size: 10px;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: #8ef;
  margin-bottom: 10px;
}

.boot-title {
  margin: 0 0 12px;
  color: var(--accent-warm);
  font-size: clamp(22px, 3vw, 30px);
  line-height: 1.2;
  text-shadow: 0 2px 0 rgba(0,0,0,.35);
}

.boot-copy {
  margin: 0 0 20px;
  color: var(--text-dim);
  font-size: 13px;
  line-height: 1.6;
}

.boot-progress-shell {
  height: 16px;
  padding: 3px;
  border-radius: 999px;
  background: rgba(8, 11, 16, .85);
  border: 1px solid rgba(46,58,85,.8);
  box-shadow: inset 0 1px 6px rgba(0,0,0,.45);
}

.boot-progress-bar {
  width: 0%;
  height: 100%;
  border-radius: 999px;
  background:
    repeating-linear-gradient(
      90deg,
      rgba(255,255,255,.14) 0 10px,
      rgba(255,255,255,0) 10px 20px
    ),
    linear-gradient(90deg, #5a9aff, #8ef 55%, #ffee88);
  box-shadow:
    0 0 18px rgba(90,154,255,.22),
    inset 0 1px 0 rgba(255,255,255,.28);
  transition: width .18s ease;
}

.boot-progress-meta {
  margin-top: 12px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  font-family: 'SproutPixel', ui-monospace, monospace;
  font-size: 12px;
}

#boot-progress-label {
  color: var(--accent-warm);
}

#boot-progress-status {
  color: #93a6c4;
  text-align: right;
}

/* ─── Game frame (responsive canvas container) ─── */
/* Base = mobile portrait: full-width top, aspect-ratio 4:3 */
#game-frame {
  width: 100%;
  max-width: 100vw;
  min-width: 0;
  aspect-ratio: 4 / 3;
  height: auto;
  max-height: 70dvh;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
}

#game-frame canvas {
  margin: 0 !important;
  image-rendering: pixelated;
  display: block;
  border-radius: 4px;
  box-shadow:
    0 0 0 1px var(--border-dim),
    0 4px 24px rgba(0,0,0,.5),
    0 0 80px -20px rgba(90,160,255,.08);
}

/* ─── HUD ─── */
/* Base = mobile compact */
#hud {
  position: fixed;
  top: 4px; left: 4px;
  font-size: 11px;
  background: rgba(9,12,16,.8);
  backdrop-filter: blur(6px);
  padding: 3px 8px;
  border-radius: 6px;
  border: 1px solid var(--border-dim);
  pointer-events: none;
  z-index: 10;
  box-shadow: 0 2px 12px rgba(0,0,0,.4);
}
#hud b { color: var(--accent-warm); }

/* ─── Panels container (wraps #panels + #right-panels) ─── */
/* Base = mobile portrait: row, proporción 2:3 */
#panels-container {
  display: flex;
  flex-direction: row;
  gap: 2px;
  flex: 1;
  min-height: 0;
}
/* Ocultar cuando ningun panel hijo es visible (menu, editor) */
#panels-container:not(:has(.panels-visible)) {
  display: none;
}

/* ─── Panel flex positions (mobile portrait base) ─── */
#panels {
  flex: 2;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
#right-panels {
  flex: 3;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
#editor-panel {
  flex: 1;
  min-height: 0;
}

/* ─── Mobile landscape: fila horizontal ─── */
@media (orientation: landscape) and (max-height: 500px) {
  body {
    flex-direction: row;
    padding: 4px;
    gap: 4px;
  }
  #game-frame {
    width: auto;
    max-width: none;
    max-height: 100dvh;
    aspect-ratio: auto;
    flex-shrink: 0;
  }
  #panels-container {
    flex-direction: row;
    gap: 4px;
  }
  #panels {
    flex: 1;
  }
  #right-panels {
    flex: 1;
  }
  #hud {
    font-size: 11px;
    padding: 3px 8px;
  }
}

/* ─── Tablet (≥768px): canvas izquierda, paneles apilados derecha ─── */
@media (min-width: 768px) {
  body {
    padding: 8px;
    gap: 8px;
  }
  /* Game: row (canvas izq + paneles der). Editor: mantiene column hasta ≥1100px. */
  body:not(.editor-active) {
    flex-direction: row;
  }
  #game-frame {
    flex: 1.5;
    width: auto;
    max-width: none;
    max-height: none;
    aspect-ratio: auto;
    align-self: center;
  }
  #panels-container {
    flex-direction: column;
    justify-content: center;
    gap: 8px;
    flex: 1;
    max-width: 250px;
  }
  #panels {
    flex: none;
    overflow-y: initial;
    -webkit-overflow-scrolling: auto;
  }
  #right-panels {
    flex: none;
    overflow-y: auto;
  }
  #hud {
    top: 8px; left: 8px;
    font-size: 14px;
    padding: 6px 12px;
  }
}

/* ─── Desktop (≥1100px): layout horizontal de 3 zonas ─── */
@media (min-width: 1100px) {
  body {
    flex-direction: row;
    align-items: center;
    justify-content: center;
    gap: 24px;
    padding: 16px 24px;
    height: auto;
    overflow: auto;
  }
  /* Contenedor transparente: los paneles se posicionan como hijos directos de body */
  #panels-container {
    display: contents;
  }
  #game-frame {
    flex: 3 1 0;
    min-width: 320px;
    max-height: 98vh;
    order: 2;
    width: auto;
    align-self: initial;
  }
  #panels      { order: 1; }
  #right-panels{ order: 3; }
  #editor-panel{ order: 3; }
}
