/* ==========================================================================
   04puzzle — 90. gadu quest spēles vizuālais stils
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=VT323&family=IBM+Plex+Sans:wght@400;600&display=swap');

:root {
  --header-height: 3.25rem;
  --scene-reveal-duration: 3s;

  /* UI — klasiskā point-and-click (Sierra / LucasArts) */
  --ui-navy:        #000080;
  --ui-navy-light:  #1a1a9e;
  --ui-silver:      #c0c0c0;
  --ui-silver-dark: #808080;
  --ui-white:       #f0f0f0;
  --ui-verb:        #ffff00;
  --ui-verb-hover:  #ffffff;
  --ui-visited:     #a0a0ff;

  /* Tēma — lidmodelistu klubs, pagalms, 90ie */
  --sky-day:        #6eb5e0;
  --sky-dusk:       #c97b5c;
  --panel-house:    #b8a88a;
  --asphalt:        #4a4a52;
  --courtyard-grass:#3d6b3a;
  --accent-orange:  #e85d04;
  --accent-red:     #c1121f;
  --shadow:         rgba(0, 0, 20, 0.75);
}

html,
body {
  height: 100%;
  margin: 0;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

/* Native Storyline passage transitions. The runtime sets one short-lived
   data attribute while the browser owns old/new view snapshots. */
html[data-passage-transition]::view-transition-old(root),
html[data-passage-transition]::view-transition-new(root) {
  animation-fill-mode: both;
  animation-timing-function: cubic-bezier(0.22, 0.61, 0.36, 1);
  mix-blend-mode: normal;
}

html[data-passage-transition="crossfade"]::view-transition-old(root) {
  animation-name: passage-fade-out;
  animation-duration: 360ms;
}

html[data-passage-transition="crossfade"]::view-transition-new(root) {
  animation-name: passage-fade-in;
  animation-duration: 360ms;
}

html[data-passage-transition="fade-black"]::view-transition {
  background: #000;
}

html[data-passage-transition="fade-black"]::view-transition-old(root) {
  animation: 190ms ease-in both passage-fade-out;
}

html[data-passage-transition="fade-black"]::view-transition-new(root) {
  animation: 210ms 170ms ease-out both passage-fade-in;
}

html[data-passage-transition="slide-left"]::view-transition-old(root) {
  animation: 420ms cubic-bezier(0.4, 0, 0.2, 1) both passage-slide-out-left;
}

html[data-passage-transition="slide-left"]::view-transition-new(root) {
  animation: 420ms cubic-bezier(0.4, 0, 0.2, 1) both passage-slide-in-right;
}

html[data-passage-transition="slide-right"]::view-transition-old(root) {
  animation: 420ms cubic-bezier(0.4, 0, 0.2, 1) both passage-slide-out-right;
}

html[data-passage-transition="slide-right"]::view-transition-new(root) {
  animation: 420ms cubic-bezier(0.4, 0, 0.2, 1) both passage-slide-in-left;
}

html[data-passage-transition="zoom"]::view-transition-old(root) {
  animation: 380ms ease-in both passage-zoom-out;
}

html[data-passage-transition="zoom"]::view-transition-new(root) {
  animation: 420ms ease-out both passage-zoom-in;
}

@keyframes passage-fade-out {
  from { opacity: 1; }
  to { opacity: 0; }
}

@keyframes passage-fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes passage-slide-out-left {
  from { transform: translateX(0); }
  to { transform: translateX(-100%); }
}

@keyframes passage-slide-in-right {
  from { transform: translateX(100%); }
  to { transform: translateX(0); }
}

@keyframes passage-slide-out-right {
  from { transform: translateX(0); }
  to { transform: translateX(100%); }
}

@keyframes passage-slide-in-left {
  from { transform: translateX(-100%); }
  to { transform: translateX(0); }
}

@keyframes passage-zoom-out {
  from { opacity: 1; transform: scale(1); }
  to { opacity: 0; transform: scale(1.08); }
}

@keyframes passage-zoom-in {
  from { opacity: 0; transform: scale(0.92); }
  to { opacity: 1; transform: scale(1); }
}

@media (prefers-reduced-motion: reduce) {
  html[data-passage-transition]::view-transition-old(root),
  html[data-passage-transition]::view-transition-new(root) {
    animation-duration: 1ms !important;
    animation-delay: 0ms !important;
  }
}

tw-story {
  font-family: 'IBM Plex Sans', 'Segoe UI', Tahoma, sans-serif;
  font-size: 1.5rem;
  line-height: 1.6;
  padding: 0 !important;
  margin: 0;
  min-height: 100vh;
  background-color: #0a0a12;
  color: var(--ui-white);
  overflow-x: hidden;
}

/* Smalks CRT / monitora efekts (90. gadu datorspēles) */
tw-story::after {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9998;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 2px,
    rgba(0, 0, 0, 0.03) 2px,
    rgba(0, 0, 0, 0.03) 4px
  );
  mix-blend-mode: multiply;
}

