/* ==========================================================================
   Pocket Dinos — The Amber Loom & Prehistoric Sanctuary (AAA Web Stylesheet)
   Visual Direction: Warm Bone, Deep Teal, Mossy Fern, Terracotta Clay,
   Amber Gold, Oxidized Cyan. Tactile painterly UI, 44px+ hit targets.
   ========================================================================== */

:root {
  --bone: #F4EFE2;
  --bone-bright: #FBF8F0;
  --bone-muted: #DDD3BD;
  --bone-ink: #2B241B;

  --deep-teal: #13343B;
  --abyss-teal: #0A1E24;
  --teal-panel: #173E47;
  --sanctum-ink: #14241C;
  --sanctum-card: rgba(20, 38, 30, 0.92);

  --moss-fern: #3D7A5A;
  --fern-deep: #24513A;
  --meadow-glow: #8CE070;

  --clay: #C96A42;
  --clay-deep: #8A3F21;

  --amber-gold: #E59F3A;
  --amber-bright: #FFD275;
  --amber-deep: #8F5410;

  --oxidized-cyan: #3AD8E6;
  --cyan-deep: #157482;

  --level-violet: #9F6FF5;
  --danger-coral: #E05A47;

  --radius-sm: 12px;
  --radius-md: 18px;
  --radius-lg: 24px;
  --radius-xl: 30px;
  --radius-pill: 999px;

  --shadow-soft: 0 8px 24px rgba(5, 16, 19, 0.28);
  --shadow-elevated: 0 18px 44px rgba(4, 13, 16, 0.52);
  --border-bone: 1px solid rgba(244, 239, 226, 0.26);
  --border-amber: 1.5px solid rgba(229, 159, 58, 0.58);
  --border-cyan: 1.5px solid rgba(58, 216, 230, 0.55);

  --font-display: "Trebuchet MS", "Avenir Next Rounded", "Segoe UI Rounded", "Nunito", system-ui, sans-serif;
  --font-body: "Segoe UI", -apple-system, BlinkMacSystemFont, "Helvetica Neue", sans-serif;
  --font-mono: ui-monospace, "Cascadia Mono", "SF Mono", Consolas, monospace;

  --hiq-safe-top: 0px;
  --hiq-safe-right: 0px;
  --hiq-safe-bottom: 0px;
  --hiq-safe-left: 0px;
  --safe-top: max(var(--hiq-safe-top), env(safe-area-inset-top, 0px));
  --safe-right: max(var(--hiq-safe-right), env(safe-area-inset-right, 0px));
  --safe-bottom: max(var(--hiq-safe-bottom), env(safe-area-inset-bottom, 0px));
  --safe-left: max(var(--hiq-safe-left), env(safe-area-inset-left, 0px));

  --hud-top-offset: 88px;
  --toast-top-offset: 92px;
  --preserve-hud-clearance: 68px;
  --dock-bottom-offset: calc(124px + var(--safe-bottom));
}

/* High Contrast Mode Overrides */
html[data-high-contrast="true"] {
  --bone: #FFFFFF;
  --bone-muted: #F0EBD8;
  --deep-teal: #091F24;
  --abyss-teal: #040D10;
  --sanctum-card: rgba(8, 18, 14, 0.98);
  --amber-gold: #FFB940;
  --oxidized-cyan: #5CEBFF;
  --border-bone: 2px solid rgba(255, 255, 255, 0.72);
  --border-amber: 2px solid #FFC44D;
  --border-cyan: 2px solid #66F0FF;
}

*,
*::before,
*::after {
  box-sizing: border-box;
  scrollbar-width: thin;
  scrollbar-color: rgba(229, 159, 58, 0.42) rgba(8, 22, 19, 0.28);
}

::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: rgba(6, 18, 20, 0.35);
  border-radius: 999px;
}

::-webkit-scrollbar-thumb {
  background: rgba(229, 159, 58, 0.44);
  border-radius: 999px;
  border: 1px solid rgba(255, 210, 117, 0.22);
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 210, 117, 0.72);
}

::-webkit-scrollbar-corner {
  background: transparent;
}

[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100dvh;
  overflow: hidden;
  background: radial-gradient(circle at 50% 18%, #184049 0%, #0B2026 60%, #061317 100%);
  color: var(--bone);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
  user-select: none;
}

body {
  display: flex;
  flex-direction: column;
}

button,
input,
textarea {
  font-family: inherit;
  color: inherit;
}

button {
  cursor: pointer;
  border: none;
  background: none;
  touch-action: manipulation;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

button:focus-visible,
input:focus-visible,
[tabindex]:focus-visible {
  outline: 3px solid var(--oxidized-cyan);
  outline-offset: 2px;
}

.svg-sprite-defs {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
  pointer-events: none;
}

.ico-sm {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.ico-md {
  width: 22px;
  height: 22px;
  flex-shrink: 0;
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: 8px;
  z-index: 9999;
  padding: 12px 18px;
  border-radius: var(--radius-pill);
  background: var(--amber-gold);
  color: #1A1206;
  font-weight: 800;
  text-decoration: none;
}

.skip-link:focus {
  left: 12px;
}

/* ==========================================================================
   1. Top Collapsible QA & Playtest Studio Deck
   ========================================================================== */
/* Hide QA & Playtest Studio Deck immediately when hosted by HearthIQ or running inside Capacitor native */
html[data-hiq-hosted="true"] #qa-deck,
html[data-capacitor-native="true"] #qa-deck {
  display: none !important;
}

.qa-deck {
  flex-shrink: 0;
  z-index: 80;
  background: linear-gradient(180deg, rgba(11, 28, 33, 0.98) 0%, rgba(16, 40, 46, 0.95) 100%);
  border-bottom: 1px solid rgba(244, 239, 226, 0.18);
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.35);
}

.qa-deck-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 6px 14px;
  min-height: 46px;
}

.qa-brand {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
  flex: 1 1 auto;
}

.qa-amber-dot {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, var(--amber-bright), var(--amber-gold) 65%, var(--amber-deep));
  box-shadow: 0 0 10px rgba(229, 159, 58, 0.8);
  flex-shrink: 0;
}

.qa-brand-title {
  font-family: var(--font-display);
  font-weight: 900;
  font-size: 0.86rem;
  letter-spacing: 0.08em;
  color: var(--bone);
  white-space: nowrap;
  flex-shrink: 0;
}

.qa-brand-sub {
  font-size: 0.76rem;
  color: rgba(244, 239, 226, 0.68);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

@media (max-width: 640px) {
  .qa-brand {
    overflow: hidden;
  }
  .qa-brand-title {
    min-width: 0;
    flex-shrink: 1;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .qa-brand-sub {
    display: none;
  }
  .qa-deck-bar {
    gap: 6px;
    padding: 6px 10px;
  }
}

.qa-quick-pills {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.qa-status-pill {
  padding: 5px 11px;
  border-radius: var(--radius-pill);
  background: rgba(61, 122, 90, 0.32);
  border: 1px solid rgba(140, 224, 112, 0.38);
  font-size: 0.74rem;
  font-weight: 700;
  color: var(--bone);
  white-space: nowrap;
}

.qa-toggle-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 36px;
  padding: 6px 13px;
  border-radius: var(--radius-pill);
  background: linear-gradient(180deg, rgba(229, 159, 58, 0.24), rgba(229, 159, 58, 0.12));
  border: 1px solid rgba(229, 159, 58, 0.52);
  color: var(--amber-bright);
  font-size: 0.78rem;
  font-weight: 800;
  white-space: nowrap;
  flex-shrink: 0;
  transition: transform 0.14s ease, background 0.14s ease;
}

.qa-toggle-btn:hover {
  background: rgba(229, 159, 58, 0.32);
}

.qa-deck:not(.is-collapsed) .qa-chevron {
  transform: rotate(180deg);
}

.qa-deck-panel {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 18px;
  padding: 8px 14px 12px;
  border-top: 1px solid rgba(244, 239, 226, 0.12);
  background: rgba(8, 22, 26, 0.85);
  max-height: 42dvh;
  overflow-y: auto;
}

.qa-group {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 8px;
}

.qa-group-label {
  font-size: 0.7rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: rgba(244, 239, 226, 0.62);
  margin-right: 2px;
}

.qa-btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.qa-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  min-height: 44px;
  padding: 8px 13px;
  border-radius: var(--radius-pill);
  background: rgba(244, 239, 226, 0.09);
  border: 1px solid rgba(244, 239, 226, 0.22);
  color: var(--bone);
  font-size: 0.76rem;
  font-weight: 700;
  white-space: nowrap;
  flex-shrink: 0;
  transition: background 0.14s ease, border-color 0.14s ease, transform 0.1s ease;
}

.qa-deck .qa-chip {
  min-height: 36px;
  padding: 6px 12px;
}

.qa-chip:hover {
  background: rgba(244, 239, 226, 0.18);
}

.qa-chip.is-active {
  background: var(--moss-fern);
  border-color: var(--meadow-glow);
  color: #FFFFFF;
  box-shadow: 0 0 12px rgba(140, 224, 112, 0.32);
}

.qa-chip-amber {
  background: rgba(229, 159, 58, 0.2);
  border-color: rgba(229, 159, 58, 0.55);
  color: var(--amber-bright);
}

.qa-chip-cyan {
  background: rgba(58, 216, 230, 0.16);
  border-color: rgba(58, 216, 230, 0.48);
  color: #A8F2FA;
}

.qa-chip-danger {
  background: rgba(224, 90, 71, 0.18);
  border-color: rgba(224, 90, 71, 0.5);
  color: #FFB4A8;
}

/* ==========================================================================
   2. Device Frame Simulator & Game Shell
   ========================================================================== */
.device-stage {
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

.game-frame {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--deep-teal);
}

html[data-device="iphone"] .device-stage,
html[data-device="ipad"] .device-stage {
  padding: 10px;
}

html[data-device="iphone"] .game-frame {
  width: 390px;
  max-width: 100%;
  height: min(844px, 100%);
  border-radius: 38px;
  border: 7px solid #1E3238;
  box-shadow:
    0 26px 70px rgba(0, 0, 0, 0.72),
    0 0 0 1.5px rgba(244, 239, 226, 0.22);
}

html[data-device="ipad"] .game-frame {
  width: 820px;
  max-width: 100%;
  height: min(1060px, 100%);
  border-radius: 30px;
  border: 7px solid #1E3238;
  box-shadow:
    0 26px 70px rgba(0, 0, 0, 0.72),
    0 0 0 1.5px rgba(244, 239, 226, 0.22);
}

/* ==========================================================================
   3. Compact Sanctuary HUD (Top Overlay)
   ========================================================================== */
.compact-hud {
  position: absolute;
  top: calc(8px + var(--safe-top));
  left: calc(10px + var(--safe-left));
  right: calc(10px + var(--safe-right));
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  pointer-events: none;
  flex-wrap: wrap;
}

.hud-pill-cluster,
.hud-atelier-cluster {
  display: flex;
  align-items: center;
  gap: 6px;
  pointer-events: auto;
  flex-shrink: 0;
}

.hud-pill-cluster {
  padding: 6px 12px;
  min-height: 44px;
  max-width: 100%;
  border-radius: var(--radius-pill);
  background: linear-gradient(180deg, rgba(22, 38, 30, 0.84) 0%, rgba(15, 29, 23, 0.9) 100%);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(244, 239, 226, 0.34);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.32);
  gap: 12px;
}

@media (min-width: 1080px) {
  html[data-device="desktop"] .compact-hud {
    flex-wrap: nowrap;
  }
}

.compact-hud[data-clay="true"] .hud-pill-cluster {
  background: linear-gradient(180deg, rgba(138, 63, 33, 0.88) 0%, rgba(96, 41, 19, 0.92) 100%);
}

.hud-stat {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  flex-shrink: 0;
  white-space: nowrap;
}

.hud-icon {
  width: 22px;
  height: 22px;
  object-fit: contain;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.45));
}

.hud-icon-sm {
  width: 20px;
  height: 20px;
  object-fit: contain;
}

.hud-val {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 0.88rem;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  color: #FFFFFF;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

.hud-level-stat,
#hud-level,
[data-testid="hud-level"],
#hud-level-val {
  flex-shrink: 0;
}

.hud-level-stack {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex-shrink: 0;
}

.hud-xp-track {
  width: 38px;
  height: 4px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.22);
  overflow: hidden;
}

.hud-xp-fill {
  display: block;
  height: 100%;
  border-radius: 4px;
  background: linear-gradient(90deg, var(--level-violet), var(--oxidized-cyan));
  transition: width 0.28s ease;
}

.hud-chip-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 44px;
  min-width: 44px;
  padding: 6px 11px;
  border-radius: var(--radius-pill);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 0.84rem;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  flex-shrink: 0;
  box-shadow: 0 5px 14px rgba(0, 0, 0, 0.3);
  transition: transform 0.14s ease, filter 0.14s ease;
}

.hud-chip-btn:hover {
  transform: translateY(-1px);
  filter: brightness(1.08);
}

.hud-chip-amber {
  background: linear-gradient(180deg, rgba(143, 84, 16, 0.9), rgba(92, 52, 8, 0.94));
  border: 1px solid rgba(255, 210, 117, 0.6);
  color: var(--amber-bright);
}

.hud-chip-cyan {
  background: linear-gradient(180deg, rgba(19, 68, 78, 0.9), rgba(11, 44, 52, 0.94));
  border: 1px solid rgba(58, 216, 230, 0.58);
  color: #B4F6FF;
}

.hud-chip-guide {
  background: linear-gradient(180deg, rgba(34, 68, 52, 0.92), rgba(20, 44, 34, 0.96));
  border: 1px solid rgba(244, 239, 226, 0.48);
  color: var(--bone);
}

.hud-coach-pill {
  pointer-events: auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  flex: 0 1 auto;
  min-width: 120px;
  min-height: 44px;
  padding: 6px 14px;
  border-radius: var(--radius-pill);
  background: linear-gradient(180deg, rgba(229, 159, 58, 0.94), rgba(176, 104, 18, 0.96));
  border: 1.5px solid rgba(255, 236, 186, 0.85);
  color: #1B1002;
  font-family: var(--font-display);
  font-weight: 900;
  font-size: 0.8rem;
  letter-spacing: 0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
  box-shadow: 0 5px 16px rgba(229, 159, 58, 0.35);
  transition: transform 0.14s ease, filter 0.14s ease;
}

.hud-coach-pill:hover {
  transform: translateY(-1px);
  filter: brightness(1.06);
}

.hud-round-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  background: rgba(20, 38, 30, 0.86);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(244, 239, 226, 0.34);
  color: var(--bone);
  box-shadow: 0 5px 14px rgba(0, 0, 0, 0.3);
}

.hud-round-btn[aria-pressed="false"] {
  color: rgba(244, 239, 226, 0.48);
}

html[data-capacitor-native="true"] #hud-fullscreen-toggle,
html[data-device="iphone"] #hud-fullscreen-toggle {
  display: none;
}

@media (max-width: 767px) {
  #hud-fullscreen-toggle {
    display: none;
  }
}

/* Compact HUD adaptation on narrow iPhone frame & mobile viewports (<= 520px) */
html[data-device="iphone"] {
  --hud-top-offset: calc(80px + var(--safe-top));
  --preserve-hud-clearance: calc(74px + var(--safe-top));
  --dock-bottom-offset: calc(74px + var(--safe-bottom));
}

html[data-device="iphone"] .compact-hud {
  left: calc(6px + var(--safe-left));
  right: calc(6px + var(--safe-right));
  top: calc(4px + var(--safe-top));
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas:
    "stats atelier"
    "coach coach";
  align-items: center;
  gap: 4px;
}

html[data-device="iphone"] .hud-pill-cluster {
  grid-area: stats;
  width: auto;
  min-width: 0;
  justify-content: flex-start;
  align-content: center;
  min-height: 44px;
  padding: 4px 7px;
  gap: 2px 5px;
  border-radius: 18px;
  flex-wrap: wrap;
  overflow-x: visible;
  scrollbar-width: none;
}

html[data-device="iphone"] .hud-stat {
  gap: 2px;
}

html[data-device="iphone"] .hud-coach-pill {
  grid-area: coach;
  width: 100%;
  min-height: 44px;
  padding: 6px 10px;
  font-size: 0.72rem;
}

html[data-device="iphone"] .hud-atelier-cluster {
  grid-area: atelier;
  width: auto;
  min-width: 0;
  justify-content: flex-end;
  gap: 3px;
  flex-wrap: nowrap;
}

html[data-device="iphone"] .hud-icon {
  width: 13px;
  height: 13px;
}

html[data-device="iphone"] .hud-icon-sm {
  width: 13px;
  height: 13px;
}

html[data-device="iphone"] .hud-xp-track {
  width: 20px;
  height: 3px;
}

html[data-device="iphone"] .hud-val,
html[data-device="iphone"] .hud-chip-btn {
  font-size: 0.65rem;
  letter-spacing: -0.02em;
}

html[data-device="iphone"] .hud-chip-btn {
  min-height: 44px;
  min-width: 44px;
  padding: 4px 6px;
  gap: 3px;
}

html[data-device="iphone"] #hud-field-guide-btn,
html[data-device="iphone"] #hud-guide-btn {
  width: 44px;
  min-width: 44px;
  justify-content: center;
  padding: 4px;
}

html[data-device="iphone"] .hud-guide-label {
  display: none;
}

html[data-device="iphone"] .hud-round-btn {
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
}

html[data-device="iphone"][data-hiq-hosted="true"] #hud-sound-toggle {
  display: none;
}

@media (max-width: 520px) {
  :root {
    --hud-top-offset: calc(98px + var(--safe-top));
    --preserve-hud-clearance: calc(94px + var(--safe-top));
    --dock-bottom-offset: calc(74px + var(--safe-bottom));
  }
  .compact-hud {
    left: calc(6px + var(--safe-left));
    right: calc(6px + var(--safe-right));
    top: calc(4px + var(--safe-top));
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
      "stats atelier"
      "coach coach";
    align-items: center;
    gap: 4px 5px;
  }
  .hud-pill-cluster {
    grid-area: stats;
    width: auto;
    min-width: 0;
    justify-content: flex-start;
    align-content: center;
    min-height: 44px;
    padding: 4px 7px;
    gap: 2px 5px;
    border-radius: 18px;
    flex-wrap: wrap;
    overflow-x: visible;
    scrollbar-width: none;
  }
  .hud-stat {
    gap: 3px;
  }
  .hud-xp-pill {
    gap: 3px;
  }
  .hud-coach-pill {
    grid-area: coach;
    width: 100%;
    min-height: 44px;
    padding: 6px 10px;
    font-size: 0.72rem;
  }
  .hud-atelier-cluster {
    grid-area: atelier;
    width: auto;
    min-width: 0;
    justify-content: flex-end;
    gap: 3px;
    flex-wrap: nowrap;
  }
  .hud-icon {
    width: 14px;
    height: 14px;
  }
  .hud-icon-sm {
    width: 14px;
    height: 14px;
  }
  .hud-xp-track {
    width: 22px;
    height: 3px;
  }
  .hud-val,
  .hud-chip-btn {
    font-size: 0.68rem;
  }
  .hud-chip-btn {
    min-height: 44px;
    min-width: 44px;
    padding: 4px 6px;
    gap: 3px;
  }
  #hud-field-guide-btn,
  #hud-guide-btn {
    width: 44px;
    min-width: 44px;
    justify-content: center;
    padding: 4px;
  }
  .hud-guide-label {
    display: none;
  }
  .hud-round-btn {
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
    flex-shrink: 0;
  }
  html[data-hiq-hosted="true"] #hud-sound-toggle {
    display: none;
  }
}

