/* Components: buttons, chips, cards, forms, bars, rings, modals, toasts. */
@keyframes stock { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }

/* ---------- cards / buttons ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.1rem 1.2rem; }

.card.tight { padding: 0.8rem 0.9rem; }

.card.accent { border-color: color-mix(in srgb, var(--ch) 40%, transparent); background: linear-gradient(135deg, color-mix(in srgb, var(--ch) 12%, var(--surface)), var(--surface)); }

.grid { display: grid; gap: 1rem; }

.grid.two { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }

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

.grid.four { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.45rem; padding: 0.62rem 1.05rem; border-radius: 12px; border: 1px solid var(--line-strong);
  background: var(--surface-2); color: var(--text); font-weight: 700; font-size: 0.95rem; transition: transform 0.08s, background 0.15s, border-color 0.15s; text-decoration: none; white-space: nowrap;
}

.btn:hover { background: var(--surface-3); }

.btn:active { transform: translateY(1px) scale(0.99); }

.btn:disabled { opacity: 0.45; cursor: not-allowed; }

.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; }

.btn.primary:hover { filter: brightness(1.06); background: var(--accent); }

.btn.ch { background: var(--ch); color: #0B0F1A; border-color: transparent; }

.btn.ghost { background: transparent; }

.btn.danger { background: transparent; border-color: color-mix(in srgb, var(--bad) 60%, transparent); color: var(--bad); }

.btn.big { padding: 0.9rem 1.4rem; font-size: 1.05rem; border-radius: 14px; }

.btn.sm { padding: 0.4rem 0.7rem; font-size: 0.82rem; border-radius: 9px; }

.btn.block { width: 100%; }

.icon-btn { background: transparent; border: 1px solid var(--line); border-radius: 9px; width: 34px; height: 34px; display: grid; place-items: center; color: var(--muted); }

.icon-btn:hover { color: var(--text); background: var(--surface-2); }

.chip { display: inline-flex; align-items: center; gap: 0.35rem; padding: 0.2rem 0.6rem; border-radius: 999px; font-size: 0.75rem; font-weight: 700; background: var(--surface-2); border: 1px solid var(--line); color: var(--muted); white-space: nowrap; }

.chip.ch { background: color-mix(in srgb, var(--ch) 18%, transparent); border-color: color-mix(in srgb, var(--ch) 45%, transparent); color: var(--text); }

.chip.good { background: color-mix(in srgb, var(--good) 18%, transparent); border-color: color-mix(in srgb, var(--good) 45%, transparent); color: var(--text); }

.chip.bad { background: color-mix(in srgb, var(--bad) 18%, transparent); border-color: color-mix(in srgb, var(--bad) 45%, transparent); color: var(--text); }

.chip.warn { background: color-mix(in srgb, var(--warn) 18%, transparent); border-color: color-mix(in srgb, var(--warn) 45%, transparent); color: var(--text); }

.chip.dot::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }

.badge { font-family: var(--font-mono); font-size: 0.68rem; padding: 0.1rem 0.45rem; border-radius: 999px; background: var(--accent); color: var(--accent-ink); font-weight: 700; }

.badge.quiet { background: var(--surface-3); color: var(--muted); }

.kbd { font-family: var(--font-mono); font-size: 0.7rem; border: 1px solid var(--line-strong); border-bottom-width: 2px; border-radius: 5px; padding: 0 0.35rem; color: var(--muted); }

/* ---------- bars & rings ---------- */
.bar { background: var(--ring-track); border-radius: 999px; overflow: hidden; width: 100%; }

.bar-fill { height: 100%; border-radius: 999px; transition: width 0.4s cubic-bezier(.2,.8,.2,1); }

.bar-row { display: grid; grid-template-columns: 110px 1fr; align-items: center; gap: 0.6rem; }

.bar-label { font-size: 0.8rem; color: var(--muted); }

.ring-wrap { position: relative; display: inline-grid; place-items: center; }

.ring-wrap svg { position: absolute; inset: 0; }

.ring-label { position: relative; font-family: var(--font-display); font-weight: 800; font-size: 0.85rem; }

.ring circle { transition: stroke-dashoffset 0.6s cubic-bezier(.2,.8,.2,1); }

@keyframes pulse { 0%, 100% { transform: scale(1); opacity: 1; } 50% { transform: scale(1.35); opacity: 0.7; } }

/* tooltip */
.tip { position: fixed; z-index: 90; background: var(--surface-3); border: 1px solid var(--line-strong); border-radius: 10px; padding: 0.5rem 0.7rem; font-size: 0.8rem; max-width: 260px; pointer-events: none; box-shadow: var(--shadow); }

.tip b { display: block; font-family: var(--font-display); }