/* Vignette — tumšākas malas kā vecās spēlēs */
tw-story::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9997;
  box-shadow: inset 0 0 120px rgba(0, 0, 0, 0.55);
}

/* --- Spēles header: nosaukums + 8 inventāra sloti ----------------------- */
#game-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--header-height);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.3rem 0.75rem;
  font-family: 'VT323', 'Courier New', monospace;
  background: linear-gradient(180deg, var(--ui-navy) 0%, var(--ui-navy-light) 100%);
  border-bottom: 3px solid var(--ui-silver);
  box-shadow:
    0 2px 0 var(--ui-silver-dark),
    0 4px 12px var(--shadow);
  z-index: 10001;
  box-sizing: border-box;
}

#game-header .header-title {
  flex: 1 1 auto;
  min-width: 0;
  font-size: 1.25rem;
  letter-spacing: 0.08em;
  color: var(--ui-verb);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#game-header .header-title.mood-race-day {
  color: var(--accent-orange);
}

#game-header .inventory-bar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 0.3rem;
}

/* Izstrādes poga — atiestata spēli (produkcijā: display: none) */
#game-reset-btn {
  flex: 0 0 auto;
  font-family: 'VT323', 'Courier New', monospace;
  font-size: 1.1rem;
  line-height: 1;
  padding: 0.15rem 0.45rem;
  color: var(--ui-verb);
  background: rgba(0, 0, 40, 0.85);
  border: 2px solid var(--ui-silver-dark);
  box-shadow:
    inset 1px 1px 0 var(--ui-silver),
    1px 1px 0 #000;
  cursor: pointer;
}

#game-reset-btn:hover {
  color: var(--ui-verb-hover);
  border-color: var(--ui-silver);
  background: rgba(26, 26, 158, 0.85);
}

#game-reset-btn:active {
  color: var(--accent-orange);
}

#dev-vars-hud {
  flex: 0 0 auto;
  font-family: 'VT323', 'Courier New', monospace;
  font-size: 1rem;
  letter-spacing: 0.04em;
  color: #9fd4ff;
  background: rgba(0, 0, 40, 0.75);
  border: 1px solid var(--ui-silver-dark);
  padding: 0.1rem 0.45rem;
  white-space: nowrap;
}

#game-header .inv-slot {
  width: 2.2rem;
  height: 2.2rem;
  flex: 0 0 2.2rem;
  background-color: rgba(0, 0, 40, 0.85);
  border: 2px solid var(--ui-silver-dark);
  box-shadow:
    inset 1px 1px 0 var(--ui-silver),
    inset -1px -1px 0 #404040,
    1px 1px 0 #000;
  background-size: 88%;
  background-repeat: no-repeat;
  background-position: center;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  display: flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
}

#game-header .inv-slot.filled {
  border-color: var(--ui-silver);
  background-color: rgba(0, 0, 60, 0.95);
}

#game-header .inv-icon {
  font-size: 1.35rem;
  line-height: 1;
  filter: saturate(0.85);
}

/* --- Passage = aina + teksts -------------------------------------------- */
tw-passage {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: flex-end;
  min-height: 100vh;
  margin: 0;
  padding: calc(var(--header-height) + 0.35rem) 1.25rem 1.25rem 1.25rem;
  box-sizing: border-box;
  background-color: #1a1a2e;
  background-size: cover;
  background-position: center top;
  background-repeat: no-repeat;
  position: relative;
  font-size: 1.5rem;
  line-height: 1.65;
  color: var(--ui-white);
}

tw-passage:not(.scene-reveal) {
  opacity: 0;
}

tw-passage.scene-reveal {
  animation: scene-fade-in var(--scene-reveal-duration) ease-out forwards;
}

@keyframes scene-fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* Stāstījuma teksts — apakšējā kreisajā pusē */
.passage-info {
  position: relative;
  z-index: 10000;
  flex: 0 0 auto;
  width: 100%;
  max-width: none;
  margin: 0;
  padding: 0.6rem 0.85rem 0.7rem;
  font-size: 1.05rem;
  background: transparent;
  border: 0;
  box-shadow: none;
  box-sizing: border-box;
  color: var(--ui-white);
  line-height: 1.45;
  text-shadow: none;
}

