/* Spirit Pet Dojo — UI styles. One deliberate look: lacquered ink plates, rice-paper text,
   dojo vermilion for actions and a jade spirit glow for progress. */
:root {
  --ink: #17201d;
  --ink-2: #22302b;
  --plate: rgba(20, 28, 25, 0.78);
  --plate-edge: rgba(243, 236, 220, 0.14);
  --paper: #f3ecdc;
  --paper-dim: #c9c1ad;
  --vermilion: #d9472b;
  --vermilion-hi: #f0603f;
  --jade: #5fe0c0;
  --gold: #e8b54a;
  --hp: #e0573f;
  --mp: #4fa6e8;
  --wither: #9a6fc4;
  --font-display: 'Lilita One', 'Trebuchet MS', system-ui, sans-serif;
  --font-body: 'Baloo 2', 'Segoe UI', system-ui, sans-serif;
  color-scheme: dark;
}

html, body { height: 100%; margin: 0; overflow: hidden; background: #9bbfc4; color: var(--paper); font-family: var(--font-body); }
* { box-sizing: border-box; }
button, input { font: inherit; color: inherit; }
.hidden { display: none !important; }
kbd {
  display: inline-block; min-width: 1.6em; padding: 0 0.4em; border-radius: 5px;
  background: rgba(243, 236, 220, 0.12); border: 1px solid rgba(243, 236, 220, 0.28);
  border-bottom-width: 3px; font: 600 0.78rem/1.5 var(--font-body); text-align: center; color: var(--paper);
}

#game { position: fixed; inset: 0; width: 100vw; height: 100vh; display: block; outline: none; }
#damage-layer { position: fixed; inset: 0; pointer-events: none; z-index: 5; overflow: hidden; }

/* ---------- screens ---------- */
.screen { position: fixed; inset: 0; display: none; z-index: 10; }
#place .panel { max-height: calc(100vh - 40px); overflow-y: auto; }
.screen.show { display: flex; }
.screen.dim { background: rgba(10, 16, 14, 0.5); backdrop-filter: blur(3px); align-items: center; justify-content: center; }

.panel {
  background: var(--plate); border: 1px solid var(--plate-edge); border-radius: 18px;
  padding: 26px 28px; box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35); backdrop-filter: blur(8px);
}
.small-panel { width: min(400px, calc(100vw - 32px)); }
h2 { font: 400 2rem/1.1 var(--font-display); margin: 0 0 18px; letter-spacing: 0.01em; text-wrap: balance; }
h3 { font: 600 0.78rem/1 var(--font-body); text-transform: uppercase; letter-spacing: 0.12em; color: var(--paper-dim); margin: 0 0 8px; }
.eyebrow { font: 600 0.8rem/1 var(--font-body); text-transform: uppercase; letter-spacing: 0.28em; color: var(--jade); margin: 0 0 10px; }