/* ---------- mode tiles ---------- */
.mode-tile {
  display: flex; flex-direction: column; gap: 0.5rem; text-align: left; padding: 1.1rem 1.1rem 1rem; border-radius: var(--radius); border: 1px solid var(--line); background: var(--surface);
  position: relative; overflow: hidden; transition: transform 0.15s, border-color 0.15s, box-shadow 0.15s; color: var(--text); text-decoration: none; min-height: 150px;
}

.mode-tile:hover { transform: translateY(-3px); border-color: color-mix(in srgb, var(--ch) 50%, var(--line)); box-shadow: var(--shadow); }

.mode-tile::before { content: ''; position: absolute; inset: 0 auto 0 0; width: 5px; background: var(--ch); }

.mode-tile .ico { font-size: 1.6rem; }

.mode-tile h3 { font-size: 1.1rem; }

.mode-tile p { color: var(--muted); font-size: 0.88rem; margin: 0; }

.mode-tile .meta { margin-top: auto; display: flex; gap: 0.4rem; flex-wrap: wrap; }

.stat { display: flex; flex-direction: column; gap: 0.1rem; }

.stat .v { font-family: var(--font-display); font-size: 1.5rem; font-weight: 800; line-height: 1; }

.stat .k { font-size: 0.75rem; color: var(--muted); }

.stats { display: flex; gap: 1.6rem; flex-wrap: wrap; }

@keyframes shake { 0%, 100% { transform: translateX(0); } 25% { transform: translateX(-5px); } 75% { transform: translateX(5px); } }

@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

@keyframes floatUp { from { opacity: 1; transform: translate(-50%, 0); } to { opacity: 0; transform: translate(-50%, -60px); } }

/* ---------- lists / tables ---------- */
.list { display: grid; gap: 0.5rem; }

.li { display: flex; align-items: center; gap: 0.8rem; padding: 0.7rem 0.9rem; border-radius: 12px; background: var(--surface); border: 1px solid var(--line); }

.li .t { font-weight: 700; }

.li .s { font-size: 0.82rem; color: var(--muted); }

/* ---------- forms ---------- */
.field { display: grid; gap: 0.3rem; }

.field label { font-size: 0.8rem; color: var(--muted); font-weight: 600; }

input[type="text"], input[type="number"], input[type="datetime-local"], select, textarea { background: var(--bg-2); border: 1px solid var(--line-strong); border-radius: 10px; padding: 0.55rem 0.7rem; color: var(--text); width: 100%; }

.seg { display: inline-flex; border: 1px solid var(--line-strong); border-radius: 12px; overflow: hidden; }

.seg button { padding: 0.5rem 0.9rem; background: transparent; border: 0; color: var(--muted); font-weight: 700; border-right: 1px solid var(--line); }

.seg button:last-child { border-right: 0; }

.seg button.on { background: var(--surface-3); color: var(--text); }

.chapter-picker { display: flex; flex-wrap: wrap; gap: 0.4rem; }

.chapter-picker button { padding: 0.4rem 0.7rem; border-radius: 999px; border: 1px solid var(--line-strong); background: transparent; color: var(--muted); font-weight: 700; font-size: 0.85rem; }

.chapter-picker button.on { background: color-mix(in srgb, var(--ch) 22%, transparent); border-color: var(--ch); color: var(--text); }

.toggle { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 0.6rem 0; border-top: 1px solid var(--line); }

.toggle:first-child { border-top: 0; }

.switch { width: 44px; height: 26px; border-radius: 999px; background: var(--surface-3); border: 1px solid var(--line-strong); position: relative; flex-shrink: 0; }

.switch::after { content: ''; position: absolute; top: 2px; left: 2px; width: 20px; height: 20px; border-radius: 50%; background: var(--muted); transition: transform 0.15s, background 0.15s; }

.switch.on { background: color-mix(in srgb, var(--accent) 40%, var(--surface-3)); border-color: var(--accent); }

.switch.on::after { transform: translateX(18px); background: var(--accent); }

/* ---------- modal / toasts ---------- */
.modal-overlay { position: fixed; inset: 0; background: rgba(5, 8, 16, 0.6); backdrop-filter: blur(4px); display: grid; place-items: center; z-index: 80; opacity: 0; transition: opacity 0.2s; padding: 1rem; }

.modal-overlay.show { opacity: 1; }

.modal { background: var(--surface); border: 1px solid var(--line-strong); border-radius: 18px; width: min(560px, 100%); max-height: 90vh; display: flex; flex-direction: column; box-shadow: var(--shadow); transform: translateY(8px); transition: transform 0.2s; }

.modal-overlay.show .modal { transform: none; }

.modal-wide { width: min(860px, 100%); }

.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 1rem 1.1rem 0.6rem; }