.passage-info > :first-child { margin-top: 0; }
.passage-info > :last-child { margin-bottom: 0; }
.passage-info h1, .passage-info h2, .passage-info h3,
.passage-info h4, .passage-info h5, .passage-info h6 {
  margin: 0.65em 0 0.25em;
  color: inherit;
  line-height: 1.15;
}
.passage-info p, .passage-info ul, .passage-info ol, .passage-info blockquote, .passage-info pre { margin: 0.45em 0; }
.passage-info blockquote { padding-left: 0.8em; border-left: 3px solid var(--ui-silver); opacity: 0.92; }
.passage-info code { padding: 0.05em 0.25em; border-radius: 0.2em; background: rgba(0, 0, 0, 0.35); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.passage-info pre { padding: 0.55em; overflow: auto; border-radius: 0.25em; background: rgba(0, 0, 0, 0.5); }
.passage-info pre code { padding: 0; background: transparent; }

/* Darbību izvēlne — tieši zem info, apakšā pa kreisi */
.passage-actions {
  position: relative;
  z-index: 10000;
  flex: 0 0 auto;
  width: 100%;
  max-width: none;
  margin: 0;
  padding: 0 0.85rem 0.7rem;
  box-sizing: border-box;
}

tw-passage > * {
  position: relative;
  z-index: 10000;
  max-width: 34rem;
  margin-left: 0;
  margin-right: auto;
  width: min(34rem, 52vw);
  text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.95);
  pointer-events: auto;
}

/*
 * The SVG scene is a body-level sibling of <tw-story>. Passage transitions
 * create stacking contexts that can trap narrative descendants
 * below the scene. Keep the original passage transparent/click-through;
 * PassageUi mirrors its content into #game-narrative-layer above the scene.
 */
html.game-has-svg-scene tw-story {
  background: transparent;
  pointer-events: none;
}

html.game-has-svg-scene tw-passage {
  background: transparent !important;
  pointer-events: none;
}

#game-narrative-layer {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: flex-end;
  padding: calc(var(--header-height) + 0.35rem) 1.25rem 1.25rem;
  box-sizing: border-box;
  pointer-events: none;
}

.passage-panel {
  width: min(34rem, 52vw);
  max-width: 34rem;
  max-height: calc(100vh - var(--header-height) - 1.95rem);
  overflow: auto;
  color: var(--ui-white);
  background: rgba(0, 0, 50, 0.78);
  border: 2px solid rgba(192, 192, 192, 0.42);
  box-shadow:
    inset 1px 1px 0 rgba(255, 255, 255, 0.1),
    0 3px 14px rgba(0, 0, 0, 0.5);
  pointer-events: auto;
  overscroll-behavior: contain;
}

tw-passage > [data-narrative-source="true"] {
  visibility: hidden;
  pointer-events: none;
}

/* SVG aina un hotspot slānis — attēls un formas izmanto vienu viewBox */
#game-scene-layer {
  position: fixed !important;
  top: 0 !important;
  right: 0 !important;
  bottom: 0 !important;
  left: 0 !important;
  z-index: 5000 !important;
  margin: 0 !important;
  padding: 0 !important;
  overflow: hidden !important;
  pointer-events: none;
}

#game-scene-svg {
  display: block;
  width: 100%;
  height: 100%;
  overflow: hidden;
  pointer-events: none;
}

.scene-background-image {
  pointer-events: none;
  user-select: none;
}

.scene-image-overlay {
  pointer-events: none;
  user-select: none;
}

.scene-text-overlay {
  overflow: hidden;
  pointer-events: none;
}

.scene-text-overlay-content {
  box-sizing: border-box;
  display: flex;
  align-items: center;
  width: 100%;
  height: 100%;
  padding: 0.45em 0.6em;
  overflow: hidden;
  color: #fff;
  background: rgba(10, 16, 30, 0.72);
  border: 2px solid rgba(255, 255, 255, 0.72);
  border-radius: 0.35em;
  line-height: 1.2;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  text-shadow: 0 1px 2px #000;
}

.scene-text-overlay-content > span {
  width: 100%;
}

.scene-hotspot-group,
.scene-hotspot-shape {
  pointer-events: all;
  cursor: pointer;
}