.menu { display: flex; flex-direction: column; gap: 10px; }
.menu button, .row button {
  appearance: none; border: 1px solid rgba(243, 236, 220, 0.22); background: rgba(243, 236, 220, 0.06);
  padding: 11px 20px; border-radius: 12px; font: 600 1.08rem/1.2 var(--font-body); cursor: pointer;
  text-align: left; transition: transform 0.12s, background 0.12s, border-color 0.12s;
}
.menu button:hover, .row button:hover { background: rgba(243, 236, 220, 0.14); border-color: rgba(243, 236, 220, 0.4); transform: translateX(3px); }
.menu button:focus-visible, .row button:focus-visible, .seg button:focus-visible, .swatch:focus-visible, .chip:focus-visible, input:focus-visible {
  outline: 2px solid var(--jade); outline-offset: 2px;
}
button.primary { background: var(--vermilion); border-color: var(--vermilion-hi); color: #fff8ef; box-shadow: 0 4px 0 #8e2a17; }
button.primary:hover { background: var(--vermilion-hi); }
button.muted { opacity: 0.55; }

/* ---------- loading ---------- */
#loading { align-items: center; justify-content: center; background: radial-gradient(circle at 50% 40%, #2b3b35, #111816); }
.load-box { text-align: center; width: min(360px, 80vw); }
.load-mark { display: flex; gap: 8px; justify-content: center; margin-bottom: 18px; }
.load-mark i { width: 18px; height: 18px; border-radius: 5px; background: var(--jade); animation: hop 0.9s ease-in-out infinite; }
.load-mark i:nth-child(2) { animation-delay: 0.15s; background: var(--gold); }
.load-mark i:nth-child(3) { animation-delay: 0.3s; background: var(--vermilion); }
@keyframes hop { 0%, 100% { transform: translateY(0) rotate(0); } 50% { transform: translateY(-12px) rotate(90deg); } }
.load-bar { height: 6px; border-radius: 3px; background: rgba(255, 255, 255, 0.1); overflow: hidden; }
.load-bar i { display: block; height: 100%; width: 0; background: var(--jade); transition: width 0.2s; }
#load-text { font-weight: 600; margin: 0 0 12px; }
#load-error { color: #ffb4a3; margin-top: 14px; line-height: 1.4; }

/* ---------- title ---------- */
#title { align-items: center; padding-left: max(16px, 7vw); background: linear-gradient(90deg, rgba(12, 20, 17, 0.72) 0%, rgba(12, 20, 17, 0.35) 38%, rgba(12, 20, 17, 0) 62%); }
.title-wrap { width: min(380px, calc(100vw - 32px)); }
.logo { margin: 0 0 28px; line-height: 0.85; font-family: var(--font-display); font-weight: 400; text-shadow: 0 4px 0 rgba(0, 0, 0, 0.25), 0 10px 40px rgba(0, 0, 0, 0.35); }
.logo .small { display: block; font-size: clamp(2rem, 4.5vw, 3rem); color: var(--paper); letter-spacing: 0.02em; }
.logo .big { display: block; font-size: clamp(4.5rem, 11vw, 7.5rem); color: var(--gold); -webkit-text-stroke: 2px #6b3d12; letter-spacing: 0.01em; }
.build-tag { margin: 22px 0 0; font-size: 0.85rem; color: var(--paper-dim); }
.note { position: fixed; left: 50%; bottom: 32px; transform: translateX(-50%); background: var(--plate); border: 1px solid var(--plate-edge); padding: 10px 18px; border-radius: 12px; opacity: 0; transition: opacity 0.25s; pointer-events: none; max-width: calc(100vw - 32px); text-align: center; }
.note.show { opacity: 1; }

/* ---------- creator ---------- */
#creator { align-items: center; padding-left: max(16px, 4vw); pointer-events: none; }
.creator-panel { pointer-events: auto; width: min(380px, calc(100vw - 32px)); max-height: calc(100vh - 40px); overflow-y: auto; }
.field-label { display: block; font: 600 0.78rem/1 var(--font-body); text-transform: uppercase; letter-spacing: 0.12em; color: var(--paper-dim); margin-bottom: 8px; }
#cr-name { width: 100%; padding: 9px 12px; border-radius: 10px; border: 1px solid rgba(243, 236, 220, 0.25); background: rgba(0, 0, 0, 0.25); font-size: 1.1rem; font-weight: 600; margin-bottom: 16px; }
.opt { margin-bottom: 14px; }
.swatches, .chips { display: flex; flex-wrap: wrap; gap: 7px; }
.swatch { width: 30px; height: 30px; border-radius: 8px; border: 2px solid rgba(255, 255, 255, 0.25); cursor: pointer; padding: 0; transition: transform 0.1s; }
.swatch:hover { transform: scale(1.1); }
.swatch[aria-checked='true'] { border-color: #fff; box-shadow: 0 0 0 2px var(--vermilion); transform: scale(1.08); }
.chip { padding: 5px 12px; border-radius: 999px; border: 1px solid rgba(243, 236, 220, 0.25); background: rgba(243, 236, 220, 0.06); cursor: pointer; font-weight: 600; font-size: 0.92rem; }
.chip[aria-checked='true'] { background: var(--paper); color: var(--ink); border-color: var(--paper); }
.row { display: flex; gap: 10px; margin-top: 18px; }
.row button { flex: 1; text-align: center; }
.creator-hint { position: fixed; right: 24px; bottom: 20px; margin: 0; font-weight: 600; color: var(--paper); text-shadow: 0 1px 3px rgba(0, 0, 0, 0.6); }

/* ---------- bonding ceremony ---------- */
#ceremony { align-items: center; padding-left: max(16px, 4vw); pointer-events: none; }
.ceremony-panel { pointer-events: auto; width: min(460px, calc(100vw - 32px)); max-height: calc(100vh - 40px); overflow-y: auto; }
.starter-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 14px; }
.starter {
  --el: var(--jade); position: relative; appearance: none; text-align: left; cursor: pointer;
  border: 1px solid rgba(243, 236, 220, 0.18); border-radius: 12px; background: rgba(243, 236, 220, 0.05);
  padding: 9px 10px 8px 14px; display: flex; flex-direction: column; gap: 2px; overflow: hidden;
  transition: transform 0.12s, background 0.12s, border-color 0.12s;
}
.starter::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 5px; background: var(--el); }
.starter:hover { background: rgba(243, 236, 220, 0.12); transform: translateY(-2px); }
.starter:focus-visible { outline: 2px solid var(--jade); outline-offset: 2px; }
.starter[aria-checked='true'] { border-color: var(--el); background: rgba(243, 236, 220, 0.14); box-shadow: 0 0 0 1px var(--el), 0 6px 20px rgba(0, 0, 0, 0.25); }
.starter b { font: 400 1.02rem/1.1 var(--font-display); letter-spacing: 0.01em; }
.starter .el { font-size: 0.74rem; font-weight: 700; color: var(--el); text-transform: uppercase; letter-spacing: 0.08em; }
.starter.locked { opacity: 0.6; }
.starter.locked .soon { font-size: 0.68rem; color: var(--paper-dim); font-weight: 600; }
.starter-detail { min-height: 196px; }
.starter-detail .lede { margin: 0 0 10px; line-height: 1.35; color: var(--paper); }
.starter-detail dl { display: grid; grid-template-columns: auto 1fr; gap: 5px 12px; margin: 0 0 10px; align-items: center; font-size: 0.92rem; }
.starter-detail dt { color: var(--paper-dim); font-weight: 600; }
.starter-detail dd { margin: 0; }
.pips { display: inline-flex; gap: 3px; vertical-align: middle; }
.pips i { width: 14px; height: 8px; border-radius: 2px; background: rgba(243, 236, 220, 0.15); }
.pips i.on { background: var(--el, var(--jade)); }
.moves { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; font-size: 0.9rem; line-height: 1.3; }
.moves li b { color: var(--paper); }
.moves li span { color: var(--paper-dim); }
.soon-note { font-size: 0.9rem; color: var(--paper-dim); line-height: 1.4; margin: 0; }
@media (max-width: 520px) { .starter-grid { grid-template-columns: repeat(2, 1fr); } }

/* ---------- settings ---------- */
.setting { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 16px; flex-wrap: wrap; }
.setting label, .setting .label { font-weight: 600; }
.seg { display: inline-flex; background: rgba(0, 0, 0, 0.25); border-radius: 10px; padding: 3px; gap: 2px; }
.seg button { border: 0; background: transparent; padding: 6px 12px; border-radius: 8px; cursor: pointer; font-weight: 600; font-size: 0.9rem; }
.seg button[aria-checked='true'] { background: var(--paper); color: var(--ink); }
input[type='range'] { width: 160px; accent-color: var(--jade); }
.toggle { appearance: none; width: 44px; height: 24px; border-radius: 12px; background: rgba(255, 255, 255, 0.18); position: relative; cursor: pointer; transition: background 0.15s; }
.toggle::after { content: ''; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: transform 0.15s; }
.toggle:checked { background: var(--jade); }
.toggle:checked::after { transform: translateX(20px); }

/* ---------- HUD ---------- */
#hud { position: fixed; inset: 0; pointer-events: none; z-index: 6; }
.plate { background: var(--plate); border: 1px solid var(--plate-edge); border-radius: 14px; backdrop-filter: blur(6px); }

.status { position: absolute; top: 16px; left: max(16px, env(safe-area-inset-left, 0px)); display: flex; gap: 12px; padding: 10px 14px 10px 10px; align-items: center; }
.portrait { width: 54px; height: 54px; border-radius: 12px; background: linear-gradient(160deg, var(--gold), var(--vermilion)); display: grid; place-items: center; font: 400 1.7rem var(--font-display); color: #fff8ef; box-shadow: inset 0 -4px 0 rgba(0, 0, 0, 0.2); }
.bars { display: flex; flex-direction: column; gap: 4px; width: 200px; }
.name-row { display: flex; justify-content: space-between; align-items: baseline; }
.name-row b { font: 400 1.1rem var(--font-display); letter-spacing: 0.02em; }
.belt { font-size: 0.72rem; font-weight: 600; padding: 0 7px; border-radius: 4px; background: #f4f1ea; color: var(--ink); }
.bar { position: relative; height: 12px; border-radius: 4px; background: rgba(0, 0, 0, 0.4); overflow: hidden; }
.bar i { position: absolute; inset: 0 auto 0 0; width: 100%; transition: width 0.15s; }
.bar.hp i { background: linear-gradient(180deg, #f07c5f, var(--hp)); }
.bar.mp i { background: linear-gradient(180deg, #7cc2f2, var(--mp)); }
.bar.wither { height: 7px; }
.bar.wither i { background: var(--wither); }
.bar span { position: absolute; left: 6px; top: 50%; transform: translateY(-50%); font-size: 0.62rem; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; color: rgba(255, 255, 255, 0.85); text-shadow: 0 1px 1px rgba(0, 0, 0, 0.5); }
.bar.wither span { display: none; }
.status.withered .bar.wither { height: 14px; box-shadow: 0 0 10px var(--wither); animation: wpulse 1.2s ease-in-out infinite; }
.status.withered .bar.wither span { display: block; font-size: 0.6rem; }
.status.withered .portrait { filter: saturate(0.25) brightness(0.85); }
@keyframes wpulse { 50% { box-shadow: 0 0 18px var(--wither); } }
.status.low .bar.hp { animation: wpulse 0.8s ease-in-out infinite; --wither: var(--hp); }
#hurt { position: fixed; inset: 0; pointer-events: none; background: radial-gradient(ellipse at center, rgba(224, 87, 63, 0) 55%, rgba(224, 87, 63, 0.45) 100%); opacity: 0; }
#hurt.show { animation: hurt 0.5s ease-out; }
@keyframes hurt { 0% { opacity: 1; } 100% { opacity: 0; } }
.ebar { position: absolute; left: 0; top: 0; width: 46px; height: 6px; border-radius: 3px; background: rgba(20, 12, 24, 0.75); border: 1px solid rgba(255, 255, 255, 0.25); overflow: hidden; }
.ebar i { display: block; height: 100%; background: linear-gradient(180deg, #e070d0, #a03aa0); }
.ebar.beast { width: 64px; }
.ebar.beast i { background: linear-gradient(180deg, #c6f59a, #6fbf4a); }

.spirit { --el: var(--jade); position: absolute; top: 104px; left: max(16px, env(safe-area-inset-left, 0px)); display: flex; gap: 10px; padding: 8px 12px 8px 8px; align-items: center; }
.spirit .bars { width: 190px; }
.sp-portrait { width: 42px; height: 42px; border-radius: 50%; background: radial-gradient(circle at 35% 30%, #fff8ef 0%, var(--el) 55%, rgba(0, 0, 0, 0.3) 100%); display: grid; place-items: center; font: 400 1.25rem var(--font-display); color: #fff8ef; text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5); box-shadow: 0 0 14px var(--el); }
.spirit .name-row b { font-size: 0.98rem; }
.stage { font-size: 0.68rem; font-weight: 700; padding: 0 6px; border-radius: 4px; background: var(--el); color: var(--ink); }
.bar.sp-hp { height: 10px; }
.bar.sp-hp i { background: linear-gradient(180deg, #8ff0a8, #3fbf6a); }
.spirit.ko .bar.sp-hp i { background: #8a8f8c; }
.sp-move { display: flex; align-items: center; gap: 6px; font-size: 0.72rem; font-weight: 700; color: var(--paper-dim); }
.sp-cd { flex: 1; height: 4px; border-radius: 2px; background: rgba(0, 0, 0, 0.4); overflow: hidden; }
.sp-cd i { display: block; height: 100%; width: 100%; background: var(--el); }
.sp-move.ready { color: var(--paper); }
.sp-move.hidden { display: none; }
/* XP to the next level (Milestone 8); gold and full when it's ready to evolve. */
.sp-xp { height: 3px; margin: 3px 0 2px; border-radius: 2px; background: rgba(0, 0, 0, 0.4); overflow: hidden; }
.sp-xp i { display: block; height: 100%; width: 0; background: #ffe066; transition: width 0.3s; }
.sp-xp.ready i { background: linear-gradient(90deg, #ffe066, #fff8d0, #ffe066); animation: xpglow 1.2s ease-in-out infinite; }
@keyframes xpglow { 50% { opacity: 0.55; } }
.stage.guardian { background: linear-gradient(90deg, var(--el), #ffe066); }
.spirit .name-row { flex-wrap: nowrap; }
.spirit .name-row b { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.spirit .stage { flex: none; white-space: nowrap; }
.sp-portrait { position: relative; flex: none; }
.sp-lv { position: absolute; right: -5px; bottom: -4px; min-width: 18px; height: 18px; padding: 0 4px; border-radius: 9px; background: #ffe066; color: var(--ink); font: 800 0.66rem/18px var(--font-body, sans-serif); text-align: center; font-style: normal; text-shadow: none; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.5); }
#spirit-callout { position: absolute; left: 50%; top: 150px; transform: translateX(-50%); font: 400 1.6rem var(--font-display); letter-spacing: 0.03em; opacity: 0; transition: opacity 0.25s; text-shadow: 0 2px 0 rgba(0, 0, 0, 0.4), 0 0 20px currentColor; white-space: nowrap; }
#spirit-callout.show { opacity: 1; animation: pop 0.3s ease-out; }

.goals { position: absolute; top: 16px; right: max(16px, env(safe-area-inset-right, 0px)); width: 280px; padding: 12px 14px; }
.goals-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 8px; }
.goals-head b { font: 400 1.05rem var(--font-display); }
#goal-count { font-weight: 800; color: var(--jade); font-variant-numeric: tabular-nums; }
#goal-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
#goal-list li { display: flex; gap: 8px; align-items: center; font-size: 0.92rem; line-height: 1.25; color: var(--paper); }
#goal-list .tick { flex: none; width: 15px; height: 15px; border-radius: 4px; border: 2px solid rgba(243, 236, 220, 0.45); }
#goal-list li.done { color: var(--paper-dim); text-decoration: line-through; text-decoration-color: rgba(201, 193, 173, 0.6); }
#goal-list li.done .tick { background: var(--jade); border-color: var(--jade); }
#goal-list li.just .tick { animation: tick 0.5s ease-out; }
@keyframes tick { 0% { transform: scale(0.4); } 60% { transform: scale(1.5); box-shadow: 0 0 14px var(--jade); } 100% { transform: scale(1); } }

.actions { position: absolute; bottom: 18px; left: 50%; transform: translateX(-50%); display: flex; gap: 10px; }
.act { --cd: 0; position: relative; width: 74px; height: 74px; border-radius: 16px; background: var(--plate); border: 1px solid var(--plate-edge); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 5px; overflow: hidden; transition: transform 0.08s; }
.act span { font-size: 0.8rem; font-weight: 700; }
.act::after { content: ''; position: absolute; inset: 0; background: rgba(0, 0, 0, 0.55); transform-origin: bottom; transform: scaleY(var(--cd)); }
.act.busy { transform: translateY(2px) scale(0.96); border-color: var(--gold); }
#act-dash.ready { border-color: rgba(95, 224, 192, 0.55); }
.act.locked { opacity: 0.45; border-style: dashed; }
.act.spell { --el: var(--jade); border-color: var(--el); box-shadow: inset 0 -3px 0 var(--el); }
.act.spell .sp-name { font-size: 0.68rem; text-align: center; line-height: 1.05; padding: 0 4px; }
.act.spell .cost { position: absolute; top: 4px; right: 6px; font: 800 0.62rem var(--font-body); font-style: normal; color: #9fd0ff; z-index: 1; }
.act.spell.empty { border-style: dashed; box-shadow: none; opacity: 0.45; }
.act.spell.low { opacity: 0.55; }
.act.spell.low .cost { color: #ff9a8a; }
.act.spell.nomana { animation: shake 0.3s; border-color: #ff6a5a; }
.act.spell.cast { transform: scale(1.1); box-shadow: inset 0 -3px 0 var(--el), 0 0 22px var(--el); }
@keyframes shake { 0%, 100% { translate: 0; } 25% { translate: -4px; } 75% { translate: 4px; } }

/* ---------- spellbook ---------- */
.book-panel { width: min(640px, calc(100vw - 32px)); max-height: calc(100vh - 40px); overflow-y: auto; }
.book-note { margin: -8px 0 14px; color: var(--paper-dim); line-height: 1.4; font-size: 0.92rem; }
.book-slots { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; margin-bottom: 16px; }
.book-slot { --el: var(--jade); border: 2px solid var(--el); border-radius: 12px; padding: 8px 12px; background: rgba(0, 0, 0, 0.2); }
.book-slot small { display: block; font-size: 0.7rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.1em; color: var(--paper-dim); }
.book-slot b { font: 400 1.1rem var(--font-display); }
.book-list { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 16px; }
.book-spell { --el: var(--jade); position: relative; border: 1px solid rgba(243, 236, 220, 0.18); border-radius: 12px; padding: 10px 12px 10px 16px; background: rgba(243, 236, 220, 0.05); overflow: hidden; display: flex; flex-direction: column; gap: 4px; }
.book-spell::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 5px; background: var(--el); }
.book-spell.equipped { background: rgba(243, 236, 220, 0.12); border-color: var(--el); }
.book-spell .head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.book-spell b { font: 400 1.05rem var(--font-display); }
.book-spell .el { font-size: 0.7rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.08em; color: var(--el); }
.book-spell p { margin: 0; font-size: 0.85rem; line-height: 1.35; color: var(--paper-dim); }
.book-spell .stats { font-size: 0.78rem; font-weight: 700; color: var(--paper); display: flex; gap: 10px; flex-wrap: wrap; }
.book-spell .stats .bonus { color: var(--gold); }
.book-spell .equip { display: flex; gap: 6px; margin-top: 4px; }
.book-spell .equip button { flex: 1; appearance: none; border: 1px solid rgba(243, 236, 220, 0.25); background: rgba(243, 236, 220, 0.06); border-radius: 8px; padding: 4px 6px; font-weight: 700; font-size: 0.82rem; cursor: pointer; }
.book-spell .equip button:hover { background: rgba(243, 236, 220, 0.16); }
.book-spell .equip button[aria-pressed='true'] { background: var(--el); color: var(--ink); border-color: var(--el); }
.book-spell .equip button:focus-visible { outline: 2px solid var(--jade); outline-offset: 2px; }
@media (max-width: 560px) { .book-list, .book-slots { grid-template-columns: 1fr; } }

/* ---------- team, bait and taming (Milestone 5) ---------- */
#spirit-plate2, #spirit-plate3 { top: 194px; }
#spirit-plate2:not(.hidden) ~ .team-strip { top: 284px; }
.team-strip { --cd: 0; position: absolute; top: 194px; left: max(16px, env(safe-area-inset-left, 0px)); display: flex; align-items: center; gap: 10px; padding: 6px 12px 6px 8px; }
.team-strip.solo .swap-hint { opacity: 0.45; }
.team-slots { display: flex; flex-wrap: wrap; gap: 6px; max-width: 394px; } /* 10 slots per row */
.tslot { --el: var(--jade); position: relative; width: 34px; height: 40px; display: flex; flex-direction: column; align-items: center; gap: 3px; opacity: 0.72; }
.tslot span { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; font: 400 0.95rem var(--font-display); color: #fff8ef; background: radial-gradient(circle at 35% 30%, #fff8ef 0%, var(--el) 60%, rgba(0, 0, 0, 0.35) 100%); text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5); border: 2px solid transparent; }
.tslot i { width: 28px; height: 4px; border-radius: 2px; background: rgba(0, 0, 0, 0.45); overflow: hidden; }
.tslot i b { display: block; height: 100%; width: 100%; background: #3fbf6a; }
.tslot.active { opacity: 1; }
.tslot.active span { border-color: var(--paper); box-shadow: 0 0 10px var(--el); }
.tslot.ko { opacity: 0.4; filter: grayscale(0.8); }
.tslot.ko i b { background: #8a8f8c; }
.team-strip::after { content: ''; position: absolute; left: 8px; right: 8px; bottom: 2px; height: 2px; border-radius: 1px; background: var(--jade); transform-origin: left; transform: scaleX(var(--cd)); opacity: 0.8; }
.swap-hint { font-size: 0.72rem; font-weight: 700; color: var(--paper-dim); white-space: nowrap; }
.swap-hint kbd { font-size: 0.68rem; }

.act.bait { --el: var(--gold); border-color: var(--el); box-shadow: inset 0 -3px 0 var(--el); }
.act.bait .b-name { font-size: 0.66rem; text-align: center; line-height: 1.05; padding: 0 4px; }
.act.bait .count { position: absolute; top: 4px; right: 6px; font: 800 0.66rem var(--font-body); font-style: normal; color: var(--paper); z-index: 1; }
.act.bait .b-next { position: absolute; top: 3px; left: 4px; z-index: 1; }
.act.bait .b-next kbd { font-size: 0.56rem; min-width: 1.4em; padding: 0 0.25em; border-bottom-width: 2px; }
.act.bait.low { opacity: 0.55; }
.act.bait.low .count { color: #ff9a8a; }
.act.bait.cast { transform: scale(1.1); box-shadow: inset 0 -3px 0 var(--el), 0 0 22px var(--el); }

#taming { position: absolute; left: 50%; top: 16px; transform: translate(-50%, -10px); width: min(360px, calc(100vw - 32px)); padding: 10px 16px; opacity: 0; transition: opacity 0.2s, transform 0.2s; }
#taming.show { opacity: 1; transform: translate(-50%, 0); }
#taming.show ~ #toast { top: 136px; }
.tm-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 8px; }
.tm-head b { font: 400 1.15rem var(--font-display); }
.tm-rarity { --rar: #fff; font-size: 0.7rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.08em; color: var(--rar); }
.tm-rarity::before { content: '✦ '; }
.tm-bar { position: relative; height: 14px; border-radius: 5px; background: rgba(0, 0, 0, 0.4); overflow: hidden; margin-bottom: 5px; }
.tm-bar i { position: absolute; inset: 0 auto 0 0; width: 0; transition: width 0.1s; }
.tm-bar.calm i { background: linear-gradient(180deg, #ffb3cf, #ff6fa0); }
.tm-bar.scare { height: 8px; }
.tm-bar.scare i { background: linear-gradient(180deg, #ff9a6a, #d9472b); }
.tm-bar span { position: absolute; left: 6px; top: 50%; transform: translateY(-50%); font-size: 0.62rem; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; color: rgba(255, 255, 255, 0.9); text-shadow: 0 1px 1px rgba(0, 0, 0, 0.5); }
.tm-bar.scare span { font-size: 0.5rem; }
.tm-prompt { margin: 8px 0 0; font-weight: 700; text-align: center; }
.tm-prompt.look { color: #ffb4a3; animation: shake 0.3s; }
.tm-prompt.warn { color: var(--gold); }
.tm-bonus { margin: 2px 0 0; font-size: 0.78rem; text-align: center; color: var(--jade); }
.tm-bonus:empty { display: none; }

.wtag { --rar: #fff; position: absolute; left: 0; top: 0; display: flex; align-items: center; gap: 5px; padding: 2px 8px 2px 6px; border-radius: 999px; background: rgba(20, 28, 25, 0.72); border: 1px solid rgba(243, 236, 220, 0.18); font-size: 0.74rem; white-space: nowrap; }
.wtag i { width: 7px; height: 7px; border-radius: 50%; background: var(--rar); box-shadow: 0 0 6px var(--rar); }
.wtag b { font-weight: 700; }
.wtag span { font-size: 0.62rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.06em; color: var(--rar); }
.wtag em { font: 400 1rem var(--font-display); font-style: normal; color: var(--gold); }
.wtag em:empty { display: none; }
.wtag.alert { border-color: #ff8a6a; }
.wtag.alert em { color: #ff8a6a; animation: pop 0.3s ease-out; }

/* Team & Sanctuary screen */
.team-panel h3 { margin-top: 6px; }
.team-list { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 16px; }
.team-list .empty { grid-column: 1 / -1; margin: 0; color: var(--paper-dim); font-size: 0.9rem; }
.tcard { --el: var(--jade); position: relative; border: 1px solid rgba(243, 236, 220, 0.18); border-radius: 12px; padding: 10px 12px 10px 16px; background: rgba(243, 236, 220, 0.05); overflow: hidden; display: flex; flex-direction: column; gap: 4px; }
.tcard::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 5px; background: var(--el); }
.tcard.out { border-color: var(--el); background: rgba(243, 236, 220, 0.12); }
.tcard b { font: 400 1.05rem var(--font-display); }
.tcard .tags { display: flex; gap: 8px; font-size: 0.68rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.06em; }
.tcard .tags .el { color: var(--el); }
.tcard .tags .rar { color: var(--rar, var(--paper-dim)); }
.tcard p { margin: 0; font-size: 0.8rem; line-height: 1.3; color: var(--paper-dim); }
.tcard .stats { font-size: 0.76rem; font-weight: 700; display: flex; gap: 8px; flex-wrap: wrap; }
.tcard .btns { display: flex; gap: 6px; margin-top: auto; padding-top: 4px; }
.tcard .btns button { flex: 1; appearance: none; border: 1px solid rgba(243, 236, 220, 0.25); background: rgba(243, 236, 220, 0.06); border-radius: 8px; padding: 4px 6px; font-weight: 700; font-size: 0.78rem; cursor: pointer; }
.tcard .btns button:hover { background: rgba(243, 236, 220, 0.16); }
.tcard .btns button:disabled { opacity: 0.45; cursor: default; }
.tcard .btns button:focus-visible { outline: 2px solid var(--jade); outline-offset: 2px; }
.tcard .badge { font-size: 0.7rem; font-weight: 700; color: var(--gold); }
/* Milestone 8: level, XP and evolution on the team cards. */
.tcard .tags { flex-wrap: wrap; row-gap: 0; }
.tcard .mv { font: inherit; font-weight: 700; color: var(--paper); }
.tcard .was { font-size: 0.72rem; color: var(--paper-dim); margin-top: -4px; }
.tcard .evo-note { font-size: 0.76rem; border-left: 2px solid var(--tr, rgba(243, 236, 220, 0.25)); padding-left: 6px; }
.tcard .xpbar { position: relative; height: 14px; border-radius: 7px; background: rgba(0, 0, 0, 0.35); overflow: hidden; }
.tcard .xpbar i { position: absolute; inset: 0 auto 0 0; background: linear-gradient(90deg, #c8a030, #ffe066); }
.tcard .xpbar span { position: relative; display: block; text-align: center; font-size: 0.68rem; font-weight: 800; line-height: 14px; color: #fff8ef; text-shadow: 0 1px 2px rgba(0, 0, 0, 0.7); }
.tcard.ready { border-color: #ffe066; box-shadow: 0 0 18px rgba(255, 224, 102, 0.35); }
.tcard .btns button.evolve { background: linear-gradient(90deg, #ffe066, #ffb43a); color: var(--ink); border-color: #ffe066; font-weight: 800; }
.tcard .btns button.evolve:hover { filter: brightness(1.1); background: linear-gradient(90deg, #ffe066, #ffb43a); }
.journal { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin-bottom: 16px; }
.jentry { --rar: #fff; display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 10px; background: rgba(0, 0, 0, 0.2); font-size: 0.85rem; }
.jentry .dot { flex: none; width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; font: 400 0.85rem var(--font-display); background: rgba(243, 236, 220, 0.12); color: var(--paper-dim); }
.jentry.tamed .dot { background: var(--el); color: #fff8ef; box-shadow: 0 0 8px var(--el); }
.jentry.seen .dot { background: rgba(243, 236, 220, 0.25); color: var(--paper); }
.jentry b { display: block; font-weight: 700; }
.jentry small { color: var(--paper-dim); }
.jentry .st { margin-left: auto; font-size: 0.7rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.06em; color: var(--rar); }
@media (max-width: 640px) { .team-list { grid-template-columns: 1fr; } .journal { grid-template-columns: 1fr; } }

.compass { position: absolute; right: max(16px, env(safe-area-inset-right, 0px)); bottom: 18px; padding: 10px; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.dial { width: 58px; height: 58px; border-radius: 50%; border: 2px solid rgba(243, 236, 220, 0.3); position: relative; background: rgba(0, 0, 0, 0.2); }
#compass-needle { position: absolute; inset: 0; transition: none; }
#compass-needle b { position: absolute; top: 2px; left: 50%; transform: translateX(-50%); font: 400 0.95rem var(--font-display); color: var(--vermilion-hi); }
#compass-needle::after { content: ''; position: absolute; left: 50%; top: 22px; width: 4px; height: 14px; margin-left: -2px; background: var(--vermilion-hi); border-radius: 2px; }
.qe { font-size: 0.75rem; font-weight: 600; display: flex; gap: 3px; align-items: center; }

#combo { position: absolute; left: 50%; bottom: 112px; transform: translateX(-50%); display: flex; align-items: baseline; gap: 8px; opacity: 0; transition: opacity 0.2s; text-shadow: 0 2px 0 rgba(0, 0, 0, 0.35), 0 0 18px rgba(0, 0, 0, 0.3); }
#combo.show { opacity: 1; }
#combo b { font: 400 2.6rem var(--font-display); color: var(--gold); }
#combo span { font: 400 1.2rem var(--font-display); letter-spacing: 0.03em; }
#combo.pop b { animation: pop 0.3s ease-out; }
@keyframes pop { 0% { transform: scale(1.8); } 100% { transform: scale(1); } }

#controls-card { position: absolute; left: max(16px, env(safe-area-inset-left, 0px)); bottom: 18px; padding: 12px 14px; width: 260px; font-size: 0.86rem; }
.cc-head { display: flex; justify-content: space-between; margin-bottom: 6px; }
.cc-head b { font: 400 1rem var(--font-display); }
#controls-card dl { display: grid; grid-template-columns: auto 1fr; gap: 4px 10px; margin: 0; align-items: center; }
#controls-card dt { white-space: nowrap; font-weight: 600; color: var(--paper-dim); }
#controls-card dd { margin: 0; }

#toast { position: absolute; top: 96px; left: 50%; transform: translate(-50%, -10px); background: var(--plate); border: 1px solid var(--plate-edge); padding: 10px 18px; border-radius: 12px; font-weight: 600; opacity: 0; transition: opacity 0.25s, transform 0.25s; max-width: calc(100vw - 32px); text-align: center; }
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#save-chip { position: absolute; right: 18px; bottom: 112px; display: flex; align-items: center; gap: 7px; padding: 4px 12px 4px 9px; border-radius: 999px; background: var(--plate); border: 1px solid var(--plate-edge); font-size: 0.85rem; font-weight: 600; color: var(--paper-dim); opacity: 0; transition: opacity 0.35s; pointer-events: none; }
#save-chip.show { opacity: 1; }
#save-chip i { width: 10px; height: 10px; border-radius: 0 60% 0 60%; background: var(--jade); }
#save-chip.show i { animation: leaf 1.2s ease-in-out; }
@keyframes leaf { 0% { transform: rotate(-30deg) scale(0.6); } 50% { transform: rotate(20deg) scale(1.15); } 100% { transform: rotate(0) scale(1); } }

/* ---------- save file (Milestone 9) ---------- */
.save-summary { display: block; font-size: 0.8rem; font-weight: 500; color: var(--paper-dim); margin-top: 2px; }
.save-summary:empty { display: none; }
button.primary .save-summary { color: rgba(255, 248, 239, 0.8); }
.save-panel .menu { margin-top: 16px; }
.save-card { --el: var(--jade); border: 1px solid var(--plate-edge); border-left: 4px solid var(--el); border-radius: 12px; padding: 10px 14px; background: rgba(243, 236, 220, 0.05); margin: 0 0 12px; display: flex; flex-direction: column; gap: 2px; }
.save-card b { font: 400 1.35rem/1.1 var(--font-display); }
.save-card .sc-partner { color: var(--el); font-weight: 700; }
.save-card small { color: var(--paper-dim); font-size: 0.85rem; line-height: 1.35; }
.sf-msg { margin: 6px 0 0; min-height: 0; font-size: 0.9rem; color: var(--jade); line-height: 1.35; overflow-wrap: anywhere; }
.sf-msg:empty { display: none; }
.sf-msg.bad, .sf-warn { color: #ffb4a3; }
.sf-warn { font-size: 0.9rem; line-height: 1.35; }

/* Damage numbers */
.dmg { position: absolute; left: 0; top: 0; font: 400 1.5rem var(--font-display); color: #fff; -webkit-text-stroke: 1.5px #3a1f0e; text-shadow: 0 3px 0 rgba(0, 0, 0, 0.35); will-change: transform, opacity; white-space: nowrap; }
.dmg.heavy { font-size: 2.1rem; color: #ffe08a; }
.dmg.crit { font-size: 2.3rem; color: #ff8a5c; }
.dmg.small { font-size: 1.15rem; }

/* ---------- Lumora Town (Milestone 6) ---------- */
.belt { background: var(--belt, #f4f1ea); }
.coins { font-size: 0.74rem; font-weight: 800; color: var(--gold); font-variant-numeric: tabular-nums; white-space: nowrap; }
.coins.bump { animation: pop 0.3s ease-out; }
.name-row { gap: 6px; }
.name-row b { margin-right: auto; }

#prompt { position: absolute; left: 50%; bottom: 104px; transform: translate(-50%, 8px); display: flex; align-items: center; gap: 8px; padding: 7px 14px 7px 8px; font-weight: 700; opacity: 0; transition: opacity 0.15s, transform 0.15s; white-space: nowrap; max-width: calc(100vw - 32px); }
#prompt.show { opacity: 1; transform: translate(-50%, 0); }
#prompt kbd { background: var(--gold); color: var(--ink); border-color: #b88a2a; }
#prompt.show ~ #combo { bottom: 150px; }

#banner { position: absolute; left: 50%; top: 30%; transform: translateX(-50%); text-align: center; opacity: 0; pointer-events: none; text-shadow: 0 2px 0 rgba(0, 0, 0, 0.35), 0 0 24px rgba(0, 0, 0, 0.35); }
#banner b { display: block; font: 400 clamp(2rem, 5vw, 3.2rem) var(--font-display); letter-spacing: 0.03em; }
#banner small { display: block; font: 600 0.85rem var(--font-body); text-transform: uppercase; letter-spacing: 0.3em; color: var(--jade); }
#banner.show { animation: banner 3.2s ease-out forwards; }
@keyframes banner { 0% { opacity: 0; transform: translate(-50%, 10px); } 12%, 70% { opacity: 1; transform: translate(-50%, 0); } 100% { opacity: 0; } }

#fade { position: fixed; inset: 0; background: #0d1412; opacity: 0; pointer-events: none; z-index: 8; transition: opacity 0.4s; }
#fade.show { opacity: 1; }

#belt-test { position: absolute; left: 50%; top: 16px; transform: translate(-50%, -10px); width: min(360px, calc(100vw - 32px)); padding: 10px 16px 12px; opacity: 0; transition: opacity 0.2s, transform 0.2s; }
#belt-test.show { opacity: 1; transform: translate(-50%, 0); }
#belt-test.show ~ #toast { top: 136px; }
#bt-name { --belt: #fff; }
#bt-name::before { content: ''; display: inline-block; width: 22px; height: 8px; margin-right: 8px; border-radius: 2px; background: var(--belt); vertical-align: middle; box-shadow: 0 0 0 1px rgba(243, 236, 220, 0.3); }
#bt-count { font: 400 1.3rem var(--font-display); color: var(--gold); font-variant-numeric: tabular-nums; }
#belt-test.counting #bt-count { animation: pop 0.5s ease-out infinite; }
#belt-test.hurry #bt-count { color: #ff8a6a; }
.bt-goal { margin: -4px 0 6px; font-size: 0.82rem; font-weight: 700; color: var(--paper-dim); }
#belt-test .tm-bar.calm i { background: linear-gradient(180deg, #ffe08a, var(--gold)); }
.bt-time { height: 4px; border-radius: 2px; background: rgba(0, 0, 0, 0.4); overflow: hidden; }
.bt-time i { display: block; height: 100%; width: 100%; background: var(--jade); }

/* The Rootheart's health bar (Milestone 7) */
#boss-bar { position: absolute; left: 50%; top: 16px; transform: translate(-50%, -10px); width: min(460px, calc(100vw - 32px)); padding: 8px 16px 10px; text-align: center; opacity: 0; pointer-events: none; transition: opacity 0.25s, transform 0.25s; }
#boss-bar.show { opacity: 1; transform: translate(-50%, 0); }
#boss-bar b { display: block; font: 400 1.15rem var(--font-display); letter-spacing: 0.04em; color: #e8c8ff; }
.bb-track { height: 12px; margin: 6px 0 4px; border-radius: 6px; background: rgba(0, 0, 0, 0.45); overflow: hidden; box-shadow: inset 0 0 0 1px rgba(243, 236, 220, 0.18); }
.bb-track i { display: block; height: 100%; width: 100%; background: linear-gradient(180deg, #ff7ae0, #b03aa8); transition: width 0.15s; }
#boss-bar.shielded .bb-track i { background: repeating-linear-gradient(45deg, #9a86b0 0 8px, #7a6a90 8px 16px); }
#boss-bar small { display: block; min-height: 1em; font-size: 0.8rem; font-weight: 700; color: var(--paper-dim); }
#boss-bar.show ~ #toast { top: 96px; }

.ntag b { font-weight: 700; }
.ntag span:empty { display: none; }

/* Town screens: teacher, Bait Shop & Kitchen, Spirit Journal */
.place-panel { width: min(720px, calc(100vw - 32px)); }
.place-panel h2 { margin-bottom: 8px; }
.place-panel h3 { margin-top: 14px; }
.quote { margin: 0 0 14px; font-style: italic; color: var(--paper); line-height: 1.4; }
.belt-track { display: flex; align-items: center; gap: 4px; margin-bottom: 14px; }
.belt-track i { flex: 1; height: 2px; background: rgba(243, 236, 220, 0.2); }
.beltchip { --belt: #fff; display: flex; align-items: center; gap: 6px; font-size: 0.78rem; font-weight: 700; color: var(--paper-dim); padding: 3px 8px; border-radius: 999px; border: 1px solid rgba(243, 236, 220, 0.2); }
.beltchip::before { content: ''; width: 16px; height: 6px; border-radius: 2px; background: var(--belt); box-shadow: 0 0 0 1px rgba(243, 236, 220, 0.3); }
.beltchip.done { color: var(--paper); }
.beltchip.now { color: var(--ink); background: var(--gold); border-color: var(--gold); }
.test-card { --belt: #fff; display: flex; gap: 14px; align-items: center; padding: 12px 14px; border-radius: 12px; background: rgba(243, 236, 220, 0.07); border: 1px solid rgba(243, 236, 220, 0.2); border-left: 6px solid var(--belt); margin-bottom: 10px; }
.test-card b { font: 400 1.1rem var(--font-display); }
.test-card p { margin: 3px 0; font-size: 0.88rem; line-height: 1.35; color: var(--paper-dim); }
.test-card small { font-size: 0.78rem; font-weight: 700; color: var(--gold); }
.test-card button { flex: none; appearance: none; border: 1px solid var(--vermilion-hi); border-radius: 10px; padding: 9px 14px; font-weight: 700; cursor: pointer; }
.test-card button:focus-visible { outline: 2px solid var(--jade); outline-offset: 2px; }
.test-card.done { border-left-color: #2b2730; }
.beltmark { display: flex; align-items: center; gap: 5px; color: var(--paper-dim) !important; }
.beltmark::before { content: ''; width: 14px; height: 5px; border-radius: 2px; background: var(--belt); box-shadow: 0 0 0 1px rgba(243, 236, 220, 0.3); }
.book-spell .known { font-weight: 700; font-size: 0.82rem; color: var(--jade); }
.book-spell .need { font-weight: 700; font-size: 0.8rem; color: var(--paper-dim); }

.wallet { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.wallet .coins { font-size: 1rem; }
.tabs { display: flex; gap: 4px; padding: 3px; border-radius: 10px; background: rgba(0, 0, 0, 0.25); }
.tabs button { appearance: none; border: 0; background: none; padding: 5px 14px; border-radius: 8px; font-weight: 700; cursor: pointer; color: var(--paper-dim); }
.tabs button[aria-selected='true'] { background: var(--paper); color: var(--ink); }
.tabs button:focus-visible { outline: 2px solid var(--jade); outline-offset: 2px; }
.shop-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 8px; }
.shop-row { --el: var(--gold); display: flex; align-items: center; gap: 12px; padding: 9px 12px; border-radius: 12px; background: rgba(243, 236, 220, 0.05); border: 1px solid rgba(243, 236, 220, 0.16); }
.shop-row > div { flex: 1; min-width: 0; }
.shop-row b { font: 400 1.02rem var(--font-display); }
.shop-row small { display: block; font-size: 0.74rem; font-weight: 700; color: var(--paper-dim); }
.shop-row p { margin: 3px 0 0; font-size: 0.82rem; line-height: 1.3; color: var(--paper-dim); }
.shop-row button { flex: none; min-width: 74px; appearance: none; border: 1px solid rgba(243, 236, 220, 0.3); background: rgba(243, 236, 220, 0.1); border-radius: 10px; padding: 7px 12px; font-weight: 800; cursor: pointer; }
.shop-row button:hover:not(:disabled) { background: rgba(243, 236, 220, 0.2); }
.shop-row button:disabled { opacity: 0.4; cursor: default; }
.shop-row button:focus-visible { outline: 2px solid var(--jade); outline-offset: 2px; }
.shop-row.later { opacity: 0.6; }
.swatch-dot { flex: none; width: 26px; height: 26px; border-radius: 8px; background: var(--el); box-shadow: inset 0 -4px 0 rgba(0, 0, 0, 0.25), 0 0 10px color-mix(in srgb, var(--el) 50%, transparent); }
.needs { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 5px; }
.needs.bag { margin: 0 0 6px; }
.need-chip { --el: #fff; display: inline-flex; align-items: center; gap: 4px; font-size: 0.74rem; font-weight: 700; padding: 2px 8px 2px 6px; border-radius: 999px; background: rgba(0, 0, 0, 0.25); color: #ff9a8a; }
.need-chip::before { content: ''; width: 8px; height: 8px; border-radius: 2px; background: var(--el); }
.need-chip.ok { color: var(--paper); }
.need-chip em { font-style: normal; color: var(--paper-dim); }

/* Charm Shop (Milestone 10) */
.charm-slots { font-size: 0.8rem; font-weight: 700; color: var(--paper-dim); }
.swatch-dot.charm { border-radius: 50%; }
.shop-row.worn { border-color: var(--el); background: color-mix(in srgb, var(--el) 12%, transparent); }
.shop-row button.primary { background: var(--el); color: var(--ink); border-color: var(--el); }

/* Quest Board (Milestone 10) */
.quest-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 8px; }
.quest { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 12px; background: #e9dcc0; color: var(--ink); border: 1px solid #b8955a; box-shadow: 0 2px 0 rgba(0, 0, 0, 0.3); }
.quest > div { flex: 1; min-width: 0; }
.quest small { display: block; font-size: 0.74rem; font-weight: 800; color: #7b5531; }
.quest p { margin: 2px 0 6px; font-size: 0.9rem; line-height: 1.3; }
.quest .reward { color: #8a5a1e; font-weight: 700; }
.quest .need { flex: none; font-size: 0.78rem; font-weight: 700; color: #7b5531; }
.quest button { flex: none; appearance: none; border-radius: 10px; padding: 8px 12px; font-weight: 800; cursor: pointer; }
.quest button:focus-visible { outline: 2px solid var(--jade); outline-offset: 2px; }
.quest.ready { border-color: #4a8a3a; box-shadow: 0 0 0 2px #8fd84a, 0 2px 0 rgba(0, 0, 0, 0.3); }
.qbar { position: relative; height: 14px; border-radius: 7px; background: rgba(0, 0, 0, 0.18); overflow: hidden; margin-bottom: 4px; }
.qbar i { position: absolute; inset: 0 auto 0 0; background: linear-gradient(90deg, #8fd84a, #5fae3a); border-radius: 7px; }
.qbar span { position: relative; display: block; text-align: center; font-size: 0.7rem; font-weight: 800; line-height: 14px; }

/* The valley map (Milestone 10) */
.valley-map { position: relative; aspect-ratio: 1.45; margin: 4px 0 14px; border-radius: 16px; overflow: hidden; background: radial-gradient(ellipse at 50% 18%, #6e5a7e 0%, transparent 32%), radial-gradient(ellipse at 50% 100%, #7aa858 0%, transparent 55%), linear-gradient(180deg, #8a9ab0, #6f9a5a); box-shadow: inset 0 0 0 2px rgba(243, 236, 220, 0.25), inset 0 0 40px rgba(0, 0, 0, 0.35); }
.valley-map .heart { position: absolute; left: 50%; top: 5%; transform: translateX(-50%); text-align: center; font: 400 0.95rem var(--font-display); color: #e8c8ff; text-shadow: 0 1px 4px #000; }
.valley-map .heart small { display: block; font: 700 0.68rem var(--font-body, sans-serif); color: #c9b6d8; }
.valley-map .town-pin { position: absolute; left: 50%; bottom: 4%; transform: translateX(-50%); padding: 4px 12px; border-radius: 999px; background: var(--paper); color: var(--ink); font: 400 0.95rem var(--font-display); box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4); }
.map-pin { --el: #fff; position: absolute; transform: translate(-50%, -50%); max-width: 32%; appearance: none; cursor: pointer; text-align: center; padding: 6px 10px; border-radius: 12px; border: 2px solid var(--el); background: rgba(23, 32, 29, 0.82); color: var(--paper); box-shadow: 0 3px 8px rgba(0, 0, 0, 0.45); }
.map-pin b { display: block; font: 400 0.98rem var(--font-display); color: var(--el); }
.map-pin small { display: block; font-size: 0.7rem; line-height: 1.25; color: var(--paper-dim); }
.map-pin.cursed { border-style: dashed; }
.map-pin.freed { background: color-mix(in srgb, var(--el) 30%, rgba(23, 32, 29, 0.85)); }
.map-pin:hover, .map-pin:focus-visible { transform: translate(-50%, -54%); outline: none; box-shadow: 0 0 0 3px var(--el), 0 6px 12px rgba(0, 0, 0, 0.5); }
@media (max-width: 640px) { .map-pin small { display: none; } }

.jbook { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin-bottom: 12px; }
.jcard { --el: #fff; --rar: #fff; display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 12px; background: rgba(0, 0, 0, 0.2); border: 1px solid rgba(243, 236, 220, 0.08); font-size: 0.85rem; }
.jcard .pic { flex: none; width: 58px; height: 58px; border-radius: 12px; display: grid; place-items: center; background: radial-gradient(circle at 50% 40%, rgba(243, 236, 220, 0.16), rgba(0, 0, 0, 0.15)); overflow: hidden; }
.jcard .pic img { width: 100%; height: 100%; object-fit: contain; }
.jcard .pic span { font: 400 1.4rem var(--font-display); color: rgba(243, 236, 220, 0.35); }
.jcard.tamed .pic { background: radial-gradient(circle at 50% 40%, color-mix(in srgb, var(--el) 45%, transparent), rgba(0, 0, 0, 0.15)); box-shadow: inset 0 0 0 2px var(--el); }
.jcard b { display: block; font-weight: 700; }
.jcard small { display: block; color: var(--paper-dim); line-height: 1.25; }
.jcard p { margin: 3px 0 0; font-size: 0.76rem; line-height: 1.3; color: var(--paper-dim); }
.jcard .st { margin-left: auto; flex: none; font-size: 0.68rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.06em; color: var(--rar); }
.jcard.unknown b { color: var(--paper-dim); }
@media (max-width: 640px) { .jbook { grid-template-columns: 1fr; } .test-card { flex-direction: column; align-items: stretch; } }

.tcard .hearts { font-size: 0.8rem; color: #ff8fb8; letter-spacing: 1px; }
.tcard .hearts span { color: rgba(243, 236, 220, 0.2); }

@media (max-width: 900px) {
  .goals { width: 220px; font-size: 0.85rem; }
  #controls-card { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
