:root {
  --ink: #2b1d0e;
  --ink-2: #5a4325;
  --paper: #f6ecd6;
  --paper-2: #ead9b4;
  --gold: #f2c14e;
  --gold-d: #b9821f;
  --sea: #1f5f86;
  --sea-d: #123c58;
  --red: #d64541;
  --green: #2fae66;
  --blue: #3f8de0;
  --purple: #9b59d0;
  --glass: rgba(18, 12, 6, .78);
  --glass-2: rgba(255, 248, 230, .92);
  --r: 18px;
  --shadow: 0 10px 30px rgba(0, 0, 0, .35);
  --font: "PingFang TC", "Microsoft JhengHei", "Noto Sans TC", "Heiti TC", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #120c06; color: var(--ink); font-family: var(--font); -webkit-user-select: none; user-select: none; }
button { font-family: inherit; cursor: pointer; border: 0; }
img { -webkit-user-drag: none; }

.screen { position: fixed; inset: 0; display: none; }
.screen.active { display: block; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px 26px; border-radius: 999px; font-size: 20px; font-weight: 900; letter-spacing: 1px;
  color: #3a2208; background: linear-gradient(180deg, #ffe08a, var(--gold) 55%, var(--gold-d));
  box-shadow: 0 4px 0 #7a520f, 0 8px 18px rgba(0, 0, 0, .35); transition: transform .08s, filter .15s;
}
.btn:hover { filter: brightness(1.08); }
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 #7a520f, 0 4px 10px rgba(0, 0, 0, .3); }
.btn.big { font-size: 28px; padding: 16px 44px; }
.btn.ghost { background: rgba(255, 255, 255, .14); color: #fff; box-shadow: inset 0 0 0 2px rgba(255, 255, 255, .45); }
.btn.red { background: linear-gradient(180deg, #ff8a7a, var(--red) 60%, #8e2320); color: #fff; box-shadow: 0 4px 0 #5e1513; }
.btn.green { background: linear-gradient(180deg, #8ff0b0, var(--green) 60%, #1b6e40); color: #fff; box-shadow: 0 4px 0 #11492a; }
.btn[disabled] { filter: grayscale(1) brightness(.8); cursor: not-allowed; }
.icon-btn {
  width: 46px; height: 46px; border-radius: 50%; font-size: 22px; background: var(--glass); color: #fff;
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, .25);
}

/* ---------- title ---------- */
#s-title { background: #000 url(../assets/bg_menu.jpg) center / cover no-repeat; }
#s-title::after { content: ""; position: absolute; inset: 0; background: radial-gradient(ellipse at center, transparent 30%, rgba(0, 0, 0, .55)); pointer-events: none; }
.title-box { position: absolute; left: 50%; top: 52%; transform: translate(-50%, -50%); text-align: center; z-index: 2; }
.logo {
  font-size: clamp(54px, 9vw, 120px); font-weight: 900; letter-spacing: 8px; margin: 0;
  color: #fff6d8; text-shadow: 0 0 2px #7a4b00, 0 4px 0 #a86a00, 0 10px 30px rgba(0, 0, 0, .7), 0 0 60px rgba(255, 200, 80, .55);
}
.logo-sub { margin: 6px 0 34px; font-size: 24px; font-weight: 700; color: #ffe9b0; letter-spacing: 6px; text-shadow: 0 2px 8px #000; }
.title-foot { position: absolute; right: 18px; bottom: 16px; z-index: 2; display: flex; gap: 10px; }

/* ---------- world (選科目) ---------- */
#s-world { background: #2a4d6e url(../assets/bg_world.jpg) center / cover no-repeat; overflow: auto; }
#s-world::before { content: ""; position: fixed; inset: 0; background: radial-gradient(ellipse at center, rgba(0, 0, 0, .05), rgba(0, 0, 0, .35)); pointer-events: none; }
.world-head { position: relative; text-align: center; margin: 86px 0 18px; color: #fff; text-shadow: 0 3px 10px rgba(0, 0, 0, .6); }
.world-head h1 { margin: 0; font-size: clamp(40px, 5vw, 64px); font-weight: 900; letter-spacing: 6px; }
.world-head p { margin: 4px 0 0; font-size: 20px; font-weight: 700; letter-spacing: 3px; }
.world-grid { position: relative; display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 18px; width: min(1180px, 92vw); margin: 0 auto 40px; }
.world-tile {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 20px 14px 16px; border-radius: 22px;
  background: linear-gradient(180deg, #fffaf0, #f3e2bb); box-shadow: 0 6px 0 color-mix(in srgb, var(--c) 70%, #000), 0 14px 26px rgba(0, 0, 0, .35), inset 0 0 0 4px var(--c);
  color: var(--ink); transition: transform .12s;
}
.world-tile:hover { transform: translateY(-4px) scale(1.02); }
.world-tile:active { transform: translateY(3px); }
.wt-ic { font-size: 56px; line-height: 1.15; }
.wt-name { font-size: 30px; font-weight: 900; color: var(--c); }
.wt-desc { font-size: 15px; font-weight: 700; color: var(--ink-2); }
.wt-prog { width: 86%; height: 10px; border-radius: 999px; background: rgba(0, 0, 0, .12); overflow: hidden; margin-top: 6px; }
.wt-prog i { display: block; height: 100%; background: var(--c); border-radius: 999px; }
.wt-stars { font-size: 15px; font-weight: 900; color: var(--ink-2); }
.world-tile .badge, .chap-card2 .badge { top: -10px; right: -8px; background: #7b1fa2; }

/* ---------- chapters (選章節) ---------- */
#s-chapters { background: radial-gradient(ellipse at 50% 0%, color-mix(in srgb, var(--c, #b9821f) 55%, #1d1309), #120c06 75%); overflow: auto; }
.chap-head { display: flex; align-items: center; gap: 14px; width: min(1180px, 92vw); margin: 82px auto 10px; }
.chap-head .ch-title { flex: 1; color: #fff; font-size: 36px; font-weight: 900; text-shadow: 0 3px 8px rgba(0, 0, 0, .5); }
.sem-tabs { display: flex; gap: 10px; width: min(1180px, 92vw); margin: 0 auto 16px; }
.sem-tabs button { padding: 10px 26px; border-radius: 999px; font-size: 20px; font-weight: 900; background: rgba(255, 255, 255, .15); color: #fff; }
.sem-tabs button.on { background: #fff; color: var(--ink); }
.chap-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 16px; width: min(1180px, 92vw); margin: 0 auto 40px; }
.chap-card2 {
  position: relative; display: flex; flex-direction: column; align-items: flex-start; gap: 6px; min-height: 128px; padding: 16px 18px; border-radius: 18px; text-align: left;
  background: linear-gradient(180deg, #fffaf0, #f0dcae); box-shadow: 0 5px 0 #b98d3c, 0 10px 20px rgba(0, 0, 0, .35); color: var(--ink); transition: transform .12s;
}
.chap-card2:hover { transform: translateY(-3px); }
.chap-card2 .cc-num { font-size: 14px; font-weight: 900; color: #fff; background: var(--c, #7a4b12); padding: 2px 10px; border-radius: 999px; }
.chap-card2 .cc-title { font-size: 21px; font-weight: 900; line-height: 1.35; }
.chap-card2 .cc-stars { margin-top: auto; font-size: 16px; font-weight: 900; color: #b37400; }
.chap-card2.todo { background: linear-gradient(180deg, #d9d2c3, #b9ae98); box-shadow: 0 5px 0 #8a7d63; opacity: .7; cursor: not-allowed; }
.chap-card2.todo .cc-stars { color: #6b5d45; }
.ver-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px; margin-top: 12px; }
.ver-card { display: flex; flex-direction: column; gap: 4px; padding: 22px 12px; border-radius: 18px; background: #fff; box-shadow: 0 4px 0 #c9a96b, inset 0 0 0 3px #e3c88a; font-size: 16px; font-weight: 700; color: var(--ink-2); }
.ver-card b { font-size: 30px; font-weight: 900; color: var(--ink); }
.ver-card.on { box-shadow: 0 4px 0 #8a5b10, inset 0 0 0 4px var(--gold-d); background: #fff7dc; }

/* ---------- map ---------- */
#s-map { background: radial-gradient(ellipse at 40% 50%, #2a7aa8, var(--sea-d) 75%); }
#s-map .sea-tex { position: absolute; inset: 0; opacity: .25; background-image: repeating-radial-gradient(circle at 30% 40%, transparent 0 22px, rgba(255, 255, 255, .25) 23px 24px, transparent 25px 48px); pointer-events: none; }
.hud { position: absolute; top: 14px; left: 18px; right: 18px; display: flex; align-items: center; gap: 12px; z-index: 5; pointer-events: none; }
.hud > * { pointer-events: auto; }
.pill {
  display: inline-flex; align-items: center; gap: 8px; padding: 8px 16px 8px 10px; border-radius: 999px;
  background: var(--glass); color: #fff; font-weight: 900; font-size: 20px; box-shadow: inset 0 0 0 2px rgba(255, 216, 120, .35);
}
.pill .ic { font-size: 22px; }
.hud .spacer { flex: 1; }

#map-svg { position: absolute; left: 0; top: 0; height: 100%; width: 64%; }
#s-map.generic #map-svg { width: 100%; } /* 一般章節：主題背景鋪滿全螢幕，關卡排在左側 */
.map-side {
  position: absolute; right: 22px; top: 82px; bottom: 22px; width: 34%; max-width: 470px; z-index: 4;
  display: flex; flex-direction: column; gap: 14px;
}
.parch {
  background: linear-gradient(180deg, #fbf3df, var(--paper) 40%, var(--paper-2)); border-radius: var(--r);
  box-shadow: var(--shadow), inset 0 0 0 3px #d9bf86, inset 0 0 40px rgba(160, 110, 30, .18); padding: 18px 22px;
}
.chap-card h2 { margin: 0; font-size: 28px; font-weight: 900; }
.chap-card .sub { color: var(--ink-2); font-weight: 700; margin-top: 2px; }
.chap-card .era { display: inline-block; margin-top: 8px; padding: 2px 12px; border-radius: 999px; background: #7a4b12; color: #ffe7b0; font-weight: 900; }
.progress { margin-top: 12px; height: 14px; border-radius: 999px; background: rgba(0, 0, 0, .15); overflow: hidden; }
.progress > i { display: block; height: 100%; background: linear-gradient(90deg, #ffd56b, #f39c12); border-radius: 999px; transition: width .6s; }
.side-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.side-btn {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 14px 8px 12px; border-radius: 16px;
  background: linear-gradient(180deg, #fff7e2, #f0dcac); box-shadow: 0 4px 0 #b98d3c, 0 8px 18px rgba(0, 0, 0, .25);
  font-weight: 900; font-size: 18px; color: var(--ink); transition: transform .08s;
}
.side-btn:active { transform: translateY(3px); box-shadow: 0 1px 0 #b98d3c; }
.side-btn .big-ic { font-size: 38px; line-height: 1.1; }
.side-btn small { font-weight: 700; color: var(--ink-2); font-size: 13px; }
.badge {
  position: absolute; top: -8px; right: -6px; min-width: 28px; height: 28px; padding: 0 8px; border-radius: 999px;
  background: var(--red); color: #fff; font-weight: 900; font-size: 15px; display: grid; place-items: center; box-shadow: 0 2px 6px rgba(0, 0, 0, .4);
}
.glow { animation: glow 1.6s ease-in-out infinite; }
@keyframes glow { 0%, 100% { box-shadow: 0 4px 0 #b98d3c, 0 0 0 0 rgba(255, 210, 90, .0); } 50% { box-shadow: 0 4px 0 #b98d3c, 0 0 22px 6px rgba(255, 210, 90, .85); } }
.daily { font-size: 15px; line-height: 1.6; }
.daily b { font-size: 17px; }

/* svg map pieces */
.node { cursor: pointer; }
.node .ring { transition: transform .2s; transform-box: fill-box; transform-origin: center; }
.node:hover .ring { transform: scale(1.12); }
.node.locked { cursor: not-allowed; }
.node.next .pulse { animation: pulse 1.5s ease-out infinite; transform-box: fill-box; transform-origin: center; }
@keyframes pulse { 0% { opacity: .9; transform: scale(1); } 100% { opacity: 0; transform: scale(1.9); } }
.monster-bob { animation: bob 1.2s ease-in-out infinite; transform-box: fill-box; transform-origin: center; }
@keyframes bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }
.ship { animation: sail 9s ease-in-out infinite alternate; }
@keyframes sail { from { transform: translate(0, 0); } to { transform: translate(18px, -8px); } }
.dash-move { animation: dash 1.2s linear infinite; }
@keyframes dash { to { stroke-dashoffset: -28; } }

/* ---------- overlays / modal ---------- */
.overlay { position: fixed; inset: 0; z-index: 50; display: none; place-items: center; background: rgba(8, 5, 2, .62); backdrop-filter: blur(3px); }
.overlay.on { display: grid; animation: fadein .2s; }
@keyframes fadein { from { opacity: 0; } }
.modal { position: relative; width: min(760px, 92vw); max-height: 90vh; overflow: auto; animation: pop .28s cubic-bezier(.2, 1.4, .4, 1); }
.modal.wide { width: min(1180px, 95vw); }
@keyframes pop { from { transform: scale(.85); opacity: 0; } }
.modal .x { position: absolute; top: 12px; right: 12px; width: 40px; height: 40px; border-radius: 50%; background: rgba(0, 0, 0, .12); font-size: 22px; font-weight: 900; color: var(--ink); }
.modal h2 { margin: 0 0 8px; font-size: 30px; font-weight: 900; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.center { text-align: center; }
.muted { color: var(--ink-2); }
.tag { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 14px; font-weight: 900; color: #fff; background: #7a4b12; }

.node-panel .head { display: flex; gap: 16px; align-items: center; }
.node-panel .head .ic { font-size: 64px; width: 96px; height: 96px; border-radius: 24px; display: grid; place-items: center; background: radial-gradient(circle at 35% 30%, #fff6d6, #e9c97c); box-shadow: inset 0 0 0 3px #c79a3c; }
.stars { font-size: 26px; letter-spacing: 2px; color: #d4b27a; }
.stars .on { color: #ffb400; text-shadow: 0 0 8px rgba(255, 180, 0, .7); }
.node-panel .acts { margin-top: 18px; display: flex; gap: 12px; flex-wrap: wrap; }

/* ---------- dialog ---------- */
#dialog { position: fixed; inset: 0; z-index: 80; display: none; }
#dialog.on { display: block; }
#dialog .shade { position: absolute; inset: 0; background: linear-gradient(0deg, rgba(0, 0, 0, .6), transparent 55%); }
#dialog img.portrait { position: absolute; left: 3vw; bottom: 0; height: 74vh; filter: drop-shadow(0 10px 30px rgba(0, 0, 0, .6)); animation: rise .4s ease-out; }
#dialog img.portrait.speaker { left: 6vw; bottom: 8vh; height: 56vh; }
@keyframes rise { from { transform: translateY(40px); opacity: 0; } }
#dialog .box {
  position: absolute; left: 24vw; right: 4vw; bottom: 4vh; min-height: 150px; padding: 22px 30px 26px;
  border-radius: 22px; background: var(--glass-2); box-shadow: var(--shadow), inset 0 0 0 4px #d9b45e; font-size: 26px; font-weight: 700; line-height: 1.6; cursor: pointer;
}
#dialog .who { position: absolute; top: -20px; left: 26px; padding: 4px 18px; border-radius: 999px; background: linear-gradient(180deg, #ffe08a, var(--gold-d)); font-weight: 900; font-size: 20px; }
#dialog .next { position: absolute; right: 22px; bottom: 12px; font-size: 18px; color: var(--gold-d); animation: blink 1s infinite; }
@keyframes blink { 50% { opacity: .2; } }

/* ---------- toast ---------- */
#toast { position: fixed; left: 50%; top: 18px; transform: translateX(-50%); z-index: 99; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast { padding: 10px 22px; border-radius: 999px; background: var(--glass); color: #fff; font-weight: 900; font-size: 18px; box-shadow: var(--shadow); animation: toast 2.6s forwards; }
@keyframes toast { 0% { opacity: 0; transform: translateY(-12px); } 10%, 85% { opacity: 1; transform: none; } 100% { opacity: 0; } }

/* ---------- play ---------- */
#s-play { background: #0d0905; }
.play-top { position: absolute; top: 0; left: 0; right: 0; z-index: 20; display: flex; align-items: center; gap: 14px; padding: 12px 18px; pointer-events: none; }
.play-top > * { pointer-events: auto; }
.play-top .ttl { color: #fff; font-weight: 900; font-size: 22px; text-shadow: 0 2px 6px #000; }
.hearts { font-size: 30px; letter-spacing: 2px; filter: drop-shadow(0 2px 3px rgba(0, 0, 0, .6)); }
.hearts .lost { opacity: .22; filter: grayscale(1); }
.shield-ic { font-size: 26px; }
#play-stage { position: absolute; inset: 0; }
.shoot-cv { position: absolute; inset: 0; width: 100%; height: 100%; cursor: none; }
.shoot-ui { position: absolute; inset: 0; pointer-events: none; }
.q-banner {
  position: absolute; left: 50%; top: 70px; transform: translateX(-50%); width: min(1000px, 86vw); text-align: center;
  padding: 16px 28px; border-radius: 20px; background: rgba(255, 248, 228, .95); box-shadow: var(--shadow), inset 0 0 0 4px #e3bb5c;
  font-size: clamp(22px, 2.4vw, 34px); font-weight: 900; line-height: 1.35; transition: transform .25s;
}
.q-banner.flash { animation: qflash .4s; }
@keyframes qflash { from { transform: translateX(-50%) scale(.9); opacity: 0; } }
.frag {
  position: absolute; left: 50%; bottom: 36px; transform: translateX(-50%); width: min(900px, 86vw);
  padding: 12px 22px 12px 60px; border-radius: 16px; color: #fff; font-size: 21px; font-weight: 700; line-height: 1.5;
  background: rgba(20, 60, 40, .92); box-shadow: var(--shadow); animation: fragin .3s ease-out;
}
.frag.bad { background: rgba(110, 24, 22, .93); }
.frag::before { content: "💎"; position: absolute; left: 18px; top: 10px; font-size: 26px; }
.frag.bad::before { content: "💡"; }
@keyframes fragin { from { transform: translate(-50%, 20px); opacity: 0; } }

/* 射擊後的解說：停在中央，點一下才繼續 */
.explain-veil { position: absolute; inset: 0; z-index: 5; display: grid; place-items: center; background: rgba(10, 6, 2, .32); pointer-events: auto; cursor: pointer; animation: fadein .2s; }
.explain-card {
  width: min(780px, 86vw); max-height: 70vh; overflow: auto; padding: 22px 30px 16px; border-radius: 24px;
  background: rgba(255, 250, 236, .98); box-shadow: var(--shadow), inset 0 0 0 5px #e3bb5c;
  font-size: clamp(20px, 1.9vw, 26px); font-weight: 700; line-height: 1.65; color: var(--ink); animation: pop .28s cubic-bezier(.2, 1.4, .4, 1);
}
.explain-card.good { box-shadow: var(--shadow), inset 0 0 0 5px #4cc982; }
.explain-card.bad { box-shadow: var(--shadow), inset 0 0 0 5px #e5675f; }
.explain-card .hd { font-size: clamp(24px, 2.3vw, 32px); font-weight: 900; margin-bottom: 8px; }
.explain-card.good .hd { color: #1d8a4c; }
.explain-card.bad .hd { color: #c0392b; }
.explain-card .go { margin-top: 14px; text-align: center; font-size: 20px; font-weight: 900; color: var(--gold-d); opacity: 0; transition: opacity .2s; }
.explain-card.ready .go { opacity: 1; animation: blink 1.2s infinite; }

/* boss panel */
.boss-panel {
  position: absolute; left: 18px; top: 74px; bottom: 18px; width: 46%; pointer-events: auto; overflow: auto;
  padding: 16px 18px; border-radius: 20px; background: rgba(255, 248, 228, .96); box-shadow: var(--shadow), inset 0 0 0 4px #e3bb5c;
}
.boss-panel img { width: 100%; border-radius: 10px; background: #fff; display: block; }
.boss-panel .opts { margin-top: 12px; display: grid; gap: 8px; }
.boss-panel .opt { display: flex; gap: 10px; align-items: flex-start; padding: 8px 12px; border-radius: 12px; background: #fff; font-size: 20px; font-weight: 700; line-height: 1.4; box-shadow: inset 0 0 0 2px #ead39a; }
.boss-panel .opt b { flex: 0 0 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; color: #fff; font-size: 18px; }
.boss-panel .opt.ok { box-shadow: inset 0 0 0 3px var(--green); background: #e9fbef; }
.boss-panel .opt.no { box-shadow: inset 0 0 0 3px var(--red); background: #fdeceb; }
.boss-panel .qmeta { font-size: 14px; color: var(--ink-2); font-weight: 700; margin-bottom: 6px; }
.boss-panel .passage-tog { margin: 0 0 8px; font-size: 15px; padding: 6px 14px; }

/* ---------- puzzles ---------- */
.puz { position: absolute; inset: 0; padding: 78px 28px 28px; background: radial-gradient(ellipse at 50% 30%, #4b3418, #1d1309 75%); overflow: hidden; }
.puz .timebar { position: absolute; left: 50%; top: 70px; transform: translateX(-50%); width: min(720px, 70vw); height: 12px; border-radius: 999px; background: rgba(255, 255, 255, .15); overflow: hidden; }
.puz .timebar > i { display: block; height: 100%; background: linear-gradient(90deg, #ff6b5a, #ffd56b); transform-origin: left; }
.puz .hint { text-align: center; color: #ffe7b0; font-weight: 900; font-size: 22px; margin: 22px 0 10px; text-shadow: 0 2px 4px #000; }

/* match */
.match { display: grid; grid-template-columns: 1fr 1.6fr; gap: 26px 90px; width: min(1100px, 94vw); margin: 0 auto; position: relative; }
.match .col { display: grid; gap: 12px; }
.mcard {
  padding: 14px 18px; border-radius: 16px; background: linear-gradient(180deg, #fff9ea, #f0dcae); font-weight: 900; font-size: 22px; text-align: center;
  box-shadow: 0 4px 0 #b98d3c, 0 8px 14px rgba(0, 0, 0, .35); cursor: pointer; transition: transform .12s, box-shadow .12s, opacity .3s;
}
.mcard.def { font-size: 19px; font-weight: 700; text-align: left; }
.mcard.sel { transform: scale(1.04); box-shadow: 0 0 0 4px var(--gold), 0 8px 20px rgba(255, 200, 80, .6); }
.mcard.done { background: linear-gradient(180deg, #d8f8e3, #9fe0b8); box-shadow: 0 2px 0 #3a8f5d; cursor: default; opacity: .85; }
.mcard.bad { animation: shake .4s; box-shadow: 0 0 0 4px var(--red); }
@keyframes shake { 20%, 60% { transform: translateX(-8px); } 40%, 80% { transform: translateX(8px); } }
.match svg { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; overflow: visible; }

/* sort */
.sort-wrap { position: absolute; inset: 0; }
.sbin {
  position: absolute; width: 230px; padding: 16px; border-radius: 22px; text-align: center; color: #fff; font-weight: 900; font-size: 26px;
  box-shadow: 0 6px 0 rgba(0, 0, 0, .35), 0 12px 24px rgba(0, 0, 0, .4); cursor: pointer; transition: transform .12s;
}
.sbin .flag { font-size: 54px; display: block; }
.sbin .key { display: inline-block; margin-top: 6px; padding: 2px 12px; border-radius: 8px; background: rgba(0, 0, 0, .25); font-size: 18px; }
.sbin .cnt { display: block; font-size: 16px; opacity: .85; }
.sbin.bump { transform: scale(1.12); }
.sbin.badflash { animation: shake .4s; filter: brightness(.6) sepia(1) hue-rotate(-50deg) saturate(4); }
.sbin.hintflash { box-shadow: 0 0 0 6px #fff, 0 0 40px 10px rgba(255, 255, 255, .7); }
.scard {
  position: absolute; left: 50%; top: 58%; width: 420px; min-height: 170px; transform: translate(-50%, -50%); padding: 26px 30px; border-radius: 24px;
  background: linear-gradient(180deg, #fffaf0, #f3e0b6); box-shadow: 0 10px 0 #b98d3c, 0 20px 40px rgba(0, 0, 0, .5);
  font-size: 30px; font-weight: 900; text-align: center; display: grid; place-items: center; line-height: 1.4; cursor: grab; touch-action: none;
}
.scard .sbar { position: absolute; left: 20px; right: 20px; bottom: 12px; height: 8px; border-radius: 999px; background: rgba(0, 0, 0, .12); overflow: hidden; }
.scard .sbar i { display: block; height: 100%; background: var(--gold-d); }
.scard.fly { transition: transform .35s cubic-bezier(.5, -.3, .8, .6), opacity .35s; opacity: 0; }
.scard.bad { animation: shake .4s; box-shadow: 0 0 0 5px var(--red), 0 20px 40px rgba(0, 0, 0, .5); }
.combo-big { position: absolute; left: 50%; top: 30%; transform: translate(-50%, -50%); font-size: 60px; font-weight: 900; color: #ffd56b; text-shadow: 0 4px 0 #8a4b00, 0 0 30px rgba(255, 180, 0, .8); pointer-events: none; animation: comboPop .7s forwards; }
@keyframes comboPop { from { transform: translate(-50%, -50%) scale(.4); opacity: 1; } 60% { transform: translate(-50%, -50%) scale(1.15); } to { transform: translate(-50%, -80%) scale(1); opacity: 0; } }

/* timeline */
.tl { position: relative; width: min(1240px, 96vw); margin: 34px auto 0; height: 300px; }
.tl .band { position: absolute; top: 0; height: 230px; border-radius: 18px; opacity: .9; }
.tl .band span { position: absolute; top: 8px; left: 14px; color: #fff; font-weight: 900; font-size: 20px; text-shadow: 0 2px 4px rgba(0, 0, 0, .5); }
.tl .axis { position: absolute; left: 0; right: 0; top: 230px; height: 8px; border-radius: 999px; background: linear-gradient(90deg, #f6d27a, #fff3c8, #f6d27a); box-shadow: 0 2px 8px rgba(0, 0, 0, .5); }
.tl .slot {
  position: absolute; top: 46px; width: 150px; height: 150px; transform: translateX(-50%); border-radius: 16px; border: 3px dashed rgba(255, 255, 255, .7);
  background: rgba(0, 0, 0, .18); display: grid; place-items: center; text-align: center; color: #fff; font-weight: 900; font-size: 18px; padding: 8px; transition: background .2s, transform .15s;
}
.tl .slot.hover { background: rgba(255, 255, 255, .3); transform: translateX(-50%) scale(1.05); }
.tl .slot.filled { border: 3px solid #fff; background: linear-gradient(180deg, #fffaf0, #f3e0b6); color: var(--ink); box-shadow: 0 0 24px rgba(255, 230, 140, .9); }
.tl .slot.bad { animation: shake .4s; background: rgba(214, 69, 65, .6); }
.tl .year { position: absolute; top: 246px; transform: translateX(-50%); color: #ffe7b0; font-weight: 900; font-size: 22px; text-shadow: 0 2px 4px #000; }
.tl .tick { position: absolute; top: 196px; width: 4px; height: 36px; transform: translateX(-50%); background: #fff3c8; border-radius: 2px; }
.tray { display: flex; flex-wrap: wrap; justify-content: center; gap: 14px; width: min(1200px, 96vw); margin: 18px auto 0; min-height: 90px; }
.tcard {
  width: 160px; min-height: 84px; padding: 10px 12px; border-radius: 14px; background: linear-gradient(180deg, #fffaf0, #f0dcae);
  box-shadow: 0 4px 0 #b98d3c, 0 8px 16px rgba(0, 0, 0, .4); font-weight: 900; font-size: 18px; text-align: center; display: grid; place-items: center;
  cursor: grab; touch-action: none; transition: transform .12s;
}
.tcard.sel { box-shadow: 0 0 0 4px var(--gold), 0 8px 20px rgba(255, 200, 80, .6); transform: translateY(-4px); }
.tcard.dragging { position: fixed; z-index: 60; pointer-events: none; transform: rotate(-3deg) scale(1.06); }

/* ---------- result ---------- */
.result .big-title { font-size: 46px; font-weight: 900; margin: 0; text-align: center; }
.result .big-title.win { color: #c27a00; text-shadow: 0 3px 0 #ffe7a0; }
.result .big-title.lose { color: #8d2a24; }
.result .rstars { font-size: 64px; text-align: center; letter-spacing: 8px; margin: 6px 0; }
.result .rstars span { display: inline-block; color: #d9c49c; transform: scale(.6); transition: transform .3s cubic-bezier(.2, 1.6, .4, 1), color .2s; }
.result .rstars span.on { color: #ffb400; transform: scale(1); text-shadow: 0 0 18px rgba(255, 180, 0, .9); }
.result .stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 12px 0; }
.result .stat { text-align: center; padding: 10px; border-radius: 14px; background: rgba(0, 0, 0, .06); font-weight: 900; }
.result .stat b { display: block; font-size: 30px; }
.loot { display: flex; justify-content: center; gap: 18px; margin: 10px 0 4px; }
.loot .pill { font-size: 24px; }
.wrong-list { margin-top: 12px; border-radius: 14px; background: rgba(214, 69, 65, .08); padding: 10px 14px; }
.wrong-list summary { cursor: pointer; font-weight: 900; color: #8d2a24; font-size: 18px; }
.wrong-item { padding: 8px 0; border-top: 1px dashed rgba(0, 0, 0, .15); font-size: 16px; line-height: 1.5; }
.wrong-item .ans { color: #1d7a45; font-weight: 900; }

/* ---------- gacha & cards ---------- */
.gacha { text-align: center; }
.orb-stage { position: relative; height: 380px; display: grid; place-items: center; }
.orb {
  width: 190px; height: 190px; border-radius: 50%; display: grid; place-items: center; font-size: 86px;
  background: radial-gradient(circle at 35% 30%, #fff, #ffe39a 30%, #e3a52d 70%, #8a5b10); box-shadow: 0 0 40px rgba(255, 210, 90, .8), inset 0 -10px 30px rgba(0, 0, 0, .25);
  animation: float 2.4s ease-in-out infinite;
}
@keyframes float { 50% { transform: translateY(-12px); } }
.orb.shake { animation: orbshake .12s linear infinite; }
@keyframes orbshake { 25% { transform: translate(-6px, 2px) rotate(-6deg); } 75% { transform: translate(6px, -2px) rotate(6deg); } }
.beam { position: absolute; inset: 0; pointer-events: none; opacity: 0; background: conic-gradient(from 0deg, transparent 0 10deg, var(--bc, #fff) 12deg 16deg, transparent 18deg 40deg, var(--bc, #fff) 42deg 46deg, transparent 48deg 70deg, var(--bc, #fff) 72deg 76deg, transparent 78deg); mask: radial-gradient(circle, #000 20%, transparent 70%); -webkit-mask: radial-gradient(circle, #000 20%, transparent 70%); }
.beam.on { animation: beam 1.4s ease-out forwards; }
@keyframes beam { 0% { opacity: 0; transform: rotate(0) scale(.4); } 30% { opacity: 1; } 100% { opacity: 0; transform: rotate(90deg) scale(1.6); } }

.card3d { width: 230px; height: 320px; perspective: 1000px; cursor: pointer; display: inline-block; }
.card3d .inner { position: relative; width: 100%; height: 100%; transition: transform .7s; transform-style: preserve-3d; }
.card3d.flipped .inner { transform: rotateY(180deg); }
.card3d .face { position: absolute; inset: 0; border-radius: 18px; backface-visibility: hidden; -webkit-backface-visibility: hidden; overflow: hidden; }
.card3d .back { transform: rotateY(180deg); }
.cface { display: flex; flex-direction: column; align-items: center; padding: 14px; color: #fff; text-align: center; }
.cface .r { align-self: flex-start; font-weight: 900; font-size: 18px; padding: 2px 10px; border-radius: 8px; background: rgba(0, 0, 0, .3); }
.cface .ic { font-size: 96px; line-height: 1.2; margin-top: 8px; filter: drop-shadow(0 6px 10px rgba(0, 0, 0, .4)); }
.cface .nm { font-size: 28px; font-weight: 900; margin-top: 4px; text-shadow: 0 2px 4px rgba(0, 0, 0, .5); }
.cface .tt { font-size: 15px; font-weight: 700; opacity: .92; }
.cface .bf { margin-top: auto; font-size: 14px; font-weight: 900; padding: 4px 10px; border-radius: 10px; background: rgba(0, 0, 0, .3); }
.cback { padding: 18px 16px; text-align: left; color: var(--ink); background: linear-gradient(180deg, #fffaf0, #f0dcae); }
.cback h4 { margin: 0 0 8px; font-size: 22px; }
.cback ul { margin: 0; padding-left: 20px; font-size: 16px; font-weight: 700; line-height: 1.6; }
.rar-N { background: linear-gradient(160deg, #9aa3ad, #59626b); box-shadow: inset 0 0 0 5px #c8ced4; }
.rar-R { background: linear-gradient(160deg, #5aa9f0, #1f5fa8); box-shadow: inset 0 0 0 5px #9fd0ff; }
.rar-SR { background: linear-gradient(160deg, #c27cf2, #6a2ea0); box-shadow: inset 0 0 0 5px #e3b8ff; }
.rar-SSR { background: linear-gradient(160deg, #ffe27a, #f39c12 45%, #c0392b); box-shadow: inset 0 0 0 5px #fff1b8, 0 0 30px rgba(255, 190, 60, .9); animation: ssr 2.5s linear infinite; }
@keyframes ssr { 50% { filter: brightness(1.15) saturate(1.2); } }
.newtag { position: absolute; top: 10px; right: 10px; z-index: 3; padding: 2px 10px; border-radius: 8px; background: #ff3b6b; color: #fff; font-weight: 900; transform: rotate(8deg); }

.coll-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; margin-top: 12px; }
.mini { position: relative; height: 200px; border-radius: 14px; display: flex; flex-direction: column; align-items: center; justify-content: center; color: #fff; cursor: pointer; text-align: center; padding: 8px; }
.mini .ic { font-size: 58px; }
.mini .nm { font-weight: 900; font-size: 18px; }
.mini .cnt { position: absolute; bottom: 6px; right: 10px; font-weight: 900; font-size: 14px; opacity: .9; }
.mini.unknown { background: repeating-linear-gradient(45deg, #3b2c1a, #3b2c1a 10px, #2f2314 10px, #2f2314 20px); color: #8c7653; box-shadow: inset 0 0 0 3px #5a4325; cursor: default; }
.mini.unknown .ic { filter: brightness(0) opacity(.35); }

/* ---------- shop / parent ---------- */
.shop-item { display: flex; align-items: center; gap: 16px; padding: 14px 16px; border-radius: 16px; background: rgba(255, 255, 255, .6); box-shadow: inset 0 0 0 2px #e3c88a; margin-top: 10px; }
.shop-item .nm { flex: 1; font-size: 22px; font-weight: 900; }
.shop-item .cost { font-weight: 900; font-size: 20px; }
.voucher { margin: 14px auto 0; padding: 18px; max-width: 460px; border-radius: 16px; border: 3px dashed #b9821f; background: #fffdf4; text-align: center; font-weight: 900; font-size: 22px; }
.st { display: inline-block; padding: 1px 10px; border-radius: 999px; font-size: 13px; font-weight: 900; color: #fff; }
.st.pending { background: #e67e22; } .st.ok { background: var(--green); } .st.no { background: #999; }
.pinpad { display: grid; grid-template-columns: repeat(3, 76px); gap: 12px; justify-content: center; margin-top: 12px; }
.pinpad button { height: 64px; border-radius: 16px; font-size: 28px; font-weight: 900; background: #fff; box-shadow: 0 3px 0 #c9a96b; }
.pindots { text-align: center; font-size: 34px; letter-spacing: 12px; margin-top: 8px; }
.tabs { display: flex; gap: 8px; margin: 8px 0 14px; flex-wrap: wrap; }
.tabs button { padding: 8px 16px; border-radius: 999px; font-weight: 900; font-size: 16px; background: rgba(0, 0, 0, .08); color: var(--ink); }
.tabs button.on { background: var(--ink); color: #fff; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 16px; }
table.tbl td, table.tbl th { padding: 8px; border-bottom: 1px solid rgba(0, 0, 0, .1); text-align: left; }
input.inp { font: inherit; font-size: 18px; padding: 8px 12px; border-radius: 10px; border: 2px solid #d6b878; background: #fff; }

/* ---------- guide ---------- */
.guide .slide { position: relative; background: #000; border-radius: 14px; overflow: hidden; }
.guide .slide img { display: block; width: 100%; }
.guide .nav { display: flex; align-items: center; justify-content: center; gap: 14px; margin-top: 10px; font-weight: 900; }
.guide .kx img { width: 100%; border-radius: 8px; margin-bottom: 10px; box-shadow: 0 2px 10px rgba(0, 0, 0, .2); }
.guide .sum { white-space: pre-wrap; font-size: 17px; line-height: 1.7; background: rgba(255, 255, 255, .5); padding: 12px 16px; border-radius: 12px; margin-bottom: 12px; }
.buffbar { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-radius: 12px; background: #fff3c4; font-weight: 900; }

/* ---------- 攻城戰 ---------- */
.war { position: absolute; inset: 0; overflow: hidden; background: #245d80; }
.war-svg { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.war-banner {
  position: absolute; left: 50%; top: 64px; transform: translateX(-50%); width: min(900px, 78vw); text-align: center; pointer-events: none;
  padding: 10px 22px; border-radius: 18px; background: rgba(255, 248, 228, .95); box-shadow: var(--shadow), inset 0 0 0 4px #e3bb5c;
}
.wb-t { font-size: clamp(20px, 2.2vw, 30px); font-weight: 900; line-height: 1.3; }
.wb-s { font-size: 16px; font-weight: 800; color: var(--ink-2); margin-top: 2px; }
.war-panel {
  position: absolute; left: 50%; bottom: 16px; transform: translate(-50%, 140%); width: min(1000px, 92vw); max-height: 42vh; overflow: auto;
  padding: 14px 20px 16px; border-radius: 22px; background: rgba(255, 248, 228, .97); box-shadow: var(--shadow), inset 0 0 0 4px #e3bb5c;
  transition: transform .35s cubic-bezier(.2, 1.2, .4, 1);
}
.war-panel:not(.on) { opacity: 0; pointer-events: none; }
.war-panel.on { transform: translate(-50%, 0); }
.wp-n { font-size: 15px; font-weight: 900; color: var(--gold-d); }
.wp-q { font-size: clamp(20px, 2.1vw, 28px); font-weight: 900; margin: 4px 0 10px; line-height: 1.4; }
.wp-o { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.war-opt-btn {
  display: flex; align-items: center; gap: 10px; text-align: left; padding: 10px 14px; border-radius: 14px; background: #fff;
  box-shadow: 0 4px 0 #c9a96b, inset 0 0 0 3px #e3c88a; font-size: clamp(17px, 1.7vw, 22px); font-weight: 800; color: var(--ink); transition: transform .1s;
}
.war-opt-btn b { flex: none; width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; background: var(--gold); color: #3a2208; }
.war-opt-btn:hover:not(:disabled) { transform: translateY(-2px); }
.war-opt-btn.right { background: #dff6e7; box-shadow: 0 4px 0 #3c9c64, inset 0 0 0 3px #4cc982; }
.war-opt-btn.wrong { background: #fde3e1; box-shadow: 0 4px 0 #b03a32, inset 0 0 0 3px #e5675f; }
.wp-ex { margin-top: 10px; font-size: 18px; font-weight: 800; line-height: 1.5; }
.wp-ex.good { color: #1d6f45; }
.war-name { font-weight: 900; fill: #2b1d0e; paint-order: stroke; stroke: #fff8e6; stroke-width: 4px; stroke-linejoin: round; pointer-events: none; }
.war-river { fill: #1d5f86; font-weight: 900; font-style: italic; paint-order: stroke; stroke: #e9f6ff; stroke-width: 3px; opacity: .85; pointer-events: none; }
.war-city .castle { stroke: #2b1d0e; stroke-width: 2; }
.siege .war-city:not(.focus) { opacity: .25; }
.siege .war-city:not(.focus) .war-name { display: none; }
.war-city .dot { stroke: #fff; stroke-width: 3; }
.war-city .flip, .war-city .big, .war-pop, .war-army, .war-opt .ring { transform-box: fill-box; transform-origin: center; }
.war-city .flip { animation: wflip .8s; }
.war-city .big { transform: scale(2.3); transition: transform .4s; }
@keyframes wflip { 40% { transform: scale(1.9); } }
.war-pop { animation: wpop .9s ease-out forwards; pointer-events: none; }
@keyframes wpop { from { transform: scale(.4); opacity: 0; } 30% { transform: scale(1.15); opacity: 1; } to { transform: translateY(-14px); opacity: 0; } }
.war-army { transform-origin: center bottom; }
.war-army.fall { animation: wfall .6s forwards; }
@keyframes wfall { to { transform: rotate(80deg) translateY(6px); opacity: 0; } }
.war-army.flee { animation: wflee .8s forwards; }
@keyframes wflee { to { transform: translateY(-20px) scale(.6); opacity: 0; } }
.war-opt { cursor: pointer; }
.war-opt .ring { fill: rgba(255, 213, 107, .28); stroke: #ffd56b; stroke-width: 5; animation: wring 1.1s ease-in-out infinite; }
.war-opt.hint .ring { stroke: #4cc982; fill: rgba(76, 201, 130, .35); }
.war-opt.no { opacity: .6; cursor: default; }
.war-opt.no .ring { animation: none; stroke: #e5675f; fill: rgba(229, 103, 95, .2); }
@keyframes wring { 50% { transform: scale(1.25); } }