@media (max-width: 400px) {
  .compact-hud {
    left: calc(4px + var(--safe-left));
    right: calc(4px + var(--safe-right));
    gap: 4px 3px;
  }
  .hud-pill-cluster {
    min-height: 44px;
    padding: 4px 6px;
    gap: 2px 4px;
    border-radius: 16px;
    flex-wrap: wrap;
    overflow-x: visible;
    flex-shrink: 1;
  }
  .hud-stat {
    gap: 2px;
  }
  .hud-atelier-cluster {
    gap: 2px;
  }
  .hud-icon,
  .hud-icon-sm {
    width: 11px;
    height: 11px;
  }
  .hud-xp-track {
    width: 18px;
    height: 3px;
  }
  .hud-val,
  .hud-chip-btn {
    font-size: 0.62rem;
    letter-spacing: -0.025em;
  }
  .hud-chip-btn {
    min-height: 44px;
    min-width: 44px;
    padding: 4px 5px;
    gap: 2px;
  }
  #hud-field-guide-btn,
  #hud-guide-btn {
    width: 44px;
    min-width: 44px;
    justify-content: center;
    padding: 4px;
  }
  .hud-round-btn {
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
  }
}

/* ==========================================================================
   4. Screen Viewport & Loading Veil
   ========================================================================== */
.screen-viewport {
  position: relative;
  flex: 1;
  min-height: 0;
  width: 100%;
  overflow: hidden;
}

.game-screen {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow-y: auto;
  overflow-x: hidden;
  scroll-padding-top: var(--hud-top-offset);
  scroll-padding-bottom: var(--dock-bottom-offset);
  -webkit-overflow-scrolling: touch;
}

#screen-preserve {
  overflow: hidden;
}

.loading-veil {
  position: absolute;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: radial-gradient(circle at 50% 38%, #1E4C56 0%, #0E272E 68%, #08171B 100%);
}

.loading-card {
  max-width: 360px;
  padding: 32px 28px;
  border-radius: var(--radius-xl);
  background: rgba(20, 38, 30, 0.92);
  border: var(--border-amber);
  text-align: center;
  box-shadow: var(--shadow-elevated);
}

.loading-amber-orb {
  width: 64px;
  height: 64px;
  margin: 0 auto 16px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #FFF2B8, var(--amber-gold) 58%, var(--amber-deep));
  box-shadow: 0 0 28px rgba(229, 159, 58, 0.75);
  animation: amberPulse 2s ease-in-out infinite;
}

.loading-title {
  margin: 0 0 8px;
  font-family: var(--font-display);
  font-size: 1.6rem;
  color: var(--bone);
}

.loading-subtitle {
  margin: 0;
  font-size: 0.92rem;
  color: var(--bone-muted);
  line-height: 1.45;
}

@keyframes amberPulse {
  0%, 100% { transform: scale(1); box-shadow: 0 0 24px rgba(229, 159, 58, 0.65); }
  50% { transform: scale(1.07); box-shadow: 0 0 40px rgba(58, 216, 230, 0.7); }
}

/* ==========================================================================
   5. Bottom 6-Tab Prehistoric Navigation Dock
   ========================================================================== */
.bottom-dock {
  position: absolute;
  bottom: calc(8px + var(--safe-bottom));
  left: 0;
  right: 0;
  margin: 0 auto;
  transform: none;
  width: min(636px, calc(100% - 14px - var(--safe-left) - var(--safe-right)));
  z-index: 42;
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 5px;
  padding: 6px 7px;
  border-radius: 26px;
  background: linear-gradient(180deg, rgba(24, 44, 34, 0.92) 0%, rgba(14, 27, 21, 0.96) 100%);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  border: 1.5px solid rgba(244, 239, 226, 0.28);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.52);
  box-sizing: border-box;
  transition: width 0.16s ease, border-radius 0.16s ease, padding 0.16s ease, gap 0.16s ease;
}

.dock-tab {
  position: relative;
  min-width: 0;
  min-height: 62px;
  padding: 5px 3px;
  border-radius: 19px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  color: rgba(244, 239, 226, 0.76);
  background: rgba(244, 239, 226, 0.04);
  border: 1px solid transparent;
  transition: transform 0.15s ease, background 0.15s ease, border-color 0.15s ease;
}

.dock-tab:hover {
  background: rgba(244, 239, 226, 0.1);
  color: var(--bone);
}

.dock-tab.is-active {
  background: linear-gradient(180deg, rgba(61, 122, 90, 0.88) 0%, rgba(36, 81, 58, 0.95) 100%);
  border-color: rgba(169, 238, 146, 0.68);
  color: #FFFFFF;
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(24, 62, 42, 0.6);
}

.dock-icon-wrap {
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.dock-icon {
  width: 28px;
  height: 28px;
  object-fit: contain;
  filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.45));
}

.dock-label {
  font-family: var(--font-display);
  font-size: 0.71rem;
  font-weight: 800;
  letter-spacing: 0.01em;
  max-width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dock-badge {
  position: absolute;
  top: 4px;
  right: 5px;
  min-width: 18px;
  height: 18px;
  padding: 0 4px;
  border-radius: var(--radius-pill);
  background: linear-gradient(180deg, var(--amber-bright), var(--amber-gold));
  color: #1F1304;
  font-size: 0.66rem;
  font-weight: 900;
  line-height: 1;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.45);
}

@media (max-width: 520px) {
  .bottom-dock {
    bottom: calc(6px + var(--safe-bottom));
    width: calc(100% - 10px - var(--safe-left) - var(--safe-right));
    gap: 3px;
    padding: 4px;
    border-radius: 18px;
  }
  .dock-tab {
    min-height: 46px;
    padding: 3px 2px;
    border-radius: 13px;
    gap: 1px;
  }
  .dock-icon-wrap {
    width: 21px;
    height: 21px;
  }
  .dock-icon {
    width: 20px;
    height: 20px;
  }
  .dock-label {
    font-size: 0.6rem;
    letter-spacing: 0;
  }
  .dock-badge {
    top: 2px;
    right: 2px;
    min-width: 15px;
    height: 15px;
    font-size: 0.58rem;
  }
}

html[data-device="iphone"] .bottom-dock {
  bottom: calc(6px + var(--safe-bottom));
  width: calc(100% - 10px);
  gap: 3px;
  padding: 4px;
  border-radius: 18px;
}

html[data-device="iphone"] .dock-tab {
  min-height: 46px;
  padding: 3px 2px;
  border-radius: 13px;
  gap: 1px;
}

html[data-device="iphone"] .dock-icon-wrap {
  width: 21px;
  height: 21px;
}

html[data-device="iphone"] .dock-icon {
  width: 20px;
  height: 20px;
}

html[data-device="iphone"] .dock-label {
  font-size: 0.6rem;
  letter-spacing: 0;
}

html[data-device="iphone"] .dock-badge {
  top: 2px;
  right: 2px;
  min-width: 15px;
  height: 15px;
  font-size: 0.58rem;
}

/* Management Screen Flex Header/Footer Layout (Zero Floating Overlap) */
html[data-active-tab]:not([data-active-tab="preserve"]) {
  --hud-top-offset: 12px;
  --dock-bottom-offset: 16px;
}

html[data-active-tab]:not([data-active-tab="preserve"]) .compact-hud {
  position: relative;
  top: auto;
  left: auto;
  right: auto;
  flex-shrink: 0;
  width: 100%;
  padding: calc(8px + var(--safe-top)) calc(12px + var(--safe-right)) 8px calc(12px + var(--safe-left));
  background: linear-gradient(180deg, rgba(11, 28, 33, 0.96) 0%, rgba(14, 34, 40, 0.92) 100%);
  border-bottom: 1px solid rgba(244, 239, 226, 0.14);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.24);
  pointer-events: auto;
}

html[data-active-tab]:not([data-active-tab="preserve"]) .bottom-dock {
  position: relative;
  bottom: auto;
  left: auto;
  right: auto;
  transform: none;
  flex-shrink: 0;
  margin: 6px auto calc(8px + var(--safe-bottom));
}

html[data-active-tab]:not([data-active-tab="preserve"])[data-device="iphone"] .compact-hud {
  padding: calc(4px + var(--safe-top)) calc(8px + var(--safe-right)) 6px calc(8px + var(--safe-left));
}

html[data-active-tab]:not([data-active-tab="preserve"])[data-device="iphone"] .bottom-dock {
  margin: 4px auto calc(6px + var(--safe-bottom));
}

@media (max-width: 520px) {
  html[data-active-tab]:not([data-active-tab="preserve"]) .compact-hud {
    padding: calc(4px + var(--safe-top)) calc(8px + var(--safe-right)) 6px calc(8px + var(--safe-left));
  }
  html[data-active-tab]:not([data-active-tab="preserve"]) .bottom-dock {
    margin: 4px auto calc(6px + var(--safe-bottom));
  }
}

/* ==========================================================================
   6. Preserve Screen (Full-Bleed Habitat + Floating Tactile Overlays)
   ========================================================================== */
.preserve-layout {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #23472B;
}

.preserve-canvas-host {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.preserve-top-controls {
  position: absolute;
  top: var(--preserve-hud-clearance, var(--hud-top-offset));
  left: calc(10px + var(--safe-left));
  right: calc(10px + var(--safe-right));
  z-index: 25;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 6px 8px;
  flex-wrap: wrap;
  pointer-events: none;
}

.preserve-top-left,
.preserve-top-right {
  display: flex;
  align-items: center;
  gap: 6px 8px;
  flex-wrap: wrap;
  pointer-events: auto;
  min-width: 0;
}

.preserve-top-right {
  flex-shrink: 0;
  margin-left: auto;
}

.hungry-pill-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  padding: 5px 12px;
  border-radius: var(--radius-pill);
  background: linear-gradient(180deg, rgba(160, 96, 20, 0.92), rgba(108, 60, 10, 0.96));
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  border: 1.5px solid rgba(251, 191, 36, 0.78);
  color: #FFF8E7;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 0.8rem;
  white-space: nowrap;
  box-shadow: var(--shadow-soft);
  transition: transform 0.14s ease, filter 0.14s ease;
}

.hungry-pill-btn:hover {
  transform: translateY(-1px);
  filter: brightness(1.08);
}

.hungry-pill-btn img {
  width: 20px;
  height: 20px;
  object-fit: contain;
  flex-shrink: 0;
}

.hungry-pill-btn.is-urgent {
  background: linear-gradient(180deg, rgba(217, 91, 30, 0.95), rgba(154, 48, 12, 0.98));
  border-color: #FDBA74;
  box-shadow: 0 0 14px rgba(249, 115, 22, 0.45), var(--shadow-soft);
}

.hungry-pill-btn.is-all-fed {
  background: linear-gradient(180deg, rgba(36, 86, 58, 0.9), rgba(20, 52, 36, 0.95));
  border-color: rgba(140, 224, 112, 0.65);
  color: #DCFCE7;
}

.habitat-pill-btn {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  min-height: 44px;
  max-width: 100%;
  padding: 5px 14px 5px 6px;
  border-radius: var(--radius-pill);
  background: rgba(20, 38, 30, 0.84);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(244, 239, 226, 0.36);
  box-shadow: var(--shadow-soft);
  color: var(--bone);
}

html[data-device="iphone"] .preserve-top-controls {
  left: calc(8px + var(--safe-left));
  right: calc(8px + var(--safe-right));
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 6px;
}

html[data-device="iphone"] .preserve-top-left {
  flex-wrap: wrap;
  gap: 4px 6px;
  min-width: 0;
  flex: 1 1 auto;
}

html[data-device="iphone"] .habitat-pill-btn {
  min-height: 44px;
  gap: 5px;
  padding: 4px 10px 4px 5px;
  max-width: 100%;
  min-width: 0;
  flex: 0 0 auto;
}

html[data-device="iphone"] .habitat-pill-thumb {
  width: 24px;
  height: 24px;
}

html[data-device="iphone"] .habitat-pill-meta {
  flex-direction: row;
  align-items: baseline;
  gap: 4px;
  min-width: 0;
}

html[data-device="iphone"] .habitat-pill-name {
  font-size: 0.76rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

html[data-device="iphone"] .habitat-pill-occ {
  font-size: 0.68rem;
  white-space: nowrap;
}

html[data-device="iphone"] .occ-suffix {
  display: none;
}

html[data-device="iphone"] .hungry-pill-btn {
  min-height: 44px;
  padding: 4px 9px;
  font-size: 0.69rem;
  gap: 4px;
}

html[data-device="iphone"] .hungry-pill-btn img {
  width: 15px;
  height: 15px;
}

html[data-device="iphone"] .zoom-step-btn {
  min-height: 44px;
  min-width: 44px;
  padding: 0 6px;
  font-size: 0.86rem;
}

html[data-device="iphone"] .zoom-reset-btn {
  display: none;
}

@media (max-width: 520px) {
  .preserve-top-controls {
    left: calc(8px + var(--safe-left));
    right: calc(8px + var(--safe-right));
    flex-wrap: wrap;
    align-items: center;
    gap: 4px 6px;
  }
  .preserve-top-left {
    flex-wrap: wrap;
    gap: 4px 6px;
    min-width: 0;
    flex: 1 1 auto;
  }
  .habitat-pill-btn {
    min-height: 44px;
    gap: 5px;
    padding: 4px 10px 4px 5px;
    max-width: 100%;
    min-width: 0;
    flex: 0 0 auto;
  }
  .habitat-pill-thumb {
    width: 24px;
    height: 24px;
  }
  .habitat-pill-meta {
    flex-direction: row;
    align-items: baseline;
    gap: 4px;
    min-width: 0;
  }
  .habitat-pill-name {
    font-size: 0.76rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .habitat-pill-occ {
    font-size: 0.68rem;
    white-space: nowrap;
  }
  .occ-suffix {
    display: none;
  }
  .hungry-pill-btn {
    min-height: 44px;
    padding: 4px 9px;
    font-size: 0.69rem;
    gap: 4px;
  }
  .hungry-pill-btn img {
    width: 15px;
    height: 15px;
  }
  .zoom-step-btn {
    min-height: 44px;
    min-width: 44px;
    padding: 0 6px;
    font-size: 0.86rem;
  }
  .zoom-reset-btn {
    display: none;
  }
}

.habitat-pill-thumb {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
  border: 1.5px solid rgba(255, 255, 255, 0.55);
  background: var(--moss-fern);
}

.habitat-pill-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  line-height: 1.15;
}

.habitat-pill-name {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 0.86rem;
}

.habitat-pill-occ {
  font-size: 0.72rem;
  color: var(--bone-muted);
  font-variant-numeric: tabular-nums;
}

.badge-new {
  padding: 2px 7px;
  border-radius: var(--radius-pill);
  background: linear-gradient(180deg, var(--amber-bright), var(--amber-gold));
  color: #1F1203;
  font-size: 0.66rem;
  font-weight: 900;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.badge-hungry {
  padding: 2px 7px;
  border-radius: var(--radius-pill);
  background: rgba(249, 115, 22, 0.24);
  border: 1px solid rgba(251, 146, 60, 0.72);
  color: #FDBA74;
  font-size: 0.64rem;
  font-weight: 900;
  white-space: nowrap;
}

.badge-fed {
  padding: 2px 7px;
  border-radius: var(--radius-pill);
  background: rgba(61, 122, 90, 0.28);
  border: 1px solid rgba(140, 224, 112, 0.55);
  color: #BBF7D0;
  font-size: 0.64rem;
  font-weight: 800;
  white-space: nowrap;
}

.zoom-control-pill {
  display: inline-flex;
  align-items: center;
  border-radius: var(--radius-pill);
  background: rgba(20, 38, 30, 0.84);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(244, 239, 226, 0.34);
  box-shadow: var(--shadow-soft);
  overflow: hidden;
}

.zoom-step-btn,
.zoom-reset-btn {
  min-height: 44px;
  min-width: 44px;
  padding: 0 10px;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 0.86rem;
  color: var(--bone);
}

.zoom-reset-btn {
  min-width: 56px;
  border-left: 1px solid rgba(244, 239, 226, 0.16);
  border-right: 1px solid rgba(244, 239, 226, 0.16);
  font-variant-numeric: tabular-nums;
}

.zoom-step-btn:hover,
.zoom-reset-btn:hover {
  background: rgba(244, 239, 226, 0.14);
}

/* Habitat Picker Gallery Drawer & Hungry Dinosaurs Drawer */
.habitat-picker-drawer,
.hungry-dinos-drawer {
  position: absolute;
  top: calc(var(--preserve-hud-clearance, var(--hud-top-offset)) + 52px);
  left: 10px;
  right: 10px;
  max-width: 680px;
  max-height: calc(100% - var(--preserve-hud-clearance, 110px) - 145px);
  overflow-y: auto;
  z-index: 32;
  padding: 14px;
  border-radius: var(--radius-lg);
  background: rgba(16, 35, 30, 0.96);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  border: var(--border-bone);
  box-shadow: var(--shadow-elevated);
}

.hungry-dinos-drawer {
  max-width: 520px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  border-color: rgba(251, 191, 36, 0.48);
}

.hungry-dinos-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.hungry-dino-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 8px 10px;
  border-radius: var(--radius-md);
  background: rgba(244, 239, 226, 0.06);
  border: 1px solid rgba(244, 239, 226, 0.18);
}

.hungry-dino-thumb {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: rgba(12, 28, 22, 0.85);
  border: 1px solid rgba(244, 239, 226, 0.24);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  overflow: hidden;
}

.hungry-dino-thumb img {
  width: 38px;
  height: 38px;
  object-fit: contain;
}

.hungry-dino-meta {
  flex: 1 1 150px;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.hungry-dino-title {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 0.86rem;
  color: var(--bone);
}

.hungry-dino-sub {
  font-size: 0.74rem;
  color: var(--bone-muted);
  margin-top: 1px;
}

.hungry-dino-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
  flex-shrink: 0;
}

.hungry-dino-actions .qa-chip,
.hungry-dino-actions .care-btn {
  min-height: 44px !important;
  min-width: 44px;
  padding: 6px 12px !important;
}

.habitat-picker-drawer .modal-close-btn,
.hungry-dinos-drawer .modal-close-btn {
  width: 44px !important;
  height: 44px !important;
  min-width: 44px !important;
  min-height: 44px !important;
}

.hungry-other-biomes {
  padding-top: 8px;
  border-top: 1px solid rgba(244, 239, 226, 0.14);
}

html[data-device="iphone"] .habitat-picker-drawer,
html[data-device="iphone"] .hungry-dinos-drawer {
  top: calc(var(--preserve-hud-clearance, 74px) + 52px);
  max-height: calc(100% - var(--preserve-hud-clearance, 74px) - 128px);
}

@media (max-width: 520px) {
  .habitat-picker-drawer,
  .hungry-dinos-drawer {
    top: calc(var(--preserve-hud-clearance, 74px) + 52px);
    max-height: calc(100% - var(--preserve-hud-clearance, 74px) - 128px);
  }
}

.habitat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(195px, 1fr));
  gap: 10px;
  margin-top: 10px;
}