.scene-hotspot-group {
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.scene-hotspot-group[data-gesture="trajectory"] {
  cursor: crosshair;
  touch-action: none;
}

.scene-hotspot-shape {
  fill: rgba(0, 0, 0, 0.001);
  stroke: transparent;
  stroke-width: 2;
  vector-effect: non-scaling-stroke;
}

.scene-hotspot-group:focus .scene-hotspot-shape,
.scene-hotspot-group:focus-visible .scene-hotspot-shape {
  stroke: var(--ui-verb);
  stroke-width: 3;
  outline: none;
}

.scene-hotspots--debug .scene-hotspot-shape {
  fill: rgba(255, 0, 0, 0.16);
  stroke: rgba(255, 80, 80, 0.95);
}

.scene-gesture-guide,
.scene-gesture-trace {
  fill: none;
  vector-effect: non-scaling-stroke;
  pointer-events: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.scene-gesture-guide {
  stroke: #00ffff;
  stroke-width: 2;
  stroke-dasharray: 7 5;
  opacity: var(--gesture-guide-opacity, 0.9);
}

.scene-gesture-trace {
  stroke: var(--ui-verb);
  stroke-width: 4;
}

.scene-gesture-trace.is-success {
  stroke: #50ff80;
}

.scene-gesture-trace.is-failure {
  stroke: #ff5050;
}

.scene-hotspot-group[hidden] {
  display: none;
}

/* Vizuālais hotspotu autors ir pieejams tikai ?debug=hotspots režīmā. */
#game-scene-svg.is-authoring {
  pointer-events: all;
  touch-action: none;
  cursor: crosshair;
}

.scene-authoring-overlay,
.scene-authoring-overlay * {
  pointer-events: none;
}

.scene-authoring-shape {
  fill: rgba(80, 255, 128, 0.2);
  stroke: #50ff80;
  stroke-width: 3;
  stroke-dasharray: 8 5;
  stroke-linecap: round;
  stroke-linejoin: round;
  vector-effect: non-scaling-stroke;
}

.scene-authoring-point {
  fill: var(--ui-verb);
  stroke: #001030;
  stroke-width: 2;
  vector-effect: non-scaling-stroke;
}

html.hotspot-authoring-active #game-header,
html.hotspot-authoring-active #game-narrative-layer {
  opacity: 0.2;
  pointer-events: none;
}

#hotspot-authoring-panel {
  position: fixed;
  top: calc(var(--header-height) + 0.75rem);
  right: 0.75rem;
  z-index: 10003;
  width: min(28rem, calc(100vw - 1.5rem));
  max-height: calc(100vh - var(--header-height) - 1.5rem);
  overflow: auto;
  box-sizing: border-box;
  color: var(--ui-white);
  background: rgba(0, 0, 50, 0.94);
  border: 2px solid var(--ui-silver);
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.65);
  font: 1rem/1.25 'IBM Plex Sans', 'Segoe UI', sans-serif;
  overscroll-behavior: contain;
}

#hotspot-authoring-panel.is-collapsed {
  width: auto;
  overflow: visible;
}

#hotspot-authoring-panel.is-drawing {
  width: min(18rem, calc(100vw - 1.5rem));
}

#hotspot-authoring-panel.is-drawing .hotspot-authoring__scene,
#hotspot-authoring-panel.is-drawing .hotspot-authoring__selection,
#hotspot-authoring-panel.is-drawing .hotspot-authoring__fields,
#hotspot-authoring-panel.is-drawing .hotspot-authoring__advanced,
#hotspot-authoring-panel.is-drawing .hotspot-authoring__hint,
#hotspot-authoring-panel.is-drawing .hotspot-authoring__actions-section,
#hotspot-authoring-panel.is-drawing .hotspot-authoring__output-controls,
#hotspot-authoring-panel.is-drawing .hotspot-authoring__code-label,
#hotspot-authoring-panel.is-drawing .hotspot-authoring__copy,
#hotspot-authoring-panel.is-drawing .hotspot-authoring__save-section,
#hotspot-authoring-panel.is-drawing .hotspot-authoring__validation,
#hotspot-authoring-panel.is-drawing .hotspot-authoring__feedback {
  display: none;
}

#hotspot-authoring-panel.is-drawing .hotspot-authoring__commands button:disabled {
  display: none;
}

#hotspot-authoring-panel button,
#hotspot-authoring-panel input,
#hotspot-authoring-panel select,
#hotspot-authoring-panel textarea {
  box-sizing: border-box;
  font: inherit;
}

#hotspot-authoring-panel button {
  min-height: 2.35rem;
  padding: 0.35rem 0.55rem;
  color: var(--ui-verb);
  background: #08085d;
  border: 1px solid var(--ui-silver-dark);
  cursor: pointer;
}

#hotspot-authoring-panel button:hover:not(:disabled),
#hotspot-authoring-panel button:focus-visible {
  color: var(--ui-verb-hover);
  border-color: var(--ui-white);
}

#hotspot-authoring-panel button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.hotspot-authoring__panel-toggle {
  width: 100%;
  font-family: 'VT323', 'Courier New', monospace !important;
  font-size: 1.25rem !important;
  text-align: left;
}

.hotspot-authoring__body {
  padding: 0.65rem;
}

.hotspot-authoring__scene,
.hotspot-authoring__coordinates,
.hotspot-authoring__feedback {
  display: block;
  margin-bottom: 0.55rem;
  color: #9fd4ff;
  font-family: 'VT323', 'Courier New', monospace;
  font-size: 1.15rem;
}

.hotspot-authoring__fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.55rem;
}

.hotspot-authoring__fields label:last-child {
  grid-column: 1 / -1;
}

