@import "../../../garden-os-theme.css";

/* Garden OS Story Mode — Design Tokens */
:root {
  /* Story Mode now inherits the shared Garden OS theme and only keeps
     mode-specific aliases and overrides here. */
  --soil: var(--soil-mid);
  --soil-dark: var(--soil);
  --text-mid: var(--text-soft);
  --text-light: rgba(245, 237, 224, 0.62);
  --leaf: var(--leaf-bright);
  --leaf-bright: var(--leaf-light);
  --sun: var(--sun-bright);
  --sun-soft: rgba(232, 200, 74, 0.15);
  --sun-warm: #f0d48e;
  --cream-dark: var(--cream-mid);
  --danger: var(--rust-light);
  --info: var(--accent-rain);
  --success: var(--leaf-light);

  /* Spacing & radii */
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 24px;
  --radius-pill: 999px;
}

#cutscene-layer {
  position: fixed;
  inset: 0;
  z-index: 100;
  pointer-events: none;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0 0 max(env(safe-area-inset-bottom, 16px), 16px);
}

.dp-panel {
  position: relative;
  pointer-events: none;
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 200ms ease, transform 200ms ease;
  display: flex;
  flex-direction: row;
  align-items: flex-end;
  gap: 12px;
  width: clamp(320px, 88vw, 720px);
  min-height: 120px;
  padding: 16px;
  margin-bottom: 24px;
  background: rgba(20, 28, 20, 0.88);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(180, 220, 140, 0.25);
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}

.dp-panel--visible {
  pointer-events: all;
  opacity: 1;
  transform: translateY(0);
}

.dp-panel[data-side="right"] {
  flex-direction: row-reverse;
}

.dp-portrait-area {
  flex-shrink: 0;
  width: 80px;
  height: 80px;
  position: relative;
}

.dp-portrait {
  width: 100%;
  height: 100%;
  position: relative;
  border-radius: 10px;
  overflow: hidden;
  background: linear-gradient(180deg, rgba(58, 122, 79, 0.85), rgba(26, 42, 26, 0.95));
  border: 1px solid rgba(180, 220, 140, 0.22);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.06);
}

.dp-portrait[data-portrait="garden_gurl"] {
  background: linear-gradient(180deg, rgba(90, 171, 107, 0.9), rgba(26, 42, 26, 0.96));
}

.dp-portrait[data-portrait="onion_man"] {
  background: linear-gradient(180deg, rgba(221, 168, 85, 0.9), rgba(64, 42, 24, 0.96));
}

.dp-portrait[data-portrait="vegeman"] {
  background: linear-gradient(180deg, rgba(212, 74, 42, 0.9), rgba(56, 28, 20, 0.96));
}

.dp-portrait[data-portrait="critters"] {
  background: linear-gradient(180deg, rgba(139, 168, 181, 0.88), rgba(30, 38, 45, 0.96));
}

.dp-portrait[data-portrait="calvin"] {
  background: linear-gradient(180deg, rgba(230, 223, 212, 0.96), rgba(78, 82, 86, 0.98));
}

.dp-portrait[data-portrait="old_gus"] {
  background: linear-gradient(180deg, rgba(194, 178, 128, 0.92), rgba(58, 42, 22, 0.96));
}

.dp-portrait[data-portrait="maya"] {
  background: linear-gradient(180deg, rgba(120, 160, 200, 0.9), rgba(32, 44, 60, 0.96));
}

.dp-portrait[data-portrait="lila"] {
  background: linear-gradient(180deg, rgba(220, 140, 100, 0.9), rgba(62, 30, 22, 0.96));
}

/* ── Emotion expression states (CSS-only portraits) ──────────────────── */
.dp-portrait.expr-neutral { filter: none; }

.dp-portrait.expr-warm {
  filter: brightness(1.12) saturate(1.15);
  box-shadow: inset 0 0 18px rgba(232, 200, 74, 0.18);
}

.dp-portrait.expr-sad {
  filter: brightness(0.88) saturate(0.7);
  box-shadow: inset 0 0 18px rgba(100, 120, 160, 0.22);
}

.dp-portrait.expr-surprised {
  filter: brightness(1.08);
  animation: dp-pop 0.25s ease-out;
}

.dp-portrait.expr-emphasis {
  filter: brightness(1.1) contrast(1.08);
  box-shadow: inset 0 0 14px rgba(232, 200, 74, 0.24);
}

.dp-portrait.expr-smirk {
  filter: brightness(1.04) saturate(1.1);
  transform: rotate(-1.5deg);
}

