/* ============ HistoryCat prototype styles ============
   The stage is always 16:9. Sizes use cqw (1cqw = 1% of the stage width),
   so everything scales with the window, from phone to big screen. */

:root {
  --ink: #2b2140;
  --paper: #fff8ee;
  --accent: #ff7a59;
  --accent-2: #ffcf4a;
  --good: #3fbf8a;
  --bad: #ef5b6c;
  --shadow: 0 0.4cqw 0 rgba(0,0,0,.18);
}

* { box-sizing: border-box; }
html, body {
  margin: 0; height: 100%;
  background: #1c1530;
  font-family: 'Nunito', system-ui, sans-serif;
  color: var(--ink);
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

#stage {
  position: absolute; inset: 0; margin: auto;
  width: min(100vw, 177.78vh);
  height: min(100vh, 56.25vw);
  container-type: size;
  overflow: hidden;
  background: #2b2140;
}

button { font-family: inherit; cursor: pointer; border: none; }
.hidden { display: none !important; }

/* ---------- Scene ---------- */
#scene, #bg, #decor, #props, #screen { position: absolute; inset: 0; }
#bg { background-size: cover; background-position: center; transition: filter .6s; }
#decor > * { position: absolute; transform: translate(-50%, -50%); pointer-events: none; line-height: 1; }
#props.locked { pointer-events: none; }
#screen:empty { pointer-events: none; }

.prop {
  position: absolute; transform: translate(-50%, -50%);
  background: none; padding: 0; line-height: 1;
  filter: drop-shadow(0 0.4cqw 0.3cqw rgba(0,0,0,.25));
  transition: transform .15s;
}
.prop:hover { transform: translate(-50%, -50%) scale(1.08); }
.prop:active { transform: translate(-50%, -50%) scale(.95); }
.prop img, .prop svg { width: 100%; height: auto; display: block; pointer-events: none; }
.prop .badge {
  position: absolute; left: 50%; top: 58%; transform: translate(-50%, -50%);
  font-size: .38em; background: rgba(255,248,238,.85); border-radius: 50%;
  width: 1.5em; height: 1.5em; display: grid; place-items: center;
}
.prop .label {
  position: absolute; left: 50%; top: 100%; transform: translateX(-50%);
  white-space: nowrap; font-size: 1.1cqw; font-weight: 800; color: #fff;
  background: rgba(43,33,64,.75); padding: .2cqw .6cqw; border-radius: 1cqw;
  opacity: 0; transition: opacity .2s; pointer-events: none;
}
.prop:hover .label { opacity: 1; }
.prop.found { animation: pop .5s forwards; pointer-events: none; }
.prop.shake { animation: shake .4s; }
.prop.glow { animation: glow 1.4s infinite; }

@keyframes pop { 50% { transform: translate(-50%,-50%) scale(1.3); } 100% { transform: translate(-50%,-50%) scale(0); opacity: 0; } }
@keyframes shake { 25% { margin-left: -0.6cqw; } 75% { margin-left: 0.6cqw; } }
@keyframes glow { 50% { filter: drop-shadow(0 0 1.2cqw #fff6a8); } }

/* ---------- Era stamp & task ---------- */
#stamp {
  position: absolute; top: 4cqw; left: 50%; transform: translateX(-50%) rotate(-3deg);
  background: var(--paper); border: 0.35cqw dashed var(--accent);
  padding: .8cqw 2.4cqw; border-radius: 1cqw;
  font-family: 'Baloo 2', sans-serif; font-weight: 800; font-size: 2.2cqw; color: var(--accent);
  box-shadow: var(--shadow); animation: stamp .5s cubic-bezier(.2,1.6,.4,1);
  text-align: center; line-height: 1.1; z-index: 5;
}
#stamp small { display: block; font-size: 1.3cqw; color: var(--ink); }
@keyframes stamp { from { transform: translateX(-50%) scale(2.5) rotate(-12deg); opacity: 0; } }

#task {
  position: absolute; top: 1.4cqw; left: 1.4cqw; z-index: 6;
  background: var(--accent-2); padding: .7cqw 1.4cqw; border-radius: 3cqw;
  font-weight: 800; font-size: 1.5cqw; box-shadow: var(--shadow);
}

/* ---------- Top bar ---------- */
#topbar { position: absolute; top: 1.2cqw; right: 1.2cqw; display: flex; gap: .8cqw; z-index: 20; }
.icon-btn {
  width: 4.4cqw; height: 4.4cqw; border-radius: 50%; font-size: 2.2cqw;
  background: var(--paper); box-shadow: var(--shadow);
}
.icon-btn:active { transform: translateY(.2cqw); }

/* ---------- Dialogue ---------- */
#dialogue {
  position: absolute; left: 2cqw; right: 2cqw; bottom: 1.6cqw;
  display: flex; align-items: flex-end; gap: 1cqw; z-index: 30;
  animation: rise .25s ease-out;
}
@keyframes rise { from { transform: translateY(3cqw); opacity: 0; } }
#portrait { width: 13cqw; flex: none; margin-bottom: -1cqw; }
#portrait.talking { animation: bob .35s infinite alternate; }
#portrait .npc-face {
  width: 11cqw; height: 11cqw; margin: 0 auto 1cqw; border-radius: 50%;
  background: var(--paper); display: grid; place-items: center; font-size: 6.5cqw;
  box-shadow: var(--shadow); border: .4cqw solid #fff;
}
@keyframes bob { to { transform: translateY(-.5cqw); } }