.hotspot-authoring__fields label,
.hotspot-authoring__selection,
.hotspot-authoring__advanced label,
.hotspot-authoring__output-controls label,
.hotspot-action__fields label,
.hotspot-authoring__code-label {
  display: grid;
  gap: 0.2rem;
}

.hotspot-authoring__fields input,
.hotspot-authoring__fields select,
.hotspot-authoring__selection select,
.hotspot-authoring__advanced textarea,
.hotspot-authoring__output-controls select,
.hotspot-action input,
.hotspot-action select,
.hotspot-action textarea,
.hotspot-authoring__code {
  width: 100%;
  color: #fff;
  background: #080828;
  border: 1px solid var(--ui-silver-dark);
  padding: 0.35rem;
}

.hotspot-authoring__selection {
  margin-bottom: 0.55rem;
}

.hotspot-authoring__advanced {
  margin-top: 0.55rem;
  padding: 0.45rem;
  border: 1px solid rgba(192, 192, 192, 0.35);
}

.hotspot-authoring__advanced summary,
.hotspot-action__advanced summary {
  cursor: pointer;
  color: #9fd4ff;
}

.hotspot-authoring__advanced textarea,
.hotspot-action__advanced textarea {
  min-height: 4.5rem;
  resize: vertical;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace !important;
  font-size: 0.78rem !important;
}

.hotspot-authoring__checkbox {
  display: flex !important;
  grid-template-columns: none !important;
  align-items: center;
  gap: 0.45rem !important;
  margin: 0.45rem 0;
}

.hotspot-authoring__checkbox input {
  width: auto;
}

.hotspot-authoring__gesture-note {
  margin: 0.4rem 0 0;
  color: #9fd4ff;
  font-size: 0.82rem;
}

.hotspot-authoring__draw-toggle,
.hotspot-authoring__copy {
  width: 100%;
  margin-top: 0.6rem;
}

.hotspot-authoring__save-section {
  margin-top: 0.65rem;
  padding-top: 0.6rem;
  border-top: 1px solid rgba(192, 192, 192, 0.35);
}

.hotspot-authoring__save-section p {
  margin: 0 0 0.45rem;
  color: #ffd98a;
  font-size: 0.78rem;
}

.hotspot-authoring__save-controls {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.4rem;
}

.hotspot-authoring__save-status {
  display: block;
  margin-top: 0.4rem;
  color: #9fd4ff;
  font-size: 0.78rem;
}

.hotspot-authoring__coordinates {
  margin: 0.55rem 0 0;
}

.hotspot-authoring__hint {
  min-height: 2.5em;
  margin: 0.35rem 0;
  font-size: 0.86rem;
}

.hotspot-authoring__commands {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.35rem;
  margin-bottom: 0.6rem;
}

.hotspot-authoring__commands button {
  min-height: 3.25rem !important;
  padding: 0.25rem !important;
  font-size: 0.8rem !important;
}

.hotspot-authoring__actions-section {
  margin-top: 0.75rem;
  padding-top: 0.55rem;
  border-top: 1px solid rgba(192, 192, 192, 0.35);
}

.hotspot-authoring__actions-section h2 {
  margin: 0 0 0.45rem;
  font: 1.25rem/1 'VT323', 'Courier New', monospace;
  color: var(--ui-verb);
}

.hotspot-actions__list {
  display: grid;
  gap: 0.55rem;
}

.hotspot-action {
  padding: 0.45rem;
  background: rgba(8, 8, 40, 0.72);
  border: 1px solid var(--ui-silver-dark);
}

.hotspot-action.has-error {
  border-color: #ff6b6b;
}

.hotspot-action__header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.35rem;
}

.hotspot-action__custom-type {
  grid-column: 1 / -1;
}

.hotspot-action__move {
  display: flex;
  gap: 0.2rem;
}

.hotspot-action__move button {
  min-width: 2.35rem;
  padding: 0.2rem !important;
}

.hotspot-action__fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.4rem;
  margin-top: 0.45rem;
}

.hotspot-action__advanced {
  margin-top: 0.4rem;
}

.hotspot-action__advanced textarea {
  width: 100%;
  margin-top: 0.3rem;
}

.hotspot-actions__add {
  width: 100%;
  margin-top: 0.5rem;
}

.hotspot-action__error,
.hotspot-authoring__validation {
  display: block;
  color: #ff9090;
  font-size: 0.78rem;
  margin-top: 0.3rem;
}

[aria-invalid="true"] {
  border-color: #ff6b6b !important;
  outline-color: #ff6b6b;
}

.hotspot-authoring__output-controls {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 0.45rem;
  margin-top: 0.75rem;
}

.hotspot-authoring__code {
  min-height: 13rem;
  margin-top: 0.25rem;
  resize: vertical;
  white-space: pre;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace !important;
  font-size: 0.78rem !important;
  line-height: 1.35;
}