.dp-portrait-layer {
  position: absolute;
  inset: 0;
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center bottom;
}

.dp-portrait-fallback {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 38px;
  filter: drop-shadow(0 8px 12px rgba(0,0,0,0.28));
}

.dp-portrait.anim-talk { animation: dp-talk 0.3s steps(2) infinite; }
.dp-portrait.anim-blink { animation: dp-blink 3s infinite; }
.dp-portrait.anim-emphasis { animation: dp-emphasis 0.15s ease-out; }
.dp-portrait.anim-surprised { animation: dp-pop 0.2s ease-out; }
.dp-portrait.anim-sad { animation: dp-sad 1.2s ease-in-out infinite; }
.dp-portrait.anim-smirk { animation: dp-smirk 1.6s ease-in-out infinite; }

@keyframes dp-talk {
  0% { transform: scaleY(1); }
  50% { transform: scaleY(0.97); }
}

@keyframes dp-blink {
  0%, 94%, 100% { transform: scaleY(1); }
  96% { transform: scaleY(0.1); }
}

@keyframes dp-emphasis {
  0% { transform: scale(1); }
  50% { transform: scale(1.04); }
  100% { transform: scale(1); }
}

@keyframes dp-pop {
  0% { transform: scale(0.92); }
  60% { transform: scale(1.06); }
  100% { transform: scale(1); }
}

@keyframes dp-sad {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(2px); }
}

@keyframes dp-smirk {
  0%, 100% { transform: rotate(0deg); }
  50% { transform: rotate(-2deg); }
}

.dp-content-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
  position: relative;
}

.dp-speaker-badge {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: rgba(180, 220, 140, 0.9);
}

.dp-speaker-badge--thought {
  color: rgba(92, 61, 30, 0.8);
}

.dp-text {
  font-size: 0.95rem;
  line-height: 1.55;
  color: rgba(240, 248, 235, 0.95);
  min-height: 3.2em;
}

.dp-panel--thought {
  background: rgba(247, 242, 234, 0.97);
  border-color: rgba(92, 61, 30, 0.18);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.22);
}

.dp-panel--thought::after {
  content: '';
  position: absolute;
  bottom: -12px;
  right: 82px;
  width: 26px;
  height: 26px;
  background: rgba(247, 242, 234, 0.97);
  border-right: 1px solid rgba(92, 61, 30, 0.18);
  border-bottom: 1px solid rgba(92, 61, 30, 0.18);
  border-bottom-right-radius: 12px;
  transform: rotate(28deg);
}

.dp-panel--thought[data-side="right"]::after {
  right: auto;
  left: 82px;
  transform: rotate(118deg);
}

.dp-panel--thought .dp-text {
  color: rgba(30, 17, 10, 0.92);
  font-style: italic;
}

.dp-panel--thought .dp-dots .dp-dot {
  background: rgba(92, 61, 30, 0.2);
}

.dp-panel--thought .dp-dots .dp-dot--active {
  background: rgba(92, 61, 30, 0.72);
}

.dp-panel--thought .dp-advance-hint {
  color: rgba(92, 61, 30, 0.45);
}

.dp-dots {
  display: flex;
  gap: 5px;
  align-items: center;
  height: 8px;
}

.dp-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: rgba(180, 220, 140, 0.3);
  transition: background 200ms;
}

.dp-dot--active {
  background: rgba(180, 220, 140, 0.9);
}

.dp-advance-hint {
  position: absolute;
  bottom: 0;
  right: 0;
  font-size: 0.65rem;
  color: rgba(180, 220, 140, 0.6);
  opacity: 0;
  transition: opacity 300ms;
  animation: dp-hint-bounce 1.2s ease-in-out infinite;
}

@keyframes dp-hint-bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(3px); }
}

.dp-skip-btn {
  position: absolute;
  top: 12px;
  right: 12px;
  padding: 4px 10px;
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  background: transparent;
  border: 1px solid rgba(180, 220, 140, 0.3);
  border-radius: 4px;
  color: rgba(180, 220, 140, 0.6);
  cursor: pointer;
  transition: border-color 150ms, color 150ms;
}

.dp-skip-btn:hover {
  border-color: rgba(180, 220, 140, 0.7);
  color: rgba(180, 220, 140, 0.9);
}

.palette-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.palette-title {
  font-family: 'DM Mono', monospace;
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: rgba(247, 242, 234, 0.4);
}

.palette-dismiss {
  background: none;
  border: 1px solid rgba(247, 242, 234, 0.15);
  color: rgba(247, 242, 234, 0.5);
  font-size: 18px;
  width: 40px;
  height: 40px;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  padding: 0;
}

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