.habitat-card {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 68px;
  height: auto;
  flex-shrink: 0;
  padding: 9px 11px;
  border-radius: var(--radius-md);
  background: rgba(244, 239, 226, 0.06);
  border: 1.5px solid rgba(244, 239, 226, 0.18);
  text-align: left;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.habitat-card:hover:not(:disabled) {
  background: rgba(244, 239, 226, 0.13);
}

.habitat-card.is-selected {
  background: rgba(61, 122, 90, 0.42);
  border-color: var(--meadow-glow);
}

.habitat-card-thumb {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  object-fit: cover;
  border: 1px solid rgba(255, 255, 255, 0.35);
  flex-shrink: 0;
  background: var(--fern-deep);
}

.habitat-card-body {
  min-width: 0;
  flex: 1;
}

.habitat-card-title {
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 0.88rem;
  color: var(--bone);
}

.habitat-card-sub {
  font-size: 0.74rem;
  color: var(--bone-muted);
  margin-top: 2px;
}

/* Preserve Lower Floating Action Strip & Selected Dinosaur Tray */
.preserve-bottom-stack {
  position: absolute;
  left: calc(10px + var(--safe-left));
  right: calc(10px + var(--safe-right));
  bottom: calc(84px + var(--safe-bottom));
  max-height: calc(100% - var(--preserve-hud-clearance, 148px) - 96px - var(--safe-bottom));
  z-index: 28;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 8px;
  pointer-events: none;
}

html[data-device="iphone"] .preserve-bottom-stack {
  left: calc(8px + var(--safe-left));
  right: calc(8px + var(--safe-right));
  bottom: calc(66px + var(--safe-bottom));
  max-height: calc(100% - var(--preserve-hud-clearance, 74px) - 114px - var(--safe-bottom));
  gap: 4px;
}

html[data-device="iphone"] .preserve-bottom-stack.has-selected-dino .preserve-utility-row {
  display: none;
}

html[data-device="iphone"] .preserve-action-cluster .preserve-bulk-locked {
  display: none;
}

html[data-device="iphone"] .preserve-bottom-stack .dino-care-tray {
  padding: 7px 9px;
  border-radius: 16px;
  max-height: min(230px, 36dvh, calc(100dvh - var(--preserve-hud-clearance, 102px) - 210px - var(--safe-bottom)));
  overflow-y: auto;
}

html[data-device="iphone"] .preserve-bottom-stack .dino-care-header {
  gap: 8px;
  align-items: flex-start;
}

html[data-device="iphone"] .preserve-bottom-stack .dino-mini-stage {
  width: 44px;
  height: 44px;
  border-radius: 12px;
}

html[data-device="iphone"] .preserve-bottom-stack .dino-mini-stage img {
  width: 38px !important;
  height: 38px !important;
}

html[data-device="iphone"] .preserve-bottom-stack .dino-care-name {
  font-size: 0.92rem;
}

html[data-device="iphone"] .preserve-bottom-stack .dino-stage-chip {
  padding: 1px 6px;
  font-size: 0.64rem;
}

html[data-device="iphone"] .preserve-bottom-stack .dino-care-sub {
  font-size: 0.7rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

html[data-device="iphone"] .preserve-bottom-stack .dino-meters-row {
  gap: 5px 10px;
  margin-top: 3px;
}

html[data-device="iphone"] .preserve-bottom-stack .mini-meter {
  font-size: 0.68rem;
  gap: 4px;
}

html[data-device="iphone"] .preserve-bottom-stack .mini-meter-bar {
  width: 42px;
  height: 5px;
}

html[data-device="iphone"] .preserve-bottom-stack .dino-stats-strip {
  font-size: 0.66rem !important;
  gap: 6px !important;
  margin-top: 2px !important;
}

html[data-device="iphone"] .preserve-bottom-stack .icon-44-btn {
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
  font-size: 0.95rem;
}

html[data-device="iphone"] .preserve-bottom-stack .dino-care-actions {
  margin-top: 6px;
  gap: 5px;
}

html[data-device="iphone"] .preserve-bottom-stack .care-btn {
  min-height: 44px;
  padding: 6px 9px;
  font-size: 0.72rem;
  gap: 4px;
  white-space: nowrap;
}

html[data-device="iphone"] .preserve-bottom-stack .care-btn img {
  width: 15px;
  height: 15px;
}

@media (max-width: 520px) {
  .preserve-bottom-stack {
    left: calc(8px + var(--safe-left));
    right: calc(8px + var(--safe-right));
    bottom: calc(66px + var(--safe-bottom));
    max-height: calc(100% - var(--preserve-hud-clearance, 74px) - 114px - var(--safe-bottom));
    gap: 4px;
  }
  .preserve-bottom-stack.has-selected-dino .preserve-utility-row {
    display: none;
  }
  .preserve-action-cluster .preserve-bulk-locked {
    display: none;
  }
  .preserve-bottom-stack .dino-care-tray {
    padding: 7px 9px;
    border-radius: 16px;
    max-height: min(230px, 36dvh, calc(100dvh - var(--preserve-hud-clearance, 102px) - 210px - var(--safe-bottom)));
    overflow-y: auto;
  }
  .preserve-bottom-stack .dino-care-header {
    gap: 8px;
    align-items: flex-start;
  }
  .preserve-bottom-stack .dino-mini-stage {
    width: 44px;
    height: 44px;
    border-radius: 12px;
  }
  .preserve-bottom-stack .dino-mini-stage img {
    width: 38px !important;
    height: 38px !important;
  }
  .preserve-bottom-stack .dino-care-name {
    font-size: 0.92rem;
  }
  .preserve-bottom-stack .dino-stage-chip {
    padding: 1px 6px;
    font-size: 0.64rem;
  }
  .preserve-bottom-stack .dino-care-sub {
    font-size: 0.7rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .preserve-bottom-stack .dino-meters-row {
    gap: 5px 10px;
    margin-top: 3px;
  }
  .preserve-bottom-stack .mini-meter {
    font-size: 0.68rem;
    gap: 4px;
  }
  .preserve-bottom-stack .mini-meter-bar {
    width: 42px;
    height: 5px;
  }
  .preserve-bottom-stack .dino-stats-strip {
    font-size: 0.66rem !important;
    gap: 6px !important;
    margin-top: 2px !important;
  }
  .preserve-bottom-stack .icon-44-btn {
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
    font-size: 0.95rem;
  }
  .preserve-bottom-stack .dino-care-actions {
    margin-top: 6px;
    gap: 5px;
  }
  .preserve-bottom-stack .care-btn {
    min-height: 44px;
    padding: 6px 9px;
    font-size: 0.72rem;
    gap: 4px;
    white-space: nowrap;
  }
  .preserve-bottom-stack .care-btn img {
    width: 15px;
    height: 15px;
  }
}

.preserve-utility-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
  pointer-events: none;
}

.preserve-action-cluster {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  pointer-events: auto;
}

.tactile-pill-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 44px;
  padding: 8px 14px;
  border-radius: var(--radius-pill);
  background: rgba(20, 38, 30, 0.88);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(244, 239, 226, 0.34);
  color: var(--bone);
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 0.82rem;
  box-shadow: var(--shadow-soft);
  transition: transform 0.14s ease, background 0.14s ease;
}

.tactile-pill-btn:hover:not(:disabled) {
  transform: translateY(-1px);
  background: rgba(34, 64, 50, 0.94);
}

.tactile-pill-amber {
  background: linear-gradient(180deg, rgba(204, 132, 34, 0.92), rgba(145, 84, 14, 0.96));
  border-color: rgba(255, 222, 145, 0.72);
  color: #FFFDF7;
}

.tactile-pill-fern {
  background: linear-gradient(180deg, rgba(61, 122, 90, 0.94), rgba(36, 81, 58, 0.96));
  border-color: rgba(164, 236, 142, 0.65);
  color: #FFFFFF;
}

.habitat-activity-strip {
  display: flex;
  align-items: center;
  gap: 6px;
  overflow-x: auto;
  max-width: 100%;
  padding: 2px;
  pointer-events: auto;
}

.activity-prop-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(20, 38, 30, 0.86);
  border: 1px solid rgba(244, 239, 226, 0.34);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: var(--shadow-soft);
}

.activity-prop-btn img {
  width: 28px;
  height: 28px;
  object-fit: contain;
}

/* Selected Dinosaur Temporary Care Tray */
.dino-care-tray {
  pointer-events: auto;
  max-width: 860px;
  width: 100%;
  margin: 0 auto;
  padding: 11px 14px;
  max-height: min(250px, 38dvh);
  overflow-y: auto;
  border-radius: var(--radius-lg);
  background: linear-gradient(180deg, rgba(20, 40, 32, 0.95) 0%, rgba(13, 27, 22, 0.98) 100%);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  border: 1.5px solid rgba(244, 239, 226, 0.32);
  box-shadow: var(--shadow-elevated);
}

.dino-care-header {
  display: flex;
  align-items: center;
  gap: 12px;
}

.dino-mini-stage {
  width: 64px;
  height: 64px;
  border-radius: 18px;
  background: radial-gradient(circle at 50% 35%, rgba(61, 122, 90, 0.52), rgba(13, 33, 28, 0.92));
  border: 1.5px solid rgba(140, 224, 112, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  overflow: hidden;
}

.dino-care-info {
  flex: 1;
  min-width: 0;
}

.dino-care-title-row {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-wrap: wrap;
}

.dino-care-name {
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 900;
  color: var(--bone);
}

.dino-stage-chip {
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  background: rgba(244, 239, 226, 0.14);
  font-size: 0.7rem;
  font-weight: 800;
  text-transform: capitalize;
}

.splice-pill-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  background: rgba(229, 159, 58, 0.22);
  border: 1px solid rgba(229, 159, 58, 0.55);
  color: var(--amber-bright);
  font-size: 0.7rem;
  font-weight: 800;
}

.dino-care-sub {
  font-size: 0.78rem;
  color: var(--bone-muted);
  margin-top: 2px;
}

.dino-meters-row {
  display: flex;
  gap: 12px;
  margin-top: 6px;
  flex-wrap: wrap;
}

.mini-meter {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.74rem;
  font-weight: 700;
}

.mini-meter-growth {
  color: #B6F4FF;
  max-width: 100%;
  flex-wrap: wrap;
  font-variant-numeric: tabular-nums;
}

.mini-meter-growth .mini-meter-bar {
  width: 76px;
  flex-shrink: 0;
}

html[data-device="iphone"] .mini-meter-growth {
  font-size: 0.7rem;
  gap: 5px;
}

html[data-device="iphone"] .mini-meter-growth .mini-meter-bar {
  width: 60px;
}

@media (max-width: 520px) {
  .mini-meter-growth {
    font-size: 0.7rem;
    gap: 5px;
  }
  .mini-meter-growth .mini-meter-bar {
    width: 60px;
  }
}

.mini-meter-bar {
  width: 68px;
  height: 6px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.16);
  overflow: hidden;
}

.mini-meter-fill {
  display: block;
  height: 100%;
  border-radius: 6px;
}

.dino-care-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 5px;
  margin-top: 9px;
  overflow-x: visible;
  padding-bottom: 0;
}

.care-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  min-height: 44px;
  padding: 6px 10px;
  border-radius: 14px;
  background: rgba(244, 239, 226, 0.1);
  border: 1px solid rgba(244, 239, 226, 0.24);
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 0.77rem;
  white-space: nowrap;
  flex-shrink: 0;
}

.care-btn span {
  white-space: nowrap;
}

.care-btn:hover:not(:disabled) {
  background: rgba(244, 239, 226, 0.18);
}

.care-btn.is-cooldown {
  opacity: 0.72;
  background: rgba(244, 239, 226, 0.05);
  border-color: rgba(140, 224, 112, 0.34);
  color: var(--bone-muted);
}

.care-btn.is-cooldown:hover {
  opacity: 0.88;
  background: rgba(244, 239, 226, 0.1);
}

.care-btn.is-needs-food {
  background: linear-gradient(180deg, rgba(229, 132, 34, 0.92), rgba(168, 76, 14, 0.96));
  border-color: #FDBA74;
  color: #FFFDF7;
  box-shadow: 0 0 12px rgba(249, 115, 22, 0.36);
}

.care-btn.is-needs-food:hover {
  filter: brightness(1.08);
  background: linear-gradient(180deg, rgba(238, 142, 42, 0.96), rgba(178, 82, 18, 0.98));
}

.care-btn img {
  width: 20px;
  height: 20px;
  object-fit: contain;
}

.care-btn-loom {
  background: linear-gradient(180deg, rgba(229, 159, 58, 0.28), rgba(58, 216, 230, 0.2));
  border-color: rgba(229, 159, 58, 0.6);
  color: var(--amber-bright);
}

.icon-44-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(244, 239, 226, 0.1);
  border: 1px solid rgba(244, 239, 226, 0.24);
  flex-shrink: 0;
}

.icon-44-btn.is-fav {
  background: rgba(229, 159, 58, 0.28);
  border-color: var(--amber-gold);
  color: var(--amber-bright);
}

/* Top-Down Placement Map Floating Banner */
.workshop-topdown-banner {
  position: absolute;
  top: calc(var(--preserve-hud-clearance, var(--hud-top-offset)) + 52px);
  left: 10px;
  right: 10px;
  z-index: 29;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
  padding: 5px 10px;
  border-radius: var(--radius-pill);
  background: rgba(11, 29, 25, 0.9);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(58, 216, 230, 0.45);
  box-shadow: var(--shadow-soft);
  pointer-events: auto;
}

.workshop-topdown-copy {
  font-family: var(--font-display);
  font-size: 0.74rem;
  font-weight: 800;
  color: var(--bone);
  line-height: 1.25;
}

.workshop-fit-btn {
  min-height: 44px;
  min-width: 44px;
  padding: 6px 12px;
  flex-shrink: 0;
}

/* Workshop Decoration Panel */
.workshop-panel {
  pointer-events: auto;
  max-width: 900px;
  width: 100%;
  margin: 0 auto;
  padding: 8px 12px;
  border-radius: var(--radius-lg);
  background: rgba(17, 34, 28, 0.96);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  border: var(--border-amber);
  box-shadow: var(--shadow-elevated);
}

.workshop-top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 6px;
}

.workshop-selected-pill {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border-radius: var(--radius-pill);
  background: rgba(58, 216, 230, 0.16);
  border: 1px solid rgba(58, 216, 230, 0.45);
  color: #C4F8FF;
  font-size: 0.72rem;
  font-weight: 800;
  max-width: 190px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.workshop-commit-btn {
  min-height: 44px;
  padding: 6px 12px;
  font-size: 0.78rem;
}

.workshop-catalog-strip {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 134px;
  gap: 7px;
  overflow-x: auto;
  padding: 2px 2px 6px;
}

.workshop-empty-note {
  grid-column: 1 / -1;
  min-width: 260px;
  padding: 12px 10px;
  font-size: 0.78rem;
  color: var(--bone-muted);
  text-align: center;
}

.decor-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 6px;
  border-radius: 14px;
  background: rgba(244, 239, 226, 0.07);
  border: 1px solid rgba(244, 239, 226, 0.2);
  text-align: center;
}

.decor-placed-card {
  cursor: pointer;
  transition: border-color 0.14s ease, background 0.14s ease;
}

.decor-placed-card.is-selected {
  background: rgba(58, 216, 230, 0.16);
  border-color: var(--oxidized-cyan);
}

.decor-inv-pill {
  font-size: 0.64rem;
  font-weight: 800;
  color: var(--amber-bright);
  background: rgba(229, 159, 58, 0.16);
  border: 1px solid rgba(229, 159, 58, 0.36);
  border-radius: var(--radius-pill);
  padding: 1px 6px;
  line-height: 1.3;
  white-space: nowrap;
}