/* Compact story graph and live state inspector, only created in debug mode. */
#debug-navigation-map {
  position: fixed;
  top: calc(var(--header-height) + 0.75rem);
  left: 0.75rem;
  z-index: 10003;
  width: min(23rem, calc(100vw - 1.5rem));
  max-height: calc(100vh - var(--header-height) - 1.5rem);
  overflow: auto;
  box-sizing: border-box;
  color: var(--ui-white);
  background: rgba(0, 0, 50, 0.94);
  border: 2px solid var(--ui-silver);
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.65);
  font: 0.86rem/1.25 'IBM Plex Sans', 'Segoe UI', sans-serif;
  overscroll-behavior: contain;
}

#debug-navigation-map.is-collapsed {
  width: auto;
  overflow: visible;
}

#debug-navigation-map button {
  box-sizing: border-box;
  min-height: 2rem;
  padding: 0.25rem 0.45rem;
  color: var(--ui-verb);
  background: #08085d;
  border: 1px solid var(--ui-silver-dark);
  font: inherit;
  cursor: pointer;
}

#debug-navigation-map button:hover,
#debug-navigation-map button:focus-visible {
  color: var(--ui-verb-hover);
  border-color: var(--ui-white);
}

.debug-map__toggle {
  width: 100%;
  font-family: 'VT323', 'Courier New', monospace !important;
  font-size: 1.25rem !important;
  text-align: left;
}

.debug-map__body {
  padding: 0.55rem;
}

.debug-map__route {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr) minmax(0, 1fr);
  gap: 0.35rem;
  align-items: start;
}

.debug-map__group {
  display: grid;
  gap: 0.25rem;
  min-width: 0;
}

.debug-map__group h2 {
  margin: 0;
  color: #9fd4ff;
  font: 1rem/1 'VT323', 'Courier New', monospace;
}

.debug-map__group button,
.debug-map__group strong {
  overflow-wrap: anywhere;
  text-align: left;
}

.debug-map__group.is-current strong {
  display: block;
  padding: 0.35rem;
  color: var(--ui-verb-hover);
  background: rgba(26, 26, 158, 0.7);
  border: 1px solid var(--ui-silver);
}

.debug-map__state {
  margin-top: 0.55rem;
  padding-top: 0.45rem;
  border-top: 1px solid rgba(192, 192, 192, 0.35);
}

.debug-map__state summary {
  color: #9fd4ff;
  cursor: pointer;
}

.debug-map__state dl {
  display: grid;
  grid-template-columns: minmax(6rem, auto) minmax(0, 1fr);
  gap: 0.2rem 0.5rem;
  margin: 0.45rem 0 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.75rem;
}

.debug-map__state dt {
  color: var(--ui-verb);
}

.debug-map__state dd {
  min-width: 0;
  margin: 0;
  overflow-wrap: anywhere;
}

#game-message {
  position: fixed;
  left: 50%;
  bottom: max(1.25rem, env(safe-area-inset-bottom));
  z-index: 10002;
  max-width: min(90vw, 32rem);
  padding: 0.45rem 0.8rem;
  font-family: 'VT323', 'Courier New', monospace;
  font-size: clamp(1.1rem, 3vmin, 1.5rem);
  color: var(--ui-verb);
  background: rgba(0, 0, 50, 0.88);
  border: 2px solid var(--ui-silver);
  text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.95);
  pointer-events: none;
  opacity: 0;
  transform: translate(-50%, 0.5rem);
  transition: opacity 0.15s ease, transform 0.15s ease;
}

#game-message.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

.game-boot-error {
  position: fixed;
  inset: auto 1rem 1rem;
  z-index: 20000;
  padding: 0.75rem 1rem;
  color: #fff;
  background: #8b0000;
  border: 2px solid #fff;
  font-family: monospace;
}

/* Mazākas atstarpes starp izvēlnes rindām */
tw-passage tw-consecutive-br {
  display: block;
  height: 0.1rem;
  line-height: 0;
  margin: 0;
  visibility: hidden;
}

/* --- Saites = darbību verbos (Talk to, Look at, Go to...) --------------- */
tw-link,
.story-choice {
  font-family: 'VT323', 'Courier New', monospace;
  font-size: clamp(0.95rem, 2.2vmin, 1.35rem);
  letter-spacing: 0.04em;
  color: var(--ui-verb) !important;
  font-weight: normal;
  text-decoration: none;
  display: block;
  margin: 0;
  padding: 0.06rem 0.45rem 0.06rem 1.5rem;
  line-height: 1.1;
  background: rgba(0, 0, 80, 0.5);
  border: 2px solid transparent;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}

tw-link::before,
.story-choice::before {
  content: '▶ ';
  position: absolute;
  left: 0.35rem;
  color: var(--accent-orange);
}