.palette-item {
  background: rgba(247, 242, 234, 0.06);
  border: 1px solid rgba(247, 242, 234, 0.1);
  border-radius: 8px;
  padding: 10px 8px;
  min-height: 88px;
  cursor: pointer;
  color: #f7f2ea;
  font-family: 'DM Sans', sans-serif;
  font-size: 13px;
  text-align: center;
  transition: border-color 0.15s;
}

.palette-item.is-selected,
.palette-item:hover {
  border-color: var(--sun);
}

.palette-emoji {
  font-size: 22px;
  margin-bottom: 2px;
}

.palette-name {
  font-size: 11px;
  line-height: 1.3;
  margin-bottom: 4px;
}

.palette-badge {
  --badge-color: #888;
  display: inline-block;
  font-family: 'DM Mono', monospace;
  font-size: 9px;
  padding: 2px 6px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--badge-color) 14%, transparent);
  color: var(--badge-color);
  border: 1px solid color-mix(in srgb, var(--badge-color) 28%, transparent);
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.palette-fit {
  display: inline-block;
  font-family: 'DM Mono', monospace;
  font-size: 8px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  margin-top: 2px;
}
.palette-fit--great { color: #5aab6b; }
.palette-fit--ok    { color: #e8c84a; }
.palette-fit--poor  { color: rgba(247,242,234,0.35); }

.intervention-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.intervention-btn {
  background: rgba(247, 242, 234, 0.06);
  border: 1px solid rgba(247, 242, 234, 0.12);
  border-radius: 10px;
  min-height: 110px;
  padding: 12px 8px;
  cursor: pointer;
  color: #f7f2ea;
  font-family: 'DM Sans', sans-serif;
  font-size: 12px;
  text-align: center;
  transition: border-color 0.15s, transform 0.15s, background 0.15s;
  -webkit-tap-highlight-color: transparent;
}

.intervention-btn:active {
  transform: scale(0.97);
}

.intervention-btn:hover {
  border-color: rgba(232, 200, 74, 0.34);
  transform: scale(1.03);
}

.intervention-btn.is-disabled {
  opacity: 0.4;
  cursor: default;
}

.targeting-sheet {
  padding-bottom: calc(32px + env(safe-area-inset-bottom, 0px));
}

.targeting-hint {
  margin-top: 4px;
  font-family: 'DM Sans', sans-serif;
  font-size: 13px;
  line-height: 1.5;
  color: rgba(247, 242, 234, 0.62);
}

.targeting-chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.targeting-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 10px;
  border-radius: 999px;
  background: rgba(61, 110, 143, 0.16);
  border: 1px solid rgba(61, 110, 143, 0.3);
  color: rgba(220, 237, 246, 0.95);
  font-family: 'DM Mono', monospace;
  font-size: 10px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.targeting-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  padding-top: 12px;
}

.targeting-actions .start-choice-btn {
  min-height: 44px;
  padding: 10px 16px;
  font-size: 13px;
}

#fab-advance.is-disabled {
  pointer-events: none;
  opacity: 0.35;
}

@media (max-width: 480px) {
  .dp-panel {
    width: 92vw;
    padding: 12px;
    gap: 10px;
    margin-bottom: 12px;
  }

  .dp-portrait-area {
    width: 60px;
    height: 60px;
  }

  .dp-text {
    font-size: 0.875rem;
  }

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

  .palette-item {
    min-height: 94px;
    padding: 12px 10px;
  }

  .palette-name {
    font-size: 12px;
  }

  .intervention-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
  }

  .intervention-btn {
    min-height: 76px;
    padding: 10px 6px;
    font-size: 11px;
  }

  .event-card__header {
    gap: 10px;
    margin-bottom: 8px;
  }

  .event-card__title {
    font-size: 20px;
    line-height: 1.25;
  }

  .event-card__valence {
    width: 28px;
    height: 28px;
    font-size: 16px;
  }

  .event-card__body {
    font-size: 13px;
    line-height: 1.5;
    margin-bottom: 10px;
  }

  .event-card__effect {
    margin-bottom: 10px;
    padding: 8px 10px;
  }

  .event-card__effect-label {
    margin-bottom: 2px;
  }

  .event-card__response {
    margin-bottom: 6px;
  }

  .event-card__intervention-icon {
    font-size: 18px;
    margin-bottom: 2px;
  }

  .event-card__intervention-title {
    margin-bottom: 1px;
  }

  .event-card__intervention-copy {
    line-height: 1.3;
  }

  .targeting-hint {
    font-size: 14px;
  }

  .targeting-actions {
    flex-direction: column-reverse;
  }

  .targeting-actions .start-choice-btn {
    width: 100%;
  }
}