#bubble {
  position: relative; flex: 1; min-height: 11cqw;
  background: var(--paper); border-radius: 2cqw; padding: 1.2cqw 2cqw 1.4cqw;
  box-shadow: 0 .6cqw 0 rgba(0,0,0,.22);
}
#speaker {
  position: absolute; top: -1.6cqw; left: 2cqw;
  background: var(--accent); color: #fff; font-family: 'Baloo 2'; font-weight: 800;
  font-size: 1.6cqw; padding: .1cqw 1.4cqw; border-radius: 2cqw;
}
#speaker.npc { background: #6c5ce7; }
#subtitle {
  font-family: 'Baloo 2', sans-serif; font-weight: 700; font-size: 2.5cqw; line-height: 1.25;
  margin-top: .6cqw; padding-right: 6cqw;
}
#subtitle .w { transition: color .1s; }
#subtitle .w.said { color: var(--ink); }
#subtitle .w.now { color: var(--accent); }
#subtitle.karaoke .w:not(.said):not(.now) { color: #a99fbf; }

#choices { display: flex; flex-wrap: wrap; gap: 1cqw; margin-top: 1cqw; }
#choices button {
  background: #fff; border: .3cqw solid var(--ink); border-radius: 2cqw;
  padding: .6cqw 1.6cqw; font-size: 1.7cqw; font-weight: 800; color: var(--ink);
  box-shadow: var(--shadow); animation: rise .3s backwards;
}
#choices button:hover { background: var(--accent-2); }
#choices button:disabled { opacity: .35; text-decoration: line-through; pointer-events: none; }
#choices button::before { content: '▸ '; color: var(--accent); }

#next {
  position: absolute; right: 1.4cqw; bottom: 1.2cqw;
  width: 4.4cqw; height: 4.4cqw; border-radius: 50%; font-size: 1.8cqw;
  background: var(--accent); color: #fff; box-shadow: var(--shadow);
}
#next.ready { animation: pulse 1s infinite; }
@keyframes pulse { 50% { transform: scale(1.12); } }
#paw {
  position: absolute; right: 7cqw; bottom: 1.6cqw;
  background: #ffe2d6; color: var(--accent); font-weight: 800; font-size: 1.4cqw;
  padding: .5cqw 1.2cqw; border-radius: 2cqw; animation: wiggle 1.5s infinite;
}
@keyframes wiggle { 0%,80%,100% { transform: rotate(0); } 85% { transform: rotate(-8deg); } 90% { transform: rotate(8deg); } }