.decor-dual-actions {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.decor-thumb-wrap {
  position: relative;
  width: 46px;
  height: 46px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
}

.decor-thumb-wrap.is-watering-hole::before {
  content: "";
  position: absolute;
  width: 34px;
  height: 25px;
  top: 54%;
  left: 51%;
  transform: translate(-50%, -46%);
  border-radius: 50%;
  background: radial-gradient(
    ellipse at 44% 38%,
    #74F5FF 0%,
    #28BED6 46%,
    #0E6C82 84%,
    #083E4D 100%
  );
  box-shadow:
    inset 0 2px 5px rgba(255, 255, 255, 0.48),
    0 0 8px rgba(58, 216, 230, 0.35);
  z-index: 0;
  pointer-events: none;
}

.decor-card img {
  position: relative;
  z-index: 1;
  width: 42px;
  height: 42px;
  object-fit: contain;
}

.decor-card-name {
  font-size: 0.71rem;
  font-weight: 800;
  line-height: 1.18;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  min-height: 2.1em;
}

.decor-card-action {
  width: 100%;
  min-height: 44px;
  padding: 6px 8px;
  border-radius: 10px;
  background: var(--moss-fern);
  color: #FFFFFF;
  font-size: 0.72rem;
  font-weight: 800;
}

.decor-card-action.decor-recall-btn {
  background: linear-gradient(180deg, rgba(204, 132, 34, 0.94), rgba(145, 84, 14, 0.96));
  color: #FFFDF7;
}

.decor-card-action.decor-buy-more-btn {
  background: rgba(244, 239, 226, 0.14);
  border: 1px solid rgba(244, 239, 226, 0.3);
  color: var(--bone);
  min-height: 44px;
  padding: 6px 8px;
  font-size: 0.68rem;
}

/* Desktop / Wide (>= 820px, non-iPhone frame): Right-Docked Full-Height Workshop Sidebar */
@media (min-width: 820px) {
  html:not([data-device="iphone"]) .workshop-topdown-banner {
    left: 10px;
    right: calc(clamp(336px, 34vw, 420px) + 22px);
    padding: 4px 10px;
  }

  html:not([data-device="iphone"]) .preserve-bottom-stack.is-workshop-editing {
    top: calc(var(--preserve-hud-clearance, 92px) + 54px);
    bottom: 86px;
    right: 12px;
    left: auto;
    width: clamp(336px, 34vw, 420px);
    display: flex;
  }

  html:not([data-device="iphone"]) .preserve-bottom-stack.is-workshop-editing .workshop-panel {
    width: 100%;
    max-width: none;
    height: 100%;
    display: flex;
    flex-direction: column;
    min-height: 0;
  }

  html:not([data-device="iphone"]) .preserve-bottom-stack.is-workshop-editing .workshop-catalog-strip {
    grid-auto-flow: row;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-auto-columns: initial;
    overflow-y: auto;
    overflow-x: hidden;
    flex: 1;
    min-height: 0;
    align-content: start;
    padding-right: 4px;
  }
}

/* Mobile / Narrow (< 820px or iPhone Frame): Ultra-Compact Bottom Workshop Strip */
@media (max-width: 819px) {
  .workshop-topdown-banner {
    top: calc(var(--preserve-hud-clearance, 142px) + 52px);
    flex-wrap: nowrap;
    padding: 4px 8px;
    gap: 6px;
  }
  .workshop-topdown-banner .workshop-topdown-copy {
    flex: 1;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 0.7rem;
  }
  .workshop-topdown-banner .workshop-fit-btn {
    min-height: 44px;
    min-width: 44px;
    padding: 6px 10px;
    font-size: 0.72rem;
  }
  .preserve-bottom-stack.is-workshop-editing {
    bottom: 76px;
    left: 8px;
    right: 8px;
  }
  .preserve-bottom-stack.is-workshop-editing .workshop-panel {
    padding: 6px 8px;
    min-width: 0;
    max-width: 100%;
    box-sizing: border-box;
    overflow: hidden;
  }
  .preserve-bottom-stack.is-workshop-editing .workshop-top-bar {
    width: 100%;
    min-width: 0;
    max-width: 100%;
    box-sizing: border-box;
    overflow: hidden;
    gap: 4px;
    margin-bottom: 4px;
    flex-direction: column;
    align-items: stretch;
  }
  .preserve-bottom-stack.is-workshop-editing .workshop-filter-row {
    display: flex;
    flex-wrap: nowrap !important;
    overflow-x: auto;
    width: 100%;
    min-width: 0;
    max-width: 100%;
    padding-bottom: 2px;
    gap: 4px;
    scrollbar-width: none;
  }
  .preserve-bottom-stack.is-workshop-editing .workshop-action-row {
    display: flex;
    flex-wrap: wrap !important;
    width: 100%;
    min-width: 0;
    max-width: 100%;
    gap: 4px;
  }
  .preserve-bottom-stack.is-workshop-editing .workshop-filter-row .qa-chip {
    flex-shrink: 0;
    min-height: 44px;
    padding: 6px 10px;
    font-size: 0.7rem;
  }
  .preserve-bottom-stack.is-workshop-editing .workshop-action-row .qa-chip,
  .preserve-bottom-stack.is-workshop-editing .workshop-commit-btn {
    flex-shrink: 0;
    min-height: 44px;
    padding: 6px 10px;
    font-size: 0.7rem;
  }
  .preserve-bottom-stack.is-workshop-editing .workshop-selected-pill {
    flex-shrink: 0;
    min-height: 28px;
    padding: 3px 8px;
    font-size: 0.67rem;
    max-width: 120px;
  }
  .preserve-bottom-stack.is-workshop-editing .workshop-catalog-strip {
    min-width: 0;
    width: 100%;
    max-width: 100%;
    grid-auto-columns: 118px;
    gap: 6px;
    padding: 2px 2px 3px;
  }
  .preserve-bottom-stack.is-workshop-editing .decor-card {
    padding: 5px;
    gap: 3px;
  }
  .preserve-bottom-stack.is-workshop-editing .decor-thumb-wrap {
    width: 34px;
    height: 34px;
  }
  .preserve-bottom-stack.is-workshop-editing .decor-thumb-wrap.is-watering-hole::before {
    width: 26px;
    height: 19px;
  }
  .preserve-bottom-stack.is-workshop-editing .decor-thumb-wrap img {
    width: 32px;
    height: 32px;
  }
  .preserve-bottom-stack.is-workshop-editing .decor-card-name {
    min-height: 1.9em;
    font-size: 0.68rem;
  }
  .preserve-bottom-stack.is-workshop-editing .workshop-panel .decor-card-action {
    min-height: 44px;
    padding: 6px 8px;
    font-size: 0.68rem;
  }
}

html[data-device="iphone"] .workshop-topdown-banner {
  top: calc(var(--preserve-hud-clearance, 142px) + 52px);
  flex-wrap: nowrap;
  padding: 4px 8px;
  gap: 6px;
}

html[data-device="iphone"] .workshop-topdown-banner .workshop-topdown-copy {
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 0.7rem;
}

html[data-device="iphone"] .workshop-topdown-banner .workshop-fit-btn {
  min-height: 44px;
  min-width: 44px;
  padding: 6px 10px;
  font-size: 0.72rem;
}

html[data-device="iphone"] .preserve-bottom-stack.is-workshop-editing {
  bottom: 76px;
  left: 8px;
  right: 8px;
}

html[data-device="iphone"] .preserve-bottom-stack.is-workshop-editing .workshop-panel {
  padding: 6px 8px;
  min-width: 0;
  max-width: 100%;
  box-sizing: border-box;
  overflow: hidden;
}

html[data-device="iphone"] .preserve-bottom-stack.is-workshop-editing .workshop-top-bar {
  width: 100%;
  min-width: 0;
  max-width: 100%;
  box-sizing: border-box;
  overflow: hidden;
  gap: 4px;
  margin-bottom: 4px;
  flex-direction: column;
  align-items: stretch;
}

html[data-device="iphone"] .preserve-bottom-stack.is-workshop-editing .workshop-filter-row {
  display: flex;
  flex-wrap: nowrap !important;
  overflow-x: auto;
  width: 100%;
  min-width: 0;
  max-width: 100%;
  padding-bottom: 2px;
  gap: 4px;
  scrollbar-width: none;
}

html[data-device="iphone"] .preserve-bottom-stack.is-workshop-editing .workshop-action-row {
  display: flex;
  flex-wrap: wrap !important;
  width: 100%;
  min-width: 0;
  max-width: 100%;
  gap: 4px;
}

html[data-device="iphone"] .preserve-bottom-stack.is-workshop-editing .workshop-filter-row .qa-chip,
html[data-device="iphone"] .preserve-bottom-stack.is-workshop-editing .workshop-action-row .qa-chip,
html[data-device="iphone"] .preserve-bottom-stack.is-workshop-editing .workshop-commit-btn {
  flex-shrink: 0;
  min-height: 44px;
  padding: 6px 10px;
  font-size: 0.7rem;
}

html[data-device="iphone"] .preserve-bottom-stack.is-workshop-editing .workshop-selected-pill {
  flex-shrink: 0;
  min-height: 28px;
  padding: 3px 8px;
  font-size: 0.67rem;
  max-width: 120px;
}

html[data-device="iphone"] .preserve-bottom-stack.is-workshop-editing .workshop-catalog-strip {
  min-width: 0;
  width: 100%;
  max-width: 100%;
  grid-auto-columns: 118px;
  gap: 6px;
  padding: 2px 2px 3px;
}

html[data-device="iphone"] .preserve-bottom-stack.is-workshop-editing .decor-card {
  padding: 5px;
  gap: 3px;
}

html[data-device="iphone"] .preserve-bottom-stack.is-workshop-editing .decor-thumb-wrap {
  width: 34px;
  height: 34px;
}

html[data-device="iphone"] .preserve-bottom-stack.is-workshop-editing .decor-thumb-wrap.is-watering-hole::before {
  width: 26px;
  height: 19px;
}

html[data-device="iphone"] .preserve-bottom-stack.is-workshop-editing .decor-thumb-wrap img {
  width: 32px;
  height: 32px;
}

html[data-device="iphone"] .preserve-bottom-stack.is-workshop-editing .decor-card-name {
  min-height: 1.9em;
  font-size: 0.68rem;
}

html[data-device="iphone"] .preserve-bottom-stack.is-workshop-editing .workshop-panel .decor-card-action {
  min-height: 44px;
  padding: 6px 8px;
  font-size: 0.68rem;
}

/* ==========================================================================
   7. Excavation / Dig Screen
   ========================================================================== */
.dig-screen-wrap {
  min-height: 100%;
  padding: var(--hud-top-offset) 12px var(--dock-bottom-offset);
  background:
    radial-gradient(circle at 50% 25%, rgba(201, 106, 66, 0.28), transparent 62%),
    linear-gradient(180deg, #3B2014 0%, #24140D 100%);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.dig-inner {
  width: min(1040px, 100%);
  min-width: 0;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.section-card,
.loom-chamber,
.dig-board-card,
.nest-card,
.cta-primary-amber {
  scroll-margin-top: var(--hud-top-offset);
  scroll-margin-bottom: var(--dock-bottom-offset);
}

.section-card {
  padding: 14px 16px;
  border-radius: var(--radius-lg);
  background: var(--sanctum-card);
  border: var(--border-bone);
  box-shadow: var(--shadow-soft);
}

.section-card-bone {
  background: linear-gradient(180deg, #F7F2E6 0%, #EAE0CA 100%);
  color: var(--bone-ink);
  border: 1.5px solid rgba(143, 84, 16, 0.32);
}

.pill-strip,
.dinodex-chip-strip {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 7px;
  max-width: 100%;
  min-width: 0;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 2px 24px 6px 2px;
  scrollbar-width: thin;
  -webkit-overflow-scrolling: touch;
  -webkit-mask-image: linear-gradient(90deg, #000 0%, #000 calc(100% - 22px), transparent 100%);
  mask-image: linear-gradient(90deg, #000 0%, #000 calc(100% - 22px), transparent 100%);
}

.pill-strip::after,
.dinodex-chip-strip::after {
  content: "";
  flex: 0 0 24px;
  min-width: 24px;
  height: 1px;
}

.pill-strip > *,
.dinodex-chip-strip > * {
  white-space: nowrap;
  flex-shrink: 0;
}

.pill-strip button,
.dinodex-chip-strip button {
  min-height: 44px;
}

@media (min-width: 768px) {
  html:not([data-device="iphone"]) .pill-strip {
    flex-wrap: wrap;
    overflow-x: visible;
    padding: 2px 2px 6px 2px;
    -webkit-mask-image: none;
    mask-image: none;
  }
  html:not([data-device="iphone"]) .pill-strip::after {
    display: none;
  }
}

.filter-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  padding: 7px 14px;
  border-radius: var(--radius-pill);
  background: rgba(244, 239, 226, 0.09);
  border: 1px solid rgba(244, 239, 226, 0.24);
  color: var(--bone);
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 0.8rem;
  white-space: nowrap;
  flex-shrink: 0;
}

.filter-pill.is-active {
  background: linear-gradient(180deg, var(--clay) 0%, var(--clay-deep) 100%);
  border-color: var(--amber-bright);
  color: #FFFFFF;
}

.filter-pill-teal.is-active {
  background: linear-gradient(180deg, var(--moss-fern), var(--fern-deep));
  border-color: var(--meadow-glow);
}

.dig-stage-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 12px;
  align-items: start;
  width: 100%;
  min-width: 0;
}

.dig-stage-grid > * {
  min-width: 0;
  max-width: 100%;
}

@media (min-width: 880px) {
  html:not([data-device="iphone"]) .dig-screen-wrap {
    padding: 6px 12px 8px;
    gap: 6px;
  }
  html:not([data-device="iphone"]) .dig-inner {
    gap: 6px;
  }
  html:not([data-device="iphone"]) [data-dig-top-controls] .section-card {
    padding: 8px 12px;
    gap: 6px;
  }
  html:not([data-device="iphone"]) .dig-stage-grid {
    grid-template-columns: minmax(280px, 330px) minmax(0, 1fr);
    gap: 10px;
  }
  html:not([data-device="iphone"]) .dig-board-card {
    padding: 8px 12px;
    gap: 6px;
  }
  html:not([data-device="iphone"]) .dig-Telemetry-bar {
    padding: 4px 10px;
  }
  html:not([data-device="iphone"]) .dig-legend-strip {
    padding: 4px 8px;
    font-size: 0.7rem;
  }
  html:not([data-device="iphone"]) .dig-canvas-host {
    width: min(100%, max(280px, min(460px, 48dvh, calc(100dvh - 505px))));
  }
  html:not([data-device="iphone"]) .dig-tools-dock {
    gap: 6px;
  }
  html:not([data-device="iphone"]) .dig-tool-medallion {
    min-height: 76px;
    padding: 20px 5px 6px;
  }
}

@media (min-width: 1024px) {
  html:not([data-device="iphone"]) .dig-inner {
    width: min(1140px, 100%);
  }
  html:not([data-device="iphone"]) .dig-stage-grid {
    grid-template-columns: minmax(250px, 275px) minmax(0, 1fr);
    gap: 10px;
  }
  html:not([data-device="iphone"]) [data-dig-tier-sidebar] .section-card {
    max-height: min(460px, calc(100dvh - 340px)) !important;
  }
  html:not([data-device="iphone"]) .dig-board-card {
    display: grid;
    grid-template-columns: auto minmax(260px, 1fr);
    grid-template-rows: auto auto auto 1fr;
    grid-template-areas:
      "telemetry telemetry"
      "legend legend"
      "canvas tools"
      "canvas ctas";
    align-items: start;
    justify-items: stretch;
    gap: 6px 12px;
    padding: 8px 12px;
  }
  html:not([data-device="iphone"]) .dig-Telemetry-bar {
    grid-area: telemetry;
  }
  html:not([data-device="iphone"]) .dig-legend-strip {
    grid-area: legend;
    padding: 3px 8px;
  }
  html:not([data-device="iphone"]) .dig-canvas-host {
    grid-area: canvas;
    width: min(420px, 46dvh, calc(100dvh - 445px));
    min-width: 280px;
    justify-self: center;
  }
  html:not([data-device="iphone"]) .dig-tools-dock {
    grid-area: tools;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
    align-content: start;
  }
  html:not([data-device="iphone"]) .dig-tool-medallion {
    width: 100%;
    min-height: 70px;
    padding: 18px 4px 6px;
  }
  html:not([data-device="iphone"]) .dig-tools-dock [data-rotate-chisel] {
    grid-column: 1 / -1;
    width: 100%;
    justify-content: center;
    min-height: 44px;
  }
  html:not([data-device="iphone"]) [data-dig-bottom-ctas] {
    grid-area: ctas;
    align-self: start;
    justify-content: stretch !important;
  }
  html:not([data-device="iphone"]) [data-dig-bottom-ctas] .cta-primary-amber {
    max-width: none !important;
    min-height: 48px;
    padding: 10px 14px;
    font-size: 0.9rem;
  }
  html:not([data-device="iphone"]) [data-dig-bottom-ctas] .tactile-pill-btn {
    flex: 1 1 auto;
    justify-content: center;
  }
}

/* Compact Desktop Height Headroom (e.g., 1024x640, 1280x720) — preserves 1180x820 & 1440x900 fold */
@media (min-width: 1024px) and (max-height: 740px) {
  html:not([data-device="iphone"]) .dig-screen-wrap {
    padding: 4px 10px 4px;
    gap: 4px;
  }
  html:not([data-device="iphone"]) .dig-inner {
    gap: 4px;
  }
  html:not([data-device="iphone"]) [data-dig-top-controls] .section-card {
    padding: 5px 10px;
    gap: 4px;
  }
  html:not([data-device="iphone"]) [data-dig-top-controls] .filter-pill,
  html:not([data-device="iphone"]) [data-dig-top-controls] .tactile-pill-btn,
  html:not([data-device="iphone"]) [data-dig-top-controls] .qa-chip {
    min-height: 34px;
    padding: 4px 10px;
    font-size: 0.75rem;
  }
  html:not([data-device="iphone"]) [data-dig-tier-sidebar] .section-card {
    max-height: min(360px, calc(100dvh - 285px)) !important;
    padding: 8px 10px;
  }
  html:not([data-device="iphone"]) .dig-board-card {
    padding: 6px 10px;
    gap: 4px 10px;
  }
  html:not([data-device="iphone"]) .dig-Telemetry-bar {
    padding: 3px 8px;
    font-size: 0.76rem;
  }
  html:not([data-device="iphone"]) .dig-guide-pill {
    min-height: 32px;
    padding: 3px 10px;
    font-size: 0.74rem;
  }
  html:not([data-device="iphone"]) .dig-legend-strip {
    padding: 2px 8px;
    font-size: 0.68rem;
    line-height: 1.2;
  }
  html:not([data-device="iphone"]) .dig-canvas-host,
  html:not([data-device="iphone"]) .dig-canvas-frame {
    width: min(320px, max(230px, calc(100dvh - 375px)));
    min-width: 220px;
  }
  html:not([data-device="iphone"]) .dig-tools-dock {
    gap: 4px;
  }
  html:not([data-device="iphone"]) .dig-tool-medallion {
    min-height: 58px;
    padding: 14px 4px 4px;
  }
  html:not([data-device="iphone"]) .dig-tools-dock [data-rotate-chisel] {
    min-height: 34px;
    padding: 4px 10px;
    font-size: 0.74rem;
  }
  html:not([data-device="iphone"]) [data-dig-bottom-ctas] {
    gap: 6px !important;
  }
  html:not([data-device="iphone"]) [data-dig-bottom-ctas] .cta-primary-amber {
    min-height: 38px;
    padding: 6px 12px;
    font-size: 0.82rem;
  }
  html:not([data-device="iphone"]) [data-dig-bottom-ctas] .tactile-pill-btn {
    min-height: 34px;
    padding: 5px 10px;
    font-size: 0.76rem;
  }
  html:not([data-device="iphone"]) .dino-care-tray {
    padding: 8px 12px;
    max-height: min(215px, 36dvh);
  }
}

@media (max-width: 520px) {
  .dig-screen-wrap {
    padding: var(--hud-top-offset) 6px var(--dock-bottom-offset);
  }
  .dig-board-card {
    padding: 8px 6px;
    border-radius: 20px;
  }
  .dig-canvas-host {
    width: 100%;
    max-width: 100% !important;
  }
  .dig-canvas-host canvas {
    width: 100% !important;
    height: 100% !important;
  }
}

html[data-device="iphone"] .dig-screen-wrap {
  padding: var(--hud-top-offset) 6px var(--dock-bottom-offset);
}

html[data-device="iphone"] .dig-board-card {
  padding: 8px 6px;
  border-radius: 20px;
}

html[data-device="iphone"] .dig-canvas-host {
  width: 100%;
  max-width: 100% !important;
}

html[data-device="iphone"] .dig-canvas-host canvas {
  width: 100% !important;
  height: 100% !important;
}

.dig-board-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 12px;
  min-width: 0;
  width: 100%;
  max-width: 100%;
  overflow: hidden;
  border-radius: var(--radius-xl);
  background: linear-gradient(180deg, rgba(64, 34, 20, 0.92), rgba(37, 20, 12, 0.96));
  border: 1.5px solid rgba(229, 159, 58, 0.42);
  box-shadow: var(--shadow-elevated);
}

.dig-Telemetry-bar {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 14px;
  background: rgba(15, 10, 7, 0.54);
  font-size: 0.8rem;
  font-weight: 800;
}

.dig-telemetry-stats {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}

.dig-guide-pill {
  min-height: 44px;
  padding: 6px 12px;
  font-weight: 900;
  flex-shrink: 0;
}

.dig-legend-strip {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 6px 10px;
  padding: 6px 10px;
  border-radius: 12px;
  background: rgba(20, 12, 8, 0.62);
  border: 1px solid rgba(244, 239, 226, 0.16);
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--bone-muted);
  line-height: 1.35;
}

.dig-legend-item strong {
  font-weight: 900;
}

.dig-legend-dots {
  color: var(--bone);
  letter-spacing: 0.08em;
}

.dig-legend-clue {
  color: #74E4FF;
  font-family: var(--font-mono);
}

.dig-legend-gold {
  color: var(--amber-bright);
}

.dig-legend-cyan {
  color: var(--oxidized-cyan);
}

.dig-legend-sep {
  opacity: 0.5;
}

.dig-canvas-host {
  width: min(460px, 48dvh, 100%);
  max-width: 100% !important;
  height: auto !important;
  aspect-ratio: 1 / 1;
  border-radius: 20px;
  overflow: hidden;
  background: #14191e;
  border: 2px solid rgba(244, 239, 226, 0.25);
  position: relative;
}

.dig-canvas-host canvas {
  display: block;
  width: 100% !important;
  height: auto !important;
  max-width: 100% !important;
}

/* 6 Tactile Illustrated Excavation Tool Medallions */
.dig-tools-dock {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px;
}

.dig-tool-medallion {
  position: relative;
  width: 82px;
  min-height: 86px;
  padding: 22px 6px 8px;
  border-radius: 22px;
  background: radial-gradient(circle at 50% 32%, #5C3A24, #2D1B10);
  border: 2px solid rgba(244, 239, 226, 0.34);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.42);
  transition: transform 0.14s ease, border-color 0.14s ease;
}

.dig-tool-medallion.is-active {
  border-color: var(--oxidized-cyan);
  box-shadow: 0 0 0 2px rgba(58, 216, 230, 0.35), 0 8px 18px rgba(0, 0, 0, 0.5);
  transform: translateY(-3px);
}

.dig-tool-medallion img {
  width: 36px;
  height: 36px;
  object-fit: contain;
}

.dig-tool-name {
  font-size: 0.68rem;
  font-weight: 800;
  line-height: 1.15;
  white-space: nowrap;
  color: var(--bone);
}

.dig-tool-charges {
  position: absolute;
  top: 4px;
  right: 4px;
  bottom: auto;
  min-width: 22px;
  height: 20px;
  padding: 0 5px;
  border-radius: var(--radius-pill);
  background: #1B120B;
  border: 1.5px solid var(--amber-gold);
  color: var(--amber-bright);
  font-size: 0.68rem;
  font-weight: 900;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.dig-tool-tier {
  position: absolute;
  top: 4px;
  left: 4px;
  padding: 1px 5px;
  border-radius: var(--radius-pill);
  background: var(--deep-teal);
  border: 1px solid rgba(244, 239, 226, 0.4);
  font-size: 0.6rem;
  font-weight: 900;
}

/* ==========================================================================
   8. Hatchery Sanctum, DNA Lab & THE AMBER LOOM (Star Feature)
   ========================================================================== */
.hatchery-screen-wrap {
  min-height: 100%;
  padding: var(--hud-top-offset) 12px var(--dock-bottom-offset);
  background-color: #162923;
  background-size: cover;
  background-position: center top;
  position: relative;
}

.hatchery-backdrop-scrim {
  width: min(1100px, 100%);
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.sanctum-mode-switcher {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 6px;
  border-radius: var(--radius-pill);
  background: rgba(14, 29, 25, 0.9);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  border: var(--border-bone);
  width: fit-content;
  max-width: 100%;
}

.sanctum-tab-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 8px 16px;
  border-radius: var(--radius-pill);
  font-family: var(--font-display);
  font-weight: 900;
  font-size: 0.84rem;
  letter-spacing: 0.02em;
  color: var(--bone-muted);
}

.sanctum-tab-btn img {
  width: 22px;
  height: 22px;
  object-fit: contain;
}

.sanctum-tab-btn.is-active {
  background: linear-gradient(135deg, var(--amber-gold) 0%, #C9761D 100%);
  color: #190F02;
  box-shadow: 0 4px 16px rgba(229, 159, 58, 0.45);
}

/* Hatchery Nests Grid (3 -> 6 Slots) */
.nests-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 12px;
}

.nest-card {
  position: relative;
  padding: 16px;
  border-radius: var(--radius-xl);
  background:
    radial-gradient(circle at 50% 62%, rgba(229, 159, 58, 0.2), transparent 62%),
    linear-gradient(180deg, rgba(28, 48, 38, 0.93) 0%, rgba(16, 29, 23, 0.97) 100%);
  border: 1.5px solid rgba(244, 239, 226, 0.28);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 8px;
  box-shadow: var(--shadow-soft);
  transition: transform 0.2s cubic-bezier(0.22, 1, 0.36, 1), border-color 0.2s ease, box-shadow 0.2s ease;
}

.nest-card:hover {
  transform: translateY(-2px);
  border-color: rgba(255, 210, 117, 0.56);
  box-shadow: 0 10px 26px rgba(5, 16, 19, 0.42);
}

.nest-card.is-ready {
  border-color: var(--amber-bright);
  animation: readyNestGlow 2.4s ease-in-out infinite;
}

@keyframes readyNestGlow {
  0%, 100% {
    box-shadow: 0 0 24px rgba(229, 159, 58, 0.34), var(--shadow-soft);
  }
  50% {
    box-shadow: 0 0 38px rgba(255, 210, 117, 0.62), var(--shadow-soft);
  }
}

.nest-bowl {
  position: relative;
  width: 112px;
  height: 112px;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 70%, #5B4226 0%, #332414 70%, #1E150B 100%);
  border: 3px solid rgba(216, 184, 120, 0.42);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: inset 0 8px 18px rgba(0, 0, 0, 0.6);
}

.nest-bowl::before {
  content: "";
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 198, 86, 0.26) 0%, transparent 72%);
  pointer-events: none;
  animation: nestThermalPulse 2.8s ease-in-out infinite;
}

@keyframes nestThermalPulse {
  0%, 100% {
    opacity: 0.45;
    transform: scale(0.96);
  }
  50% {
    opacity: 0.92;
    transform: scale(1.06);
  }
}

.nest-egg-visual {
  width: 72px;
  height: 86px;
  border-radius: 50% 50% 46% 46% / 60% 60% 40% 40%;
  position: relative;
  box-shadow:
    inset -8px -10px 18px rgba(0, 0, 0, 0.38),
    inset 6px 8px 14px rgba(255, 255, 255, 0.32),
    0 6px 14px rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
}

.nest-card.is-ready .nest-egg-visual {
  animation: eggWobble 1.9s ease-in-out infinite;
}

@keyframes eggWobble {
  0%, 100% { transform: rotate(0deg) scale(1); }
  18% { transform: rotate(-7deg) translateY(-4px) scale(1.03); }
  36% { transform: rotate(7deg) translateY(-4px) scale(1.03); }
  54% { transform: rotate(-4deg) translateY(-1px); }
  72% { transform: rotate(4deg) translateY(-1px); }
}

/* THE AMBER LOOM ATELIER STAGE */
.loom-chamber {
  border-radius: var(--radius-xl);
  padding: 16px;
  background-color: rgba(12, 29, 34, 0.94);
  background-size: cover;
  background-position: center;
  border: var(--border-amber);
  box-shadow: var(--shadow-elevated);
  position: relative;
  overflow: hidden;
}

.loom-chamber::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(10, 26, 31, 0.78) 0%, rgba(12, 30, 35, 0.9) 100%);
  pointer-events: none;
}