/* GRAPHICAL OVERHAUL - PHASE 2 */
:root {
  --story-paper: #f3eadb;
  --story-paper-strong: rgba(243, 234, 219, 0.94);
  --story-paper-soft: rgba(251, 246, 238, 0.82);
  --story-ink: #26160a;
  --story-ink-soft: rgba(56, 35, 19, 0.72);
  --story-border: rgba(104, 68, 40, 0.24);
  --story-border-strong: rgba(104, 68, 40, 0.38);
  --story-shadow: 0 20px 54px rgba(15, 9, 4, 0.34);
  --story-shadow-soft: 0 12px 32px rgba(18, 11, 5, 0.22);
  --story-accent: var(--story-season-accent, #d4a820);
  --story-accent-rgb: var(--story-season-accent-rgb, 212, 168, 32);
  --story-accent-soft: rgba(var(--story-accent-rgb), 0.16);
  --story-stamp: rgba(93, 63, 36, 0.12);
}

.dp-panel {
  gap: 16px;
  align-items: stretch;
  padding: 18px 18px 14px;
  min-height: 146px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.24), rgba(255, 255, 255, 0)),
    linear-gradient(135deg, rgba(var(--story-accent-rgb), 0.1), transparent 54%),
    var(--story-paper-strong);
  color: var(--story-ink);
  border: 1px solid var(--story-border);
  border-radius: 22px;
  box-shadow: var(--story-shadow);
  backdrop-filter: blur(14px);
}

.dp-panel::before {
  content: "cutscene dispatch";
  position: absolute;
  top: 12px;
  right: 18px;
  padding: 4px 8px;
  border-radius: 999px;
  border: 1px solid rgba(var(--story-accent-rgb), 0.2);
  background: rgba(var(--story-accent-rgb), 0.08);
  color: rgba(93, 63, 36, 0.72);
  font-family: 'DM Mono', monospace;
  font-size: 9px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.dp-panel[data-side="right"]::before {
  right: auto;
  left: 18px;
}

.dp-panel--thought {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.22), rgba(255, 255, 255, 0)),
    rgba(250, 244, 235, 0.98);
  border-color: rgba(104, 68, 40, 0.22);
  box-shadow: var(--story-shadow-soft);
}

.dp-panel--thought::after {
  background: rgba(250, 244, 235, 0.98);
  border-right: 1px solid rgba(104, 68, 40, 0.22);
  border-bottom: 1px solid rgba(104, 68, 40, 0.22);
}

.dp-portrait-area {
  width: 92px;
  height: 98px;
}

.dp-portrait {
  border-radius: 18px;
  background:
    radial-gradient(circle at 50% 18%, rgba(255, 255, 255, 0.28), transparent 42%),
    linear-gradient(180deg, rgba(108, 144, 81, 0.92), rgba(41, 25, 11, 0.96));
  border: 1px solid rgba(104, 68, 40, 0.26);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.24),
    0 8px 20px rgba(25, 15, 8, 0.18);
}

.dp-portrait::after {
  content: "";
  position: absolute;
  inset: 10px;
  border: 1px dashed rgba(255, 255, 255, 0.22);
  border-radius: 12px;
  pointer-events: none;
}

.dp-portrait-fallback {
  font-size: 42px;
  filter: drop-shadow(0 8px 12px rgba(0, 0, 0, 0.22));
}

.dp-content-area {
  gap: 10px;
  padding-top: 8px;
}

.dp-speaker-badge {
  font-family: 'DM Mono', monospace;
  font-size: 0.62rem;
  letter-spacing: 0.16em;
  color: rgba(104, 68, 40, 0.72);
}

.dp-speaker-badge--thought {
  color: rgba(90, 58, 32, 0.7);
}

.dp-text {
  font-family: 'DM Sans', sans-serif;
  font-size: 0.98rem;
  line-height: 1.68;
  color: rgba(38, 22, 10, 0.92);
}

.dp-panel--thought .dp-text {
  color: rgba(38, 22, 10, 0.86);
}

.dp-dots {
  gap: 6px;
}

.dp-dot {
  width: 6px;
  height: 6px;
  background: rgba(104, 68, 40, 0.18);
}

.dp-dot--active {
  background: rgba(var(--story-accent-rgb), 0.88);
  box-shadow: 0 0 0 4px rgba(var(--story-accent-rgb), 0.12);
}

