/* Pixel UI: every window uses a 9-slice frame generated in art.js (--fr-*), flat colors and hard shadows. */
:root {
  --ink: #1c1b2e;
  --cream: #fff4d6;
  --parch: #f4e4c1;
  --parch-d: #e6cf9e;
  --wood: #9a6235;
  --wood-d: #5a3822;
  --rust: #c2471f;
  --orange: #f08a2a;
  --orange-l: #ffb45a;
  --orange-d: #b85a1a;
  --yellow: #ffd84a;
  --green: #5dbb4a;
  --blue: #3d9bff;
  --red: #d63a3a;
  --title: 'Jersey 10', 'Press Start 2P', monospace;
  --pix: 'Pixelify Sans', 'Trebuchet MS', sans-serif;
  --sans: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --o2: 2px 0 0 var(--ink), -2px 0 0 var(--ink), 0 2px 0 var(--ink), 0 -2px 0 var(--ink), 2px 2px 0 var(--ink), -2px 2px 0 var(--ink), 2px -2px 0 var(--ink), -2px -2px 0 var(--ink);
  --o3: 3px 0 0 var(--ink), -3px 0 0 var(--ink), 0 3px 0 var(--ink), 0 -3px 0 var(--ink), 3px 3px 0 var(--ink), -3px 3px 0 var(--ink), 3px -3px 0 var(--ink), -3px -3px 0 var(--ink);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  overflow: hidden; background: #14122a; color: var(--cream);
  font-family: var(--pix); user-select: none; -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent; touch-action: none;
}
button { font: inherit; color: inherit; }
button:focus-visible, a:focus-visible { outline: 3px solid var(--yellow); outline-offset: 2px; }
[hidden] { display: none !important; }
kbd {
  font-family: var(--pix); font-weight: 700; font-size: 12px; line-height: 1; padding: 2px 5px; margin-left: 8px;
  background: var(--cream); color: var(--ink); box-shadow: 0 0 0 2px var(--ink); vertical-align: 2px;
}

#game { position: fixed; inset: 0; display: block; image-rendering: pixelated; }

/* frames */
.fr { border-style: solid; border-color: transparent; image-rendering: pixelated; border-image-repeat: stretch; }
#dialog, .d-choices, .bt-info, .bt-msg, .bt-moves, .bt-moveinfo, .t-menu {
  border: 18px solid transparent; border-image: var(--fr-dialog) 6 fill / 18px stretch; image-rendering: pixelated;
}
#unitframe, #actionbar, #loot, #tooltip, .ach, .panel.slate, .d-name, .b-sub, .lv-tag, .mm-ring, #dialog.narration, #dialog.narration .d-choices {
  border: 18px solid transparent; border-image: var(--fr-ink) 6 fill / 18px stretch; image-rendering: pixelated;
}
.panel.parchment, .zone-sign, .fin-card {
  border: 18px solid transparent; border-image: var(--fr-wood) 6 fill / 18px stretch; image-rendering: pixelated;
}
.d-portrait, .ab-btn, .slot, .uf-portrait-wrap {
  border: 12px solid transparent; border-image: var(--fr-slot) 6 fill / 12px stretch; image-rendering: pixelated;
}
.d-portrait { border-image-source: var(--fr-paper); }
#tooltip, .d-name, .b-sub, .lv-tag, .mm-ring { border-width: 12px; border-image-width: 12px; }