.loom-chamber > * {
  position: relative;
  z-index: 1;
}

.codon-vault-ribbon {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  background: rgba(8, 20, 24, 0.78);
  border: 1px solid rgba(58, 216, 230, 0.32);
  margin-bottom: 12px;
}

.codon-chips-group {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.codon-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border-radius: var(--radius-pill);
  background: rgba(244, 239, 226, 0.08);
  border: 1px solid rgba(244, 239, 226, 0.2);
  font-size: 0.78rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.codon-pill img {
  width: 20px;
  height: 20px;
  object-fit: contain;
}

.dna-subtabs {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 14px;
  padding: 4px;
  border-radius: var(--radius-pill);
  background: rgba(7, 18, 22, 0.8);
  border: 1px solid rgba(244, 239, 226, 0.2);
}

.dna-subtab-btn {
  min-height: 44px;
  padding: 8px 16px;
  border-radius: var(--radius-pill);
  font-family: var(--font-display);
  font-weight: 900;
  font-size: 0.8rem;
  letter-spacing: 0.04em;
  color: var(--bone-muted);
}

.dna-subtab-btn.is-active {
  background: linear-gradient(135deg, rgba(58, 216, 230, 0.3), rgba(229, 159, 58, 0.34));
  border: 1px solid var(--oxidized-cyan);
  color: #FFFFFF;
}

.loom-workbench-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
  align-items: start;
}

@media (min-width: 880px) {
  html[data-device="desktop"] .loom-workbench-grid,
  html[data-device="ipad"] .loom-workbench-grid {
    grid-template-columns: minmax(330px, 450px) 1fr;
  }
}

/* 4-Ring Rotating SVG Amber Helix Dial */
.helix-dial-card {
  padding: 14px;
  border-radius: var(--radius-lg);
  background: radial-gradient(circle at 50% 45%, rgba(26, 68, 76, 0.55), rgba(9, 23, 28, 0.92));
  border: 1.5px solid rgba(229, 159, 58, 0.45);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.helix-svg-wrap {
  width: min(360px, 100%);
  aspect-ratio: 1 / 1;
  position: relative;
}

.helix-dial-svg {
  width: 100%;
  height: 100%;
  overflow: visible;
}

.helix-ring-group {
  transform-origin: 210px 210px;
  transition: transform 0.55s cubic-bezier(0.22, 1, 0.36, 1);
}

.helix-calib-ring {
  transform-origin: 210px 210px;
  animation: helixOrbitSpin 38s linear infinite;
}

.helix-core-pulse {
  transform-origin: 210px 210px;
  animation: helixCoreBreathe 3.2s ease-in-out infinite;
}

@keyframes helixOrbitSpin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

@keyframes helixCoreBreathe {
  0%, 100% {
    opacity: 0.85;
    filter: drop-shadow(0 0 6px rgba(255, 210, 117, 0.38));
  }
  50% {
    opacity: 1;
    filter: drop-shadow(0 0 14px rgba(255, 210, 117, 0.72));
  }
}

.helix-node {
  cursor: pointer;
}

.helix-node:hover circle.node-hit {
  stroke: #FFFFFF;
  stroke-width: 3px;
}

.locus-selector-tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  width: 100%;
}

.locus-tab-btn {
  min-height: 48px;
  padding: 6px 8px;
  border-radius: 14px;
  background: rgba(244, 239, 226, 0.07);
  border: 1px solid rgba(244, 239, 226, 0.2);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  font-size: 0.74rem;
  font-weight: 800;
}

.locus-tab-btn.is-active {
  background: rgba(229, 159, 58, 0.24);
  border-color: var(--amber-gold);
  color: var(--amber-bright);
}

.locus-controls-box {
  width: 100%;
  padding: 12px;
  border-radius: 16px;
  background: rgba(8, 20, 24, 0.78);
  border: 1px solid rgba(244, 239, 226, 0.18);
}

.swatch-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 8px;
}

.color-gem-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  padding: 5px 10px;
  border-radius: var(--radius-pill);
  background: rgba(244, 239, 226, 0.08);
  border: 1.5px solid rgba(244, 239, 226, 0.22);
  font-size: 0.76rem;
  font-weight: 800;
}

.color-gem-btn.is-selected {
  border-color: #FFFFFF;
  background: rgba(244, 239, 226, 0.22);
  box-shadow: 0 0 12px rgba(255, 255, 255, 0.28);
}

.gem-dot {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 1.5px solid rgba(255, 255, 255, 0.75);
  box-shadow: inset 0 2px 4px rgba(255, 255, 255, 0.35);
  flex-shrink: 0;
}

.splice-trait-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 8px;
  margin-top: 8px;
}

.splice-trait-card {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 54px;
  padding: 7px 9px;
  border-radius: 14px;
  background: rgba(244, 239, 226, 0.07);
  border: 1.5px solid rgba(244, 239, 226, 0.18);
  text-align: left;
}

.splice-trait-card.is-selected {
  background: rgba(229, 159, 58, 0.24);
  border-color: var(--amber-bright);
}

.splice-trait-card img {
  width: 32px;
  height: 32px;
  object-fit: contain;
  flex-shrink: 0;
}

/* Live 60fps Specimen Preview Chamber & Parent Pedestals */
.specimen-stage-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.parents-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.parent-pedestal-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 72px;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  background: rgba(18, 42, 48, 0.88);
  border: 1.5px solid rgba(58, 216, 230, 0.36);
  text-align: left;
}

.parent-pedestal-btn:hover {
  border-color: var(--amber-bright);
}

.live-preview-chamber {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  padding: 14px;
  border-radius: var(--radius-lg);
  background:
    radial-gradient(circle at 50% 42%, rgba(229, 159, 58, 0.22), rgba(58, 216, 230, 0.08) 48%, rgba(8, 21, 25, 0.95) 85%);
  border: 1.5px solid rgba(58, 216, 230, 0.45);
  align-items: center;
}

@media (min-width: 600px) {
  .live-preview-chamber {
    grid-template-columns: 220px 1fr;
  }
}

.preview-canvas-pedestal {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.loom-specimen-canvas {
  width: 200px;
  height: 200px;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 60%, rgba(28, 72, 62, 0.36), rgba(8, 22, 26, 0.94));
  border: 2px solid rgba(229, 159, 58, 0.68);
  box-shadow:
    0 0 36px rgba(229, 159, 58, 0.32),
    inset 0 0 26px rgba(58, 216, 230, 0.22);
}

.cta-primary-amber {
  width: 100%;
  min-height: 52px;
  padding: 12px 20px;
  border-radius: var(--radius-pill);
  background: linear-gradient(180deg, #FFD070 0%, var(--amber-gold) 48%, #B86D14 100%);
  color: #1B1002;
  font-family: var(--font-display);
  font-weight: 900;
  font-size: 0.98rem;
  letter-spacing: 0.03em;
  box-shadow: 0 8px 24px rgba(229, 159, 58, 0.45);
  transition: transform 0.14s ease, filter 0.14s ease;
}

.cta-primary-amber:hover:not(:disabled) {
  transform: translateY(-1px);
  filter: brightness(1.06);
}

/* 6-Rung Amber Base-Pair Sequencer */
.sequencer-rungs-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 12px 0;
}

.sequencer-rung-row {
  display: grid;
  grid-template-columns: 76px 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 16px;
  background: rgba(14, 32, 38, 0.88);
  border: 1.5px solid rgba(229, 159, 58, 0.32);
}

.sequencer-rung-row.is-matched {
  border-color: var(--oxidized-cyan);
  background: rgba(18, 52, 58, 0.9);
}

.template-base-gem {
  height: 46px;
  border-radius: 12px;
  background: linear-gradient(135deg, rgba(229, 159, 58, 0.35), rgba(143, 84, 16, 0.6));
  border: 1.5px solid var(--amber-bright);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: 1.2rem;
  font-weight: 900;
  color: var(--amber-bright);
}

.hbond-bridge {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  min-width: 40px;
}

.hbond-line {
  width: 100%;
  height: 3px;
  border-radius: 3px;
  background: rgba(244, 239, 226, 0.16);
}

.sequencer-rung-row.is-matched .hbond-line {
  background: linear-gradient(90deg, var(--amber-bright), var(--oxidized-cyan));
  box-shadow: 0 0 8px rgba(58, 216, 230, 0.7);
}

.base-choice-group {
  display: flex;
  gap: 6px;
}

.nucleotide-btn {
  width: 46px;
  height: 46px;
  border-radius: 12px;
  background: rgba(244, 239, 226, 0.08);
  border: 1.5px solid rgba(244, 239, 226, 0.24);
  font-family: var(--font-mono);
  font-size: 1rem;
  font-weight: 900;
  color: var(--bone);
}

.nucleotide-btn.is-selected {
  background: rgba(58, 216, 230, 0.28);
  border-color: var(--oxidized-cyan);
  color: #FFFFFF;
}

/* ==========================================================================
   9. Dinodex Screen (2,808 Genomes + Fern Wreaths + Splice Codex Ribbon)
   ========================================================================== */
.dinodex-screen-wrap {
  min-height: 100%;
  padding: var(--hud-top-offset) 14px var(--dock-bottom-offset);
  background:
    radial-gradient(circle at 50% 18%, #1A4750 0%, var(--deep-teal) 52%, #091C21 100%);
  position: relative;
}

.dinodex-fern-corner {
  position: fixed;
  width: 110px;
  height: 110px;
  color: rgba(88, 162, 108, 0.34);
  pointer-events: none;
  z-index: 0;
}

.dinodex-inner {
  position: relative;
  z-index: 1;
  width: min(1120px, 100%);
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.dinodex-hero-header {
  text-align: center;
  padding: 6px 0 2px;
}

.dinodex-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.75rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  color: var(--bone);
}

.dinodex-counter {
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 800;
  color: var(--amber-bright);
  margin-top: 2px;
}

.dinodex-breakdown {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--bone-muted);
  margin-top: 3px;
}

.splice-codex-ribbon {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  padding: 10px 14px;
  border-radius: var(--radius-lg);
  background: rgba(9, 26, 31, 0.84);
  border: 1px solid rgba(229, 159, 58, 0.42);
}

.splice-badges-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.codex-splice-medallion {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(244, 239, 226, 0.06);
  border: 1.5px solid rgba(244, 239, 226, 0.2);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 5px;
  cursor: pointer;
  transition: transform 0.14s ease, border-color 0.14s ease, box-shadow 0.14s ease;
}