.dp-panel--thought .dp-dots .dp-dot {
  background: rgba(104, 68, 40, 0.18);
}

.dp-panel--thought .dp-dots .dp-dot--active {
  background: rgba(104, 68, 40, 0.76);
}

.dp-advance-hint {
  color: rgba(104, 68, 40, 0.54);
  font-family: 'DM Mono', monospace;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.dp-skip-btn {
  top: 14px;
  right: 14px;
  padding: 5px 12px;
  border-radius: 999px;
  border: 1px solid rgba(104, 68, 40, 0.18);
  background: rgba(255, 255, 255, 0.24);
  color: rgba(104, 68, 40, 0.72);
}

.dp-skip-btn:hover {
  border-color: rgba(var(--story-accent-rgb), 0.34);
  color: rgba(73, 46, 22, 0.92);
}

.palette-title {
  color: rgba(84, 53, 29, 0.74);
  letter-spacing: 0.14em;
}

.palette-dismiss {
  border-radius: 999px;
  border-color: rgba(104, 68, 40, 0.16);
  background: rgba(255, 255, 255, 0.34);
  color: rgba(104, 68, 40, 0.74);
}

.palette-item,
.intervention-btn {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.18), rgba(255, 255, 255, 0)),
    rgba(255, 249, 242, 0.42);
  border: 1px solid rgba(104, 68, 40, 0.14);
  color: rgba(38, 22, 10, 0.92);
  border-radius: 14px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.34);
}

.palette-item.is-selected,
.palette-item:hover,
.intervention-btn:hover {
  border-color: rgba(var(--story-accent-rgb), 0.36);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.26), rgba(255, 255, 255, 0)),
    rgba(var(--story-accent-rgb), 0.08);
}

.palette-name {
  color: rgba(38, 22, 10, 0.92);
}

.palette-fit--poor {
  color: rgba(84, 53, 29, 0.38);
}

.targeting-hint {
  color: rgba(56, 35, 19, 0.72);
}

.targeting-chip {
  background: rgba(var(--story-accent-rgb), 0.1);
  border-color: rgba(var(--story-accent-rgb), 0.22);
  color: rgba(73, 46, 22, 0.88);
}

.event-card__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.event-card__eyebrow,
.event-card__response,
.event-card__effect-label {
  font-family: 'DM Mono', monospace;
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.event-card__eyebrow,
.event-card__response {
  color: rgba(84, 53, 29, 0.54);
}

.event-card__title {
  font-family: 'Fraunces', serif;
  font-weight: 600;
  font-size: 23px;
  line-height: 1.28;
  color: rgba(38, 22, 10, 0.94);
}

.event-card__valence {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 999px;
  background: rgba(var(--story-accent-rgb), 0.1);
  border: 1px solid rgba(var(--story-accent-rgb), 0.22);
  color: var(--event-accent, var(--story-accent));
  font-weight: 700;
  font-size: 18px;
  flex-shrink: 0;
}

.event-card__body {
  font-size: 14px;
  line-height: 1.7;
  color: rgba(56, 35, 19, 0.84);
  margin-bottom: 16px;
}

.event-card__effect {
  margin-bottom: 16px;
  padding: 12px 14px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.26);
  border: 1px solid rgba(104, 68, 40, 0.12);
  color: rgba(56, 35, 19, 0.78);
  font-family: 'DM Mono', monospace;
  font-size: 11px;
}

.event-card__effect-label {
  margin-bottom: 6px;
  color: rgba(84, 53, 29, 0.44);
}

.event-card__intervention-icon {
  font-size: 20px;
  margin-bottom: 6px;
}

.event-card__intervention-title {
  font-weight: 600;
  margin-bottom: 3px;
}

.event-card__intervention-copy {
  font-size: 10px;
  line-height: 1.35;
  color: rgba(84, 53, 29, 0.56);
}

@media (max-width: 380px) {
  .intervention-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .dp-skip-btn {
    top: 10px;
    right: 10px;
    min-height: 34px;
  }

  .event-card-sheet {
    font-size: 13px;
  }

  .panel-sheet {
    padding: 14px 12px;
  }
}

