/* Hub world — Sprout Lands tilemap + camera */
.hub-screen {
  position: fixed;
  inset: 0;
  width: 100dvw;
  height: 100dvh;
  z-index: 15;
  overflow: hidden;
  background: #3498db;
}

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

.hub-viewport {
  position: absolute;
  inset: 0;
  overflow: hidden;
  background: linear-gradient(180deg, #5dade2 0%, #3498db 45%, #2874a6 100%);
}

/* Unified design canvas — same as maps/ui-pad.tmj (844×390) */
.hub-stage {
  position: absolute;
  width: 844px;
  height: 390px;
  overflow: hidden;
  transform-origin: top left;
  z-index: 1;
  contain: layout style paint;
}

.hub-map-wrap {
  position: absolute;
  top: 0;
  left: 0;
  overflow: hidden;
  transform-origin: top left;
  --hub-tile: 16px;
}

.hub-world {
  position: absolute;
  top: 0;
  left: 0;
  will-change: transform;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

.hub-canvas {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 1;
  display: block;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

.hub-canvas-fg {
  z-index: 11;
  pointer-events: none;
}

.hub-canvas-animals {
  z-index: 4;
  pointer-events: none;
}

/* Player — hub map uses SVG slime with hop + ground shadow */
.hub-player {
  position: absolute;
  left: 0;
  top: 0;
  bottom: auto !important;
  width: var(--hub-tile, 16px);
  height: calc(var(--hub-tile, 16px) * 1.29);
  --bridge-cell-size: var(--hub-tile, 16px);
  z-index: 10;
  pointer-events: none;
  transform-origin: bottom center;
  overflow: visible;
  visibility: visible;
}

.hub-player-shadow {
  position: absolute;
  left: 50%;
  bottom: 1px;
  width: 72%;
  height: 14%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.3);
  border-radius: 50%;
  pointer-events: none;
  z-index: 0;
  transform-origin: center center;
}

.hub-player-body {
  position: absolute;
  inset: 0;
  transform-origin: bottom center;
  z-index: 1;
  pointer-events: none;
  will-change: transform;
}

.hub-player-body.character--slime::before,
.hub-player-body.character--slime::after {
  display: none !important;
}

.hub-player-body.character--slime .slime-sprite {
  position: absolute;
  left: 50%;
  bottom: 0;
  width: 150%;
  height: auto;
  transform: translateX(-50%);
  overflow: visible;
  pointer-events: none;
}

.hub-player.hub-player--behind {
  z-index: 6;
}

.hub-player.hub-player--in-front {
  z-index: 12;
}

.hub-player.character {
  position: absolute;
  left: 0;
  top: 0;
  bottom: auto !important;
  width: var(--hub-tile, 16px);
  height: calc(var(--hub-tile, 16px) * 1.29);
  --bridge-cell-size: var(--hub-tile, 16px);
  z-index: 10;
  pointer-events: none;
  transform-origin: bottom center;
}

.hub-player-sprite {
  position: absolute;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  display: block;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  pointer-events: none;
  filter: drop-shadow(0 1px 0 rgba(0, 0, 0, 0.35));
}

.hub-player.character--sprite {
  width: calc(var(--hub-tile, 16px) * 2);
  height: calc(var(--hub-tile, 16px) * 2);
}

.hub-player.character--sprite::before,
.hub-player.character--sprite::after {
  display: none !important;
}

.hub-player.character:not(.character--sprite).facing-left {
  transform: scaleX(-1);
}

/* Floating building prompt — compact card on house roof */
.hub-world > .hub-prompt.hub-game-card--compact {
  position: absolute;
  z-index: 200;
  width: calc(var(--hub-tile, 16px) * 3);
  min-width: 0;
  max-width: calc(var(--hub-tile, 16px) * 3.15);
  padding: calc(var(--hub-tile, 16px) * 0.35) 2px calc(var(--hub-tile, 16px) * 0.2);
  background: #1a2a3a;
  border: 2px solid #0d1824;
  outline: 1px solid #4fc3f7;
  box-shadow:
    2px 2px 0 rgba(8, 16, 24, 0.65),
    inset 0 0 0 1px #2a4058;
  text-align: center;
  box-sizing: border-box;
  pointer-events: auto;
  cursor: pointer;
  touch-action: manipulation;
  image-rendering: pixelated;
  animation: hub-prompt-pop 0.18s ease-out;
  font: inherit;
  color: inherit;
  appearance: none;
  -webkit-appearance: none;
}

.hub-world > .hub-prompt.hub-game-card--compact::after {
  bottom: -4px;
  border-left-width: 3px;
  border-right-width: 3px;
  border-top-width: 4px;
}

.hub-world > .hub-prompt.hub-game-card--compact::before {
  bottom: -2px;
  border-left-width: 2px;
  border-right-width: 2px;
  border-top-width: 3px;
}

.hub-world > .hub-prompt {
  position: absolute;
  z-index: 120;
  width: calc(var(--hub-tile, 16px) * 4.25);
  min-width: 0;
  max-width: calc(var(--hub-tile, 16px) * 4.5);
  padding: 3px 4px 4px;
  background: #1a2a3a;
  border: 2px solid #0d1824;
  outline: 1px solid #4fc3f7;
  box-shadow:
    2px 2px 0 rgba(8, 16, 24, 0.65),
    inset 0 0 0 1px #2a4058;
  text-align: center;
  box-sizing: border-box;
  pointer-events: auto;
  cursor: pointer;
  touch-action: manipulation;
  image-rendering: pixelated;
  animation: hub-prompt-pop 0.18s ease-out;
  font: inherit;
  color: inherit;
  appearance: none;
  -webkit-appearance: none;
}

.hub-world > .hub-prompt::after {
  content: '';
  position: absolute;
  left: 50%;
  bottom: -5px;
  transform: translateX(-50%);
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-top: 5px solid #0d1824;
}

.hub-world > .hub-prompt::before {
  content: '';
  position: absolute;
  left: 50%;
  bottom: -3px;
  transform: translateX(-50%);
  border-left: 3px solid transparent;
  border-right: 3px solid transparent;
  border-top: 4px solid #1a2a3a;
  z-index: 1;
}

.hub-game-card--compact .hub-prompt__title {
  font-size: clamp(5px, calc(var(--hub-tile, 16px) * 0.28), 7px);
  margin: 0 0 calc(var(--hub-tile, 16px) * 0.15);
  padding-top: 1px;
  line-height: 1.55;
}

.hub-game-card--compact .hub-prompt__enter {
  font-size: clamp(5px, calc(var(--hub-tile, 16px) * 0.26), 7px);
  padding: 2px 3px;
  margin-top: 0;
}

.hub-prompt[hidden] {
  display: none !important;
}

@keyframes hub-prompt-pop {
  from { opacity: 0; transform: translateY(calc(var(--hub-tile, 16px) * 0.15)); }
  to { opacity: 1; transform: translateY(0); }
}

.hub-prompt__title {
  font-family: 'Press Start 2P', monospace;
  font-size: clamp(6px, calc(var(--hub-tile, 16px) * 0.42), 11px);
  color: #ffe566;
  text-shadow: 1px 1px 0 #1a3a5a;
  margin: 0 0 calc(var(--hub-tile, 16px) * 0.2);
  line-height: 1.6;
}

.hub-prompt__hint {
  font-size: clamp(6px, calc(var(--hub-tile, 16px) * 0.34), 10px);
  color: #e8f8ff;
  margin: 0 0 calc(var(--hub-tile, 16px) * 0.25);
  line-height: 1.5;
}

.hub-prompt__enter {
  display: inline-block;
  font-family: 'Press Start 2P', monospace;
  font-size: clamp(5px, calc(var(--hub-tile, 16px) * 0.28), 7px);
  color: #fff;
  background: #43a047;
  border: 1px solid #1b5e20;
  box-shadow: 1px 1px 0 #0d3d12;
  padding: 2px 4px;
  margin-top: 0;
  pointer-events: none;
}

.hub-world > .hub-prompt:active {
  transform: translate(2px, 2px);
  box-shadow:
    2px 2px 0 rgba(8, 16, 24, 0.65),
    inset 0 0 0 2px #2a4058;
}

.hub-world > .hub-prompt:active .hub-prompt__enter {
  transform: translate(0, 0);
  box-shadow: 1px 1px 0 #0d3d12;
}

/* Overlay UI */
.hub-screen__header {
  position: absolute;
  top: max(6px, env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  z-index: 20;
  text-align: center;
  padding: 6px 14px;
  background: rgba(22, 38, 54, 0.72);
  border: 2px solid rgba(26, 42, 58, 0.9);
  box-shadow: 3px 3px 0 rgba(8, 16, 24, 0.35);
  pointer-events: none;
}

.hub-screen__title {
  font-family: 'Press Start 2P', monospace;
  font-size: clamp(7px, 2vmin, 11px);
  color: #fff;
  text-shadow: 2px 2px 0 #1a3a5a;
  margin: 0 0 3px;
  line-height: 1.5;
}

.hub-screen__hint {
  font-size: clamp(6px, 1.6vmin, 9px);
  color: #d8ecff;
  margin: 0;
  line-height: 1.4;
}

.hub-controls-hint {
  position: absolute;
  bottom: max(18px, env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  z-index: 20;
  margin: 0;
  padding: 4px 10px;
  font-size: clamp(6px, 1.5vmin, 9px);
  color: #fff;
  text-shadow: 1px 1px 0 #1a3a5a;
  background: rgba(22, 38, 54, 0.65);
  border: 2px solid rgba(26, 42, 58, 0.85);
  white-space: nowrap;
  pointer-events: none;
}

.hub-credit {
  position: absolute;
  bottom: max(4px, env(safe-area-inset-bottom));
  right: max(6px, env(safe-area-inset-right));
  z-index: 20;
  margin: 0;
  font-size: clamp(5px, 1.2vmin, 8px);
  color: rgba(255, 255, 255, 0.75);
  text-shadow: 1px 1px 0 rgba(0, 0, 0, 0.35);
  pointer-events: none;
}

.panel-back-bar {
  flex-shrink: 0;
  width: 100%;
  padding:
    6px
    max(10px, env(safe-area-inset-right))
    max(6px, env(safe-area-inset-bottom))
    max(10px, env(safe-area-inset-left));
  box-sizing: border-box;
  background: rgba(36, 59, 85, 0.95);
  border-top: 3px solid #1a2a3a;
}

.panel-back-bar .game-back-button {
  width: 100%;
}

.custom-panel .panel-back-bar {
  position: relative;
  z-index: 10;
}