.codex-splice-medallion:hover {
  transform: translateY(-1px);
  border-color: var(--oxidized-cyan);
}

.codex-splice-medallion.is-discovered {
  background: radial-gradient(circle, rgba(229, 159, 58, 0.34), rgba(19, 52, 59, 0.9));
  border-color: var(--amber-bright);
  box-shadow: 0 0 12px rgba(229, 159, 58, 0.4);
}

.codex-splice-medallion.is-active {
  border-color: var(--oxidized-cyan);
  box-shadow: 0 0 0 2px rgba(58, 216, 230, 0.5), 0 0 16px rgba(58, 216, 230, 0.45);
  transform: scale(1.06);
}

.codex-splice-medallion:not(.is-discovered) img {
  filter: grayscale(1) brightness(0.45);
  opacity: 0.6;
}

.codex-splice-medallion img {
  width: 30px;
  height: 30px;
  object-fit: contain;
}

.dinodex-filter-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px 12px;
}

.dinodex-filter-primary-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.dinodex-status-group {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  align-items: center;
}

.dinodex-filter-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  margin-left: auto;
}

.dinodex-trait-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  padding: 6px 12px;
  border-color: rgba(58, 216, 230, 0.45);
  background: rgba(19, 68, 78, 0.56);
  color: var(--bone);
  font-weight: 800;
}

.dinodex-trait-toggle.is-active {
  border-color: var(--oxidized-cyan);
  background: linear-gradient(180deg, rgba(24, 92, 106, 0.92), rgba(14, 58, 68, 0.96));
  color: #FFFFFF;
}

.dinodex-filter-count-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: var(--radius-pill);
  background: linear-gradient(180deg, var(--amber-bright), var(--amber-gold));
  color: #1F1304;
  font-size: 0.72rem;
  font-weight: 900;
  line-height: 1;
}

.dinodex-toggle-caret {
  font-size: 0.78rem;
  opacity: 0.88;
}

.dinodex-pagination {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.dinodex-trait-filters-panel {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-top: 8px;
  border-top: 1px solid rgba(244, 239, 226, 0.14);
}

.dinodex-trait-filters-panel[hidden] {
  display: none !important;
}

@media (min-width: 1024px) and (max-height: 740px) {
  .dinodex-screen-wrap {
    padding: 8px 12px 12px;
  }
  .dinodex-inner {
    gap: 8px;
  }
  .dinodex-hero-header {
    padding: 2px 0;
  }
  .dinodex-title {
    font-size: 1.4rem;
  }
  .splice-codex-ribbon {
    padding: 7px 12px;
    gap: 8px;
  }
  .dinodex-filter-card {
    padding: 8px 10px;
    gap: 6px;
  }
  .dinodex-trait-toggle {
    min-height: 36px;
    padding: 4px 10px;
  }
}

/* 4-column portrait iPhone grid, adaptive columns on iPad & Desktop */
.dinodex-wreath-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

@media (min-width: 680px) {
  html:not([data-device="iphone"]) .dinodex-wreath-grid {
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 14px;
  }
}

@media (min-width: 980px) {
  html[data-device="desktop"] .dinodex-wreath-grid {
    grid-template-columns: repeat(8, minmax(0, 1fr));
  }
}

.wreath-cell-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 6px 4px;
  border-radius: 18px;
  background: rgba(8, 24, 29, 0.42);
  border: 1px solid rgba(244, 239, 226, 0.1);
  transition: transform 0.14s ease, border-color 0.14s ease;
}

.wreath-cell-btn:hover {
  transform: translateY(-2px);
  border-color: rgba(140, 224, 112, 0.55);
}

.wreath-ring {
  position: relative;
  width: 74px;
  height: 74px;
  border-radius: 50%;
  background:
    radial-gradient(circle at 50% 45%, #234E39 0%, #122B20 68%, #2E5E38 100%);
  border: 3px solid #4E8A57;
  box-shadow:
    inset 0 3px 10px rgba(0, 0, 0, 0.55),
    0 4px 10px rgba(0, 0, 0, 0.38);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: visible;
}

.wreath-nest-bg {
  position: absolute;
  inset: -5px;
  width: calc(100% + 10px);
  height: calc(100% + 10px);
  object-fit: contain;
  pointer-events: none;
}

.wreath-dino-img {
  position: relative;
  z-index: 2;
  width: 56px;
  height: 56px;
  object-fit: contain;
}

.wreath-cell-btn.is-locked .wreath-dino-img {
  filter: brightness(0) opacity(0.55);
}

.wreath-padlock {
  position: absolute;
  bottom: -5px;
  z-index: 3;
  width: 20px;
  height: 20px;
  padding: 2px;
  border-radius: 50%;
  background: #231A0E;
  color: #D8B878;
  border: 1px solid rgba(216, 184, 120, 0.6);
}

.wreath-color-pip {
  position: absolute;
  top: 2px;
  right: 2px;
  z-index: 3;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 1.5px solid #FFFFFF;
}

.wreath-caption {
  font-size: 0.68rem;
  font-weight: 800;
  color: var(--bone);
  text-align: center;
  line-height: 1.15;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.wreath-splice-caption {
  font-size: 0.62rem;
  font-weight: 800;
  color: var(--amber-bright);
  text-align: center;
  line-height: 1.15;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.wreath-splice-caption.is-chimera {
  color: var(--oxidized-cyan);
}

/* ==========================================================================
   10. More Screen (Sanctuary, Museum L20, Tools, Expeditions, Renown, Settings)
   ========================================================================== */
.more-screen-wrap {
  min-height: 100%;
  padding: var(--hud-top-offset) 14px var(--dock-bottom-offset);
  background: linear-gradient(180deg, #17362C 0%, #0E221D 100%);
}

.more-inner {
  width: min(1060px, 100%);
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.more-locked-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 12px;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  background: rgba(12, 28, 24, 0.72);
  border: 1px dashed rgba(244, 239, 226, 0.22);
}

.more-locked-footer-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-display);
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--bone-muted);
}

.more-locked-pill-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  min-width: 0;
  max-width: 100%;
}

.more-locked-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  max-width: 100%;
  padding: 8px 12px;
  border-radius: var(--radius-pill);
  background: rgba(244, 239, 226, 0.06);
  border: 1px solid rgba(255, 210, 117, 0.3);
  color: var(--bone-muted);
  font-family: var(--font-display);
  font-size: 0.78rem;
  font-weight: 800;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: background 0.14s ease, border-color 0.14s ease, color 0.14s ease;
}

.more-locked-pill:hover {
  background: rgba(229, 159, 58, 0.16);
  border-color: rgba(255, 210, 117, 0.62);
  color: var(--bone-bright);
}

.more-locked-pill.is-active {
  background: linear-gradient(180deg, rgba(229, 159, 58, 0.34), rgba(143, 84, 16, 0.44));
  border-color: var(--amber-bright);
  color: var(--bone-bright);
}

html[data-keeper-stage="onboarding"] .hud-coach-pill {
  box-shadow: 0 0 0 2px rgba(255, 236, 186, 0.28), 0 6px 18px rgba(229, 159, 58, 0.42);
}

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

.meta-item-card {
  padding: 14px;
  border-radius: var(--radius-md);
  background: rgba(244, 239, 226, 0.06);
  border: 1px solid rgba(244, 239, 226, 0.18);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.progress-bar-outer {
  width: 100%;
  height: 8px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.14);
  overflow: hidden;
}

.progress-bar-inner {
  height: 100%;
  border-radius: 8px;
  background: linear-gradient(90deg, var(--moss-fern), var(--meadow-glow));
}

/* ==========================================================================
   11. Authored Modals & Toast Region (Zero Platform Alerts / Menus)
   ========================================================================== */
.modal-root {
  position: absolute;
  inset: 0;
  z-index: 70;
  background: rgba(5, 14, 17, 0.76);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.authored-modal-card {
  width: min(580px, 100%);
  max-height: min(86dvh, 760px);
  overflow-y: auto;
  padding: 20px;
  border-radius: var(--radius-xl);
  background: linear-gradient(180deg, #18363E 0%, #0F2329 100%);
  border: 1.5px solid rgba(244, 239, 226, 0.36);
  box-shadow: var(--shadow-elevated);
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.authored-modal-card.is-celebration {
  border-color: var(--amber-bright);
  background:
    radial-gradient(circle at 50% 18%, rgba(229, 159, 58, 0.28), transparent 55%),
    linear-gradient(180deg, #1B3B34 0%, #0F2320 100%);
}

/* Futuristic Gene-Splicing Cutscene Modal */
.authored-modal-card.splice-cutscene-modal {
  width: min(540px, 100%);
  padding: 16px;
  gap: 11px;
  background: radial-gradient(circle at 50% 24%, rgba(19, 58, 68, 0.98) 0%, rgba(7, 20, 25, 0.99) 100%);
  border: 1.5px solid rgba(58, 216, 230, 0.56);
  box-shadow: 0 0 42px rgba(58, 216, 230, 0.22), 0 20px 52px rgba(0, 0, 0, 0.72);
}

.splice-phase-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 9px;
  border-radius: var(--radius-pill);
  background: rgba(58, 216, 230, 0.14);
  border: 1px solid rgba(58, 216, 230, 0.45);
  color: var(--oxidized-cyan);
  font-family: var(--font-mono);
  font-size: 0.67rem;
  font-weight: 800;
  letter-spacing: 0.05em;
}

.splice-cutscene-stage {
  width: 100%;
  height: 218px;
  border-radius: 18px;
  overflow: hidden;
  border: 1.5px solid rgba(229, 159, 58, 0.48);
  background: #040e12;
  position: relative;
  box-shadow: inset 0 0 28px rgba(58, 216, 230, 0.16);
}

.splice-cutscene-canvas {
  width: 100%;
  height: 100%;
  display: block;
}

.splice-fusion-strip {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px 12px;
  border-radius: 14px;
  background: rgba(6, 18, 22, 0.78);
  border: 1px solid rgba(244, 239, 226, 0.16);
}

.splice-fusion-equation {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 6px 8px;
  font-size: 0.78rem;
  font-weight: 800;
}

.splice-fusion-node {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 8px;
  border-radius: var(--radius-pill);
  background: rgba(244, 239, 226, 0.08);
  border: 1px solid rgba(244, 239, 226, 0.22);
}

.splice-fusion-op {
  color: var(--amber-bright);
  font-weight: 900;
  font-size: 0.86rem;
}

.splice-outcome-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}

.splice-outcome-chip {
  padding: 6px 8px;
  border-radius: 10px;
  border: 1px solid rgba(244, 239, 226, 0.16);
  background: rgba(10, 28, 34, 0.72);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  font-size: 0.72rem;
  min-width: 0;
  transition: transform 0.16s ease, border-color 0.16s ease, opacity 0.2s ease, box-shadow 0.2s ease;
}

.splice-outcome-chip.is-scanning {
  border-color: var(--oxidized-cyan);
  box-shadow: 0 0 12px rgba(58, 216, 230, 0.38);
  background: rgba(58, 216, 230, 0.14);
}

.splice-outcome-chip.is-landed {
  border-color: var(--amber-bright);
  box-shadow: 0 0 16px rgba(255, 210, 117, 0.45);
  background: rgba(229, 159, 58, 0.18);
  transform: scale(1.015);
}

.splice-outcome-chip.is-unchosen {
  opacity: 0.42;
}

.modal-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.modal-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.22rem;
  font-weight: 900;
  color: var(--bone);
}

.modal-close-btn {
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
  border-radius: 50%;
  background: rgba(244, 239, 226, 0.12);
  border: 1px solid rgba(244, 239, 226, 0.28);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--bone);
  flex-shrink: 0;
}

.authored-input {
  width: 100%;
  min-height: 46px;
  padding: 10px 14px;
  border-radius: 14px;
  background: rgba(7, 18, 22, 0.82);
  border: 1.5px solid rgba(244, 239, 226, 0.32);
  color: var(--bone);
  font-size: 0.96rem;
  font-weight: 700;
}

.toast-region,
.toast-container {
  position: absolute;
  top: var(--toast-top-offset, calc(var(--hud-top-offset) + 4px));
  left: 50%;
  transform: translateX(-50%);
  z-index: 65;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  pointer-events: none;
  width: min(440px, calc(100% - 24px));
}

@media (max-width: 640px) {
  html[data-active-tab="preserve"] .toast-region,
  html[data-active-tab="preserve"] .toast-container {
    top: max(var(--toast-top-offset, 156px), calc(var(--preserve-hud-clearance, 102px) + 54px));
  }
}

html[data-device="iphone"][data-active-tab="preserve"] .toast-region,
html[data-device="iphone"][data-active-tab="preserve"] .toast-container {
  top: max(var(--toast-top-offset, 156px), calc(var(--preserve-hud-clearance, 102px) + 54px));
}

@media (min-width: 1024px) {
  html[data-active-tab]:not([data-active-tab="preserve"]) .toast-region,
  html[data-active-tab]:not([data-active-tab="preserve"]) .toast-container {
    top: auto;
    bottom: calc(96px + var(--safe-bottom, 0px));
    left: auto;
    right: 18px;
    transform: none;
    align-items: flex-end;
    width: min(360px, calc(100% - 36px));
  }
}

.sanctuary-toast {
  padding: 10px 16px;
  border-radius: var(--radius-pill);
  background: rgba(16, 38, 32, 0.95);
  border: 1.5px solid var(--amber-gold);
  color: var(--bone);
  font-family: var(--font-display);
  font-size: 0.84rem;
  font-weight: 800;
  text-align: center;
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.48);
}

/* 3-Step Paleo-Genetics Pipeline, Sequencer Handoff, Reconstruction & Onboarding Guides */
.genetics-pipeline-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  padding: 8px 10px;
  border-radius: var(--radius-lg);
  background: rgba(9, 24, 28, 0.88);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(58, 216, 230, 0.36);
}

.pipeline-step-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  padding: 6px 12px;
  border-radius: var(--radius-pill);
  background: rgba(244, 239, 226, 0.08);
  border: 1px solid rgba(244, 239, 226, 0.22);
  color: var(--bone);
  font-family: var(--font-display);
  font-size: 0.78rem;
  font-weight: 800;
  transition: transform 0.14s ease, border-color 0.14s ease, background 0.14s ease;
}

.pipeline-step-pill:hover {
  transform: translateY(-1px);
  border-color: var(--amber-bright);
  background: rgba(244, 239, 226, 0.14);
}

.pipeline-step-pill.is-active {
  background: linear-gradient(135deg, rgba(229, 159, 58, 0.32), rgba(58, 216, 230, 0.24));
  border-color: var(--amber-bright);
  color: #FFFFFF;
}

.pipeline-step-num {
  color: var(--amber-bright);
  font-weight: 900;
}

.pipeline-arrow {
  color: var(--amber-gold);
  font-size: 0.86rem;
  font-weight: 900;
  opacity: 0.85;
}

.sequence-complete-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 12px 14px;
  margin-bottom: 12px;
  border-radius: var(--radius-lg);
  background:
    radial-gradient(circle at 20% 50%, rgba(229, 159, 58, 0.26), rgba(18, 56, 54, 0.92));
  border: 1.5px solid var(--amber-bright);
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.35);
}

.sequence-complete-copy {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
  min-width: 220px;
}

.sequencer-zero-amber-bar {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 12px;
  padding: 14px;
  border-radius: var(--radius-lg);
  background: rgba(10, 28, 34, 0.86);
  border: 1.5px solid rgba(58, 216, 230, 0.42);
}

.loom-unlock-card {
  margin-bottom: 14px;
  border-color: rgba(229, 159, 58, 0.65);
  background:
    radial-gradient(circle at 15% 30%, rgba(229, 159, 58, 0.2), rgba(12, 32, 36, 0.92));
}

.receipt-progress-card {
  border-color: rgba(229, 159, 58, 0.55);
  background: rgba(10, 28, 33, 0.84);
}

.receipt-progress-card.is-ready {
  border-color: var(--meadow-glow);
  background: rgba(22, 54, 38, 0.88);
}

.reconstruct-modal-card {
  max-width: 620px;
  width: min(620px, 100%);
}

.reconstruct-species-row {
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  flex-shrink: 0;
  height: auto;
}

.reconstruct-species-row .habitat-card-title {
  flex-wrap: wrap;
}

.reconstruct-species-info {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 245px;
  flex: 1 1 245px;
  overflow: hidden;
}

.reconstruct-species-actions {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
  flex: 0 0 auto;
  margin-left: auto;
}

.reconstruct-species-actions .tactile-pill-btn {
  justify-content: center;
  text-align: center;
  max-width: 100%;
  white-space: normal;
}

.name-input-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.name-reroll-btn {
  flex-shrink: 0;
  white-space: nowrap;
}

@media (max-width: 480px) {
  .reconstruct-species-info {
    min-width: 0;
    flex: 1 1 100%;
  }
  .reconstruct-species-actions {
    width: 100%;
    align-items: stretch;
    margin-left: 0;
  }
}

html[data-device="iphone"] .reconstruct-species-info {
  min-width: 0;
  flex: 1 1 100%;
}

html[data-device="iphone"] .reconstruct-species-actions {
  width: 100%;
  align-items: stretch;
  margin-left: 0;
}

.reconstruct-count-missing {
  color: #FFB899;
  font-weight: 800;
}

.reconstruct-count-ready {
  color: var(--meadow-glow);
  font-weight: 800;
}

.synth-dna-btn {
  font-size: 0.76rem;
  padding: 7px 12px;
}

.synth-dna-coins-btn {
  background: linear-gradient(180deg, rgba(22, 74, 86, 0.92), rgba(12, 46, 56, 0.96));
  border-color: rgba(58, 216, 230, 0.65);
  color: #D4FAFF;
}

.guide-modal-card {
  border-color: rgba(229, 159, 58, 0.58);
}

/* ==========================================================================
   12. Shared Element Pills, Locus IV Combat Adaptations & Stats Strips
   ========================================================================== */
.element-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  font-size: 0.71rem;
  font-weight: 800;
  line-height: 1.3;
  letter-spacing: 0.01em;
  border: 1px solid rgba(255, 255, 255, 0.22);
  white-space: nowrap;
}

.element-verdant {
  background: rgba(45, 118, 60, 0.42);
  border-color: rgba(91, 185, 107, 0.7);
  color: #C7F8CE;
}

.element-ember {
  background: rgba(154, 54, 24, 0.44);
  border-color: rgba(232, 106, 58, 0.75);
  color: #FFD2BF;
}

.element-tide {
  background: rgba(21, 96, 122, 0.44);
  border-color: rgba(52, 168, 199, 0.75);
  color: #C4F2FF;
}

.element-frost {
  background: rgba(54, 108, 140, 0.44);
  border-color: rgba(142, 214, 245, 0.75);
  color: #E3F6FF;
}

.element-terra {
  background: rgba(120, 86, 38, 0.46);
  border-color: rgba(201, 157, 90, 0.75);
  color: #F7E1BE;
}