/* Harvest reveal — A+ confetti burst (CSS-only pseudo-elements) */
.confetti-burst {
  position: absolute;
  inset: -20px;
  pointer-events: none;
}
.confetti-burst::before,
.confetti-burst::after {
  content: '';
  position: absolute;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  animation: confettiPop 1s ease-out forwards;
}
.confetti-burst::before {
  background: #e8c84a;
  top: 50%;
  left: 50%;
  box-shadow:
    -14px -18px 0 #5aab6b,
    16px -12px 0 #d44a2a,
    -20px 8px 0 #4a9aba,
    18px 14px 0 #e8c84a,
    -6px -22px 0 #dda855,
    10px 20px 0 #5aab6b,
    -18px -4px 0 #d44a2a,
    22px 2px 0 #4a9aba;
}
.confetti-burst::after {
  background: #5aab6b;
  top: 50%;
  left: 50%;
  box-shadow:
    12px -20px 0 #e8c84a,
    -16px -14px 0 #4a9aba,
    20px 6px 0 #dda855,
    -14px 16px 0 #d44a2a,
    8px -24px 0 #5aab6b,
    -10px 22px 0 #e8c84a,
    16px -6px 0 #4a9aba,
    -22px -2px 0 #dda855;
}
@keyframes confettiPop {
  0%   { transform: scale(0); opacity: 1; }
  50%  { transform: scale(1.4); opacity: 0.8; }
  100% { transform: scale(2.2); opacity: 0; }
}

/* Event card slide-in animation */
@keyframes eventSlideIn {
  from { transform: translateX(20px) translateY(100%); opacity: 0.6; }
  to   { transform: translateX(0) translateY(0); opacity: 1; }
}

/* Event card sheet — ensure the colored top border renders */
.event-card-sheet {
  overflow: visible;
}

/* ── Focus visible ─────────────────────────────────── */
button:focus-visible,
[role='button']:focus-visible,
[role='tab']:focus-visible,
[tabindex]:not([tabindex='-1']):focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 2px solid var(--sun);
  outline-offset: 2px;
}

/* ── Reduced motion ────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* Zine Press Sprint 1 dialogue layer */
.dp-panel {
  border-radius: 8px;
  background:
    var(--story-print-fiber, repeating-linear-gradient(0deg, rgba(42, 24, 10, 0.025) 0, rgba(42, 24, 10, 0.025) 1px, transparent 1px, transparent 7px)),
    linear-gradient(135deg, var(--story-zone-wash, rgba(138, 125, 61, 0.14)), transparent 60%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.28), rgba(255, 255, 255, 0)),
    var(--story-print-paper-light, #fff7eb);
  border: 1px solid var(--story-print-rule, rgba(79, 48, 27, 0.28));
  box-shadow: var(--story-registration-shadow, 0 12px 30px rgba(14, 8, 4, 0.22));
}

.dp-panel::before {
  content: "field note";
  border-radius: 4px;
  border-color: rgba(var(--story-zone-accent-rgb, 138, 125, 61), 0.32);
  background: rgba(var(--story-zone-accent-rgb, 138, 125, 61), 0.12);
  color: rgba(48, 29, 15, 0.82);
}

.dp-panel:not(.dp-panel--thought)::after {
  content: "";
  position: absolute;
  inset: 9px;
  pointer-events: none;
  border: 1px dashed rgba(65, 39, 21, 0.14);
}

.dp-panel--thought {
  border-radius: 8px;
}

.dp-portrait {
  border-radius: 8px;
  border-color: rgba(65, 39, 21, 0.28);
  background:
    radial-gradient(circle at 50% 16%, rgba(255, 255, 255, 0.3), transparent 38%),
    repeating-linear-gradient(135deg, rgba(255, 255, 255, 0.09) 0 3px, transparent 3px 9px),
    linear-gradient(180deg, rgba(var(--story-zone-accent-rgb, 138, 125, 61), 0.88), rgba(44, 26, 13, 0.96));
}

.dp-portrait::after {
  border-radius: 5px;
  border-color: rgba(255, 255, 255, 0.26);
}

.dp-portrait[data-portrait="garden_gurl"] {
  background:
    radial-gradient(circle at 50% 16%, rgba(255, 255, 255, 0.28), transparent 38%),
    repeating-linear-gradient(135deg, rgba(255, 255, 255, 0.08) 0 3px, transparent 3px 9px),
    linear-gradient(180deg, rgba(93, 129, 75, 0.92), rgba(36, 31, 18, 0.96));
}

.dp-portrait[data-portrait="onion_man"] {
  background:
    radial-gradient(circle at 50% 16%, rgba(255, 255, 255, 0.3), transparent 38%),
    repeating-linear-gradient(135deg, rgba(255, 255, 255, 0.08) 0 3px, transparent 3px 9px),
    linear-gradient(180deg, rgba(213, 168, 91, 0.94), rgba(76, 44, 24, 0.98));
}