tw-link,
.story-choice {
  position: relative;
}

.story-choice {
  cursor: pointer;
  box-sizing: border-box;
}

tw-passage tw-link:first-of-type,
tw-passage .story-choice:first-of-type {
  margin-top: 0.6rem;
}

tw-link:hover,
.story-choice:hover {
  color: var(--ui-verb-hover) !important;
  background: rgba(26, 26, 158, 0.7);
  border-color: var(--ui-silver);
}

tw-link:active,
.story-choice:active {
  color: var(--accent-orange) !important;
}

.visited {
  color: var(--ui-visited) !important;
}

tw-broken-link {
  color: #ff6b6b !important;
  border-bottom-color: #ff6b6b;
  opacity: 0.7;
}

/* ==========================================================================
   AINAS — pievieno atbilstošo tag passage
   Tag shēma: scene-<nosaukums>  (+ visual-ready kad gatavs)
   ========================================================================== */

tw-passage[tags~='scene-intro'] {
  background-color: #0a0a12;
  background-image:
    linear-gradient(0deg, rgba(0, 0, 40, 0.45) 0%, transparent 50%),
    url('assets/images/intro.png');
  background-size: cover;
  background-position: center center;
  background-repeat: no-repeat;
}

tw-passage[tags~='scene-prologue'] {
  background-color: #0a0a12;
  background-image:
    linear-gradient(0deg, rgba(0, 0, 40, 0.45) 0%, transparent 50%),
    url('assets/images/TimeWarpIntro.png');
  background-size: cover;
  background-position: center center;
  background-repeat: no-repeat;
}

tw-passage[tags~='scene-pie-apsarga'] {
  background-color: #3a3530;
  background-image:
    linear-gradient(0deg, rgba(0, 0, 0, 0.45) 0%, transparent 45%),
    url('assets/images/PieApsarga.png');
  background-size: cover;
  background-position: center center;
  background-repeat: no-repeat;
}

tw-passage[tags~='scene-pie-apsarga2'] {
  background-color: #3a3530;
  background-image:
    linear-gradient(0deg, rgba(0, 0, 0, 0.45) 0%, transparent 45%),
    url('assets/images/PieApsarga2.png');
  background-size: cover;
  background-position: center center;
  background-repeat: no-repeat;
}

tw-passage[tags~='scene-pie-apsarga3'] {
  background-color: #3a3530;
  background-image:
    linear-gradient(0deg, rgba(0, 0, 0, 0.45) 0%, transparent 45%),
    url('assets/images/PieApsarga3.png');
  background-size: cover;
  background-position: center center;
  background-repeat: no-repeat;
}

tw-passage[tags~='scene-pie-apsarga4'] {
  background-color: #3a3530;
  background-image:
    linear-gradient(0deg, rgba(0, 0, 0, 0.45) 0%, transparent 45%),
    url('assets/images/PieApsarga4.png');
  background-size: cover;
  background-position: center center;
  background-repeat: no-repeat;
}

tw-passage[tags~='scene-game-start'] {
  background-color: #0a0a12;
  background-image:
    linear-gradient(0deg, rgba(0, 0, 40, 0.45) 0%, transparent 50%),
    url('assets/images/GameStart.png');
  background-size: cover;
  background-position: center center;
  background-repeat: no-repeat;
}

tw-passage[tags~='scene-annas-iela'] {
  background-color: var(--panel-house);
  background-image:
    linear-gradient(0deg, rgba(0, 0, 40, 0.5) 0%, transparent 40%),
    linear-gradient(180deg, rgba(110, 181, 224, 0.15) 0%, transparent 25%),
    url('assets/images/AnnasIelasIeeja.png');
  background-size: cover;
  background-position: center center;
  background-repeat: no-repeat;
}

tw-passage[tags~='scene-annas-ielas-rokturis'] {
  background-color: var(--panel-house);
  background-image:
    linear-gradient(0deg, rgba(0, 0, 40, 0.5) 0%, transparent 40%),
    linear-gradient(180deg, rgba(110, 181, 224, 0.15) 0%, transparent 25%),
    url('assets/images/AnnasIelasRokturis.png');
  background-size: cover;
  background-position: center center;
  background-repeat: no-repeat;
}

tw-passage[tags~='scene-nikita-bmx'] {
  background-color: var(--asphalt);
  background-image:
    linear-gradient(0deg, rgba(0, 0, 40, 0.45) 0%, transparent 40%),
    linear-gradient(180deg, rgba(110, 181, 224, 0.12) 0%, transparent 30%),
    url('assets/images/AnnasIela_NikitaBMX.png');
  background-size: cover;
  background-position: center center;
  background-repeat: no-repeat;
}