.element-aether {
  background: rgba(104, 48, 146, 0.46);
  border-color: rgba(182, 108, 232, 0.75);
  color: #EED4FF;
}

.element-fill-verdant { background: linear-gradient(90deg, #3D9A50, #72D983); }
.element-fill-ember { background: linear-gradient(90deg, #C84D24, #F5895A); }
.element-fill-tide { background: linear-gradient(90deg, #21819E, #5AD0EE); }
.element-fill-frost { background: linear-gradient(90deg, #5BA7CC, #ACE3FA); }
.element-fill-terra { background: linear-gradient(90deg, #A07535, #DFB574); }
.element-fill-aether { background: linear-gradient(90deg, #8A45BD, #CB8CF7); }

.element-border-verdant { border-color: rgba(91, 185, 107, 0.56); }
.element-border-ember { border-color: rgba(232, 106, 58, 0.58); }
.element-border-tide { border-color: rgba(52, 168, 199, 0.58); }
.element-border-frost { border-color: rgba(142, 214, 245, 0.58); }
.element-border-terra { border-color: rgba(201, 157, 90, 0.58); }
.element-border-aether { border-color: rgba(182, 108, 232, 0.58); }

.dino-stats-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 5px 8px;
  font-size: 0.71rem;
  font-weight: 800;
  color: var(--bone-muted);
  padding: 4px 8px;
  border-radius: 10px;
  background: rgba(9, 24, 28, 0.52);
  border: 1px solid rgba(244, 239, 226, 0.12);
}

.dino-stats-strip span {
  white-space: nowrap;
}

.locus-4-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 8px;
  margin-top: 8px;
}

.adapt-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 10px;
  border-radius: 14px;
  text-align: left;
  background: rgba(13, 34, 40, 0.78);
  border: 1.5px solid rgba(244, 239, 226, 0.16);
  color: var(--bone);
  transition: transform 0.14s ease, border-color 0.14s ease, background 0.14s ease;
  min-width: 0;
}

.adapt-card:hover:not(:disabled) {
  transform: translateY(-1px);
  background: rgba(20, 48, 56, 0.9);
  border-color: rgba(229, 159, 58, 0.55);
}

.adapt-card.is-selected {
  background: linear-gradient(180deg, rgba(44, 92, 74, 0.88), rgba(20, 52, 44, 0.94));
  border-color: var(--amber-bright);
  box-shadow: 0 0 0 1px rgba(255, 224, 138, 0.35), 0 6px 14px rgba(0, 0, 0, 0.32);
}

.adapt-card.is-locked {
  opacity: 0.62;
}

.adapt-offense {
  border-left: 3px solid #E86A3A;
}

.adapt-defense {
  border-left: 3px solid #3AD8E6;
}

.adapt-glyph-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 8px;
  background: rgba(244, 239, 226, 0.1);
  font-size: 0.95rem;
  flex-shrink: 0;
}

.care-btn-arena {
  background: linear-gradient(180deg, rgba(164, 78, 36, 0.92), rgba(114, 44, 18, 0.96));
  border-color: rgba(255, 186, 128, 0.65);
  color: #FFF4E6;
}

.care-btn-arena:hover {
  background: linear-gradient(180deg, rgba(188, 92, 44, 0.96), rgba(132, 52, 22, 0.98));
}

/* ==========================================================================
   13. Sanctuary Battle Arena & Live AI-vs-AI Bot Lab
   ========================================================================== */
.arena-screen-scroll {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-width: 1120px;
  margin: 0 auto;
  width: 100%;
  min-height: 100%;
  padding: var(--hud-top-offset) 14px var(--dock-bottom-offset);
  box-sizing: border-box;
  min-width: 0;
}

.arena-top-header {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
}

.arena-title-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.arena-heading {
  margin: 0 0 2px;
}

.arena-subheading {
  margin: 0;
}

.arena-record-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.arena-record-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 5px 10px;
  border-radius: var(--radius-pill);
  font-size: 0.75rem;
  font-weight: 800;
  background: rgba(15, 38, 44, 0.84);
  border: 1px solid rgba(244, 239, 226, 0.2);
  color: var(--bone);
}

.arena-subtab-bar {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.arena-subtab-btn {
  min-height: 44px;
  padding: 8px 14px;
  border-radius: 16px;
  font-family: var(--font-display);
  font-size: 0.88rem;
  font-weight: 800;
  color: var(--bone-muted);
  background: rgba(14, 34, 40, 0.82);
  border: 1.5px solid rgba(244, 239, 226, 0.18);
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.arena-subtab-btn.is-active {
  color: #FFFFFF;
  background: linear-gradient(180deg, rgba(61, 122, 90, 0.92), rgba(32, 76, 54, 0.96));
  border-color: rgba(169, 238, 146, 0.75);
  box-shadow: 0 6px 16px rgba(14, 44, 30, 0.45);
}

.arena-setup-grid {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
}

.arena-card {
  background: linear-gradient(180deg, rgba(16, 40, 46, 0.9), rgba(11, 28, 34, 0.95));
  border: 1.5px solid rgba(244, 239, 226, 0.18);
  border-radius: 20px;
  padding: 14px;
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.32);
  min-width: 0;
  box-sizing: border-box;
}

.arena-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.arena-card-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.02rem;
  color: var(--bone);
}

.arena-card-hint {
  margin: 2px 0 0;
  font-size: 0.78rem;
  color: var(--bone-muted);
}

.arena-pill-group {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.arena-opponent-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 8px;
}

.arena-opponent-card {
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 10px 12px;
  border-radius: 14px;
  text-align: left;
  background: rgba(10, 26, 32, 0.74);
  border: 1.5px solid rgba(244, 239, 226, 0.15);
  color: var(--bone);
  transition: transform 0.14s ease, border-color 0.14s ease, background 0.14s ease;
  min-width: 0;
}

.arena-opponent-card:hover {
  transform: translateY(-1px);
  border-color: rgba(229, 159, 58, 0.55);
}

.arena-opponent-card.is-selected {
  background: linear-gradient(180deg, rgba(64, 92, 52, 0.65), rgba(26, 56, 44, 0.92));
  border-color: var(--amber-bright);
  box-shadow: 0 0 0 1px rgba(255, 224, 138, 0.35);
}

.arena-opponent-card.is-locked {
  opacity: 0.66;
}

.arena-opp-top {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.arena-opp-glyph {
  font-size: 1.1rem;
}

.arena-opp-name {
  font-weight: 800;
  font-size: 0.88rem;
}

.arena-opp-sub {
  font-size: 0.75rem;
  color: var(--bone-muted);
  line-height: 1.35;
}

.arena-opp-meta {
  display: flex;
  justify-content: space-between;
  gap: 6px;
  flex-wrap: wrap;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--amber-bright);
}

.arena-tag-pill {
  margin-left: auto;
  padding: 2px 7px;
  border-radius: var(--radius-pill);
  font-size: 0.67rem;
  font-weight: 800;
}

.arena-tag-pill.is-ready {
  background: rgba(58, 216, 230, 0.2);
  color: #B4F5FF;
}

.arena-tag-pill.is-cleared {
  background: rgba(91, 185, 107, 0.28);
  color: #C7F8CE;
}

.arena-tag-pill.is-locked {
  background: rgba(232, 106, 58, 0.24);
  color: #FFD2BF;
}

.arena-opp-elements {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin: 2px 0;
}

.arena-selected-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-bottom: 10px;
}

.arena-selected-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 9px;
  border-radius: 12px;
  background: rgba(16, 40, 48, 0.85);
  border: 1px solid rgba(244, 239, 226, 0.18);
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--bone);
}

.arena-selected-chip.is-lead {
  border-color: rgba(229, 159, 58, 0.65);
  background: rgba(66, 48, 18, 0.55);
}

.arena-selected-name {
  max-width: 112px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.arena-lead-chip-btn {
  padding: 6px 12px;
  min-height: 44px;
  font-size: 0.74rem;
}

.arena-remove-chip-btn {
  padding: 6px 10px;
  min-width: 44px;
  min-height: 44px;
  font-size: 0.9rem;
  line-height: 1;
}

.arena-element-filter-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
}

.arena-squad-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 8px;
}

.arena-squad-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px;
  border-radius: 14px;
  text-align: left;
  background: rgba(10, 26, 32, 0.76);
  border: 1.5px solid rgba(244, 239, 226, 0.15);
  color: var(--bone);
  transition: transform 0.14s ease, border-color 0.14s ease;
  min-width: 0;
}

.arena-squad-card.is-selected {
  background: linear-gradient(180deg, rgba(42, 88, 70, 0.78), rgba(18, 48, 42, 0.92));
  border-color: var(--meadow-glow);
  box-shadow: 0 0 0 1px rgba(169, 238, 146, 0.35);
}

.arena-squad-head {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
}

.arena-squad-thumb {
  width: 44px;
  height: 44px;
  border-radius: 11px;
  object-fit: cover;
  background: rgba(255, 255, 255, 0.08);
  flex-shrink: 0;
}

.arena-squad-thumb-fallback {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
}

.arena-squad-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
  flex: 1;
}

.arena-squad-name-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.arena-squad-name {
  font-weight: 800;
  font-size: 0.88rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.arena-slot-badge {
  padding: 2px 7px;
  border-radius: var(--radius-pill);
  font-size: 0.67rem;
  font-weight: 900;
  background: var(--amber-gold);
  color: #1F1304;
  flex-shrink: 0;
}

.arena-squad-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
}

.arena-lv-chip {
  display: inline-flex;
  align-items: center;
  padding: 2px 7px;
  border-radius: var(--radius-pill);
  font-size: 0.69rem;
  font-weight: 800;
  background: rgba(229, 159, 58, 0.24);
  border: 1px solid rgba(229, 159, 58, 0.52);
  color: #FFE08A;
}

.arena-adapt-mini {
  font-size: 0.72rem;
  font-weight: 700;
  color: #AEEAF5;
}

.arena-start-btn {
  min-height: 44px;
  padding: 9px 18px;
  font-weight: 900;
  background: linear-gradient(180deg, #EFA840, #C4751A);
  border-color: #FFE08A;
  color: #1E1103;
}

.arena-bench-btn {
  min-height: 44px;
  padding: 9px 18px;
  font-weight: 800;
  background: linear-gradient(180deg, rgba(36, 108, 128, 0.92), rgba(18, 66, 82, 0.96));
  border-color: rgba(58, 216, 230, 0.72);
  color: #DDFBFF;
}

/* Active Match Layout */
.arena-match-pane {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
}

.arena-match-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
  padding: 9px 12px;
  border-radius: 16px;
  background: rgba(14, 34, 40, 0.9);
  border: 1px solid rgba(244, 239, 226, 0.18);
}

.arena-match-meta,
.arena-match-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.arena-mode-badge {
  font-family: var(--font-display);
  font-size: 0.86rem;
  font-weight: 800;
  color: var(--bone);
}

.arena-turn-badge {
  padding: 3px 9px;
  border-radius: var(--radius-pill);
  font-size: 0.74rem;
  font-weight: 800;
  background: rgba(58, 216, 230, 0.18);
  color: #B4F5FF;
}

.arena-forfeit-chip {
  border-color: rgba(232, 106, 58, 0.6);
  color: #FFC6B0;
}

.arena-hud-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.arena-hud-card {
  display: flex;
  flex-direction: column;
  gap: 7px;
  padding: 11px 12px;
  border-radius: 16px;
  background: rgba(12, 30, 36, 0.92);
  border: 1.5px solid rgba(244, 239, 226, 0.18);
  min-width: 0;
}

.arena-hud-card.is-blue {
  border-color: rgba(58, 216, 230, 0.55);
}

.arena-hud-card.is-red {
  border-color: rgba(232, 106, 58, 0.58);
}

.arena-hud-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 6px;
  flex-wrap: wrap;
}

.arena-side-tag {
  font-size: 0.64rem;
  font-weight: 900;
  letter-spacing: 0.06em;
  display: block;
}