.dp-portrait[data-portrait="vegeman"] {
  background:
    radial-gradient(circle at 50% 16%, rgba(255, 255, 255, 0.24), transparent 38%),
    repeating-linear-gradient(135deg, rgba(255, 255, 255, 0.08) 0 3px, transparent 3px 9px),
    linear-gradient(180deg, rgba(188, 74, 43, 0.94), rgba(48, 23, 15, 0.98));
}

.dp-portrait[data-portrait="critters"] {
  background:
    radial-gradient(circle at 50% 16%, rgba(255, 255, 255, 0.24), transparent 38%),
    repeating-linear-gradient(135deg, rgba(255, 255, 255, 0.08) 0 3px, transparent 3px 9px),
    linear-gradient(180deg, rgba(90, 110, 86, 0.92), rgba(29, 31, 24, 0.98));
}

.dp-speaker-badge {
  color: rgba(65, 39, 21, 0.72);
}

.dp-text {
  color: var(--story-print-ink, #271408);
  text-wrap: pretty;
}

.dp-choice-btn {
  border-radius: 8px;
}

/* Zine Press Sprint 2 character identity layer */
.dp-portrait-area {
  width: 98px;
  height: auto;
  min-height: 122px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
}

.dp-portrait {
  width: 92px;
  height: 92px;
  flex: 0 0 92px;
  isolation: isolate;
}

.dp-portrait::before {
  content: "";
  position: absolute;
  z-index: 1;
  pointer-events: none;
  opacity: 0.9;
  filter: drop-shadow(0 7px 8px rgba(18, 10, 4, 0.22));
}

.dp-portrait-layer {
  z-index: 2;
}

.dp-portrait::after {
  z-index: 4;
}

.dp-portrait-fallback {
  z-index: 3;
  opacity: 0.34;
  mix-blend-mode: multiply;
}

.dp-portrait[data-portrait="garden_gurl"]::before {
  inset: 12px 13px 10px;
  background:
    linear-gradient(rgba(28, 25, 16, 0.92), rgba(28, 25, 16, 0.92)) 50% 19% / 86% 8px no-repeat,
    linear-gradient(180deg, rgba(42, 47, 24, 0.94), rgba(25, 31, 17, 0.98)) 50% 29% / 48% 20px no-repeat,
    radial-gradient(ellipse at 50% 47%, rgba(202, 171, 123, 0.92) 0 31%, transparent 32%),
    linear-gradient(165deg, rgba(77, 96, 50, 0.95), rgba(40, 49, 29, 0.98)) 50% 91% / 58% 39% no-repeat;
  border-radius: 11px 11px 18px 18px;
}

.dp-portrait[data-portrait="onion_man"]::before {
  inset: 13px 18px 10px;
  background:
    radial-gradient(ellipse at 50% 42%, rgba(246, 214, 156, 0.96) 0 38%, transparent 39%),
    radial-gradient(ellipse at 50% 58%, rgba(209, 139, 74, 0.92) 0 43%, transparent 44%),
    linear-gradient(180deg, rgba(72, 45, 28, 0.92), rgba(48, 31, 22, 0.98)) 50% 91% / 50% 31% no-repeat;
  clip-path: polygon(50% 0, 74% 18%, 92% 50%, 72% 82%, 50% 100%, 27% 82%, 8% 50%, 27% 18%);
}

.dp-portrait[data-portrait="vegeman"]::before {
  inset: 15px 10px 8px;
  background:
    radial-gradient(circle at 50% 30%, rgba(126, 175, 71, 0.95) 0 22%, transparent 23%),
    linear-gradient(160deg, transparent 0 24%, rgba(46, 80, 36, 0.96) 25% 78%, transparent 79%) 18% 74% / 42% 47% no-repeat,
    linear-gradient(200deg, transparent 0 24%, rgba(46, 80, 36, 0.96) 25% 78%, transparent 79%) 82% 74% / 42% 47% no-repeat,
    linear-gradient(180deg, rgba(100, 155, 57, 0.96), rgba(42, 74, 33, 0.98)) 50% 84% / 62% 48% no-repeat;
  border-radius: 40% 40% 22% 22%;
  transform: rotate(-2deg) scaleX(1.1);
}

.dp-portrait[data-portrait="critters"]::before {
  inset: 16px 12px 12px;
  background:
    radial-gradient(circle at 26% 50%, rgba(92, 67, 42, 0.96) 0 15%, transparent 16%),
    radial-gradient(circle at 48% 36%, rgba(79, 99, 50, 0.96) 0 17%, transparent 18%),
    radial-gradient(circle at 70% 54%, rgba(111, 73, 50, 0.96) 0 16%, transparent 17%),
    radial-gradient(circle at 55% 72%, rgba(55, 62, 38, 0.96) 0 12%, transparent 13%);
}

.dp-portrait[data-emotion="sad"]::before {
  transform: translateY(2px) scale(0.97);
}

.dp-portrait[data-emotion="surprised"]::before,
.dp-portrait[data-emotion="emphasis"]::before {
  filter:
    drop-shadow(0 7px 8px rgba(18, 10, 4, 0.2))
    drop-shadow(0 0 10px rgba(var(--story-zone-accent-rgb, 138, 125, 61), 0.26));
}

.dp-portrait[data-emotion="smirk"]::before {
  transform: rotate(-3deg);
}

.dp-cast-strip {
  width: 92px;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 4px;
  pointer-events: none;
}

.dp-cast-token {
  position: relative;
  height: 18px;
  overflow: hidden;
  border: 1px solid rgba(65, 39, 21, 0.24);
  border-radius: 4px;
  background:
    var(--story-print-fiber, repeating-linear-gradient(0deg, rgba(42, 24, 10, 0.025) 0, rgba(42, 24, 10, 0.025) 1px, transparent 1px, transparent 7px)),
    rgba(255, 247, 235, 0.72);
  opacity: 0.56;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.38);
  transform: translateY(0);
  transition: opacity 150ms ease, transform 150ms ease, border-color 150ms ease;
}