.modal-body { padding: 0.4rem 1.1rem 1rem; overflow: auto; }

.modal-actions { display: flex; justify-content: flex-end; gap: 0.6rem; padding: 0.8rem 1.1rem; border-top: 1px solid var(--line); flex-wrap: wrap; }

.toasts { position: fixed; top: 1rem; left: 50%; transform: translateX(-50%); z-index: 99; display: grid; gap: 0.5rem; pointer-events: none; width: min(420px, 92vw); }

.toast { background: var(--surface-3); color: var(--text); border: 1px solid var(--line-strong); border-radius: 12px; padding: 0.65rem 0.9rem; font-weight: 600; font-size: 0.9rem; opacity: 0; transform: translateY(-8px); transition: opacity 0.25s, transform 0.25s; box-shadow: var(--shadow); text-align: center; }

.toast.show { opacity: 1; transform: none; }

.toast-good { border-color: var(--good); }

.toast-bad { border-color: var(--bad); }

.toast-xp { border-color: var(--accent); color: var(--accent); font-family: var(--font-mono); }

.confetti { position: fixed; inset: 0; z-index: 98; pointer-events: none; }

.card { border-color: var(--line); background: color-mix(in srgb, var(--surface) 88%, transparent); backdrop-filter: blur(6px); box-shadow: 0 1px 0 rgba(255,255,255,0.03) inset, 0 10px 30px rgba(0,0,0,0.12); }

@keyframes viewIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

.btn.primary { background: linear-gradient(135deg, color-mix(in srgb, var(--accent) 90%, white), var(--accent)); box-shadow: 0 6px 18px color-mix(in srgb, var(--accent) 35%, transparent); }

.btn.primary:hover { transform: translateY(-1px); box-shadow: 0 10px 24px color-mix(in srgb, var(--accent) 45%, transparent); }

.btn.ch { box-shadow: 0 6px 18px color-mix(in srgb, var(--ch) 35%, transparent); }

.btn.ch:hover { transform: translateY(-1px); filter: brightness(1.05); }

.ldot { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--line-strong); background: transparent; padding: 0; transition: transform 0.15s, background 0.15s; }

.ldot.done { background: var(--ch); border-color: var(--ch); opacity: 0.6; }

.ldot.on { background: var(--ch); border-color: var(--ch); transform: scale(1.3); box-shadow: 0 0 0 4px color-mix(in srgb, var(--ch) 25%, transparent); }

.glyph { font-size: 2.4rem; width: 64px; height: 64px; display: grid; place-items: center; border-radius: 18px; background: color-mix(in srgb, var(--ch) 20%, var(--bg-2)); border: 1px solid color-mix(in srgb, var(--ch) 40%, transparent); flex-shrink: 0; animation: popIn 0.4s cubic-bezier(.2,.8,.2,1) both; }

.lines { display: grid; gap: 0.7rem; max-width: 64ch; }

.line { margin: 0; font-size: 1.12rem; line-height: 1.7; animation: fadeUp 0.45s cubic-bezier(.2,.8,.2,1) both; animation-delay: calc(var(--i) * 140ms); padding-left: 1rem; border-left: 3px solid color-mix(in srgb, var(--ch) 45%, transparent); }

@keyframes fadeUp { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

@keyframes popIn { from { opacity: 0; transform: scale(0.6); } to { opacity: 1; transform: none; } }

.callout { display: flex; gap: 0.8rem; padding: 0.9rem 1rem; border-radius: 16px; margin-top: 1.1rem; background: var(--bg-2); border: 1px solid var(--line); font-size: 1rem; line-height: 1.6; animation: fadeUp 0.45s cubic-bezier(.2,.8,.2,1) both; animation-delay: calc(var(--i, 3) * 140ms); }

.callout.example { border-color: color-mix(in srgb, var(--ch) 40%, var(--line)); }

.callout.hint { background: color-mix(in srgb, var(--accent) 10%, var(--bg-2)); font-style: italic; }

.callout-ico { font-size: 1.3rem; flex-shrink: 0; }

.versus { display: grid; grid-template-columns: 1fr auto 1fr; gap: 1rem; align-items: stretch; }

.vs-side { padding: 1rem 1.1rem; border-radius: 16px; background: color-mix(in srgb, var(--info) 10%, var(--bg-2)); border: 1px solid color-mix(in srgb, var(--info) 35%, transparent); font-size: 1.02rem; line-height: 1.65; animation: fadeUp 0.45s both; }

.vs-side.trap { background: color-mix(in srgb, var(--warn) 12%, var(--bg-2)); border-color: color-mix(in srgb, var(--warn) 40%, transparent); animation-delay: 0.15s; }

.vs-side p { margin: 0.3rem 0 0; }

.vs-badge { align-self: center; font-family: var(--font-display); font-weight: 800; font-size: 1.1rem; width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-3); border: 1px solid var(--line-strong); }