.arena-side-tag.is-blue { color: #7EEAF5; }
.arena-side-tag.is-red { color: #FFA886; }

.arena-hud-name-line {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.arena-hud-name {
  font-family: var(--font-display);
  font-size: 0.98rem;
  color: var(--bone);
}

.arena-hud-elements {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  align-items: center;
}

.arena-hud-adapt {
  font-size: 0.69rem;
  font-weight: 800;
  color: #DDF8FF;
  padding: 2px 7px;
  border-radius: var(--radius-pill);
  background: rgba(255, 255, 255, 0.09);
}

.arena-hp-block {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.arena-hp-labels {
  display: flex;
  justify-content: space-between;
  font-size: 0.76rem;
  font-weight: 800;
  color: var(--bone);
}

.arena-shield-text {
  color: #8BE8FF;
}

.arena-hp-track {
  position: relative;
  height: 11px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.48);
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.14);
}

.arena-hp-fill {
  height: 100%;
  border-radius: 999px;
  transition: width 0.24s ease;
}

.arena-hp-fill.is-high { background: linear-gradient(90deg, #3EB960, #88E884); }
.arena-hp-fill.is-mid { background: linear-gradient(90deg, #D48E24, #F5CB5C); }
.arena-hp-fill.is-low { background: linear-gradient(90deg, #C8372D, #F57263); }

.arena-shield-fill {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  background: rgba(58, 216, 230, 0.45);
  border-right: 2px solid #9BF4FF;
  pointer-events: none;
}

.arena-energy-row {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-wrap: wrap;
}

.arena-energy-label {
  font-size: 0.73rem;
  font-weight: 800;
  color: #FFE08A;
}

.arena-energy-pips {
  display: inline-flex;
  gap: 4px;
}

.arena-energy-pip {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.14);
  border: 1px solid rgba(255, 224, 138, 0.4);
}

.arena-energy-pip.is-filled {
  background: radial-gradient(circle at 35% 35%, #FFF4BD, #E59F3A);
  box-shadow: 0 0 7px rgba(229, 159, 58, 0.75);
}

.arena-status-row {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-left: auto;
}

.arena-status-pill {
  padding: 2px 6px;
  border-radius: 8px;
  font-size: 0.67rem;
  font-weight: 800;
  background: rgba(255, 255, 255, 0.12);
  color: var(--bone);
}

.arena-status-pill.status-burn { background: rgba(232, 106, 58, 0.32); color: #FFD2BF; }
.arena-status-pill.status-chill { background: rgba(142, 214, 245, 0.28); color: #E3F6FF; }
.arena-status-pill.status-debuff { background: rgba(201, 157, 90, 0.28); color: #F7E1BE; }
.arena-status-pill.status-buff { background: rgba(91, 185, 107, 0.28); color: #C7F8CE; }

.arena-bench-dots {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.arena-bench-dot {
  padding: 2px 7px;
  border-radius: 8px;
  font-size: 0.68rem;
  font-weight: 700;
  background: rgba(255, 255, 255, 0.08);
  color: var(--bone-muted);
}

.arena-bench-dot.is-active {
  background: rgba(169, 238, 146, 0.22);
  color: #DDFCD0;
  border: 1px solid rgba(169, 238, 146, 0.5);
}

.arena-bench-dot.is-fainted {
  opacity: 0.45;
  text-decoration: line-through;
}

.arena-bench-dot.is-clickable {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-family: inherit;
  border: 1px solid rgba(244, 239, 226, 0.22);
  cursor: pointer;
  transition: transform 0.12s ease, border-color 0.12s ease, background 0.12s ease;
}

.arena-bench-dot.is-clickable:hover:not(:disabled) {
  transform: translateY(-1px);
  border-color: rgba(255, 224, 138, 0.65);
  background: rgba(255, 255, 255, 0.14);
}

.arena-bench-dot.is-clickable.is-advantage {
  border-color: rgba(106, 214, 125, 0.78);
  background: rgba(91, 185, 107, 0.22);
  color: #E2FDE6;
}

.arena-bench-dot.is-clickable:disabled {
  cursor: default;
}

.arena-dot-eff {
  padding: 1px 5px;
  border-radius: 6px;
  font-size: 0.62rem;
  font-weight: 900;
}

/* PixiJS v8 Battle Stage Container */
.arena-stage-wrap {
  position: relative;
  width: 100%;
  height: clamp(250px, 34vh, 320px);
  border-radius: 20px;
  overflow: hidden;
  background: radial-gradient(circle at 50% 42%, #245047 0%, #10262A 100%);
  border: 2px solid rgba(244, 239, 226, 0.24);
  box-shadow: 0 14px 32px rgba(0, 0, 0, 0.42);
}

.arena-stage-wrap canvas {
  display: block;
  width: 100% !important;
  height: 100% !important;
}

/* Move Buttons & Switch Bench */
.arena-controls-wrap {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}

.arena-moves-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.arena-move-btn {
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 10px 12px;
  border-radius: 15px;
  text-align: left;
  background: linear-gradient(180deg, rgba(18, 44, 52, 0.92), rgba(11, 29, 36, 0.96));
  border: 1.5px solid rgba(244, 239, 226, 0.22);
  color: var(--bone);
  transition: transform 0.13s ease, border-color 0.13s ease, box-shadow 0.13s ease;
  min-width: 0;
}

.arena-move-btn:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.35);
}

.arena-move-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.arena-move-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.arena-move-name {
  font-family: var(--font-display);
  font-size: 0.9rem;
  font-weight: 800;
}

.arena-move-cost {
  padding: 2px 7px;
  border-radius: var(--radius-pill);
  font-size: 0.7rem;
  font-weight: 900;
  background: rgba(229, 159, 58, 0.25);
  color: #FFE08A;
}

.arena-move-cost.is-short {
  background: rgba(200, 55, 45, 0.35);
  color: #FFC6BE;
}

.arena-move-mid {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.arena-move-power {
  font-size: 0.72rem;
  font-weight: 800;
  color: var(--bone-muted);
}

.arena-eff-chip {
  margin-left: auto;
  padding: 2px 7px;
  border-radius: var(--radius-pill);
  font-size: 0.69rem;
  font-weight: 900;
}

.arena-eff-chip.eff-mega { background: rgba(255, 198, 66, 0.35); color: #FFF1B8; border: 1px solid #FFD466; }
.arena-eff-chip.eff-super { background: rgba(91, 185, 107, 0.34); color: #C7F8CE; border: 1px solid #6AD67D; }
.arena-eff-chip.eff-neutral { background: rgba(244, 239, 226, 0.12); color: var(--bone-muted); }
.arena-eff-chip.eff-resist { background: rgba(232, 106, 58, 0.26); color: #FFD2BF; }
.arena-eff-chip.eff-double-resist { background: rgba(200, 55, 45, 0.38); color: #FFC6BE; }
.arena-eff-chip.eff-support { background: rgba(58, 216, 230, 0.22); color: #B4F5FF; }

.arena-move-desc {
  font-size: 0.73rem;
  color: var(--bone-muted);
  line-height: 1.32;
}

.arena-switch-bar {
  display: flex;
  flex-direction: column;
  gap: 7px;
  padding: 8px 10px;
  border-radius: 14px;
  background: rgba(12, 30, 36, 0.88);
  border: 1px solid rgba(244, 239, 226, 0.16);
}

.arena-switch-bar.is-opening {
  border-color: rgba(229, 159, 58, 0.52);
  background: linear-gradient(180deg, rgba(24, 52, 54, 0.92), rgba(14, 34, 40, 0.94));
}

.arena-switch-bar.is-prompting {
  border: 1.5px solid rgba(255, 212, 102, 0.88);
  background: linear-gradient(180deg, rgba(56, 40, 14, 0.94), rgba(22, 32, 36, 0.96));
  box-shadow: 0 0 0 2px rgba(255, 212, 102, 0.22);
}

.arena-switch-bar.is-prompting .arena-switch-title {
  color: #FFE59A;
}

.arena-switch-title {
  font-size: 0.74rem;
  font-weight: 800;
  color: var(--bone-muted);
}

.arena-switch-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 7px;
  width: 100%;
}

.arena-switch-btn {
  min-height: 44px;
  padding: 7px 10px;
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
  font-size: 0.76rem;
  text-align: left;
  background: rgba(244, 239, 226, 0.08);
  border: 1.5px solid rgba(244, 239, 226, 0.2);
  color: var(--bone);
  min-width: 0;
  transition: transform 0.12s ease, border-color 0.12s ease, background 0.12s ease;
}

.arena-switch-btn:hover:not(:disabled) {
  transform: translateY(-1px);
  border-color: rgba(255, 224, 138, 0.65);
  background: rgba(244, 239, 226, 0.14);
}

.arena-switch-btn.is-advantage {
  border-color: rgba(106, 214, 125, 0.75);
  background: rgba(61, 122, 90, 0.24);
  box-shadow: 0 0 12px rgba(91, 185, 107, 0.18);
}

.arena-switch-btn.is-active {
  border-color: var(--meadow-glow);
  background: rgba(61, 122, 90, 0.35);
}

.arena-switch-btn.is-fainted {
  opacity: 0.45;
}

.arena-switch-btn:disabled {
  cursor: default;
}

.arena-switch-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  width: 100%;
}

.arena-switch-top strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.arena-switch-hp {
  font-size: 0.7rem;
  font-weight: 800;
  color: var(--bone-muted);
  flex-shrink: 0;
}

.arena-switch-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
  width: 100%;
}

.arena-switch-meta .element-pill {
  font-size: 0.66rem;
  padding: 1px 6px;
}

.arena-bot-live-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
  padding: 9px 12px;
  border-radius: 14px;
  background: rgba(14, 38, 46, 0.88);
  border: 1px solid rgba(58, 216, 230, 0.35);
  font-size: 0.78rem;
  color: #C4F2FF;
}

/* Post-Battle Summary Card */
.arena-result-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px;
  border-radius: 18px;
  background: linear-gradient(180deg, rgba(18, 44, 48, 0.96), rgba(11, 28, 34, 0.98));
  border: 2px solid rgba(229, 159, 58, 0.65);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.42);
}

.arena-result-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  padding: 10px 12px;
  border-radius: 14px;
}

.arena-result-banner.is-win {
  background: rgba(54, 128, 72, 0.36);
  border: 1px solid rgba(169, 238, 146, 0.52);
}

.arena-result-banner.is-loss {
  background: rgba(142, 62, 36, 0.34);
  border: 1px solid rgba(232, 106, 58, 0.48);
}

.arena-result-banner h3 {
  margin: 0 0 2px;
  font-family: var(--font-display);
  font-size: 1.08rem;
  color: var(--bone);
}

.arena-result-banner p {
  margin: 0;
  font-size: 0.78rem;
  color: var(--bone-muted);
}

.arena-result-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.arena-rewards-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.arena-reward-chip {
  padding: 5px 10px;
  border-radius: var(--radius-pill);
  font-size: 0.78rem;
  font-weight: 800;
  background: rgba(229, 159, 58, 0.2);
  border: 1px solid rgba(229, 159, 58, 0.48);
  color: #FFE49E;
}

.arena-prog-list {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.arena-prog-row {
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 9px 11px;
  border-radius: 12px;
  background: rgba(10, 26, 32, 0.78);
  border: 1px solid rgba(244, 239, 226, 0.14);
}

.arena-prog-row.is-level-up {
  border-color: rgba(255, 224, 138, 0.65);
  background: rgba(56, 84, 46, 0.38);
}

.arena-prog-head,
.arena-prog-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  flex-wrap: wrap;
  font-size: 0.79rem;
}

.arena-prog-meta {
  font-size: 0.73rem;
  color: var(--bone-muted);
}

.arena-levelup-badge {
  margin-left: 5px;
  padding: 2px 7px;
  border-radius: var(--radius-pill);
  font-size: 0.68rem;
  font-weight: 900;
  background: linear-gradient(180deg, #FFE08A, #E59F3A);
  color: #1F1304;
}

.arena-stat-deltas {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.delta-chip {
  padding: 3px 8px;
  border-radius: 8px;
  font-size: 0.73rem;
  font-weight: 800;
  background: rgba(255, 255, 255, 0.08);
  color: var(--bone-muted);
}

.delta-chip.is-gain {
  background: rgba(91, 185, 107, 0.28);
  color: #C7F8CE;
  border: 1px solid rgba(91, 185, 107, 0.58);
}

/* Combat Log */
.arena-log-panel {
  border-radius: 14px;
  background: rgba(9, 23, 28, 0.86);
  border: 1px solid rgba(244, 239, 226, 0.14);
  padding: 9px 11px;
}

.arena-log-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}

.arena-log-title {
  font-size: 0.76rem;
  font-weight: 800;
  color: var(--bone);
}

.arena-log-sub {
  font-size: 0.69rem;
  color: var(--bone-muted);
}

.arena-combat-log {
  max-height: 126px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 3px;
  font-size: 0.75rem;
  line-height: 1.38;
  color: var(--bone-muted);
}

.arena-log-line {
  padding: 2px 4px;
  border-radius: 6px;
}

.arena-log-line:nth-child(even) {
  background: rgba(255, 255, 255, 0.03);
}

.arena-empty-note {
  padding: 10px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.05);
  font-size: 0.8rem;
  color: var(--bone-muted);
}

/* Bot Lab & 50-Match Benchmark Charts */
.bot-lab-controls {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 12px;
}

.bot-lab-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
  padding-bottom: 8px;
  border-bottom: 1px solid rgba(244, 239, 226, 0.09);
}

.bot-lab-label {
  font-size: 0.8rem;
  font-weight: 800;
  color: var(--bone);
  min-width: 132px;
}

.arena-num-input {
  width: 78px;
  min-height: 36px;
  padding: 5px 9px;
  border-radius: 10px;
  border: 1.5px solid rgba(244, 239, 226, 0.25);
  background: rgba(9, 23, 28, 0.9);
  color: var(--bone);
  font-weight: 800;
  font-size: 0.82rem;
}

.arena-seed-input {
  width: 112px;
}

.bot-lab-cta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.arena-benchmark-box {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1.5px solid rgba(244, 239, 226, 0.16);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.arena-benchmark-loading {
  padding: 14px;
  text-align: center;
  font-weight: 800;
  color: #B4F5FF;
}

.arena-bench-kpis {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.bench-kpi {
  padding: 9px 10px;
  border-radius: 12px;
  background: rgba(10, 26, 32, 0.8);
  border: 1px solid rgba(244, 239, 226, 0.15);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.bench-kpi span {
  font-size: 0.7rem;
  color: var(--bone-muted);
}

.bench-kpi strong {
  font-size: 0.95rem;
  color: var(--bone);
}

.bench-kpi.is-ok {
  border-color: rgba(91, 185, 107, 0.55);
}

.bench-kpi.is-ok strong {
  color: #C7F8CE;
}

.bench-kpi.is-warn {
  border-color: rgba(232, 106, 58, 0.65);
}

.bench-split-card {
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(10, 26, 32, 0.78);
  border: 1px solid rgba(244, 239, 226, 0.14);
}

.bench-split-head {
  display: flex;
  justify-content: space-between;
  font-size: 0.78rem;
  font-weight: 800;
  margin-bottom: 6px;
}

.bench-split-head .is-blue { color: #7EEAF5; }
.bench-split-head .is-red { color: #FFA886; }

.bench-split-bar {
  display: flex;
  height: 12px;
  border-radius: 999px;
  overflow: hidden;
  background: rgba(0, 0, 0, 0.4);
}

.bench-split-blue {
  background: linear-gradient(90deg, #278CA8, #5AD8F0);
}

.bench-split-red {
  background: linear-gradient(90deg, #D9653B, #B83D28);
}

.bench-columns {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 10px;
}

.bench-group {
  padding: 10px 12px;
  border-radius: 14px;
  background: rgba(10, 26, 32, 0.78);
  border: 1px solid rgba(244, 239, 226, 0.14);
  display: flex;
  flex-direction: column;
  gap: 7px;
  min-width: 0;
}

.bench-group h4 {
  margin: 0 0 2px;
  font-family: var(--font-display);
  font-size: 0.86rem;
  color: var(--bone);
}

.bench-bar-row {
  display: grid;
  grid-template-columns: minmax(96px, 1.1fr) minmax(60px, 1fr) auto;
  align-items: center;
  gap: 7px;
  font-size: 0.73rem;
}

.bench-bar-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--bone);
  font-weight: 700;
}

.bench-bar-track {
  height: 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
  overflow: hidden;
}

.bench-bar-fill {
  height: 100%;
  border-radius: 999px;
}

.bench-bar-fill.is-brain {
  background: linear-gradient(90deg, #E59F3A, #FFE08A);
}

.bench-bar-fill.is-adapt {
  background: linear-gradient(90deg, #3AD8E6, #9EF4FC);
}

.bench-bar-val {
  font-weight: 800;
  color: var(--bone-muted);
  white-space: nowrap;
}

/* Responsive Battle Arena for 390px iPhone & Narrow Viewports */
@media (max-width: 520px) {
  .arena-screen-scroll {
    padding: calc(var(--hud-top-offset, 12px) + 4px) 10px var(--dock-bottom-offset);
  }
  .arena-subtab-bar {
    grid-template-columns: 1fr;
  }
  .arena-hud-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
  }
  .arena-hud-card {
    padding: 7px 8px;
    gap: 4px;
    min-width: 0;
  }
  .arena-hud-name {
    font-size: 0.84rem;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .arena-hud-elements .element-pill {
    font-size: 0.63rem;
    padding: 1px 6px;
  }
  .arena-hp-labels {
    font-size: 0.68rem;
    gap: 4px;
    flex-wrap: wrap;
  }
  .arena-energy-row {
    gap: 4px;
  }
  .arena-energy-label {
    font-size: 0.65rem;
  }
  .arena-energy-pip {
    width: 8px;
    height: 8px;
  }
  .arena-bench-dot {
    font-size: 0.62rem;
    padding: 1px 5px;
  }
  .arena-stage-wrap {
    height: 185px;
  }
  .arena-moves-grid {
    grid-template-columns: 1fr;
  }
  .arena-switch-row {
    grid-template-columns: 1fr;
  }
  .arena-opponent-grid,
  .arena-squad-grid,
  .locus-4-grid {
    grid-template-columns: 1fr;
  }
  .arena-bench-kpis {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .bot-lab-label {
    min-width: 0;
    width: 100%;
  }
}

html[data-device="iphone"] .arena-screen-scroll {
  padding: calc(var(--hud-top-offset, 12px) + 4px) 10px var(--dock-bottom-offset);
}

html[data-device="iphone"] .arena-subtab-bar {
  grid-template-columns: 1fr;
}

html[data-device="iphone"] .arena-hud-row {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}

html[data-device="iphone"] .arena-hud-card {
  padding: 7px 8px;
  gap: 4px;
  min-width: 0;
}

html[data-device="iphone"] .arena-hud-name {
  font-size: 0.84rem;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

html[data-device="iphone"] .arena-hud-elements .element-pill {
  font-size: 0.63rem;
  padding: 1px 6px;
}

html[data-device="iphone"] .arena-hp-labels {
  font-size: 0.68rem;
  gap: 4px;
  flex-wrap: wrap;
}

html[data-device="iphone"] .arena-energy-row {
  gap: 4px;
}

html[data-device="iphone"] .arena-energy-label {
  font-size: 0.65rem;
}

html[data-device="iphone"] .arena-energy-pip {
  width: 8px;
  height: 8px;
}

html[data-device="iphone"] .arena-bench-dot {
  font-size: 0.62rem;
  padding: 1px 5px;
}

html[data-device="iphone"] .arena-stage-wrap {
  height: 185px;
}

html[data-device="iphone"] .arena-moves-grid {
  grid-template-columns: 1fr;
}

html[data-device="iphone"] .arena-switch-row {
  grid-template-columns: 1fr;
}

html[data-device="iphone"] .arena-opponent-grid,
html[data-device="iphone"] .arena-squad-grid,
html[data-device="iphone"] .locus-4-grid {
  grid-template-columns: 1fr;
}

html[data-device="iphone"] .arena-bench-kpis {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

html[data-device="iphone"] .bot-lab-label {
  min-width: 0;
  width: 100%;
}

/* ==========================================================================
   14. HearthIQ Family Games Bridge, Touch Policy, Locked Arena & Safe Area
   ========================================================================== */
canvas,
.preserve-canvas-host,
.dig-canvas-host,
.arena-stage-wrap {
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

.dock-tab.is-locked {
  opacity: 0.68;
  border-color: rgba(255, 210, 117, 0.32);
}

.dock-tab.is-locked:hover {
  opacity: 0.92;
  background: rgba(229, 159, 58, 0.16);
}

.dock-badge.is-lock-badge {
  background: linear-gradient(180deg, #3D5148, #223029);
  color: var(--amber-bright);
  border: 1px solid rgba(255, 210, 117, 0.55);
  font-size: 0.68rem;
}

.care-btn-arena.is-locked {
  opacity: 0.78;
  border-color: rgba(255, 210, 117, 0.45);
}

.hud-val.is-preview-capped {
  color: var(--amber-bright);
}

.arena-locked-card {
  max-width: 520px;
  margin: 48px auto 24px;
  padding: 28px 24px;
  border-radius: var(--radius-xl);
  background: linear-gradient(180deg, rgba(20, 42, 36, 0.94), rgba(11, 27, 24, 0.97));
  border: var(--border-amber);
  box-shadow: var(--shadow-elevated);
  text-align: center;
}

.arena-locked-badge {
  width: 60px;
  height: 60px;
  margin: 0 auto 14px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.7rem;
  background: rgba(229, 159, 58, 0.16);
  border: 1.5px solid rgba(255, 210, 117, 0.6);
}

.arena-locked-title {
  margin: 0 0 10px;
  font-family: var(--font-display);
  font-size: 1.35rem;
  color: var(--bone-bright);
}

.arena-locked-copy {
  margin: 0 0 18px;
  font-size: 0.95rem;
  line-height: 1.5;
  color: var(--bone-muted);
}

.arena-unlock-btn {
  min-height: 46px;
  padding: 10px 22px;
}

.hiq-init-error-actions {
  margin-top: 18px;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
}

.hiq-orphan-banner {
  position: fixed;
  bottom: calc(82px + var(--safe-bottom));
  left: 50%;
  transform: translateX(-50%);
  z-index: 55;
  max-width: calc(100% - 20px);
  display: inline-flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
  padding: 8px 14px;
  border-radius: var(--radius-pill);
  background: rgba(15, 34, 28, 0.94);
  border: var(--border-amber);
  color: var(--bone);
  font-size: 0.8rem;
  box-shadow: var(--shadow-soft);
}

.hiq-orphan-banner a {
  color: var(--amber-bright);
  font-weight: 800;
  text-decoration: underline;
}

@media (max-height: 450px) and (orientation: landscape) {
  :root {
    --dock-bottom-offset: calc(84px + var(--safe-bottom));
  }
  .compact-hud {
    top: calc(4px + var(--safe-top));
    gap: 4px;
    flex-wrap: nowrap;
  }
  .compact-hud .hud-pill-cluster {
    padding: 4px 10px;
    gap: 8px;
    flex-shrink: 0;
  }
  .compact-hud .hud-coach-pill {
    min-width: 0;
    padding: 4px 10px;
    font-size: 0.72rem;
  }
  .compact-hud .hud-chip-btn {
    padding: 4px 8px;
    font-size: 0.74rem;
  }
  .preserve-top-controls {
    gap: 4px 6px;
    flex-wrap: nowrap;
  }
  .preserve-bottom-stack {
    bottom: calc(62px + var(--safe-bottom));
    max-height: calc(100% - var(--preserve-hud-clearance, 76px) - 52px - 66px - var(--safe-bottom));
    gap: 4px;
  }
  .preserve-bottom-stack .preserve-utility-row .tactile-pill-btn {
    min-height: 44px;
    padding: 4px 10px;
    font-size: 0.72rem;
  }
  .preserve-bottom-stack .dino-care-tray {
    padding: 5px 10px;
    max-height: min(145px, 38dvh, calc(100dvh - var(--preserve-hud-clearance, 76px) - 138px - var(--safe-bottom)));
    overflow-y: auto;
  }
  .preserve-bottom-stack .dino-mini-stage {
    width: 36px;
    height: 36px;
    border-radius: 10px;
  }
  .preserve-bottom-stack .dino-care-sub,
  .preserve-bottom-stack .dino-stats-strip {
    display: none !important;
  }
  .preserve-bottom-stack .dino-meters-row {
    margin-top: 2px;
    gap: 8px;
    font-size: 0.72rem;
  }
  .preserve-bottom-stack .dino-care-actions {
    flex-wrap: nowrap;
    overflow-x: auto;
    margin-top: 4px;
    gap: 5px;
  }
  .preserve-bottom-stack .care-btn {
    min-height: 44px;
    padding: 4px 9px;
    font-size: 0.74rem;
  }
  .bottom-dock {
    bottom: calc(6px + var(--safe-bottom));
    padding: 4px 6px;
  }
  .dock-tab {
    min-height: 46px;
    padding: 3px 2px;
    gap: 1px;
  }
  .dock-icon-wrap {
    width: 22px;
    height: 22px;
  }
  .dock-icon {
    width: 20px;
    height: 20px;
  }
}

/* ==========================================================================
   15. Reduce Motion Compliance
   ========================================================================== */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

html[data-reduce-motion="true"] *,
html[data-reduce-motion="true"] *::before,
html[data-reduce-motion="true"] *::after {
  animation-duration: 0.01ms !important;
  animation-iteration-count: 1 !important;
  transition-duration: 0.01ms !important;
}