tw-passage[tags~='scene-nikita-bmx-trick'] {
  background-color: var(--asphalt);
  background-image:
    linear-gradient(0deg, rgba(0, 0, 40, 0.45) 0%, transparent 40%),
    linear-gradient(180deg, rgba(110, 181, 224, 0.12) 0%, transparent 30%),
    url('assets/images/AnnasIela_NikitaBMX_trick.png');
  background-size: cover;
  background-position: center center;
  background-repeat: no-repeat;
}

tw-passage[tags~='scene-nikita-bmx-crash'] {
  background-color: var(--asphalt);
  background-image:
    linear-gradient(0deg, rgba(0, 0, 40, 0.45) 0%, transparent 40%),
    linear-gradient(180deg, rgba(110, 181, 224, 0.12) 0%, transparent 30%),
    url('assets/images/AnnasIela_NikitaBMX_crash.png');
  background-size: cover;
  background-position: center center;
  background-repeat: no-repeat;
}

tw-passage[tags~='scene-annas-gaiteņi'] {
  background-color: #3a3530;
  background-image:
    linear-gradient(0deg, rgba(0, 0, 0, 0.65) 0%, transparent 55%),
    repeating-linear-gradient(
      90deg,
      #4a4540 0px,
      #4a4540 80px,
      #3d3835 80px,
      #3d3835 160px
    );
}

tw-passage[tags~='scene-burgeris'] {
  background-color: #2a1810;
  background-image:
    linear-gradient(180deg, #ff9f5a 0%, transparent 30%),
    linear-gradient(0deg, rgba(0, 0, 0, 0.5) 0%, transparent 50%),
    linear-gradient(160deg, #8b4513 0%, #4a2510 100%);
}

tw-passage[tags~='scene-klubs'] {
  background-color: #1a3050;
  background-image:
    linear-gradient(180deg, var(--sky-dusk) 0%, var(--sky-day) 35%, transparent 60%),
    linear-gradient(0deg, rgba(0, 0, 60, 0.4) 0%, transparent 40%),
    repeating-linear-gradient(
      0deg,
      transparent,
      transparent 48px,
      rgba(255, 255, 255, 0.06) 48px,
      rgba(255, 255, 255, 0.06) 50px
    ),
    linear-gradient(170deg, #5a8ab0 0%, #2a5070 60%, #1a3040 100%);
}

tw-passage[tags~='scene-epilogs'] {
  background-color: #0a0a12;
  background-image:
    linear-gradient(0deg, rgba(0, 0, 40, 0.45) 0%, transparent 50%),
    url('assets/images/epilogs.png');
  background-size: cover;
  background-position: center center;
  background-repeat: no-repeat;
}

tw-passage[tags~='mood-night'] {
  filter: brightness(0.55) saturate(0.7);
}

@media (max-width: 576px) {
  :root {
    --header-height: 3rem;
  }

  #game-header .header-title {
    font-size: 1rem;
    letter-spacing: 0.04em;
  }

  #game-header .inv-slot {
    width: 1.85rem;
    height: 1.85rem;
    flex-basis: 1.85rem;
  }

  #game-header .inventory-bar {
    gap: 0.2rem;
  }

  #game-reset-btn {
    font-size: 1rem;
    padding: 0.12rem 0.4rem;
  }

  tw-story {
    font-size: 1.25rem;
  }

  tw-passage {
    font-size: 1.25rem;
    padding-left: 0.85rem;
    padding-right: 0.85rem;
    padding-bottom: 1rem;
  }

  .passage-info {
    font-size: 0.95rem;
    line-height: 1.4;
  }

  .passage-panel,
  tw-passage > * {
    width: min(100%, 34rem);
  }

  #game-narrative-layer {
    padding-left: 0.85rem;
    padding-right: 0.85rem;
    padding-bottom: 1rem;
  }

  tw-link {
    font-size: clamp(0.88rem, 2.4vmin, 1.15rem);
  }

  #debug-navigation-map {
    top: calc(var(--header-height) + 0.4rem);
    left: 0.4rem;
    width: calc(100vw - 0.8rem);
    max-height: calc(100vh - var(--header-height) - 0.8rem);
  }

  #debug-navigation-map.is-collapsed {
    width: auto;
  }
}

@media (max-width: 420px) {
  #game-header {
    gap: 0.3rem;
    padding-left: 0.4rem;
    padding-right: 0.4rem;
  }

  #game-header .header-title,
  #dev-vars-hud {
    display: none;
  }

  #game-header .inventory-bar {
    flex: 1 1 auto;
    justify-content: space-between;
    min-width: 0;
  }

  #game-header .inv-slot {
    width: 1.7rem;
    height: 1.7rem;
    flex-basis: 1.7rem;
  }

  #game-header .inv-icon {
    font-size: 1rem;
  }
}