.dp-cast-token[data-active="true"] {
  opacity: 1;
  border-color: rgba(var(--story-zone-accent-rgb, 138, 125, 61), 0.56);
  background:
    linear-gradient(180deg, rgba(var(--story-zone-accent-rgb, 138, 125, 61), 0.24), rgba(255, 247, 235, 0.72)),
    var(--story-print-paper-light, #fff7eb);
  transform: translateY(-1px);
  box-shadow:
    0 5px 10px rgba(21, 11, 4, 0.16),
    inset 0 1px 0 rgba(255, 255, 255, 0.42);
}

.dp-cast-token::before {
  content: "";
  position: absolute;
  inset: 4px 5px 3px;
  background: rgba(48, 29, 15, 0.66);
  border-radius: 50% 50% 34% 34%;
}

.dp-cast-token[data-speaker="garden_gurl"]::before {
  border-radius: 3px 3px 42% 42%;
  clip-path: polygon(8% 28%, 92% 28%, 92% 45%, 62% 45%, 62% 100%, 38% 100%, 38% 45%, 8% 45%);
}

.dp-cast-token[data-speaker="onion_man"]::before {
  clip-path: polygon(50% 0, 80% 22%, 94% 58%, 66% 100%, 34% 100%, 6% 58%, 20% 22%);
}

.dp-cast-token[data-speaker="vegeman"]::before {
  border-radius: 28% 28% 18% 18%;
  transform: scaleX(1.16);
}

.dp-cast-token[data-speaker="critters"]::before {
  inset: 4px 4px 3px;
  background:
    radial-gradient(circle at 25% 52%, rgba(48, 29, 15, 0.68) 0 21%, transparent 22%),
    radial-gradient(circle at 50% 38%, rgba(48, 29, 15, 0.68) 0 24%, transparent 25%),
    radial-gradient(circle at 74% 55%, rgba(48, 29, 15, 0.68) 0 21%, transparent 22%);
  border-radius: 0;
}

.dp-cast-token__mark {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 9px;
  opacity: 0.48;
  transform: translateY(0.5px);
}

.dp-cast-token[data-active="true"] .dp-cast-token__mark {
  opacity: 0.72;
}

.dp-panel::before {
  right: 88px;
}

.dp-panel[data-side="right"]::before {
  right: auto;
  left: 18px;
}

@media (max-width: 480px) {
  .dp-panel::before {
    top: 10px;
    right: 74px;
  }

  .dp-panel[data-side="right"]::before {
    right: auto;
    left: 14px;
  }

  .dp-portrait-area {
    width: 64px;
    min-height: 84px;
    gap: 5px;
  }

  .dp-portrait {
    width: 60px;
    height: 60px;
    flex-basis: 60px;
  }

  .dp-cast-strip {
    width: 60px;
    gap: 3px;
  }

  .dp-cast-token {
    height: 13px;
    border-radius: 3px;
  }

  .dp-cast-token::before {
    inset: 3px 4px 2px;
  }

  .dp-cast-token__mark {
    font-size: 7px;
  }
}