/* ---------- Kitten (SVG) ---------- */
.kitten { width: 100%; height: auto; overflow: visible; }
.kitten .tail { transform-origin: 70px 150px; animation: tail 2.4s ease-in-out infinite; }
.kitten .eyes { animation: blink 4s infinite; transform-origin: 100px 82px; }
.kitten .mouth-open { display: none; }
.talking .kitten .mouth-open { display: inline; animation: talk .18s infinite alternate; transform-origin: 100px 104px; }
.talking .kitten .mouth-closed { display: none; }
@keyframes tail { 50% { transform: rotate(14deg); } }
@keyframes blink { 0%, 94%, 100% { transform: scaleY(1); } 97% { transform: scaleY(.1); } }
@keyframes talk { to { transform: scaleY(.4); } }

/* ---------- Generic screens ---------- */
.screen-center {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; text-align: center;
}
.big-btn {
  background: var(--accent); color: #fff; font-family: 'Baloo 2'; font-weight: 800;
  font-size: 2.6cqw; padding: .8cqw 4cqw; border-radius: 3cqw;
  box-shadow: 0 .6cqw 0 #c4513a; margin-top: 2cqw;
}
.big-btn:active { transform: translateY(.4cqw); box-shadow: 0 .2cqw 0 #c4513a; }
.big-btn.alt { background: #6c5ce7; box-shadow: 0 .6cqw 0 #4a3db8; }

/* Title */
.title-screen { background: radial-gradient(circle at 50% 40%, #ffb36b, #e2557a 55%, #43306e); }
.title-screen h1 {
  font-family: 'Baloo 2'; font-weight: 800; font-size: 8cqw; margin: 0; line-height: .9;
  color: #fff; text-shadow: 0 .6cqw 0 #8a2d5a;
}
.title-screen h2 { font-family: 'Baloo 2'; color: #fff3c4; font-size: 2.6cqw; margin: .5cqw 0 0; }
.title-screen .title-cat { width: 16cqw; margin-bottom: -1cqw; }
.title-screen .hint { color: #fff; opacity: .8; font-size: 1.3cqw; margin-top: 1.5cqw; }

/* Mission map */
.map-screen { background: linear-gradient(180deg, #3b2d63, #6a4c93); }
.map-screen h3 {
  position: absolute; top: 1.5cqw; left: 0; right: 0; text-align: center; margin: 0;
  font-family: 'Baloo 2'; color: #fff; font-size: 3cqw;
}
.map-node {
  position: absolute; transform: translate(-50%, -50%); width: 15cqw;
  background: rgba(255,255,255,.1); border: .3cqw dashed rgba(255,255,255,.5);
  border-radius: 2cqw; padding: 1cqw; color: #fff; text-align: center;
}
.map-node .ico { font-size: 4.5cqw; filter: brightness(0) invert(.2); }
.map-node .nm { font-family: 'Baloo 2'; font-weight: 800; font-size: 1.7cqw; }
.map-node .clue { font-size: 1.15cqw; opacity: .9; }
.map-node:hover { background: rgba(255,255,255,.2); }
.map-node.done { background: var(--paper); color: var(--ink); border: .3cqw solid var(--good); }
.map-node.done .ico { filter: none; }
.map-node.done::after {
  content: '✓'; position: absolute; top: -1.2cqw; right: -1.2cqw; width: 3cqw; height: 3cqw;
  border-radius: 50%; background: var(--good); color: #fff; display: grid; place-items: center; font-size: 1.8cqw;
}
.map-mug { position: absolute; left: 50%; top: 52%; transform: translate(-50%,-50%); width: 13cqw; transition: opacity 1s; }
.map-lines { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }

/* Finale */
.finale-screen { background: linear-gradient(180deg, #ffe7b8, #ffb59a); }
.finale-screen h3 { font-family: 'Baloo 2'; font-size: 3cqw; margin: 2cqw 0 0; text-align: center; }
.slots { position: absolute; top: 8.5cqw; left: 4cqw; right: 4cqw; display: flex; gap: 1.2cqw; }
.slot {
  flex: 1; height: 13cqw; border: .35cqw dashed rgba(43,33,64,.4); border-radius: 1.6cqw;
  display: grid; place-items: center; font-size: 1.3cqw; color: rgba(43,33,64,.5); font-weight: 800;
}
.slot.filled { border: .35cqw solid var(--good); background: #fff; color: var(--ink); animation: pop-in .4s; }
@keyframes pop-in { from { transform: scale(.6); } }
.arrow-line { position: absolute; top: 22.8cqw; left: 4cqw; right: 4cqw; height: .5cqw; background: var(--ink); border-radius: 1cqw; }
.arrow-line::before { content: 'OLDEST'; position: absolute; left: 0; top: .8cqw; font-weight: 800; font-size: 1.2cqw; }
.arrow-line::after { content: 'NEWEST ➜'; position: absolute; right: 0; top: .8cqw; font-weight: 800; font-size: 1.2cqw; }
.cards { position: absolute; top: 27.5cqw; left: 4cqw; right: 4cqw; display: flex; gap: 1.2cqw; justify-content: center; }
.card {
  width: 14cqw; height: 13cqw; background: #fff; border-radius: 1.6cqw; box-shadow: var(--shadow);
  display: flex; flex-direction: column; align-items: center; justify-content: center; padding: .6cqw;
  font-weight: 800; font-size: 1.3cqw; text-align: center;
}
.card .ico, .slot .ico { font-size: 4.5cqw; line-height: 1.1; }
.card.shake { animation: shake .4s; background: #ffd9dd; }
.card.used { visibility: hidden; }

/* ---------- Mini-game panel ---------- */
#panel {
  position: absolute; left: 50%; top: 44%; transform: translate(-50%, -50%);
  width: 50cqw; background: var(--paper); border-radius: 2.4cqw; padding: 2cqw;
  box-shadow: 0 1cqw 0 rgba(0,0,0,.25); text-align: center; z-index: 25;
  animation: rise .3s;
}
#panel h4 { font-family: 'Baloo 2'; font-size: 2.4cqw; margin: 0 0 1cqw; }
.meter { height: 2cqw; background: #eadfd0; border-radius: 1cqw; overflow: hidden; margin: 1cqw 0; }
.meter > div { height: 100%; width: 0; background: linear-gradient(90deg, #f6c453, #e8a33a); transition: width .15s; }
.press-art { font-size: 6cqw; line-height: 1.1; }
.press-art .plate { display: inline-block; transition: transform .1s; }
.price-board { display: flex; gap: 1.2cqw; justify-content: center; margin-bottom: 1cqw; }
.price-board div { background: #fff; border-radius: 1.2cqw; padding: .6cqw 1.2cqw; font-weight: 800; font-size: 1.4cqw; box-shadow: var(--shadow); }
.price-board .e { font-size: 3cqw; display: block; }
.bean-count { font-family: 'Baloo 2'; font-weight: 800; font-size: 4cqw; }
.row { display: flex; gap: 1cqw; justify-content: center; flex-wrap: wrap; }
.small-btn {
  background: #fff; border: .3cqw solid var(--ink); border-radius: 2cqw;
  padding: .5cqw 1.4cqw; font-size: 1.6cqw; font-weight: 800; box-shadow: var(--shadow);
}
.small-btn.go { background: var(--good); color: #fff; border-color: var(--good); }

/* ---------- Overlays ---------- */
#overlay { position: absolute; inset: 0; background: rgba(20,14,36,.7); z-index: 40; display: grid; place-items: center; }
#overlay-card {
  position: relative; width: 86cqw; max-height: 48cqw; overflow: auto;
  background: var(--paper); border-radius: 2.4cqw; padding: 2.4cqw 3cqw; animation: rise .25s;
}
#overlay-card h2 { font-family: 'Baloo 2'; margin: 0 0 1cqw; font-size: 3cqw; }
#overlay-card p { font-size: 1.8cqw; line-height: 1.45; margin: .6cqw 0; }
#overlay-card .close {
  position: absolute; top: 1.2cqw; right: 1.2cqw; width: 4cqw; height: 4cqw; border-radius: 50%;
  background: var(--ink); color: #fff; font-size: 1.8cqw;
}
#overlay-card.paw-note { width: 60cqw; border: .5cqw solid #ffcfbf; }

.museum-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1.2cqw; }
.museum-item { background: #fff; border-radius: 1.4cqw; padding: 1cqw; text-align: center; box-shadow: var(--shadow); min-height: 13cqw; }
.museum-item .ico { font-size: 4.5cqw; }
.museum-item b { display: block; font-size: 1.5cqw; }
.museum-item span { font-size: 1.15cqw; display: block; margin-top: .4cqw; }
.museum-item.locked { background: #eee5d8; color: #9a8f86; }
.museum-item.locked .ico { filter: brightness(0) opacity(.25); }

.timeline { position: relative; height: 30cqw; margin-top: 1cqw; }
.timeline .bar { position: absolute; left: 0; right: 0; top: 15cqw; height: .6cqw; background: var(--ink); border-radius: 1cqw; }
.timeline .tick { position: absolute; top: 16.2cqw; transform: translateX(-50%); font-size: 1.1cqw; font-weight: 800; color: #8a7f99; }
.timeline .ev { position: absolute; transform: translateX(-50%); text-align: center; width: 11cqw; font-size: 1.1cqw; font-weight: 800; }
.timeline .ev .ico { font-size: 3cqw; }
.timeline .ev.up { bottom: 15.8cqw; }
.timeline .ev.down { top: 17.6cqw; }
.timeline .ev.dim { opacity: .25; filter: grayscale(1); }
.timeline .ev.meanwhile { color: #6c5ce7; font-weight: 600; font-style: italic; }
.timeline .ev .dot { width: 1.4cqw; height: 1.4cqw; border-radius: 50%; background: var(--accent); margin: .3cqw auto; }

.setting-row { display: flex; align-items: center; gap: 1.5cqw; font-size: 1.8cqw; margin: 1.2cqw 0; }
.setting-row input[type=range] { width: 20cqw; }

/* ---------- Toast & warp ---------- */
#toast {
  position: absolute; top: 7cqw; left: 50%; transform: translateX(-50%); z-index: 50;
  background: var(--good); color: #fff; font-weight: 800; font-size: 1.8cqw;
  padding: .8cqw 2cqw; border-radius: 3cqw; box-shadow: var(--shadow); animation: rise .3s;
}
#warp {
  position: absolute; inset: 0; z-index: 60; pointer-events: none;
  background: repeating-conic-gradient(from 0deg, #ff7a59 0 10deg, #ffcf4a 10deg 20deg, #6c5ce7 20deg 30deg);
  animation: warp 1.1s ease-in-out forwards;
}
@keyframes warp {
  0% { clip-path: circle(0% at 50% 50%); transform: rotate(0); }
  45%, 55% { clip-path: circle(80% at 50% 50%); }
  100% { clip-path: circle(0% at 50% 50%); transform: rotate(160deg); }
}

/* Item reward card */
.reward { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(20,14,36,.6); z-index: 35; }
.reward > div {
  background: var(--paper); border-radius: 2.4cqw; padding: 2cqw 3cqw; text-align: center; width: 44cqw;
  animation: pop-in .5s cubic-bezier(.2,1.6,.4,1); border: .5cqw solid var(--accent-2);
}
.reward .ico { font-size: 9cqw; line-height: 1.1; }
.reward .ico svg { width: 9cqw; }
.reward h4 { font-family: 'Baloo 2'; margin: 0; font-size: 1.5cqw; color: var(--accent); letter-spacing: .1cqw; }
.reward h3 { font-family: 'Baloo 2'; margin: 0; font-size: 3cqw; }
.reward p { font-size: 1.6cqw; margin: .6cqw 0 0; }

/* Mug fading */
.mug-wrap svg { width: 100%; height: auto; }
.mug-solid .steam { display: inline; }
.steam { display: none; }
.steam path { animation: steam 2s infinite; }
.steam path:nth-child(2) { animation-delay: .6s; }
.steam path:nth-child(3) { animation-delay: 1.2s; }
@keyframes steam { 0% { transform: translateY(6px); opacity: 0; } 50% { opacity: .9; } 100% { transform: translateY(-10px); opacity: 0; } }
.flicker { animation: flicker 2.2s infinite; }
@keyframes flicker { 0%, 100% { opacity: var(--o, .3); } 50% { opacity: calc(var(--o, .3) * .5); } }
.restore { animation: restore 2.5s forwards; }
@keyframes restore { 0% { opacity: .3; filter: brightness(3); transform: scale(1); } 60% { transform: scale(1.25); } 100% { opacity: 1; filter: none; transform: scale(1); } }
#decor svg { width: 100%; height: auto; display: block; }
