/* Herald quests: the homepage Dungeon Master (home.html #qp, quest.js). Uses the tokens from styles.css. */

.herald [hidden] { display: none !important; }

.herald-tabs { margin-left: auto; display: flex; gap: 4px; background: var(--paper); border: 1px solid var(--line); border-radius: 999px; padding: 3px; }
.herald-tab { font: inherit; font-size: 0.85rem; font-weight: 700; background: transparent; color: var(--ink-soft); border: 0; border-radius: 999px; padding: 5px 14px; cursor: pointer; }
.herald-tab[aria-selected="true"] { background: var(--rust); color: #fff; }
.chat-tools { display: flex; justify-content: flex-end; margin: -4px 0 8px; }

.qp-intro { max-width: none; margin: 0 0 12px; color: var(--ink-soft); font-size: 0.92rem; line-height: 1.5; }
.qp-pick { border: 0; margin: 0 0 14px; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 8px; }
.qp-pick legend { font-weight: 700; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--rust-dark); margin-bottom: 8px; padding: 0; }
.qp-card, .qp-chip { position: relative; cursor: pointer; }
.qp-card input[type="radio"], .qp-chip input[type="radio"] { position: absolute; opacity: 0; pointer-events: none; }
.qp-card > span { display: block; height: 100%; box-sizing: border-box; padding: 10px 12px; border: 2px solid var(--line); border-radius: 8px; background: var(--card); font-size: 0.85rem; color: var(--ink-soft); line-height: 1.4; }
.qp-card strong { display: block; color: var(--ink); font-size: 0.95rem; margin-bottom: 2px; }
.qp-card input:checked + span, .qp-chip input:checked + span { border-color: var(--rust-dark); background: linear-gradient(100deg, #2c2a26, #33261c); }
.qp-card input:focus-visible + span, .qp-chip input:focus-visible + span { outline: 2px solid #ffd76a; outline-offset: 2px; }
.qp-card-own input[type="text"] { display: block; width: 100%; box-sizing: border-box; margin-top: 6px; font: inherit; font-size: 0.85rem; padding: 6px 8px; border-radius: 5px; border: 1px solid var(--line); background: var(--paper); color: var(--ink); }
.qp-classes { grid-template-columns: repeat(4, auto) 1fr; align-items: center; }
.qp-chip > span { display: block; padding: 7px 14px; border: 2px solid var(--line); border-radius: 999px; background: var(--card); font-weight: 700; font-size: 0.9rem; white-space: nowrap; }
.qp-chip small { font-weight: 400; color: var(--ink-soft); }
.qp-name { display: flex; align-items: center; gap: 8px; font-size: 0.85rem; color: var(--ink-soft); }
.qp-name input { flex: 1; min-width: 0; font: inherit; font-size: 0.9rem; padding: 7px 10px; border-radius: 6px; border: 2px solid var(--line); background: var(--paper); color: var(--ink); }
.qp-begin { width: 100%; }


.qp-roll { display: inline-flex; align-items: center; gap: 4px; margin-top: 6px; font-size: 0.75rem; font-weight: 700; padding: 2px 9px; border-radius: 999px; border: 1px solid var(--line); background: var(--paper); }
.qp-die { font-size: 0.65rem; color: var(--ink-soft); }
.qp-roll-disaster { color: #ff7b6b; border-color: #8a3a30; }
.qp-roll-fail { color: #e0a08a; }
.qp-roll-mixed { color: #ffd76a; }
.qp-roll-success { color: #8fd69a; border-color: #3f6f47; }
.qp-roll-legendary { color: #1a1a18; background: #ffd76a; border-color: #ffd76a; }
.ak-user-msg .qp-roll { float: right; margin-left: 8px; margin-top: 2px; }
.qp-change { margin: 6px 0 0; font-size: 0.78rem; font-weight: 700; color: #ffd76a; }

.qp-opts { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.qp-opts:empty { display: none; }
.qp-opt { font: inherit; font-size: 0.82rem; background: var(--card); color: var(--ink); border: 1px solid var(--line); border-radius: 999px; padding: 5px 12px; cursor: pointer; }
.qp-opt:hover { border-color: var(--rust-dark); }
.qp-opt:disabled { opacity: 0.5; cursor: wait; }

.qp-end { text-align: center; padding: 16px 12px; margin-top: 4px; border: 2px solid #ffd76a; border-radius: 10px; background: linear-gradient(160deg, #2c2a26, #33261c); }
.qp-end-kicker { margin: 0; font-size: 0.75rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.1em; color: var(--rust-dark); }
.qp-end h3 { margin: 6px 0; font-size: 1.3rem; }
.qp-end p { max-width: none; margin: 0 0 12px; color: var(--ink-soft); font-size: 0.88rem; }
.qp-end-actions .herald-clear { margin-left: 0; }
.qp-end-actions { display: flex; justify-content: center; gap: 10px; flex-wrap: wrap; align-items: center; }

/* Saved quests */
.qp-label { margin: 0 0 8px; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--rust-dark); }
.qp-saves { margin-bottom: 16px; }
.qp-saves ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.qp-save { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--card); }
.qp-save-info { flex: 1; min-width: 0; display: flex; flex-direction: column; font-size: 0.8rem; color: var(--ink-soft); }
.qp-save-info strong { color: var(--ink); font-size: 0.95rem; }
.qp-save .herald-clear { margin-left: 0; }
.qp-save-go { padding: 6px 14px; }
.qp-class-note { margin: -6px 0 18px; font-size: 0.82rem; color: var(--ink-soft); max-width: none; }
.qp-lengths { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.qp-lengths .qp-chip > span { border-radius: 8px; white-space: normal; }
.qp-lengths small { display: block; }

/* Play: story column and HUD. A "holo-arcane" look: dark glass panels,
   cyan rune light, corner brackets, monospace readouts. */
.herald.qp-wide { max-width: 1120px; }
.qp-play {
  --holo: #5fe3ff; --holo-dim: rgba(95, 227, 255, 0.28); --holo-faint: rgba(95, 227, 255, 0.07);
  --arc: #b98cff; --gold: #ffd76a; --hud: #0d141e; --hud-2: #121c2a;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  position: relative; display: grid; grid-template-columns: minmax(0, 1fr) 310px; gap: 14px; align-items: start;
}
.qp-main { min-width: 0; }
.qp-topbar { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; margin-bottom: 8px; font-size: 0.82rem; color: var(--ink-soft); }
.qp-quest-title { font-weight: 700; color: var(--ink); font-size: 0.95rem; }
.qp-turn { font-family: var(--mono); font-size: 0.72rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--holo); }
.qp-turn::before { content: "\25C8  "; }
.qp-log.ak-log { max-height: max(340px, calc(100vh - 360px)); padding: 10px; border: 1px solid var(--holo-dim); border-radius: 6px; background: linear-gradient(180deg, var(--holo-faint), transparent 120px), var(--paper); }
.qp-system-msg { align-self: center; max-width: 100%; text-align: center; background: #3a2f12; border-color: var(--gold); color: var(--gold); font-weight: 700; font-size: 0.85rem; }
.qp-used { display: inline-block; margin-top: 6px; margin-right: 6px; font-family: var(--mono); font-size: 0.68rem; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase; color: var(--arc); }
.qp-armed { margin: 0 0 8px; padding: 6px 10px; border: 1px dashed var(--arc); border-radius: 6px; color: #d6caff; font-size: 0.82rem; max-width: none; box-shadow: 0 0 14px rgba(185, 140, 255, 0.18); }
.qp-foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.qp-foot .herald-clear { margin-left: 0; font-size: 0.75rem; }
.qp-roll { font-family: var(--mono); }

/* Scene painting */
.qp-scene { position: relative; margin: 0 0 8px; aspect-ratio: 16 / 6; overflow: hidden; border: 1px solid var(--holo-dim); border-radius: 6px; background: var(--hud); animation: qp-fade 0.8s ease; }
.qp-scene img { display: block; width: 100%; height: 100%; object-fit: cover; }
.qp-scene::after { content: ""; position: absolute; inset: 0; pointer-events: none; background: repeating-linear-gradient(0deg, rgba(0, 0, 0, 0.16) 0 1px, transparent 1px 3px), radial-gradient(ellipse at center, transparent 55%, rgba(5, 10, 18, 0.6)); }
.qp-scene figcaption { position: absolute; left: 0; right: 0; bottom: 0; z-index: 1; padding: 18px 12px 8px; background: linear-gradient(transparent, rgba(5, 10, 18, 0.9)); font-weight: 700; font-size: 0.9rem; color: var(--ink); }
.qp-scene-tag { font-family: var(--mono); font-size: 0.62rem; letter-spacing: 0.16em; text-transform: uppercase; color: var(--holo); margin-right: 6px; }

/* HUD panels */
.qp-hud { display: grid; gap: 8px; position: sticky; top: 76px; max-height: calc(100vh - 96px); overflow-y: auto; scrollbar-width: thin; }
.qp-panel { position: relative; border: 1px solid var(--holo-dim); border-radius: 4px; background: linear-gradient(180deg, var(--holo-faint), transparent 60px), var(--hud); padding: 9px 11px; font-size: 0.84rem; box-shadow: inset 0 0 22px rgba(95, 227, 255, 0.05); }
.qp-panel::before { content: ""; position: absolute; inset: -1px; pointer-events: none; border-radius: 4px;
  background: linear-gradient(var(--holo), var(--holo)) top left / 12px 2px no-repeat, linear-gradient(var(--holo), var(--holo)) top left / 2px 12px no-repeat,
    linear-gradient(var(--holo), var(--holo)) bottom right / 12px 2px no-repeat, linear-gradient(var(--holo), var(--holo)) bottom right / 2px 12px no-repeat; opacity: 0.75; }
.qp-panel > summary { cursor: pointer; font-family: var(--mono); font-weight: 700; font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.16em; color: var(--holo); list-style: none; }
.qp-panel > summary::-webkit-details-marker { display: none; }
.qp-panel > summary::before { content: "\25C6  "; color: var(--arc); }
.qp-panel > summary::after { content: "+"; float: right; color: var(--ink-soft); }
.qp-panel[open] > summary::after { content: "\2212"; }
.qp-panel[open] > summary { margin-bottom: 8px; }
.qp-count { margin-left: 6px; color: var(--ink-soft); letter-spacing: 0.05em; }
.qp-sub { margin: 10px 0 6px; font-family: var(--mono); font-size: 0.64rem; letter-spacing: 0.16em; text-transform: uppercase; color: var(--gold); max-width: none; }

/* Hero card */
.qp-herocard { background: radial-gradient(circle at 0 0, rgba(185, 140, 255, 0.16), transparent 60%), linear-gradient(180deg, var(--holo-faint), transparent), var(--hud-2); border-color: rgba(185, 140, 255, 0.45); }
.qp-hero-line { display: flex; gap: 10px; align-items: center; margin-bottom: 9px; }
.qp-portrait { flex: none; width: 46px; height: 52px; display: grid; place-items: center; font-size: 1.55rem; background: radial-gradient(circle, rgba(185, 140, 255, 0.5), rgba(13, 20, 30, 0.95) 70%); clip-path: polygon(50% 0, 100% 25%, 100% 75%, 50% 100%, 0 75%, 0 25%); }
.qp-hero-id { display: flex; flex-direction: column; min-width: 0; }
.qp-hero-id strong { font-size: 1rem; line-height: 1.2; }
.qp-hero-id span { font-family: var(--mono); font-size: 0.7rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--gold); }
.qp-meter { display: grid; grid-template-columns: 24px 1fr auto; gap: 7px; align-items: center; margin-bottom: 6px; font-family: var(--mono); font-size: 0.72rem; color: var(--ink-soft); }
.qp-meter-label { font-weight: 700; color: var(--holo); }
.qp-bar { height: 10px; border-radius: 2px; background: rgba(255, 255, 255, 0.04); border: 1px solid var(--holo-dim); overflow: hidden; }
.qp-bar span { display: block; height: 100%; transition: width 0.5s ease; }
.qp-bar-hp span { background: repeating-linear-gradient(90deg, #4fe08a 0 7px, #2b9a5c 7px 9px); box-shadow: 0 0 10px rgba(79, 224, 138, 0.55); }
.qp-bar-hp span.low { background: repeating-linear-gradient(90deg, #ff5d4f 0 7px, #a8322a 7px 9px); box-shadow: 0 0 10px rgba(255, 93, 79, 0.6); animation: qp-pulse 1.2s ease-in-out infinite; }
.qp-bar-xp span { background: linear-gradient(90deg, #7b5cff, var(--arc), #7b5cff); background-size: 200% 100%; box-shadow: 0 0 10px rgba(185, 140, 255, 0.55); animation: qp-shimmer 3s linear infinite; }
.qp-gold { font-family: var(--mono); font-size: 0.78rem; color: var(--gold); text-shadow: 0 0 8px rgba(255, 215, 106, 0.35); }

/* Abilities */
.qp-abilities, .qp-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 5px; }
ol.qp-list { counter-reset: done; }
ol.qp-list li { counter-increment: done; }
ol.qp-list li::before { content: counter(done, decimal-leading-zero) "  "; font-family: var(--mono); color: var(--holo); font-size: 0.7rem; }
.qp-ability { width: 100%; text-align: left; font: inherit; cursor: pointer; display: grid; grid-template-columns: 1fr auto; gap: 2px 8px; padding: 6px 8px; border-radius: 4px; border: 1px solid var(--holo-dim); background: rgba(255, 255, 255, 0.02); color: var(--ink); transition: border-color 0.15s, box-shadow 0.15s; }
.qp-ability:hover:not(:disabled) { border-color: var(--arc); box-shadow: 0 0 12px rgba(185, 140, 255, 0.25); }
.qp-ability.is-armed { border-color: var(--arc); background: rgba(123, 92, 255, 0.18); box-shadow: 0 0 0 1px var(--arc) inset, 0 0 16px rgba(185, 140, 255, 0.4); }
.qp-ability:disabled { opacity: 0.45; cursor: default; }
.qp-ability-name { font-weight: 700; font-size: 0.84rem; }
.qp-ability-desc { grid-column: 1 / -1; font-size: 0.74rem; color: var(--ink-soft); }
.qp-pips { display: inline-flex; gap: 3px; align-items: center; }
.qp-pips span { width: 8px; height: 8px; transform: rotate(45deg); border: 1px solid var(--arc); }
.qp-pips span.on { background: var(--arc); box-shadow: 0 0 6px var(--arc); }
.qp-rest { width: 100%; margin-top: 6px; font-family: var(--mono); font-size: 0.7rem; letter-spacing: 0.06em; text-transform: uppercase; padding: 6px 8px; border-radius: 4px; border: 1px dashed var(--holo-dim); background: transparent; color: var(--ink-soft); cursor: pointer; }
.qp-rest:hover:not(:disabled) { color: var(--holo); border-color: var(--holo); }
.qp-rest:disabled { cursor: default; opacity: 0.7; }

/* Inventory slots */
.qp-slots { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 5px; }
.qp-slot { box-sizing: border-box; width: 100%; aspect-ratio: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; padding: 3px; font: inherit; color: var(--ink); cursor: pointer; background: radial-gradient(circle at 50% 40%, rgba(95, 227, 255, 0.1), transparent 70%), rgba(255, 255, 255, 0.02); border: 1px solid var(--holo-dim); border-radius: 4px; overflow: hidden; transition: border-color 0.15s, box-shadow 0.15s, transform 0.15s; }
.qp-slot:hover { border-color: var(--holo); box-shadow: inset 0 0 12px rgba(95, 227, 255, 0.3); transform: translateY(-1px); }
.qp-slot.is-picked { border-color: var(--gold); box-shadow: 0 0 0 1px var(--gold) inset, 0 0 14px rgba(255, 215, 106, 0.4); }
.qp-slot-icon { font-size: 1.3rem; line-height: 1; }
.qp-slot-name { max-width: 100%; font-size: 0.56rem; line-height: 1.1; text-align: center; color: var(--ink-soft); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.qp-slot-empty { cursor: default; border-style: dashed; opacity: 0.3; background: transparent; }
.qp-slot-empty:hover { transform: none; box-shadow: none; border-color: var(--holo-dim); }
.qp-slots-near .qp-slot { border-style: dashed; border-color: rgba(255, 215, 106, 0.5); background: radial-gradient(circle at 50% 40%, rgba(255, 215, 106, 0.1), transparent 70%); }
.qp-slots-near .qp-empty { grid-column: 1 / -1; }
.qp-item-detail { margin-top: 9px; padding: 8px 9px; border: 1px solid rgba(255, 215, 106, 0.45); border-radius: 4px; background: rgba(255, 215, 106, 0.05); animation: qp-fade 0.2s ease; }
.qp-detail-head { display: flex; align-items: center; gap: 8px; }
.qp-detail-icon { font-size: 1.4rem; }
.qp-item-detail .qp-item-note { margin: 5px 0 0; max-width: none; }
.qp-item-note { font-size: 0.74rem; color: var(--ink-soft); }
.qp-detail-actions { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 8px; }
.qp-mini { font-family: var(--mono); font-size: 0.68rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; padding: 5px 9px; border-radius: 3px; border: 1px solid var(--holo-dim); background: rgba(95, 227, 255, 0.06); color: var(--holo); cursor: pointer; }
.qp-mini:hover:not(:disabled) { border-color: var(--holo); box-shadow: 0 0 10px rgba(95, 227, 255, 0.35); }
.qp-mini:disabled { opacity: 0.45; cursor: default; }

.qp-where { margin: 0; font-weight: 700; max-width: none; color: var(--ink); }
.qp-goal { margin: 4px 0 0; font-size: 0.8rem; max-width: none; }
.qp-list li { font-size: 0.8rem; color: var(--ink-soft); line-height: 1.4; }
.qp-list strong { color: var(--ink); }
.qp-empty { font-style: italic; color: var(--ink-soft); font-size: 0.8rem; }

/* Reaction pop-ups (GIF or sticker) */
.qp-pop { position: fixed; right: 18px; bottom: 18px; z-index: 60; max-width: 240px; padding: 8px; text-align: center; cursor: pointer; background: #0d141e; border: 1px solid #5fe3ff; border-radius: 8px; box-shadow: 0 0 28px rgba(95, 227, 255, 0.35), 0 10px 30px rgba(0, 0, 0, 0.5); opacity: 0; transform: translateY(24px) scale(0.92) rotate(-2deg); transition: opacity 0.25s ease, transform 0.25s ease; }
.qp-pop.is-on { opacity: 1; transform: none; }
.qp-pop img { display: block; max-width: 224px; width: auto; height: auto; max-height: 200px; margin: 0 auto; border-radius: 4px; }
.qp-pop-sticker { padding: 12px 14px; }
.qp-pop-emoji { display: block; font-size: 3.2rem; line-height: 1.1; animation: qp-bounce 0.7s ease; }
.qp-pop-cap { margin: 6px 0 0; max-width: none; font-size: 0.82rem; font-weight: 700; color: #ffd76a; }
.qp-pop-credit { display: block; margin-top: 4px; font-size: 0.6rem; letter-spacing: 0.06em; color: var(--ink-soft); }

@keyframes qp-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes qp-pulse { 50% { opacity: 0.6; } }
@keyframes qp-shimmer { to { background-position: -200% 0; } }
@keyframes qp-bounce { 0% { transform: scale(0.3); } 60% { transform: scale(1.2); } 100% { transform: scale(1); } }
@media (prefers-reduced-motion: reduce) {
  .qp-scene, .qp-item-detail, .qp-pop-emoji, .qp-bar span, .qp-bar-hp span.low, .qp-bar-xp span { animation: none; }
  .qp-pop, .qp-slot, .qp-bar span { transition: none; }
}

@media (max-width: 900px) {
  .qp-play { grid-template-columns: 1fr; }
  .qp-hud { position: static; max-height: none; order: -1; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
  .qp-herocard { grid-column: 1 / -1; }
  .qp-hud .qp-panel:not(.qp-herocard) { align-self: start; }
}

@media (max-width: 560px) {
  .qp-pop { right: 10px; bottom: 10px; max-width: 200px; }
  .qp-pop img { max-width: 184px; }
  .qp-scene { aspect-ratio: 16 / 8; }
  .qp-classes { grid-template-columns: repeat(2, 1fr); }
  .qp-name { grid-column: 1 / -1; }
  .herald-tab { padding: 5px 10px; }
}

/* Accounts and the Tavern switch */
.qp-account { margin-bottom: 14px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--card); font-size: 0.85rem; }
.qp-account-line { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 0; max-width: none; color: var(--ink-soft); }
.qp-account-line .herald-clear { margin-left: 0; }
.qp-account-line > span:first-child { flex: 1 1 260px; }
.qp-tavern-link { font-weight: 700; white-space: nowrap; }
.qp-auth { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 12px; margin-top: 10px; }
.qp-auth label { display: flex; flex-direction: column; gap: 4px; font-size: 0.8rem; color: var(--ink-soft); }
.qp-auth input { font: inherit; font-size: 0.9rem; padding: 7px 10px; border-radius: 6px; border: 2px solid var(--line); background: var(--paper); color: var(--ink); }
.qp-auth-actions { grid-column: 1 / -1; display: flex; gap: 10px; align-items: center; }
.qp-auth-actions .herald-clear { margin-left: 0; }
.qp-auth-note { grid-column: 1 / -1; margin: 0; font-size: 0.78rem; color: var(--ink-soft); max-width: none; }
.qp-auth-note.is-error { color: #ff7b6b; }
.qp-check { display: flex; gap: 8px; align-items: flex-start; margin: 0 0 14px; font-size: 0.85rem; color: var(--ink-soft); line-height: 1.45; }
.qp-check input { margin-top: 3px; accent-color: var(--rust); }
.qp-watch { text-decoration: none; }
@media (max-width: 560px) {
  .qp-auth { grid-template-columns: 1fr; }
  .qp-tavern-link { margin-left: 0; }
}

/* ---- Game screen v3: everything on one screen ------------------------------ */
.qp-scene img { position: absolute; inset: 0; }
.qp-scene-old { z-index: 0; }
#qp-scene-img { z-index: 0; }
#qp-scene-img.is-new { animation: qp-crossfade 1.2s ease; }
.qp-scene-busy { position: absolute; top: 8px; right: 10px; z-index: 2; font-family: var(--mono); font-size: 0.62rem; letter-spacing: 0.14em; text-transform: uppercase; color: var(--holo); background: rgba(5, 10, 18, 0.7); padding: 3px 8px; border-radius: 999px; animation: qp-pulse 1.2s ease-in-out infinite; }
@keyframes qp-crossfade { from { opacity: 0; transform: scale(1.04); filter: blur(4px); } to { opacity: 1; transform: none; filter: none; } }
.qp-styles { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.qp-styles .qp-chip > span { border-radius: 8px; white-space: normal; }
.qp-styles small { display: block; }

/* Quest tracker */
.qp-tracker { border-color: rgba(255, 215, 106, 0.45); background: linear-gradient(180deg, rgba(255, 215, 106, 0.07), transparent 70px), var(--hud); }
.qp-tracker::before { background: linear-gradient(var(--gold), var(--gold)) top left / 12px 2px no-repeat, linear-gradient(var(--gold), var(--gold)) top left / 2px 12px no-repeat, linear-gradient(var(--gold), var(--gold)) bottom right / 12px 2px no-repeat, linear-gradient(var(--gold), var(--gold)) bottom right / 2px 12px no-repeat; }
.qp-track-label { margin: 0 0 3px; font-family: var(--mono); font-size: 0.64rem; letter-spacing: 0.18em; text-transform: uppercase; color: var(--gold); max-width: none; }
.qp-track-label::before { content: "\25C6  "; }
.qp-track-goal { margin: 0; font-weight: 700; font-size: 0.92rem; line-height: 1.35; color: var(--ink); max-width: none; }
.qp-track-where { margin: 5px 0 0; font-size: 0.78rem; color: var(--holo); max-width: none; }
.qp-track-done { list-style: none; margin: 7px 0 0; padding: 0; display: grid; gap: 3px; }
.qp-track-done li { position: relative; padding-left: 18px; font-size: 0.76rem; line-height: 1.35; color: var(--ink-soft); }
.qp-track-done li::before { content: "\2714"; position: absolute; left: 0; color: #4fe08a; }
.qp-track-done li.qp-track-open::before { content: "?"; color: var(--arc); font-weight: 700; left: 3px; }

/* HUD tabs */
.qp-hud-tabs { display: grid; grid-template-columns: repeat(4, 1fr); gap: 3px; }
.qp-hud-tab { position: relative; font-family: var(--mono); font-size: 0.66rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; padding: 7px 2px; border: 1px solid var(--holo-dim); border-radius: 4px 4px 0 0; background: rgba(255, 255, 255, 0.02); color: var(--ink-soft); cursor: pointer; }
.qp-hud-tab[aria-selected="true"] { color: var(--holo); background: var(--hud); border-bottom-color: var(--hud); box-shadow: inset 0 2px 0 var(--holo); }
.qp-hud-tab.has-news::after { content: ""; position: absolute; top: 4px; right: 5px; width: 7px; height: 7px; border-radius: 50%; background: var(--gold); box-shadow: 0 0 8px var(--gold); animation: qp-pulse 1s ease-in-out infinite; }
.qp-hud-tab .qp-count { margin-left: 2px; letter-spacing: 0; }
.qp-hud-body { margin-top: -9px; padding: 10px; border: 1px solid var(--holo-dim); border-top: 0; border-radius: 0 0 4px 4px; background: var(--hud); }
.qp-pane > .qp-sub:first-child { margin-top: 0; }
.qp-given li { display: flex; align-items: baseline; gap: 6px; flex-wrap: wrap; }
.qp-given-icon { opacity: 0.6; filter: grayscale(0.6); }

/* Story text with game flavor */
.ak-herald-msg .qp-say { color: #9fe8ff; font-style: italic; }
.qp-hl-item { color: var(--gold); font-weight: 700; text-shadow: 0 0 8px rgba(255, 215, 106, 0.35); }
.qp-hl-npc { color: #c9b0ff; font-weight: 700; }
.qp-hl-hero { color: #8fe3b0; font-weight: 700; }
.qp-sfx { display: inline-block; margin: 0 2px; font-family: "Impact", "Haettenschweiler", "Arial Black", sans-serif; font-size: 1.12em; letter-spacing: 0.04em; color: #ffcf3f; -webkit-text-stroke: 0.6px #6b2a00; text-shadow: 2px 2px 0 #b1450e; transform: rotate(-4deg); animation: qp-sfx 0.6s ease; }
@keyframes qp-sfx { 0% { transform: scale(0.2) rotate(-12deg); } 60% { transform: scale(1.3) rotate(3deg); } 100% { transform: scale(1) rotate(-4deg); } }
.ak-herald-msg.is-fresh { animation: qp-rise 0.45s ease; }
.ak-herald-msg .ak-body > p:first-child::first-letter { font-size: 1.5em; font-weight: 800; color: var(--gold); }
.ak-herald-msg.is-typing .ak-body > p:last-child::after { content: "\258C"; margin-left: 2px; color: var(--holo); animation: qp-blink 0.8s steps(1) infinite; }
@keyframes qp-rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes qp-blink { 50% { opacity: 0; } }
.qp-roll.is-spinning { box-shadow: 0 0 12px rgba(95, 227, 255, 0.6); }
.qp-roll-n { display: inline-block; min-width: 1.2em; text-align: center; }

/* Screen effects */
.qp-main { position: relative; }
.qp-main.fx-shake { animation: qp-shake 0.5s ease; }
.qp-main.fx-shake-small { animation: qp-shake-small 0.35s ease; }
.qp-main::after { content: ""; position: absolute; inset: 0; pointer-events: none; border-radius: 8px; opacity: 0; }
.qp-main.fx-red::after { background: radial-gradient(ellipse at center, transparent 40%, rgba(255, 60, 40, 0.45)); animation: qp-flash 0.8s ease; }
.qp-main.fx-gold::after { background: radial-gradient(ellipse at center, rgba(255, 215, 106, 0.3), transparent 70%); animation: qp-flash 1s ease; }
@keyframes qp-shake { 0%, 100% { transform: none; } 15% { transform: translate(-6px, 2px) rotate(-0.5deg); } 30% { transform: translate(6px, -2px) rotate(0.5deg); } 45% { transform: translate(-4px, 1px); } 60% { transform: translate(4px, -1px); } 80% { transform: translate(-2px, 0); } }
@keyframes qp-shake-small { 0%, 100% { transform: none; } 25% { transform: translateX(-3px); } 50% { transform: translateX(3px); } 75% { transform: translateX(-2px); } }
@keyframes qp-flash { 0% { opacity: 0; } 20% { opacity: 1; } 100% { opacity: 0; } }
.qp-banner { position: absolute; left: 50%; top: 38%; z-index: 5; transform: translate(-50%, -50%); pointer-events: none; font-family: "Impact", "Arial Black", sans-serif; font-size: clamp(2rem, 5vw, 3.4rem); letter-spacing: 0.06em; white-space: nowrap; animation: qp-banner 1.6s ease forwards; }
.qp-banner.is-good { color: #ffd76a; -webkit-text-stroke: 1px #6b4a00; text-shadow: 0 0 24px rgba(255, 215, 106, 0.8), 3px 3px 0 #b1450e; }
.qp-banner.is-bad { color: #ff6b5b; -webkit-text-stroke: 1px #4a0a00; text-shadow: 0 0 24px rgba(255, 80, 60, 0.7), 3px 3px 0 #3a0a05; }
@keyframes qp-banner { 0% { opacity: 0; transform: translate(-50%, -50%) scale(0.3) rotate(-8deg); } 25% { opacity: 1; transform: translate(-50%, -50%) scale(1.15) rotate(2deg); } 70% { opacity: 1; transform: translate(-50%, -50%) scale(1); } 100% { opacity: 0; transform: translate(-50%, -70%) scale(1); } }
.qp-float { position: fixed; z-index: 70; transform: translate(-50%, -100%); pointer-events: none; font-family: var(--mono, ui-monospace, monospace); font-weight: 800; font-size: 0.95rem; white-space: nowrap; text-shadow: 0 2px 0 rgba(0, 0, 0, 0.8), 0 0 10px currentColor; animation: qp-float 1.4s ease-out forwards; }
.qp-float.is-hurt { color: #ff6b5b; }
.qp-float.is-heal { color: #4fe08a; }
.qp-float.is-xp { color: #c9b0ff; }
.qp-float.is-gold { color: #ffd76a; }
.qp-float.is-item { color: #ffd76a; }
.qp-float.is-gone { color: #b0a996; }
@keyframes qp-float { 0% { opacity: 0; transform: translate(-50%, -60%) scale(0.6); } 15% { opacity: 1; transform: translate(-50%, -110%) scale(1.15); } 100% { opacity: 0; transform: translate(-50%, -260%) scale(1); } }

/* While playing on a big screen: no page scrolling, the story scrolls inside */
@media (min-width: 901px) {
  body.qp-playing .hero { padding: 10px 14px; margin-bottom: 16px; }
  body.qp-playing .hero > .kicker, body.qp-playing .hero > h1, body.qp-playing .herald-elsewhere { display: none; }
  body.qp-playing .herald { margin-top: 0; }
  body.qp-playing .qp-play { height: var(--qp-h, calc(100vh - 168px)); min-height: 520px; }
  body.qp-playing .qp-main { display: flex; flex-direction: column; height: 100%; min-height: 0; }
  body.qp-playing .qp-scene { flex: none; height: clamp(120px, 25vh, 250px); aspect-ratio: auto; }
  body.qp-playing .qp-log.ak-log { flex: 1 1 auto; min-height: 120px; max-height: none; }
  body.qp-playing .qp-main > .qp-opts, body.qp-playing .qp-main > form, body.qp-playing .qp-main > .qp-foot { flex: none; }
  body.qp-playing .qp-foot { margin-top: 6px; }
  body.qp-playing .qp-hud { position: static; height: 100%; max-height: none; overflow-y: auto; align-content: start; }
}
@media (prefers-reduced-motion: reduce) {
  #qp-scene-img.is-new, .qp-sfx, .ak-herald-msg.is-fresh, .qp-hud-tab.has-news::after, .qp-scene-busy { animation: none; }
}

.qp-toolbar { justify-content: flex-start; margin: 0 0 8px; gap: 6px; }
.qp-toolbar .herald-clear { font-size: 0.7rem; padding: 3px 10px; }
body.qp-playing .qp-toolbar { flex: none; margin-top: 0; }

/* Party quests */
.qp-modes { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.qp-modes .qp-chip > span { border-radius: 8px; white-space: normal; height: 100%; box-sizing: border-box; }
.qp-modes small { display: block; }
.qp-join-chip input[type="text"] { display: block; width: 100%; box-sizing: border-box; margin-top: 4px; font: inherit; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.95rem; letter-spacing: 0.2em; text-transform: uppercase; padding: 4px 8px; border-radius: 5px; border: 1px solid var(--line); background: var(--paper); color: var(--ink); }
.qp-party-note { margin: -4px 0 14px; font-size: 0.85rem; color: #9fe8ff; max-width: none; }
.qp-party-note.is-error { color: #ff7b6b; }
.qp-party { list-style: none; margin: 9px 0 0; padding: 8px 0 0; border-top: 1px dashed var(--holo-dim); display: grid; gap: 5px; }
.qp-party-row { display: grid; grid-template-columns: 20px 1fr auto; grid-template-rows: auto 4px; gap: 1px 6px; align-items: center; font-size: 0.76rem; color: var(--ink-soft); padding: 2px 4px; border-radius: 4px; }
.qp-party-row.is-turn { background: rgba(255, 215, 106, 0.1); box-shadow: inset 2px 0 0 var(--gold); color: var(--ink); }
.qp-party-row.is-me .qp-party-name { color: #8fe3b0; }
.qp-party-icon { grid-row: 1 / 3; font-size: 0.95rem; }
.qp-party-name { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.qp-party-meta { font-family: var(--mono); font-size: 0.66rem; }
.qp-party-bar { grid-column: 2 / 4; height: 4px; border-radius: 2px; background: rgba(255, 255, 255, 0.06); overflow: hidden; }
.qp-party-bar span { display: block; height: 100%; background: #4fe08a; }
.qp-gate { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 6px 0 8px; padding: 7px 12px; border: 1px dashed var(--holo-dim); border-radius: 6px; font-family: var(--mono); font-size: 0.75rem; letter-spacing: 0.04em; color: var(--ink-soft); }
.qp-gate.is-mine { border-style: solid; border-color: var(--gold); color: var(--gold); box-shadow: 0 0 14px rgba(255, 215, 106, 0.2); animation: qp-pulse 2s ease-in-out infinite; }
.qp-gate .herald-clear { margin-left: auto; }
.qp-party-code { font-family: var(--mono); letter-spacing: 0.06em; color: var(--gold); border-color: rgba(255, 215, 106, 0.5); }
#qp-q:disabled { opacity: 0.6; cursor: not-allowed; }
body.qp-playing .qp-main > .qp-gate { flex: none; }
@media (max-width: 560px) { .qp-modes { grid-template-columns: 1fr; } }
@media (prefers-reduced-motion: reduce) { .qp-gate.is-mine { animation: none; } }