@media (max-width: 640px) { .versus { grid-template-columns: 1fr; } .vs-badge { justify-self: center; } .slide { padding: 1.2rem 1.1rem 1.4rem; } }

@keyframes draw { to { stroke-dashoffset: 0; } }

input[type=range] { accent-color: var(--accent); width: 100%; max-width: 320px; }

.line { font-size: 1.2rem; }

/* ---------- buttons: stone slabs, crimson banners ---------- */
.btn {
  font-family: var(--font-display); font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; font-size: 0.78rem;
  background: linear-gradient(180deg, #4A4038, #332B24); color: var(--text); border: 1px solid rgba(0,0,0,0.6);
  box-shadow: inset 0 1px 0 rgba(234,219,192,0.14), inset 0 -2px 0 rgba(0,0,0,0.45), 0 4px 10px rgba(0,0,0,0.35);
  border-radius: 6px; padding: 0.7rem 1.1rem;
}

.btn:hover { background: linear-gradient(180deg, #574B41, #3A312A); transform: translateY(-1px); }

.btn:active { transform: translateY(1px); box-shadow: inset 0 2px 4px rgba(0,0,0,0.5); }

.btn.primary, .btn.ch {
  background: linear-gradient(180deg, var(--crimson-2), var(--crimson) 55%, #5E1313); color: #F6E7C8; border-color: #3a0c0c;
  box-shadow: inset 0 1px 0 rgba(255,220,180,0.25), inset 0 0 0 1px rgba(201,162,39,0.35), 0 6px 16px rgba(139,30,30,0.45);
  text-shadow: 0 1px 0 rgba(0,0,0,0.5);
}

.btn.primary:hover, .btn.ch:hover { background: linear-gradient(180deg, #C43A33, #96221F 55%, #641414); filter: none; }

.btn.ghost { background: transparent; box-shadow: none; border-color: var(--line-strong); }

.btn.danger { border-color: var(--bad); color: var(--bad); background: transparent; box-shadow: none; }

.btn.big { font-size: 0.92rem; padding: 0.95rem 1.5rem; }

.btn.sm { font-size: 0.68rem; padding: 0.45rem 0.75rem; }

.btn:disabled { opacity: 0.45; }

.icon-btn { background: linear-gradient(180deg, #4A4038, #332B24); border-color: rgba(0,0,0,0.6); }

:root[data-theme="light"] .btn { background: linear-gradient(180deg, #F3E6C8, #DCC89C); color: var(--text); border-color: rgba(59,42,23,0.45); box-shadow: inset 0 1px 0 rgba(255,255,255,0.6), inset 0 -2px 0 rgba(59,42,23,0.2), 0 4px 10px rgba(59,42,23,0.2); }

:root[data-theme="light"] .btn:hover { background: linear-gradient(180deg, #FAF0D8, #E6D4AA); }

:root[data-theme="light"] .btn.primary, :root[data-theme="light"] .btn.ch { background: linear-gradient(180deg, var(--crimson-2), var(--crimson) 55%, #5E1313); color: #F6E7C8; }

/* ---------- chips as bronze plaques, badges as wax seals ---------- */
.chip { font-family: var(--font-display); letter-spacing: 0.06em; font-size: 0.66rem; text-transform: uppercase; background: linear-gradient(180deg, #4A3C2C, #3A2E21); border: 1px solid rgba(0,0,0,0.6); color: var(--text); box-shadow: inset 0 1px 0 rgba(234,219,192,0.12); border-radius: 4px; }

.chip.ch { background: linear-gradient(180deg, color-mix(in srgb, var(--ch) 45%, #3A2E21), color-mix(in srgb, var(--ch) 25%, #2A241D)); border-color: color-mix(in srgb, var(--ch) 50%, black); }

.chip.good { background: linear-gradient(180deg, #4F6A3F, #3A4F2E); }

.chip.bad { background: linear-gradient(180deg, #7A2A22, #5A1E18); }

.chip.warn { background: linear-gradient(180deg, #7A5A1E, #5A4216); }

.badge { background: radial-gradient(circle at 35% 35%, #C94A3A, #8B1E1E 70%); color: #F6E7C8; border-radius: 50%; min-width: 1.5em; text-align: center; box-shadow: 0 1px 3px rgba(0,0,0,0.6); font-size: 0.6rem; letter-spacing: 0.05em; }

.badge.quiet { background: var(--surface-3); color: var(--muted); border-radius: 4px; }

.kbd { border-color: var(--iron); }

.bar { background: rgba(0,0,0,0.45); box-shadow: inset 0 1px 2px rgba(0,0,0,0.6); }

.glyph { background: radial-gradient(circle at 40% 35%, #4A3C2C, #2A241D 70%); border: 1px solid rgba(0,0,0,0.6); box-shadow: inset 0 1px 0 rgba(234,219,192,0.1); border-radius: 50%; }

.line { border-left: 3px solid var(--gold); }

.callout { background: rgba(14,11,8,0.5); border: 1px solid rgba(0,0,0,0.6); border-radius: 6px; }

.callout.example { border-left: 4px solid var(--gold); }

.callout.hint { background: rgba(201,162,39,0.12); }

.vs-side { background: rgba(127,163,184,0.1); border: 1px solid rgba(0,0,0,0.6); border-left: 4px solid var(--info); border-radius: 6px; }

.vs-side.trap { background: rgba(217,164,65,0.12); border-left-color: var(--warn); }

.vs-badge { background: radial-gradient(circle at 40% 35%, #6b6b70, #3a3a3e 70%); border: 1px solid #111; color: #EADBC0; font-family: var(--font-display); }

.ldot { border-color: var(--iron); }

.ldot.on, .ldot.done { background: var(--gold); border-color: var(--gold); }

/* ---------- misc ---------- */
.seg { border-color: rgba(0,0,0,0.6); background: rgba(0,0,0,0.3); border-radius: 6px; }

.seg button { font-family: var(--font-display); text-transform: uppercase; letter-spacing: 0.06em; font-size: 0.68rem; }

.seg button.on { background: linear-gradient(180deg, #8B1E1E, #5E1313); color: #F6E7C8; }

.chapter-picker button { font-family: var(--font-display); text-transform: uppercase; letter-spacing: 0.05em; font-size: 0.66rem; border-radius: 4px; }

.chapter-picker button.on { background: linear-gradient(180deg, color-mix(in srgb, var(--ch) 50%, #2A241D), color-mix(in srgb, var(--ch) 25%, #2A241D)); border-color: var(--gold); }

input[type="text"], input[type="number"], input[type="datetime-local"], select { background: rgba(0,0,0,0.4); border: 1px solid rgba(0,0,0,0.7); border-radius: 4px; color: var(--text); box-shadow: inset 0 2px 4px rgba(0,0,0,0.5); font-family: var(--font-body); font-size: 1rem; }

.toast { background: var(--stone-grad); border: 1px solid var(--gold); color: var(--text); font-family: var(--font-display); letter-spacing: 0.04em; font-size: 0.8rem; border-radius: 6px; }

.toast-good { border-color: var(--good); }

.toast-bad { border-color: var(--bad); }

.toast-xp { border-color: var(--gold); color: var(--gold-2); }

.modal-overlay { background: rgba(8, 6, 4, 0.75); }

:root[data-theme="light"] .chip { background: linear-gradient(180deg, #F3E6C8, #DCC89C); color: var(--text); border-color: rgba(59,42,23,0.45); box-shadow: inset 0 1px 0 rgba(255,255,255,0.5); }

:root[data-theme="light"] .chip.ch { background: linear-gradient(180deg, color-mix(in srgb, var(--ch) 40%, #F3E6C8), color-mix(in srgb, var(--ch) 22%, #DCC89C)); }

.chip.good, .chip.bad, .chip.warn { color: #F6E7C8; }

:root[data-theme="light"] .vs-side { background: rgba(2,132,199,0.08); border-color: rgba(59,42,23,0.3); }

:root[data-theme="light"] .vs-side.trap { background: rgba(217,164,65,0.18); }

:root[data-theme="light"] .toast { background: linear-gradient(180deg, #F6EAD0, #E6D4AA); color: var(--text); }

/* ---------- organic buttons: ribbon banners and chipped stone ---------- */
.btn { position: relative; isolation: isolate; background: transparent !important; border: 0 !important; box-shadow: none !important; filter: drop-shadow(0 5px 7px rgba(0, 0, 0, 0.5)); padding-left: 1.25rem; padding-right: 1.25rem; }

.btn::before { content: ''; position: absolute; inset: 0; z-index: -1;
  background: linear-gradient(180deg, #5A4D42, #3A312A 55%, #2A231D); box-shadow: inset 0 1px 0 rgba(234, 219, 192, 0.14), inset 0 -2px 0 rgba(0, 0, 0, 0.45);
  clip-path: polygon(2% 0, 97% 0, 100% 14%, 99% 55%, 100% 86%, 96% 100%, 3% 100%, 0 88%, 1% 48%, 0 12%); transition: filter 0.15s; }

.btn:hover::before { filter: brightness(1.15); }

.btn:active { transform: translateY(2px); filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.5)); }

.btn.primary, .btn.ch { padding-left: 1.6rem; padding-right: 1.6rem; }

.btn.primary::before, .btn.ch::before { background: linear-gradient(180deg, #C43A33, #8B1E1E 55%, #5E1313); box-shadow: inset 0 1px 0 rgba(255, 220, 180, 0.25), inset 0 -2px 0 rgba(0, 0, 0, 0.45);
  clip-path: polygon(0 0, 100% 0, calc(100% - 11px) 50%, 100% 100%, 0 100%, 11px 50%); }

.btn.primary::after, .btn.ch::after { content: ''; position: absolute; left: 14px; right: 14px; top: 3px; bottom: 3px; z-index: -1; border-top: 1px solid rgba(201, 162, 39, 0.55); border-bottom: 1px solid rgba(201, 162, 39, 0.55); pointer-events: none; }

.btn.ch::before { background: linear-gradient(180deg, color-mix(in srgb, var(--ch) 85%, white), color-mix(in srgb, var(--ch) 75%, #2A1C0E) 55%, color-mix(in srgb, var(--ch) 50%, #1A1206)); }

.btn.ghost::before { background: rgba(0, 0, 0, 0.25); box-shadow: inset 0 0 0 1px var(--line-strong); }

.btn.danger::before { background: rgba(139, 30, 30, 0.2); box-shadow: inset 0 0 0 1px var(--bad); }

.btn.sm { padding-left: 0.9rem; padding-right: 0.9rem; }

.btn:disabled { filter: none; }

:root[data-theme="light"] .btn::before { background: linear-gradient(180deg, #F6EAD0, #DCC89C 60%, #CDB47C); box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.6), inset 0 -2px 0 rgba(59, 42, 23, 0.2); }

:root[data-theme="light"] .btn.primary::before, :root[data-theme="light"] .btn.ch::before { background: linear-gradient(180deg, #C43A33, #8B1E1E 55%, #5E1313); }

.icon-btn { border-radius: 50%; }

/* ---------- chips as bronze plaques, badges as wax seals ---------- */
.chip { border-radius: 2px; clip-path: polygon(7px 0, calc(100% - 7px) 0, 100% 50%, calc(100% - 7px) 100%, 7px 100%, 0 50%); padding-left: 0.85rem; padding-right: 0.85rem; border: 0; }

.chip.dot::before { display: none; }

.badge { border-radius: 50%; }

.toast { border: 0; clip-path: polygon(0 10%, 2% 0, 98% 4%, 100% 14%, 99% 90%, 97% 100%, 3% 96%, 0 86%); background: linear-gradient(90deg, #CDB47C, #EADBB5 10%, #F0E1BC 50%, #EADBB5 90%, #CDB47C); color: #2E2114; box-shadow: none; padding: 0.75rem 1.4rem; }

.toast-good { color: #2F4A22; }

.toast-bad { color: #8B1E1E; }

.toast-xp { color: #7A5A12; }

.toasts { filter: drop-shadow(0 8px 14px rgba(0, 0, 0, 0.5)); }

.modal { border: 0; border-radius: 8px; border-top: 12px solid #5C3A1E; border-bottom: 12px solid #5C3A1E; background: linear-gradient(90deg, #CDB47C 0%, #E6D3A8 5%, #F0E1BC 50%, #E6D3A8 95%, #CDB47C 100%); color: #2E2114;
  --text: #2E2114; --muted: #6E5A3E; --line: rgba(59,42,23,0.2); --line-strong: rgba(59,42,23,0.4); --surface-2: #E8D8B2; --bg-2: #EADBB5; }

.modal::after { display: none; }

.modal h3 { color: #3B2A17; }

.modal .modal-actions { border-top-color: rgba(59, 42, 23, 0.25); }

.modal input[type="text"] { background: rgba(255, 250, 235, 0.7); border-color: rgba(59, 42, 23, 0.4); color: #2E2114; box-shadow: none; }

.modal .btn:not(.primary):not(.danger)::before { background: linear-gradient(180deg, #F6EAD0, #DCC89C 60%, #CDB47C); }

.modal .btn { color: #2E2114; }

.modal .btn.primary { color: #F6E7C8; }

.modal .btn.danger { color: #8B1E1E; }

.stat .v { text-shadow: 0 2px 6px rgba(0, 0, 0, 0.5); }

/* ---------- Imperium icon set (app/icons.js) ---------- */
.ico { display: inline-grid; place-items: center; width: var(--ico-size, 20px); height: var(--ico-size, 20px); vertical-align: -0.2em; line-height: 0; flex-shrink: 0; }
.ico svg { width: 100%; height: 100%; display: block; overflow: visible; filter: drop-shadow(0 1px 0 rgba(0, 0, 0, 0.45)); }
.ico .ico-f { fill: var(--ico-fill, var(--bronze-light)); stroke: var(--ico-stroke, var(--bronze-dark)); stroke-width: 1.2; }
.ico .ico-s { stroke: var(--ico-stroke, var(--bronze-dark)); fill: none; }
.ico .ico-hl { stroke: var(--ico-hl, rgba(255, 240, 200, 0.55)); fill: none; }
.ico.tone-gold { --ico-fill: var(--gold-leaf); --ico-stroke: var(--gold-leaf-dark); --ico-hl: rgba(255, 250, 220, 0.7); }
.ico.tone-ink { --ico-fill: var(--vellum-ink); --ico-stroke: var(--vellum-ink); --ico-hl: rgba(255, 245, 225, 0.4); }
.ico.tone-parchment { --ico-fill: var(--vellum); --ico-stroke: var(--bronze-dark); --ico-hl: rgba(255, 255, 255, 0.7); }
.ico.tone-crimson { --ico-fill: var(--pompeian-light); --ico-stroke: var(--pompeian-dark); --ico-hl: rgba(255, 220, 200, 0.5); }
.ico.tone-laurel { --ico-fill: var(--laurel); --ico-stroke: var(--laurel-dark); --ico-hl: rgba(230, 255, 220, 0.5); }
.ico.tone-iron { --ico-fill: var(--iron-light); --ico-stroke: var(--iron-dark); --ico-hl: rgba(255, 255, 255, 0.45); }
.ico.tone-mono { --ico-fill: currentColor; --ico-stroke: currentColor; --ico-hl: transparent; }
.ico.tone-mono .ico-f { fill-opacity: 0.25; }

/* ===================================================================
   PHASE 1 — icons everywhere, parchment and stone panels, master
   volume, toasts off the answers, the XP coin flight.
   =================================================================== */
.ico.flip { transform: rotate(180deg); }
.ico.up { transform: rotate(-90deg); }
.ico.down { transform: rotate(90deg); }
.nav-link > .ico, .bottom-nav a > .ico { width: 24px; height: 24px; font-size: 0; text-align: center; }
.mode-tile > .ico, .world > .ico, .quest-ico, .callout-ico { font-size: 0; display: grid; place-items: center; }
.mode-tile > .ico { width: 48px; height: 48px; }
.callout-ico { width: 28px; height: 28px; flex-shrink: 0; }
h1.row, h2.row, h3.row { gap: 0.55rem; }
.btn > .ico { margin-right: 0.1rem; }
.back { display: inline-flex; align-items: center; gap: 0.3rem; }

/* ---------- panels ---------- */
.panel { position: relative; padding: 1.2rem 1.35rem; color: var(--text); isolation: isolate; }
.panel.parchment { color: var(--vellum-ink); filter: drop-shadow(0 10px 18px rgba(0, 0, 0, 0.45)); }
.panel.parchment::before { content: ''; position: absolute; inset: 0; z-index: -1; background: var(--parch-grain), linear-gradient(180deg, #F2E4C2, #E6D3A8 60%, #DAC391); clip-path: polygon(0 1.5%, 1.2% 0, 30% 0.6%, 55% 0, 80% 0.8%, 99% 0, 100% 2%, 99.4% 40%, 100% 70%, 99.2% 98%, 98% 100%, 70% 99.2%, 40% 100%, 12% 99.3%, 0.5% 100%, 0 97%, 0.6% 60%, 0 30%); }
.panel.parchment .muted, .panel.parchment .small.muted { color: var(--vellum-ink-soft); }
.panel.parchment .eyebrow { color: var(--pompeian); }
.panel.stone { background: linear-gradient(180deg, #3A322A, #2A241D 60%, #1C1612); border: 1px solid rgba(0, 0, 0, 0.6); box-shadow: var(--bevel-stone); border-radius: var(--radius-stone); }
.panel.stone::before { content: ''; position: absolute; inset: 0; z-index: -1; border-radius: inherit; background: var(--grain); opacity: 0.6; pointer-events: none; }

/* ---------- chips and small HUD bits ---------- */
.chip { gap: 0.3rem; }
.chip.pips { gap: 3px; }
.chip.pips .pip { width: 8px; height: 8px; border-radius: 50%; background: rgba(255, 255, 255, 0.14); border: 1px solid rgba(0, 0, 0, 0.45); }
.chip.pips .pip.on { background: var(--gold-leaf); }
.chip.reason { margin-left: auto; background: rgba(139, 30, 30, 0.35); border-color: rgba(201, 162, 39, 0.5); color: #F6E7C8; }
.hearts { display: inline-flex; gap: 3px; align-items: center; filter: none; font-size: 0; }
.combo { display: inline-flex; align-items: center; gap: 0.3rem; }
.timer { display: inline-flex; align-items: center; gap: 0.3rem; }

/* ---------- master volume in the top bar ---------- */
.vol { display: inline-flex; align-items: center; gap: 0.4rem; }
.vol-btn { width: 34px; height: 34px; border-radius: 50%; border: 1px solid #1a1410; background: radial-gradient(circle at 38% 32%, #D9B45A, #8E6B1C 60%, #3E2D0C 100%); box-shadow: var(--bevel-bronze); display: grid; place-items: center; cursor: pointer; padding: 0; transition: transform var(--dur-fast) var(--ease-spring); }
.vol-btn:hover:not(:disabled) { transform: scale(1.08); }
.vol-btn.muted { background: radial-gradient(circle at 38% 32%, #8A8A8E, #4A4A4E 55%, #202022 100%); }
.vol-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.vol-btn:focus-visible { outline: 2px solid var(--gold-leaf); outline-offset: 2px; }
.vol-range { -webkit-appearance: none; appearance: none; width: 86px; height: 6px; border-radius: 3px; background: linear-gradient(180deg, #1C1612, #2A241D); border: 1px solid rgba(0, 0, 0, 0.6); box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.6); cursor: pointer; margin: 0; }
.vol-range::-webkit-slider-thumb { -webkit-appearance: none; width: 16px; height: 16px; border-radius: 50%; background: radial-gradient(circle at 38% 32%, #E3C76A, #C9A227 55%, #6B4B12); border: 1px solid #3E2D0C; box-shadow: 0 2px 4px rgba(0, 0, 0, 0.5); }
.vol-range::-moz-range-thumb { width: 16px; height: 16px; border-radius: 50%; background: #C9A227; border: 1px solid #3E2D0C; }
.vol-range:focus-visible { outline: 2px solid var(--gold-leaf); outline-offset: 2px; }
.vol-range:disabled { opacity: 0.4; }
.vol.off .vol-range { display: none; }
@media (max-width: 640px) { .vol-range { display: none; } .topbar .chip { font-size: 0.68rem; } }

/* ---------- toasts: top right, never over the answers ---------- */
.toasts { top: 0.8rem; bottom: auto; left: auto; right: 0.9rem; transform: none; width: min(340px, 86vw); justify-items: end; }
@media (max-width: 900px) { .toasts { right: 0.6rem; top: 0.6rem; width: min(300px, 80vw); } }
.toast { text-align: left; font-size: 0.78rem; }

/* ---------- +XP coin flight to the XP bar ---------- */
.xp-coin { position: fixed; z-index: 130; pointer-events: none; display: flex; align-items: center; gap: 0.4rem; transform: translate(-50%, -50%); font-family: var(--font-display); font-weight: 700; color: var(--gold-leaf-light); text-shadow: 0 2px 6px rgba(0, 0, 0, 0.7); font-size: 0.95rem; opacity: 0; }
.xp-coin-disc { width: 22px; height: 22px; border-radius: 50%; background: radial-gradient(circle at 38% 32%, #F0D98A, #C9A227 55%, #6B4B12); border: 1px solid #3E2D0C; box-shadow: 0 2px 4px rgba(0, 0, 0, 0.6), inset 0 1px 0 rgba(255, 255, 255, 0.5); }
.xp-coin.lift { animation: coinLift 0.42s var(--ease-spring) forwards; }
@keyframes coinLift { 0% { opacity: 0; transform: translate(-50%, -50%) scale(0.4); } 100% { opacity: 1; transform: translate(-50%, calc(-50% - 26px)) scale(1); } }
.xp-coin.fly { animation: coinFly 0.62s cubic-bezier(0.5, 0, 0.2, 1) forwards; }
@keyframes coinFly { 0% { opacity: 1; transform: translate(-50%, calc(-50% - 26px)) scale(1); } 100% { opacity: 0; transform: translate(calc(-50% + var(--dx, 0px)), calc(-50% + var(--dy, 0px))) scale(0.5); } }
.xp-coin.static { animation: coinStatic 0.9s ease-out forwards; }
@keyframes coinStatic { 0% { opacity: 0; transform: translate(-50%, -50%); } 20% { opacity: 1; } 100% { opacity: 0; transform: translate(-50%, calc(-50% - 40px)); } }
.xpbar.shimmer { animation: xpShimmer 0.7s ease-out; }
@keyframes xpShimmer { 0% { box-shadow: 0 0 0 0 rgba(201, 162, 39, 0); } 30% { box-shadow: 0 0 0 4px rgba(201, 162, 39, 0.55), 0 0 22px rgba(201, 162, 39, 0.6); } 100% { box-shadow: 0 0 0 0 rgba(201, 162, 39, 0); } }
