.shelf-story-layer,
.shelf-cinema {
  --shelf-top: max(10px, env(safe-area-inset-top));
  --shelf-right: max(14px, env(safe-area-inset-right));
  --shelf-bottom: max(12px, env(safe-area-inset-bottom));
  --shelf-left: max(14px, env(safe-area-inset-left));
  position: fixed;
  inset: 0;
  z-index: 60;
  font-family: var(--f-ui);
}

.shelf-ui-button {
  appearance: none;
  min-height: 44px;
  padding: 6px 13px;
  border: 2px solid var(--ink);
  border-radius: 5px;
  background: var(--paper);
  box-shadow: 2px 3px var(--ink);
  color: var(--ink);
  font: 800 17px/1.1 var(--f-ui);
  cursor: pointer;
}

.shelf-ui-primary { background: var(--sun); }
.shelf-ui-button:active { transform: translate(1px, 2px); box-shadow: 1px 1px var(--ink); }
.shelf-ui-button:focus-visible { outline: 3px solid var(--mint); outline-offset: 2px; }
.shelf-ui-kicker {
  font: 800 12px/1.2 system-ui, sans-serif;
  letter-spacing: .075em;
  text-transform: uppercase;
}

.shelf-story-layer {
  display: grid;
  grid-template-rows: minmax(0, 1fr);
  place-items: center;
  padding: var(--shelf-top) var(--shelf-right) var(--shelf-bottom) var(--shelf-left);
  background: #120d27cf;
}

.shelf-story-card {
  display: flex;
  flex-direction: column;
  width: min(700px, 100%);
  max-height: 100%;
  min-height: 0;
  overflow: hidden;
  border: 3px solid var(--ink);
  border-radius: 10px 5px 11px 6px;
  background: var(--paper);
  box-shadow: 4px 5px 0 var(--sun), 7px 8px 0 var(--ink);
  color: var(--ink);
}