/* buttons */
.btn {
  cursor: pointer; font-family: var(--title); font-size: 26px; line-height: 1; color: var(--ink);
  background: var(--orange); border: 0; padding: 7px 16px 10px; margin: 3px;
  box-shadow: 0 0 0 3px var(--ink), inset 0 3px 0 var(--orange-l), inset 0 -4px 0 var(--orange-d);
}
.btn:hover { background: #ff9c3c; }
.btn:active { transform: translateY(2px); box-shadow: 0 0 0 3px var(--ink), inset 0 -1px 0 var(--orange-d); }
.btn kbd { font-size: 12px; }

/* ---------------- title ---------------- */
#title {
  position: fixed; inset: 0; z-index: 50; display: grid; place-items: center;
  background: rgba(16, 12, 30, .5); box-shadow: inset 0 0 220px rgba(0, 0, 0, .75);
  transition: opacity .7s steps(6);
}
#title.gone { opacity: 0; pointer-events: none; }
.t-inner { text-align: center; padding: 24px; display: flex; flex-direction: column; align-items: center; }
.t-kicker {
  font-family: var(--title); font-size: 24px; letter-spacing: 3px; color: var(--yellow); text-transform: uppercase;
  text-shadow: var(--o2);
}
.t-logo {
  margin: 4px 0 18px; font-family: var(--title); font-weight: 400; line-height: .82;
  display: flex; flex-direction: column; align-items: center; text-transform: uppercase;
  animation: bob 2.4s steps(2) infinite;
}
.t-logo span {
  color: var(--cream); font-size: clamp(76px, 15vw, 168px); letter-spacing: 2px;
  text-shadow: var(--o3), 0 9px 0 var(--rust), 3px 9px 0 var(--ink), -3px 9px 0 var(--ink), 0 13px 0 var(--ink);
}
.t-logo .l2 { color: var(--yellow); font-size: clamp(56px, 11vw, 124px); }
.t-sub { font-family: var(--title); font-size: clamp(26px, 3.4vw, 36px); color: var(--cream); text-shadow: var(--o2); }
.t-role { font-weight: 600; font-size: 16px; color: var(--cream); text-shadow: var(--o2); margin-top: 4px; }
.t-menu { display: flex; flex-direction: column; width: min(380px, 88vw); margin-top: 26px; padding: 4px 0; }
.t-item {
  position: relative; cursor: pointer; text-align: left; background: none; border: 0; color: var(--ink);
  font-weight: 700; font-size: 22px; padding: 7px 12px 7px 38px;
}
.t-item small { font-weight: 500; font-size: 15px; color: #5a6aa0; }
.t-item::before { content: '▶'; position: absolute; left: 12px; color: var(--red); opacity: 0; }
.t-item:hover, .t-item:focus-visible { background: #e3e9f8; outline: none; }
.t-item:hover::before, .t-item:focus-visible::before { opacity: 1; animation: blink 1s steps(1) infinite; }
.t-press { margin-top: 20px; font-family: var(--title); font-size: 26px; color: var(--cream); text-shadow: var(--o2); animation: blink 1.2s steps(1) infinite; }
.t-foot { position: absolute; bottom: 14px; left: 16px; right: 16px; text-align: center; font-size: 14px; font-weight: 600; color: var(--cream); text-shadow: var(--o2); }

/* ---------------- HUD ---------------- */
#hud { position: fixed; inset: 0; pointer-events: none; z-index: 20; }
#hud > * { pointer-events: auto; transition: opacity .3s steps(3); }

#unitframe { position: absolute; top: 10px; left: 10px; display: flex; align-items: center; gap: 12px; padding: 0 4px 0 0; }
.uf-portrait-wrap { position: relative; width: 92px; height: 92px; }
#uf-portrait { width: 68px; height: 68px; image-rendering: pixelated; display: block; background: #6a9ae8; box-shadow: inset 0 -16px 0 #4a7ad0; }
.uf-level {
  position: absolute; left: -16px; bottom: -16px; min-width: 30px; height: 30px; padding: 0 4px;
  display: grid; place-items: center; background: var(--yellow); color: var(--ink);
  font-family: var(--title); font-size: 26px; line-height: 1; box-shadow: 0 0 0 3px var(--ink);
}
.uf-name { font-family: var(--title); font-size: 28px; line-height: .9; color: var(--cream); margin-bottom: 4px; }
.uf-bar { position: relative; width: 170px; height: 16px; margin-top: 5px; background: #120d0b; box-shadow: 0 0 0 2px var(--ink); }
.uf-bar i { position: absolute; inset: 0 auto 0 0; display: block; transition: width .4s steps(8); }
.uf-bar.hp i { background: var(--green); box-shadow: inset 0 3px 0 #8fe07a, inset 0 -3px 0 #3a8a32; }
.uf-bar.coffee i { background: #d0782e; box-shadow: inset 0 3px 0 #f0a860, inset 0 -3px 0 #9a5220; }
.uf-bar span { position: relative; display: block; text-align: center; font-size: 12px; line-height: 16px; font-weight: 700; color: var(--cream); text-shadow: 1px 0 0 var(--ink), -1px 0 0 var(--ink), 0 1px 0 var(--ink), 0 -1px 0 var(--ink); }

#minimap-wrap { position: absolute; top: 6px; right: 10px; width: 180px; text-align: center; }
#zone-name { font-family: var(--title); font-size: 26px; line-height: 1; color: var(--yellow); text-shadow: var(--o2); margin-bottom: 6px; }
.mm-ring { width: 176px; height: 176px; margin: 0 auto; }
#minimap { width: 152px; height: 152px; display: block; cursor: crosshair; image-rendering: pixelated; }

#tracker { position: absolute; top: 228px; right: 14px; width: 260px; text-align: right; }
.tr-head { font-family: var(--title); font-size: 26px; line-height: 1; color: var(--yellow); text-shadow: var(--o2); margin-bottom: 4px; }
.tr-head span { color: var(--cream); margin-left: 6px; }
.tr-item { display: block; width: 100%; text-align: right; cursor: pointer; background: none; border: 0; padding: 3px 0; text-shadow: var(--o2); }
.tr-title { display: block; font-family: var(--title); font-size: 24px; line-height: 1; color: var(--yellow); }
.tr-obj { display: block; font-size: 14px; font-weight: 600; color: var(--cream); }
.tr-item.next .tr-title::before { content: '▶ '; font-size: 16px; vertical-align: 3px; animation: blink 1s steps(1) infinite; }
.tr-item:hover .tr-title { color: #fff; }
.tr-item.done { font-family: var(--title); font-size: 24px; color: #8fe07a; }

.btn-cv {
  position: absolute; top: 16px; left: 50%; transform: translateX(-50%); cursor: pointer;
  font-family: var(--title); font-size: 26px; line-height: 1; color: var(--ink);
  background: var(--cream); border: 0; padding: 6px 16px 9px 34px;
  box-shadow: 0 0 0 3px var(--ink), inset 0 -4px 0 var(--parch-d), 5px 5px 0 3px rgba(0, 0, 0, .35);
}
.btn-cv::before { content: ''; position: absolute; left: 14px; top: 50%; width: 10px; height: 10px; margin-top: -6px; background: #2fbf5a; box-shadow: 0 0 0 2px var(--ink); animation: blink 1.4s steps(1) infinite; }
.btn-cv:hover { background: var(--yellow); box-shadow: 0 0 0 3px var(--ink), inset 0 -4px 0 #e0a82a, 5px 5px 0 3px rgba(0, 0, 0, .35); }

#actionbar { position: absolute; left: 50%; bottom: 24px; transform: translateX(-50%); display: flex; gap: 2px; }
.ab-btn { position: relative; width: 58px; height: 58px; padding: 0; cursor: pointer; background: none; }
.ab-btn:hover, .ab-btn.on { filter: brightness(1.3); }
.ab-btn.on { box-shadow: 0 0 0 3px var(--yellow); }
.ab-btn:active { transform: translateY(2px); }
.ab-icon { position: absolute; inset: 0; background: center / contain no-repeat; image-rendering: pixelated; }
.ab-key { position: absolute; top: -12px; left: -10px; font-family: var(--title); font-size: 18px; line-height: 1; color: var(--cream); text-shadow: var(--o2); }
.ab-count { position: absolute; right: -10px; bottom: -12px; font-family: var(--title); font-size: 18px; line-height: 1; color: var(--cream); text-shadow: var(--o2); }
.ab-label {
  position: absolute; bottom: calc(100% + 22px); left: 50%; transform: translateX(-50%); white-space: nowrap;
  font-family: var(--title); font-size: 22px; line-height: 1; padding: 4px 8px 6px; color: var(--cream);
  background: var(--ink); box-shadow: 0 0 0 2px var(--wood); opacity: 0; pointer-events: none;
}
.ab-btn:hover .ab-label { opacity: 1; }
.ab-btn.off .ab-icon { opacity: .3; }
.ab-btn.off::after { content: ''; position: absolute; left: -2px; right: -2px; top: 50%; height: 4px; margin-top: -2px; background: var(--red); box-shadow: 0 0 0 2px var(--ink); transform: rotate(-40deg); }
.ab-btn.flash { animation: flashSlot 1.2s steps(2); }

#xpbar { position: absolute; left: 0; right: 0; bottom: 0; height: 18px; background: #120d0b; box-shadow: 0 -3px 0 var(--ink); }
#xp-fill { height: 100%; width: 0; background: var(--blue); box-shadow: inset 0 3px 0 #8fd2ff, inset 0 -3px 0 #2766a8; transition: width .25s steps(4); }
.xp-ticks { position: absolute; inset: 0; background: repeating-linear-gradient(90deg, transparent 0 calc(5% - 2px), var(--ink) calc(5% - 2px) 5%); }
#xp-text { position: absolute; inset: 0; text-align: center; font-size: 12px; line-height: 18px; font-weight: 700; color: var(--cream); text-shadow: 1px 0 0 var(--ink), -1px 0 0 var(--ink), 0 1px 0 var(--ink), 0 -1px 0 var(--ink); }

body.dialog-open #actionbar, body.dialog-open #xpbar, body.cutscene #actionbar, body.cutscene #tracker, body.cutscene .btn-cv, body.cutscene #xpbar { opacity: 0; pointer-events: none; }
#bars i { position: fixed; left: 0; right: 0; height: 0; background: #000; z-index: 54; transition: height .45s steps(5); pointer-events: none; }
#bars i:first-child { top: 0; }
#bars i:last-child { bottom: 0; }
body.cutscene #bars i { height: 10vh; }

/* ---------------- intro stage ---------------- */
#stage {
  position: fixed; inset: 0; z-index: 45; display: grid; place-items: center; padding-bottom: 200px;
  opacity: 0; transition: opacity .5s steps(5); pointer-events: none;
  background: rgba(10, 8, 22, .62); box-shadow: inset 0 0 260px rgba(0, 0, 0, .8);
}
#stage.show { opacity: 1; }
#stage canvas { image-rendering: pixelated; display: block; animation: bob 1.6s steps(2) infinite; filter: drop-shadow(0 12px 0 rgba(0, 0, 0, .45)); }

/* ---------------- dialog ---------------- */
#dialog {
  position: fixed; left: 50%; bottom: 100px; transform: translateX(-50%); z-index: 60;
  width: min(780px, calc(100vw - 20px)); min-height: 132px; padding: 8px 16px 10px;
  color: var(--ink); font-size: 23px; line-height: 1.4; font-weight: 500; cursor: pointer;
  filter: drop-shadow(6px 6px 0 rgba(0, 0, 0, .35));
  animation: dlgIn .2s steps(3);
}
#dialog.narration { color: var(--cream); }
#dialog.has-portrait { padding-left: 148px; min-height: 144px; }
.d-portrait { position: absolute; left: -2px; top: 50%; width: 126px; height: 126px; margin-top: -63px; display: none; }
#dialog.has-portrait .d-portrait { display: block; }
.d-portrait canvas { width: 102px; height: 102px; display: block; image-rendering: pixelated; }
.d-name {
  position: absolute; top: -48px; left: -10px; padding: 0 6px 2px;
  font-family: var(--title); font-size: 26px; line-height: 1; color: var(--yellow);
}
.d-text .hl { color: var(--red); font-weight: 700; }
#dialog.narration .d-text .hl { color: var(--yellow); }
.d-next { position: absolute; right: 2px; bottom: -4px; color: var(--red); font-size: 18px; animation: nudge .6s steps(2) infinite; }
#dialog.narration .d-next { color: var(--yellow); }
.d-choices { position: absolute; right: -18px; bottom: calc(100% + 24px); display: flex; flex-direction: column; min-width: 230px; padding: 2px 0; color: var(--ink); }
#dialog.narration .d-choices { color: var(--cream); }
.d-choice { position: relative; text-align: left; background: none; border: 0; padding: 6px 12px 6px 32px; font-size: 21px; font-weight: 700; cursor: pointer; color: inherit; }
.d-choice.sel::before { content: '▶'; position: absolute; left: 8px; color: var(--red); }
.d-choice:hover { background: rgba(90, 106, 160, .16); }

/* ---------------- banners & messages ---------------- */
.banner { position: fixed; top: 15%; left: 0; right: 0; z-index: 55; text-align: center; pointer-events: none; opacity: 0; padding: 0 16px; }
.banner.show { animation: bannerIn 3.4s linear forwards; }
.b-sub { display: inline-block; padding: 0 8px 2px; font-family: var(--title); font-size: clamp(20px, 2.4vw, 28px); line-height: 1.1; color: var(--yellow); letter-spacing: 1px; }
.b-title {
  margin-top: 10px; font-family: var(--title); font-size: clamp(54px, 8.5vw, 110px); line-height: .9; color: var(--cream);
  text-shadow: var(--o3), 0 8px 0 var(--rust), 3px 8px 0 var(--ink), -3px 8px 0 var(--ink), 0 12px 0 var(--ink);
}

.zone-sign {
  position: fixed; top: 116px; left: 10px; z-index: 56; min-width: 240px; padding: 0 18px 4px; text-align: center;
  transform: translateX(-120vw); pointer-events: none; filter: drop-shadow(5px 5px 0 rgba(0, 0, 0, .35));
}
.zone-sign.show { animation: signDrop 2.9s linear forwards; }
.zs-name { font-family: var(--title); font-size: 38px; line-height: 1; color: var(--ink); }
.zs-sub { font-weight: 700; font-size: 15px; color: var(--wood-d); }

.levelup { position: fixed; top: 22%; left: 50%; transform: translateX(-50%); z-index: 56; text-align: center; pointer-events: none; opacity: 0; }
.levelup.show { animation: levelIn 2.6s linear forwards; }
.lv-tag { display: inline-block; padding: 0 8px 2px; font-family: var(--title); font-size: 28px; line-height: 1.1; color: var(--yellow); }
.lv-big {
  font-family: var(--title); font-size: clamp(96px, 13vw, 150px); line-height: .85; color: var(--yellow); white-space: nowrap;
  text-shadow: var(--o3), 0 8px 0 var(--rust), 3px 8px 0 var(--ink), -3px 8px 0 var(--ink), 0 12px 0 var(--ink);
}
.lv-big span { font-size: .45em; color: var(--cream); margin-right: .15em; vertical-align: .55em; }
.lv-sub { margin-top: 10px; font-weight: 700; font-size: 18px; color: var(--cream); text-shadow: var(--o2); }

#sys { position: fixed; top: 62%; left: 0; right: 0; z-index: 57; display: flex; flex-direction: column; align-items: center; gap: 2px; pointer-events: none; }
.sys-msg { font-family: var(--title); font-size: 30px; line-height: 1.1; color: var(--yellow); text-shadow: var(--o2); transition: opacity .6s steps(4); padding: 0 16px; text-align: center; }
.sys-msg.out { opacity: 0; }

#toasts { position: fixed; right: 14px; bottom: 110px; z-index: 62; display: flex; flex-direction: column; gap: 8px; pointer-events: none; }
.ach {
  width: min(430px, 94vw); display: flex; align-items: center; gap: 14px; padding: 0 6px 0 0;
  filter: drop-shadow(6px 6px 0 rgba(0, 0, 0, .35)); animation: toastIn .4s steps(4); transition: opacity .6s steps(4);
}
.ach.out { opacity: 0; }
.ach-shield { position: relative; flex: 0 0 auto; width: 60px; height: 60px; }
.ach-shield img { width: 60px; height: 60px; image-rendering: pixelated; display: block; }
.ach-shield span { position: absolute; inset: 0; display: grid; place-items: center; padding-bottom: 6px; font-family: var(--title); font-size: 24px; color: var(--ink); }
.ach-label { font-family: var(--title); font-size: 22px; line-height: 1; color: var(--yellow); }
.ach-name { font-weight: 700; font-size: 19px; color: var(--cream); }
.ach-desc { font-size: 14px; color: #d9c9b0; }

/* ---------------- items ---------------- */
.icon {
  position: relative; width: 46px; height: 46px; flex: 0 0 auto; display: inline-grid; place-items: center;
  background: #231a16; border: 3px solid var(--rc); box-shadow: 0 0 0 2px var(--ink); cursor: help;
}
.icon img { width: 36px; height: 36px; image-rendering: pixelated; }
.icon.glyph { background: var(--ic); box-shadow: 0 0 0 2px var(--ink), inset 0 3px 0 rgba(255, 255, 255, .28), inset 0 -4px 0 rgba(0, 0, 0, .3); }
.icon.glyph b { font-family: var(--title); font-weight: 400; font-size: 24px; line-height: 1; color: #fff; text-shadow: 2px 2px 0 rgba(0, 0, 0, .55); }
.icon.glyph b.len3 { font-size: 19px; }
.icon.sm { width: 38px; height: 38px; }
.icon.sm img { width: 28px; height: 28px; }
.icon.r-legendary { animation: legend 1.2s steps(1) infinite; }

#tooltip { position: fixed; z-index: 200; max-width: 320px; padding: 2px 6px; pointer-events: none; font-size: 15px; line-height: 1.35; color: var(--cream); filter: drop-shadow(5px 5px 0 rgba(0, 0, 0, .4)); }
.tt-name { font-weight: 700; font-size: 17px; }
.tt-row { display: flex; justify-content: space-between; gap: 18px; margin-bottom: 2px; }
.tt-use { color: #5dff4a; margin-top: 4px; }
.tt-flavor { color: var(--yellow); margin-top: 4px; }
.tt-bind { color: #a89a8a; font-size: 13px; margin-top: 4px; }

#loot {
  position: fixed; left: 50%; top: 46%; transform: translate(-50%, -50%); z-index: 65; width: min(380px, 94vw);
  padding: 0 2px; filter: drop-shadow(6px 6px 0 rgba(0, 0, 0, .4)); animation: popIn .2s steps(3);
}
.loot-head { display: flex; justify-content: space-between; align-items: baseline; padding: 0 2px 8px; }
.loot-head span { font-family: var(--title); font-size: 34px; line-height: 1; color: var(--yellow); }
.loot-head small { font-weight: 600; color: #d9c9b0; }
.loot-list { display: flex; flex-direction: column; gap: 6px; max-height: 50vh; overflow: auto; padding: 3px; }
.loot-row { display: flex; align-items: center; gap: 12px; padding: 6px 8px 6px 6px; background: #3a2c25; box-shadow: inset 0 -3px 0 #2a201c; animation: rowIn .25s steps(3) backwards; }
.loot-name { font-weight: 700; font-size: 17px; }
#loot .btn { width: calc(100% - 6px); margin-top: 14px; }

/* ---------------- panels ---------------- */
.panel {
  position: fixed; left: 50%; top: 50%; transform: translate(-50%, -50%); z-index: 70;
  width: min(860px, 96vw); max-height: 84vh; display: flex; flex-direction: column;
  filter: drop-shadow(8px 8px 0 rgba(0, 0, 0, .4)); animation: popIn .2s steps(3);
}
.panel-head { display: flex; justify-content: space-between; align-items: center; padding: 0 0 8px 4px; }
.panel-head h2 { margin: 0; font-family: var(--title); font-weight: 400; font-size: 38px; line-height: 1; }
.parchment { color: #3a2a14; }
.parchment .panel-head h2 { color: var(--ink); }
.slate .panel-head h2 { color: var(--yellow); }
.panel-close {
  cursor: pointer; width: 34px; height: 34px; padding: 0 0 4px; border: 0; background: var(--red); color: var(--cream);
  font-family: var(--title); font-size: 26px; line-height: 1; box-shadow: 0 0 0 3px var(--ink), inset 0 -4px 0 #8a2020;
}
.panel-close:hover { background: #ee4a4a; }
.panel-body { overflow: auto; padding: 4px; }

#panel-quests .panel-body { display: grid; grid-template-columns: minmax(250px, 310px) 1fr; gap: 18px; }
.q-list { display: flex; flex-direction: column; gap: 6px; padding: 3px; }
.q-item {
  display: grid; grid-template-columns: 22px 1fr auto; align-items: center; gap: 8px; padding: 6px 9px; text-align: left; cursor: pointer;
  background: var(--parch-d); border: 0; color: inherit; box-shadow: inset 0 -3px 0 #d0b47e;
}
.q-item:hover { background: #efdcb0; }
.q-item.sel { background: var(--cream); box-shadow: 0 0 0 3px var(--ink), inset 0 -3px 0 var(--parch-d); }
.q-mark { font-family: var(--title); font-size: 28px; line-height: 1; color: var(--orange); text-align: center; }
.q-item.done .q-mark { color: #2f8a3a; }
.q-txt { display: flex; flex-direction: column; }
.q-label { font-size: 13px; font-weight: 600; color: #8a6a3a; }
.q-title { font-weight: 700; font-size: 16px; }
.q-years { font-family: var(--title); font-size: 20px; color: #8a5a34; white-space: nowrap; }
.q-detail h3 { margin: 2px 0 8px; font-family: var(--title); font-weight: 400; font-size: 44px; line-height: .95; color: var(--ink); }
.q-chapter { font-weight: 700; font-size: 15px; color: var(--rust); }
.q-detail p { font-size: 18px; line-height: 1.45; margin: 0 0 14px; user-select: text; }
.q-obj { font-weight: 700; margin-bottom: 14px; }
.q-obj.ok { color: #2f7a3a; }
.q-rew-title { font-family: var(--title); font-size: 26px; color: var(--ink); margin-bottom: 8px; }
.q-rewards { display: flex; flex-wrap: wrap; gap: 10px; margin: 0 0 12px 2px; }
.q-xp { font-family: var(--title); font-size: 24px; color: #2766a8; margin-bottom: 10px; }

.slate { color: var(--cream); }
.bag-grid { display: grid; grid-template-columns: repeat(auto-fill, 74px); gap: 2px; justify-content: center; }
.slot { width: 74px; height: 74px; display: grid; place-items: center; }
.bag-foot { text-align: center; font-size: 14px; font-weight: 600; color: #b8a890; margin: 12px 0 16px; }
.ach-title { font-family: var(--title); font-size: 30px; line-height: 1; color: var(--yellow); margin-bottom: 10px; }
.ach-title span { font-family: var(--pix); font-weight: 600; font-size: 15px; color: #d9c9b0; margin-left: 8px; }
.ach-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 8px; padding: 3px; }
.ach-cell { display: flex; align-items: center; gap: 10px; padding: 7px 9px; background: #3a2c25; box-shadow: 0 0 0 2px var(--ink); font-weight: 700; font-size: 15px; opacity: .45; }
.ach-cell.got { opacity: 1; box-shadow: 0 0 0 2px var(--ink), inset 4px 0 0 var(--yellow); }
.ach-pts { font-family: var(--title); font-size: 20px; line-height: 1; color: var(--ink); background: var(--yellow); padding: 3px 5px 4px; box-shadow: 0 0 0 2px var(--ink); }

#panel-project { position: fixed; left: 50%; top: 50%; transform: translate(-50%, -50%); z-index: 72; width: min(600px, 94vw); animation: popIn .2s steps(3); }
.proj-screen {
  position: relative; overflow: hidden; padding: 18px 22px 20px; background: #0b1a24; color: #cdf9ff;
  box-shadow: 0 0 0 4px #41f0ff, 0 0 0 8px #2b3445, 0 0 0 11px var(--ink), 10px 10px 0 11px rgba(0, 0, 0, .4);
}
.proj-screen::after { content: ''; position: absolute; inset: 0; pointer-events: none; background: repeating-linear-gradient(0deg, rgba(0, 0, 0, .22) 0 2px, transparent 2px 4px); }
.proj-top { display: flex; justify-content: space-between; font-family: var(--title); font-size: 20px; color: #41f0ff; }
.proj-screen h3 { font-family: var(--title); font-weight: 400; font-size: 42px; line-height: .95; color: #41f0ff; margin: 12px 0 10px; }
.proj-screen p { font-size: 18px; line-height: 1.5; margin: 0 0 14px; user-select: text; }
.tags { display: flex; flex-wrap: wrap; gap: 8px; }
.tags span { font-weight: 700; font-size: 14px; padding: 2px 8px 3px; color: #0b1a24; background: #41f0ff; }
.proj-note { font-size: 14px; color: #8fb8c8; margin-top: 16px; }
.btn-cyan { cursor: pointer; margin-top: 18px; font-family: var(--title); font-size: 24px; line-height: 1; padding: 6px 14px 8px; border: 0; background: #41f0ff; color: #0b1a24; box-shadow: inset 0 -4px 0 #1fa8b8; }

/* ---------------- battle ---------------- */
#battle { position: fixed; inset: 0; z-index: 90; background: #000; overflow: hidden; }
.battle .bt-scene, .battle .bt-bottom { transition: opacity .3s steps(3); }
.battle.intro .bt-scene, .battle.intro .bt-bottom { opacity: 0; }
.battle.intro::before { content: ''; position: absolute; inset: 0; z-index: 5; background: #fff; animation: battleFlash 1.3s steps(1) forwards; }
.battle.outro { opacity: 0; transition: opacity .5s steps(5); }
.battle.flashfx::after { content: ''; position: absolute; inset: 0; background: #fff; animation: flashOnce .5s steps(4) forwards; pointer-events: none; }
.bt-scene {
  position: absolute; left: 0; right: 0; top: 0; bottom: 176px;
  background: linear-gradient(#8ccaf4 0 12%, #a2d6f7 12% 24%, #b8e1fa 24% 36%, #cdebfc 36% 46%, #a8dc8a 46% 58%, #96d078 58% 74%, #86c46a 74%);
}
.bt-plat { position: absolute; border-radius: 50%; background: #c4e6a0; box-shadow: inset 0 -8px 0 #8cc46a, 0 0 0 3px #6aa850; }
.bt-plat-e { right: 9%; top: 40%; width: min(320px, 38vw); height: 70px; }
.bt-plat-p { left: 5%; bottom: 4%; width: min(380px, 44vw); height: 80px; }
.bt-spr { position: absolute; }
.bt-spr canvas { display: block; image-rendering: pixelated; }
.bt-enemy { right: calc(9% + min(320px, 38vw) / 2); top: calc(40% + 35px); transform: translate(50%, -100%); animation: slideInR .7s steps(7); transition: transform .18s, opacity .6s steps(4); }
.bt-enemy canvas { width: min(168px, 26vw); height: auto; }
.bt-enemy canvas.f1 { display: none; }
.bt-enemy.alt canvas.f0 { display: none; }
.bt-enemy.alt canvas.f1 { display: block; }
.bt-player { left: calc(5% + min(380px, 44vw) / 2); bottom: calc(4% + 30px); transform: translateX(-50%); animation: slideInL .7s steps(7); transition: transform .18s; }
.bt-player canvas { width: min(168px, 26vw); height: auto; }
.bt-player.lunge { transform: translate(-30%, -8%); }
.bt-enemy.lunge-e { transform: translate(30%, -90%); }
.bt-enemy.faint { transform: translate(50%, -40%); opacity: 0; }
.bt-spr.hit { animation: hitBlink .5s steps(2) 1; }
.bt-info { position: absolute; min-width: min(320px, 46vw); padding: 0 6px 2px; color: var(--ink); filter: drop-shadow(6px 6px 0 rgba(28, 27, 46, .3)); }
.bt-enemy-info { left: 5%; top: 8%; }
.bt-player-info { right: 5%; bottom: 9%; }
.bt-name { font-family: var(--title); font-size: 30px; line-height: 1; display: flex; justify-content: space-between; gap: 14px; }
.bt-hp { display: flex; align-items: center; gap: 8px; margin-top: 6px; }
.bt-hp em { font-style: normal; font-family: var(--title); font-size: 18px; line-height: 1; color: var(--yellow); background: var(--ink); padding: 1px 5px 3px; }
.bt-bar { flex: 1; height: 12px; background: #4a4a5a; box-shadow: 0 0 0 3px var(--ink); }
.bt-bar i { display: block; height: 100%; width: 100%; background: #58d068; box-shadow: inset 0 3px 0 #9cf0a8; transition: width .7s steps(10); }
.bt-bar i.mid { background: #f0c030; box-shadow: inset 0 3px 0 #ffe080; }
.bt-bar i.low { background: #e84838; box-shadow: inset 0 3px 0 #ff9080; }
.bt-num { text-align: right; font-family: var(--title); font-size: 26px; line-height: 1; margin-top: 4px; }
.bt-bottom { position: absolute; left: 0; right: 0; bottom: 0; height: 176px; padding: 10px; display: flex; gap: 6px; background: var(--ink); }
.bt-msg { position: relative; flex: 1; padding: 6px 14px; font-size: 25px; font-weight: 600; line-height: 1.35; cursor: pointer; color: var(--ink); }
.bt-next { position: absolute; right: 2px; bottom: -4px; color: var(--red); animation: nudge .6s steps(2) infinite; }
.bt-moves { width: min(470px, 52%); display: grid; grid-template-columns: 1fr 1fr; gap: 2px; padding: 0 4px; }
.bt-move { position: relative; text-align: left; background: none; border: 0; padding: 6px 8px 6px 30px; font-family: var(--title); font-size: 26px; line-height: 1; color: var(--ink); cursor: pointer; }
.bt-move.sel::before { content: '▶'; position: absolute; left: 8px; top: 9px; font-family: var(--pix); font-size: 16px; color: var(--red); }
.bt-move.sel { background: #e3e9f8; }
.bt-move.super { color: #0a8a7a; }
.bt-moveinfo { width: 180px; padding: 4px 10px; color: var(--ink); font-family: var(--title); font-size: 24px; line-height: 1.1; display: flex; flex-direction: column; justify-content: center; gap: 6px; }
.bt-moveinfo b { font-weight: 400; color: var(--rust); }

/* ---------------- recruiter ---------------- */
#recruiter { position: fixed; inset: 0; z-index: 120; overflow: auto; background: #fbf5e6; color: var(--ink); font-family: var(--sans); user-select: text; touch-action: pan-y; animation: fadeIn .2s steps(3); }
.rc-wrap { max-width: 960px; margin: 0 auto; padding: 0 22px 64px; }
.rc-bar { position: sticky; top: 0; z-index: 2; display: flex; justify-content: space-between; align-items: center; gap: 12px; margin: 0 -22px; padding: 10px 22px; background: var(--ink); color: var(--cream); font-family: var(--title); font-size: 22px; }
.rc-close { cursor: pointer; font-family: var(--title); font-size: 22px; line-height: 1; padding: 5px 12px 7px; border: 0; background: var(--yellow); color: var(--ink); box-shadow: inset 0 -3px 0 #d0a020; white-space: nowrap; }
.rc-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-end; gap: 18px; padding: 36px 0 18px; border-bottom: 3px solid var(--ink); }
.rc-head h1 { margin: 0; font-family: var(--title); font-weight: 400; font-size: clamp(56px, 9vw, 96px); line-height: .85; }
.rc-role { margin: 8px 0 6px; font-size: 19px; font-weight: 700; color: var(--rust); }
.rc-loc { margin: 0; color: #4a4860; font-size: 15px; }
.rc-loc a { color: inherit; }
.rc-actions { display: flex; gap: 12px; flex-wrap: wrap; }
.rc-btn {
  display: inline-flex; align-items: center; padding: 9px 16px; color: var(--ink); text-decoration: none; font-family: var(--sans); font-weight: 800; font-size: 15px;
  background: #fff; border: 3px solid var(--ink); box-shadow: 4px 4px 0 var(--ink); transition: transform .08s, box-shadow .08s;
}
.rc-btn.primary { background: var(--orange); }
.rc-btn:hover { transform: translate(-1px, -1px); box-shadow: 5px 5px 0 var(--ink); }
.rc-btn:active { transform: translate(3px, 3px); box-shadow: 1px 1px 0 var(--ink); }
#recruiter section { margin-top: 34px; }
#recruiter h2 { display: flex; align-items: center; gap: 10px; font-family: var(--title); font-weight: 400; font-size: 34px; line-height: 1; margin: 0 0 12px; }
#recruiter h2::before { content: ''; width: 14px; height: 14px; background: var(--orange); box-shadow: 0 0 0 3px var(--ink); }
#recruiter h3 { margin: 0 0 4px; font-size: 17px; font-weight: 800; }
#recruiter p { margin: 0 0 6px; line-height: 1.6; font-size: 15.5px; }
.rc-muted { color: #5c5a72; }
.rc-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 16px; margin-top: 12px; }
.rc-cards article { background: #fff; border: 3px solid var(--ink); box-shadow: 6px 6px 0 var(--ink); padding: 16px; }
.rc-timeline { list-style: none; margin: 0; padding: 0; }
.rc-timeline li { display: grid; grid-template-columns: 170px 1fr; gap: 16px; padding: 14px 0; border-bottom: 2px dashed #d8ccb0; }
.rc-years { font-family: var(--title); font-size: 26px; line-height: 1; color: var(--rust); }
.rc-skill { margin-bottom: 14px; }
.rc-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.rc-chips span { background: #fff; border: 2px solid var(--ink); padding: 3px 10px; font-size: 14px; font-weight: 600; }
.rc-edu { list-style: none; margin: 0; padding: 0; }
.rc-edu li { display: flex; flex-direction: column; padding: 10px 0; border-bottom: 2px dashed #d8ccb0; }
.rc-edu span { color: #5c5a72; font-size: 14px; }
.rc-foot { margin-top: 40px; font-size: 13px; color: #6a6880; text-align: center; }

/* ---------------- final ---------------- */
#final { position: fixed; inset: 0; z-index: 110; display: grid; place-items: center; padding: 16px; background: rgba(16, 12, 30, .72); animation: fadeIn .3s steps(3); }
.fin-card { width: min(680px, 96vw); max-height: 94vh; overflow: auto; text-align: center; padding: 6px 10px 10px; color: #3a2a14; filter: drop-shadow(10px 10px 0 rgba(0, 0, 0, .45)); animation: popIn .3s steps(4); }
.fin-kicker { font-family: var(--title); font-size: 26px; color: var(--rust); }
.fin-card h2 {
  margin: 4px 0 18px; font-family: var(--title); font-weight: 400; font-size: clamp(56px, 9vw, 84px); line-height: .9; color: var(--yellow);
  text-shadow: var(--o3), 0 7px 0 var(--rust), 3px 7px 0 var(--ink), -3px 7px 0 var(--ink), 0 10px 0 var(--ink);
}
.fin-stats { display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; margin: 0 4px 18px; }
.fin-stats div { background: var(--cream); box-shadow: 0 0 0 3px var(--ink), inset 0 -4px 0 var(--parch-d); padding: 8px 4px 10px; }
.fin-stats b { display: block; font-family: var(--title); font-weight: 400; font-size: 40px; line-height: 1; color: var(--rust); }
.fin-stats span { font-weight: 700; font-size: 13px; }
.fin-text { font-size: 19px; line-height: 1.45; margin: 0 0 18px; user-select: text; }
.fin-contact { display: flex; flex-wrap: wrap; justify-content: center; gap: 14px; }
.fin-mail { margin-top: 14px; font-weight: 700; font-size: 16px; user-select: text; }
.fin-actions { display: flex; justify-content: center; gap: 14px; margin-top: 16px; flex-wrap: wrap; }
.btn-ghost { cursor: pointer; font-family: var(--title); font-size: 24px; line-height: 1; padding: 5px 14px 7px; background: transparent; color: var(--ink); border: 3px solid var(--ink); }
.btn-ghost:hover { background: var(--cream); }

/* ---------------- touch ---------------- */
#touch { position: fixed; left: 0; right: 0; bottom: 36px; height: 170px; z-index: 30; pointer-events: none; }
.dpad { position: absolute; left: 16px; bottom: 34px; width: 156px; height: 156px; display: grid; grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(3, 1fr); }
.dpad button { pointer-events: auto; position: relative; margin: 3px; background: rgba(28, 27, 46, .72); border: 0; box-shadow: 0 0 0 3px var(--ink), inset 0 -4px 0 rgba(0, 0, 0, .4); touch-action: none; }
.dpad button.on { background: var(--orange); }
.dpad button::after { content: ''; position: absolute; left: 50%; top: 50%; border: 9px solid transparent; transform: translate(-50%, -50%); }
.dpad [data-d=up] { grid-area: 1 / 2; }
.dpad [data-d=left] { grid-area: 2 / 1; }
.dpad [data-d=right] { grid-area: 2 / 3; }
.dpad [data-d=down] { grid-area: 3 / 2; }
.dpad [data-d=up]::after { border-bottom-color: var(--cream); margin-top: -4px; }
.dpad [data-d=down]::after { border-top-color: var(--cream); margin-top: 4px; }
.dpad [data-d=left]::after { border-right-color: var(--cream); margin-left: -4px; }
.dpad [data-d=right]::after { border-left-color: var(--cream); margin-left: 4px; }
.btn-a { pointer-events: auto; position: absolute; right: 22px; bottom: 60px; width: 78px; height: 78px; border-radius: 50%; background: var(--red); border: 0; color: var(--cream); font-family: var(--title); font-size: 38px; box-shadow: 0 0 0 4px var(--ink), inset 0 -6px 0 #8a2020, inset 0 4px 0 #f06a6a; touch-action: none; }
.btn-a:active { transform: translateY(3px); }

#fade { position: fixed; inset: 0; z-index: 300; background: #000; opacity: 0; pointer-events: none; }

/* ---------------- responsive ---------------- */
@media (max-width: 1000px) { #tracker { display: none; } }
@media (max-width: 700px) {
  #unitframe { transform: scale(.72); transform-origin: top left; top: 6px; left: 6px; }
  .uf-bar { width: 130px; }
  #minimap-wrap { width: 124px; top: 4px; right: 6px; }
  .mm-ring { width: 124px; height: 124px; }
  #minimap { width: 100px; height: 100px; }
  #zone-name { font-size: 20px; }
  .btn-cv { top: 100px; left: 10px; transform: none; font-size: 20px; }
  #actionbar { bottom: 22px; }
  .ab-btn { width: 50px; height: 50px; }
  #dialog { font-size: 18px; min-height: 112px; }
  #dialog.has-portrait { padding-left: 100px; min-height: 120px; }
  .d-portrait { width: 92px; height: 92px; margin-top: -46px; }
  .d-portrait canvas { width: 68px; height: 68px; }
  .d-choice { font-size: 17px; }
  #panel-quests .panel-body { grid-template-columns: 1fr; }
  .rc-timeline li { grid-template-columns: 1fr; gap: 4px; }
  .fin-stats { grid-template-columns: repeat(3, 1fr); }
  .bt-bottom { flex-direction: column; height: 236px; }
  .bt-scene { bottom: 236px; }
  .bt-moves { width: 100%; }
  .bt-moveinfo { display: none !important; }
  .bt-msg { font-size: 18px; }
  .bt-name { font-size: 22px; }
  .bt-move { font-size: 21px; }
  .zone-sign { top: 146px; left: 6px; }
}
@media (pointer: coarse) {
  #dialog { bottom: 214px; }
  #actionbar { left: auto; right: 8px; transform: none; bottom: auto; top: 150px; flex-direction: column; }
  .ab-btn { width: 48px; height: 48px; }
  body #interior { place-items: start center; padding-top: 18vh; }
}

/* ---------------- animations (stepped, like sprite animation) ---------------- */
@keyframes bob { 50% { transform: translateY(-6px); } }
@keyframes blink { 50% { opacity: 0; } }
@keyframes nudge { 50% { transform: translateY(4px); } }
@keyframes popIn { from { opacity: 0; transform: translate(-50%, -46%); } }
.fin-card { animation-name: popCard; }
@keyframes popCard { from { opacity: 0; transform: translateY(24px); } }
@keyframes dlgIn { from { opacity: 0; transform: translate(-50%, 16px); } }
@keyframes fadeIn { from { opacity: 0; } }
@keyframes toastIn { from { opacity: 0; transform: translateY(-30px); } }
@keyframes rowIn { from { opacity: 0; transform: translateX(-12px); } }
@keyframes flashSlot { 50% { filter: brightness(2); } }
@keyframes legend { 50% { border-color: var(--yellow); } }
@keyframes bannerIn {
  0% { opacity: 0; transform: translateY(-24px); }
  4% { opacity: 1; transform: translateY(6px); }
  8% { transform: translateY(0); }
  82% { opacity: 1; }
  86% { opacity: .5; }
  90%, 100% { opacity: 0; }
}
@keyframes signDrop {
  0% { transform: translateX(-110%); }
  10% { transform: translateX(10px); }
  14%, 82% { transform: translateX(0); }
  100% { transform: translateX(-110%); }
}
@keyframes levelIn {
  0% { opacity: 0; transform: translateX(-50%) scale(.5); }
  5% { opacity: 1; transform: translateX(-50%) scale(1.15); }
  10% { transform: translateX(-50%) scale(1); }
  80% { opacity: 1; transform: translateX(-50%); }
  88% { opacity: .5; }
  100% { opacity: 0; transform: translateX(-50%) translateY(-24px); }
}
@keyframes battleFlash { 0% { opacity: 1; } 12% { opacity: 0; } 24% { opacity: 1; } 36% { opacity: 0; } 48% { opacity: 1; } 60% { opacity: 0; background: #000; } 100% { opacity: 1; background: #000; } }
@keyframes flashOnce { from { opacity: .9; } to { opacity: 0; } }
@keyframes hitBlink { 50% { opacity: 0; } }
@keyframes slideInR { from { opacity: 0; translate: 60vw 0; } }
@keyframes slideInL { from { opacity: 0; translate: -60vw 0; } }

@media (prefers-reduced-motion: reduce) {
  .t-logo, #stage canvas, .t-press, .tr-item.next .tr-title::before { animation: none; }
}

/* ---------------- Sergio's portrait ---------------- */
#stage canvas.hero { border: 18px solid transparent; border-image: var(--fr-paper) 6 fill / 18px stretch; background: #6a9ae8; box-shadow: inset 0 -60px 0 #4a7ad0; }
.rc-id { display: flex; align-items: flex-end; gap: 18px; }
.rc-avatar canvas { display: block; width: 136px; height: 136px; image-rendering: pixelated; background: var(--orange); box-shadow: 0 0 0 3px var(--ink), 6px 6px 0 3px var(--ink); }
.fin-avatar { display: flex; justify-content: center; margin: 6px 0 4px; }
.fin-avatar canvas { width: 136px; height: 136px; image-rendering: pixelated; background: #6a9ae8; box-shadow: 0 0 0 3px var(--ink), inset 0 -40px 0 #4a7ad0; animation: bob 1.6s steps(2) infinite; }
@media (max-width: 700px) { .rc-avatar canvas { width: 96px; height: 96px; } .rc-id { flex-wrap: wrap; } }

/* ---------------- interiors & transitions ---------------- */
#interior { position: fixed; inset: 0; z-index: 53; display: grid; place-items: center; background: #0c0a16; }
#interior canvas { display: block; image-rendering: pixelated; box-shadow: 0 0 0 4px var(--ink); }
#wipe { position: fixed; inset: 0; z-index: 299; width: 100%; height: 100%; image-rendering: pixelated; pointer-events: none; }

/* ---------------- minigames ---------------- */
#minigame { position: fixed; inset: 0; z-index: 64; display: grid; place-items: center; padding: 12px; background: rgba(12, 10, 22, .55); }
.mg-card {
  position: relative; width: min(720px, 96vw); max-height: 94vh; overflow: auto; padding: 0 8px 6px; color: #3a2a14;
  border: 18px solid transparent; border-image: var(--fr-wood) 6 fill / 18px stretch; image-rendering: pixelated;
  filter: drop-shadow(8px 8px 0 rgba(0, 0, 0, .4)); animation: popCard .25s steps(3);
}
.mg-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.mg-kicker { font-family: var(--title); font-size: 22px; line-height: 1; color: var(--rust); }
.mg-head h3 { margin: 0; font-family: var(--title); font-weight: 400; font-size: 44px; line-height: .95; color: var(--ink); }
.mg-skip { cursor: pointer; font-family: var(--title); font-size: 22px; line-height: 1; padding: 4px 10px 6px; background: transparent; color: var(--ink); border: 3px solid var(--ink); }
.mg-skip:hover { background: var(--cream); }
.mg-skip kbd { font-size: 10px; }
.mg-timer { height: 14px; margin: 10px 0; background: #3a2c25; box-shadow: 0 0 0 3px var(--ink); }
.mg-timer i { display: block; height: 100%; width: 100%; background: var(--green); box-shadow: inset 0 3px 0 #8fe07a; }
.mg-timer i.low { background: var(--red); box-shadow: inset 0 3px 0 #f06a6a; animation: blink .4s steps(1) infinite; }
.mg-hint { margin: 0 0 12px; font-size: 17px; font-weight: 600; line-height: 1.35; }
.mg-status { min-height: 26px; margin-top: 12px; font-family: var(--title); font-size: 26px; line-height: 1; color: var(--rust); text-align: center; }
.mg-result {
  position: absolute; inset: 0; display: grid; place-items: center; text-align: center; padding: 20px;
  font-family: var(--title); font-size: clamp(44px, 8vw, 72px); line-height: .95; color: var(--yellow);
  text-shadow: var(--o3), 0 6px 0 var(--rust), 0 9px 0 var(--ink); background: rgba(244, 228, 193, .82); animation: popCard .25s steps(3);
}
.mg-result.lose { color: var(--cream); }
.shake { animation: shake .35s steps(4); }
@keyframes shake { 25% { transform: translateX(-5px); } 75% { transform: translateX(5px); } }

.mg-repair { display: grid; grid-template-columns: 1fr 1.4fr; gap: 14px; }
.mg-device, .mg-tray { display: flex; flex-wrap: wrap; gap: 10px; align-content: flex-start; padding: 12px; background: #2a201c; box-shadow: 0 0 0 3px var(--ink), inset 0 0 0 3px #3e302a; }
.mg-tray { background: #e6cf9e; box-shadow: 0 0 0 3px var(--ink), inset 0 -4px 0 #d0b47e; }
.mg-device-title { width: 100%; font-family: var(--title); font-size: 22px; line-height: 1; color: var(--cream); }
.mg-tray .mg-device-title { color: var(--ink); }
.mg-slot, .mg-part {
  width: 76px; height: 82px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; cursor: pointer;
  background: #3a2c25; border: 0; color: var(--cream); box-shadow: 0 0 0 3px var(--ink), inset 0 -4px 0 #231a16;
}
.mg-part { background: var(--cream); color: var(--ink); box-shadow: 0 0 0 3px var(--ink), inset 0 -4px 0 var(--parch-d); }
.mg-slot img, .mg-part img { width: 42px; height: 42px; image-rendering: pixelated; }
.mg-slot small, .mg-part small { font-size: 12px; font-weight: 700; }
.mg-broken { font-family: var(--title); font-size: 40px; line-height: 1; color: var(--red); }
.mg-slot.ok { background: #2f6a3a; box-shadow: 0 0 0 3px var(--ink), inset 0 -4px 0 #1f4a28; }
.mg-part.sel { background: var(--yellow); transform: translateY(-4px); }
.mg-part.used { opacity: .25; cursor: default; }

.mg-shop { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.mg-product {
  position: relative; height: 112px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; cursor: pointer;
  background: #fbf5e6; border: 0; color: var(--ink); box-shadow: 0 0 0 3px var(--ink), inset 0 -4px 0 var(--parch-d);
}
.mg-product small { font-weight: 700; }
.mg-tee { width: 52px; height: 46px; background: var(--c); clip-path: polygon(30% 0, 70% 0, 100% 22%, 86% 40%, 78% 34%, 78% 100%, 22% 100%, 22% 34%, 14% 40%, 0 22%); }
.mg-err { position: absolute; inset: 0; display: none; place-items: center; font-family: var(--title); font-size: 30px; color: var(--cream); background: var(--red); box-shadow: inset 0 -5px 0 #8a2020; }
.mg-product.broken .mg-err { display: grid; animation: shake .3s steps(3) infinite; }
.mg-product.fixed { background: #b8f0a8; }

.mg-tickets { display: flex; flex-direction: column; gap: 14px; }
.mg-ticket { position: relative; min-height: 110px; padding: 12px 16px; background: #fffdf5; box-shadow: 0 0 0 3px var(--ink), 6px 6px 0 3px rgba(0, 0, 0, .25); }
.mg-ticket.in { animation: rowIn .2s steps(3); }
.mg-ticket.right { background: #d8f5cf; }
.mg-ticket.wrong { background: #fbd5d0; }
.mg-ticket-top { display: flex; justify-content: space-between; font-family: var(--title); font-size: 20px; color: #8a6a3a; }
.mg-ticket-text { margin-top: 6px; font-weight: 700; font-size: 22px; line-height: 1.25; }
.mg-verdict { position: absolute; right: 12px; bottom: 8px; font-family: var(--title); font-size: 26px; color: var(--ink); }
.mg-pri { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.mg-btn { cursor: pointer; font-family: var(--title); font-size: 24px; line-height: 1; padding: 10px 6px 12px; border: 0; color: var(--ink); box-shadow: 0 0 0 3px var(--ink), inset 0 -4px 0 rgba(0, 0, 0, .25); }
.mg-btn kbd { margin: 0 6px 0 0; font-size: 11px; }
.mg-btn.p0 { background: #f0705a; }
.mg-btn.p1 { background: var(--yellow); }
.mg-btn.p2 { background: #8fd2ff; }
.mg-btn:hover { filter: brightness(1.1); }
.mg-btn:active { transform: translateY(2px); }

.mg-flow { display: flex; flex-direction: column; gap: 18px; }
.mg-line { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.mg-spot { min-height: 70px; padding: 6px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; text-align: center; font-weight: 700; font-size: 13px; background: #e6cf9e; box-shadow: inset 0 0 0 3px #c9a96e; }
.mg-spot b { font-family: var(--title); font-weight: 400; font-size: 28px; line-height: 1; color: #a08050; }
.mg-spot.ok { background: #2f6a3a; color: var(--cream); box-shadow: 0 0 0 3px var(--ink); }
.mg-spot.ok b { color: var(--yellow); }
.mg-cards { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; }
.mg-step { cursor: pointer; font-weight: 700; font-size: 17px; padding: 12px 16px; border: 0; background: #41f0ff; color: #0b1a24; box-shadow: 0 0 0 3px var(--ink), inset 0 -4px 0 #1fa8b8; }
.mg-step:hover { background: #8ff6ff; }
.mg-step.used { opacity: .2; cursor: default; }

@media (max-width: 700px) {
  .mg-head h3 { font-size: 34px; }
  .mg-repair { grid-template-columns: 1fr; }
  .mg-slot, .mg-part { width: 64px; height: 74px; }
  .mg-shop { grid-template-columns: repeat(2, 1fr); }
  .mg-product { height: 92px; }
  .mg-line { grid-template-columns: repeat(5, 1fr); gap: 4px; }
  .mg-spot { font-size: 10px; min-height: 60px; }
  .mg-btn { font-size: 18px; }
}

.fin-best { margin: -8px 0 12px; font-family: var(--title); font-size: 26px; color: var(--rust); }

/* ---------------- guestbook ---------------- */
#panel-guestbook { z-index: 115; }
.gb-body { display: grid; grid-template-columns: minmax(240px, 300px) 1fr; gap: 18px; user-select: text; touch-action: auto; }
.gb-form { display: flex; flex-direction: column; gap: 10px; }
.gb-intro { margin: 0; font-weight: 700; font-size: 16px; }
.gb-form label { display: flex; flex-direction: column; gap: 4px; font-family: var(--title); font-size: 22px; line-height: 1; color: var(--ink); }
.gb-form input, .gb-form textarea {
  font-family: var(--pix); font-size: 17px; padding: 8px 10px; color: var(--ink); background: var(--cream);
  border: 0; box-shadow: 0 0 0 3px var(--ink), inset 0 3px 0 var(--parch-d); resize: vertical; user-select: text;
}
.gb-form input:focus, .gb-form textarea:focus { outline: 3px solid var(--orange); outline-offset: 3px; }
.gb-hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
.gb-status { min-height: 22px; font-family: var(--title); font-size: 22px; color: var(--rust); }
.gb-mode { font-size: 13px; color: #8a6a3a; }
.gb-list { display: flex; flex-direction: column; gap: 10px; max-height: 56vh; overflow: auto; padding: 4px; }
.gb-entry { padding: 10px 12px; background: #fffdf5; box-shadow: 0 0 0 3px var(--ink), 5px 5px 0 3px rgba(0, 0, 0, .18); }
.gb-entry header { display: flex; justify-content: space-between; gap: 10px; font-family: var(--title); font-size: 22px; line-height: 1; }
.gb-entry time { color: #8a6a3a; }
.gb-entry p { margin: 6px 0 0; font-size: 16px; line-height: 1.4; overflow-wrap: anywhere; }
.gb-empty { font-weight: 600; color: #8a6a3a; }
@media (max-width: 700px) { .gb-body { grid-template-columns: 1fr; } }

body { font-variant-ligatures: none; font-synthesis: none; }

/* ---------------- language switch ---------------- */
.lang-switch { position: absolute; top: 14px; right: 14px; display: flex; gap: 6px; z-index: 2; }
.lang-switch button { cursor: pointer; font-family: var(--title); font-size: 22px; line-height: 1; padding: 4px 10px 6px; border: 0; color: var(--cream); background: rgba(28, 27, 46, .7); box-shadow: 0 0 0 3px var(--ink); }
.lang-switch button.on { background: var(--yellow); color: var(--ink); }
.lang-switch.small { position: static; }
.lang-switch.small button { font-size: 18px; padding: 3px 8px 4px; }
.rc-bar-right { display: flex; align-items: center; gap: 12px; }

/* ---------------- online counter ---------------- */
#online { margin-top: 6px; font-family: var(--title); font-size: 20px; color: #8fe07a; text-shadow: var(--o2); }

/* ---------------- AI panel ---------------- */
#panel-ask { position: fixed; left: 50%; top: 50%; transform: translate(-50%, -50%); z-index: 72; width: min(620px, 94vw); animation: popIn .18s steps(3); user-select: text; touch-action: auto; }
.ask-screen .proj-top { align-items: center; }
.ask-close { cursor: pointer; border: 0; background: transparent; color: #41f0ff; font-family: var(--title); font-size: 24px; }
.ask-log { position: relative; z-index: 1; max-height: 38vh; min-height: 90px; overflow: auto; display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
.ask-q { font-family: var(--title); font-size: 22px; color: #ffd84a; }
.ask-a { font-size: 17px; line-height: 1.45; color: #cdf9ff; }
.ask-dots { animation: blink .6s steps(1) infinite; }
.ask-sugg { position: relative; z-index: 1; display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.ask-sugg button { cursor: pointer; font-weight: 600; font-size: 14px; padding: 4px 9px; border: 1px solid #41f0ff; background: transparent; color: #9ff7ff; }
.ask-sugg button:hover { background: rgba(65, 240, 255, .15); }
.ask-form { position: relative; z-index: 1; display: flex; gap: 8px; }
.ask-form input { flex: 1; min-width: 0; font-family: var(--pix); font-size: 17px; padding: 8px 10px; border: 0; color: #0b1a24; background: #cdf9ff; box-shadow: inset 0 3px 0 #8fdde8; }
.ask-form .btn-cyan { margin: 0; }

/* ---------------- extras modal ---------------- */
#panel-extra { position: fixed; inset: 0; z-index: 118; display: grid; place-items: center; padding: 12px; background: rgba(12, 10, 22, .6); user-select: text; touch-action: auto; }
.extra-card {
  width: min(560px, 96vw); max-height: 94vh; overflow: auto; padding: 0 8px 6px; color: #3a2a14;
  border: 18px solid transparent; border-image: var(--fr-wood) 6 fill / 18px stretch; image-rendering: pixelated;
  filter: drop-shadow(8px 8px 0 rgba(0, 0, 0, .4)); animation: popCard .25s steps(3);
}
#panel-extra.wide .extra-card { width: min(860px, 96vw); }
.extra-kicker { font-family: var(--title); font-size: 22px; color: var(--rust); }
.extra-card h3 { margin: 0 0 8px; font-family: var(--title); font-weight: 400; font-size: 44px; line-height: .95; color: var(--ink); }
.extra-card p { font-size: 17px; line-height: 1.4; margin: 0 0 12px; }
.extra-form { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.extra-form input { flex: 1; min-width: 180px; font-family: var(--pix); font-size: 18px; padding: 8px 10px; border: 0; color: var(--ink); background: var(--cream); box-shadow: 0 0 0 3px var(--ink), inset 0 3px 0 var(--parch-d); }
.extra-form .btn, .extra-actions .btn { margin: 3px; }
.extra-actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.extra-actions a { text-decoration: none; }
.extra-note { font-size: 14px !important; color: #8a6a3a; margin-top: 10px !important; }
.diploma-preview canvas { width: 100%; height: auto; display: block; margin: 4px 0 12px; box-shadow: 0 0 0 3px var(--ink); }
.board-notes { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; margin: 6px 0 14px; padding: 4px; }
.note { padding: 12px; box-shadow: 0 0 0 3px var(--ink), 5px 5px 0 3px rgba(0, 0, 0, .2); transform: rotate(-1deg); }
.note.n0 { background: #fff3b0; } .note.n1 { background: #d6efff; transform: rotate(1deg); } .note.n2 { background: #ffe0e6; } .note.n3 { background: #e2f7d6; transform: rotate(1.2deg); }
.note h4 { margin: 0 0 6px; font-family: var(--title); font-weight: 400; font-size: 26px; line-height: 1; }
.note h4 a { color: var(--ink); }
.note p { font-size: 15px !important; margin: 0 0 8px !important; }
.note-tags { display: flex; flex-wrap: wrap; gap: 4px; }
.note-tags span { font-size: 12px; font-weight: 700; padding: 1px 6px; background: rgba(28, 27, 46, .1); }

/* ---------------- ranking on the final screen ---------------- */
.fin-rank { margin: 14px auto 0; max-width: 460px; text-align: left; }
.rank-title { font-family: var(--title); font-size: 30px; color: var(--ink); text-align: center; margin-bottom: 6px; }
.rank-list { list-style: none; margin: 0 0 10px; padding: 0; }
.rank-list li { display: grid; grid-template-columns: 34px 1fr auto; gap: 8px; align-items: center; padding: 4px 8px; font-weight: 600; }
.rank-list li:nth-child(odd) { background: rgba(28, 27, 46, .06); }
.rank-list li.me { background: var(--yellow); }
.rank-list b { font-family: var(--title); font-weight: 400; font-size: 24px; color: var(--rust); }
.rank-list em { font-style: normal; font-family: var(--title); font-size: 22px; }
.rank-list li.empty { display: block; text-align: center; color: #8a6a3a; }
.rank-status { font-family: var(--title); font-size: 24px; color: var(--rust); text-align: center; }

/* ---------------- boss battle ---------------- */
.battle.boss .bt-scene { background: linear-gradient(#3a2a5a 0 12%, #4a3a6a 12% 24%, #5a4a7a 24% 36%, #6a5a8a 36% 46%, #c9b07a 46% 58%, #b89a62 58% 74%, #a8885a 74%); }
.battle.boss .bt-plat { background: #e6cf9e; box-shadow: inset 0 -8px 0 #c9a96e, 0 0 0 3px #8a6a3a; }

body.dialog-open #toasts { bottom: auto; top: 96px; }

body.capturing #title, body.capturing #hud, body.capturing #interior { display: none !important; }

.t-foot a { color: var(--cream); }
.gb-privacy { font-size: 13px; color: #8a6a3a; }
.proj-note a { color: #41f0ff; }