.shelf-story-head {
  position: relative;
  flex: none;
  padding: clamp(10px, 2vw, 18px) 90px clamp(10px, 2vw, 16px) clamp(12px, 3vw, 22px);
  border-bottom: 3px solid var(--ink);
  background: radial-gradient(#4a2a541f 1px, transparent 1.4px) 0 0 / 6px 6px, #ffe394;
}

.shelf-story-head h2 {
  margin-block: 4px;
  font: 900 clamp(20px, 4.5vw, 34px)/1.08 var(--f-display);
  letter-spacing: -.03em;
  overflow-wrap: anywhere;
}

.shelf-story-head h2:focus { outline: none; }
.shelf-story-description { margin-top: 6px; font: 700 clamp(14px, 2.5vw, 18px)/1.22 var(--f-ui); }
.shelf-story-dismiss { position: absolute; top: 10px; right: 10px; }

.shelf-story-list {
  display: grid;
  gap: 7px;
  min-height: 0;
  margin: 0;
  padding: 10px clamp(10px, 2.5vw, 17px) 13px;
  overflow: auto;
  overscroll-behavior: contain;
  touch-action: pan-y;
  list-style: none;
}

.shelf-story-entry {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  padding: 7px 9px;
  border: 2px solid var(--ink);
  border-radius: 6px;
  background: #fffaf0;
}

.shelf-story-entry-inactive { background: #f0e5d5; }
.shelf-story-copy { flex: 1 1 140px; min-width: 0; overflow-wrap: anywhere; }
.shelf-story-copy h3 { font: 900 clamp(16px, 3vw, 20px)/1.12 var(--f-ui); }
.shelf-story-copy p { margin-top: 3px; color: #4c405e; font: 700 14px/1.2 var(--f-ui); }
.shelf-story-badge {
  padding: 3px 5px;
  border-radius: 3px;
  background: #e7dcf2;
  color: #4b306a;
  text-align: center;
  font: 800 12px/1.15 var(--f-ui);
}

.shelf-story-footer {
  display: flex;
  flex: none;
  flex-wrap: wrap;
  gap: 7px;
  max-height: 45vh;
  overflow: auto;
  touch-action: pan-y;
  padding: 9px 12px 12px;
  border-top: 2px solid var(--ink);
}

.shelf-story-actions { display: flex; flex-wrap: wrap; gap: 7px; }
.shelf-story-actions > button { flex: 1 1 130px; }

.shelf-act {
  display: grid;
  gap: 4px;
  padding: 9px 11px;
  border: 2px solid var(--ink);
  border-inline-start: 6px solid var(--shelf-act-color, var(--mint));
  border-radius: 5px;
  background: #2a1d4c;
  color: var(--paper);
}
.shelf-act-eyebrow { color: #ffdd66; font: 700 12px/1.15 system-ui, sans-serif; letter-spacing: .05em; text-transform: uppercase; }
.shelf-act-title { font: 900 clamp(16px, 3vw, 24px)/1.12 var(--f-display); }
.shelf-act-detail { font: 700 15px/1.18 var(--f-ui); }

.shelf-cinema-active #app { visibility: hidden; }
.shelf-cinema {
  z-index: 61;
  --scene-accent: var(--sun);
  background: linear-gradient(180deg, #100b21f8 0%, #130d27c9 8%, transparent 26%, transparent 65%, #110b25eb 95%);
  color: var(--paper);
  touch-action: manipulation;
}

.shelf-cinema-header {
  position: absolute;
  top: var(--shelf-top);
  left: var(--shelf-left);
  display: flex;
  gap: 7px;
  align-items: center;
  max-width: min(540px, calc(100% - var(--shelf-left) - var(--shelf-right) - 86px));
  padding: 6px 12px 8px;
  border: 2px solid #fff3dcdd;
  border-left: 5px solid var(--scene-accent);
  border-radius: 3px 5px 5px 3px;
  background: #1a1238f2;
  box-shadow: 3px 3px #0d0923;
  overflow-wrap: anywhere;
}

.shelf-cinema-emblem { flex: none; width: clamp(22px, 3vw, 32px); color: var(--scene-accent); }
.shelf-cinema-emblem > svg { display: block; width: 100%; }
.shelf-cinema-header .shelf-ui-kicker { color: #ffdf76; font-size: clamp(10px, 2.2vw, 12px); }
.shelf-cinema-header h2 {
  margin-block: 3px 0;
  font: 900 clamp(17px, 3.5vw, 34px)/1.08 var(--f-display);
  letter-spacing: -.028em;
}
.shelf-cinema-detail { margin-top: 3px; font: 700 clamp(13px, 2vw, 16px)/1.1 var(--f-ui); }

.shelf-cinema-skip {
  position: absolute;
  top: var(--shelf-top);
  right: var(--shelf-right);
  min-width: 65px;
}

.shelf-cinema-captions {
  position: absolute;
  left: 50%;
  bottom: calc(var(--shelf-bottom) + 7px);
  transform: translateX(-50%);
  display: flex;
  align-items: end;
  width: min(720px, calc(100% - var(--shelf-right) - var(--shelf-left)));
  gap: clamp(6px, 1.2vw, 12px);
}

.shelf-cinema-portrait {
  flex: none;
  width: clamp(46px, 10vw, 78px);
  height: clamp(56px, 15vh, 98px);
  display: grid;
  place-items: end center;
}
.shelf-cinema-portrait .pcard {
  width: 100%;
  height: 100%;
  border-width: 2px;
  border-radius: 7px;
  box-shadow: 3px 3px var(--ink);
  transform: rotate(-3deg);
  animation: shelf-portrait-enter .22s ease-out both;
}
.shelf-cinema-portrait > svg { width: 100%; max-height: 100%; }
@keyframes shelf-portrait-enter {
  from { transform: translateY(5px) rotate(-4deg); opacity: .5; }
  to { transform: rotate(-3deg); opacity: 1; }
}

.shelf-cinema-copy {
  flex: 1;
  max-height: 35vh;
  overflow: auto;
  padding: 7px clamp(9px, 2vw, 15px) 9px;
  border: 2px solid #fff3dcdd;
  border-left: 5px solid var(--scene-accent);
  border-radius: 4px 7px 4px 5px;
  background: #16112aee;
  box-shadow: 3px 3px #090617;
}
.shelf-cinema-speaker { margin-bottom: 3px; color: #ffe084; font: 800 clamp(13px, 2.2vw, 16px)/1.02 var(--f-ui); }
.shelf-cinema-line { font: 700 clamp(16px, 3.1vw, 23px)/1.2 var(--f-ui); }
.shelf-cinema-secondary { margin-top: 3px; color: #e0d4ef; font: 600 clamp(13px, 2.2vw, 16px)/1.15 var(--f-ui); }

.shelf-cinema-progress {
  position: absolute;
  bottom: max(3px, env(safe-area-inset-bottom));
  left: var(--shelf-left);
  right: var(--shelf-right);
  height: 3px;
  background: #fff3dc44;
}
.shelf-cinema-progress i { display: block; height: 100%; transform-origin: left; background: var(--scene-accent); }
.shelf-cinema-countdown {
  position: absolute;
  top: 46%;
  left: 50%;
  transform: translate(-50%, -50%) rotate(-5deg);
  min-width: 1.5em;
  padding: .04em .14em .10em;
  border: 3px solid var(--ink);
  border-radius: 6px;
  background: var(--sun);
  box-shadow: 4px 5px var(--ink);
  color: var(--ink);
  text-align: center;
  font: 900 clamp(40px, 19vh, 98px)/1.02 var(--f-display);
}
.shelf-cinema-flash { position: absolute; inset: 0; background: var(--paper); opacity: 0; pointer-events: none; }

@media (max-width: 380px) {
  .shelf-story-entry { gap: 5px; padding-inline: 6px; }
  .shelf-story-entry .shelf-ui-button { padding-inline: 8px; font-size: 15px; }
  .shelf-story-badge { font-size: 11px; }
  .shelf-cinema-header { padding-inline: 7px; }
}

@media (max-height: 400px) {
  .shelf-cinema-header { padding-block: 4px 6px; }
  .shelf-cinema-header h2 { font-size: clamp(17px, 4.8vh, 25px); }
  .shelf-cinema-line { font-size: clamp(15px, 5.6vh, 19px); }
  .shelf-cinema-captions { width: min(610px, calc(100% - var(--shelf-left) - var(--shelf-right))); }
  .shelf-cinema-copy { padding-block: 5px 6px; }
  .shelf-story-head { padding-block: 8px; }
  .shelf-story-list { padding-block: 6px 9px; }
}

@media (prefers-reduced-motion: reduce) {
  .shelf-cinema-portrait .pcard { animation: none; }
}
