:root {
  --ink: #3b2a1e;
  --ink-soft: #6d5a48;
  --cream: #fffaf0;
  --cream2: #fbf3e3;
  --wood: #9a6434;
  --wood-d: #6e4320;
  --wood-l: #c08850;
  --green: #5cbf6b;
  --green-d: #3f9a50;
  --orange: #f07a24;
  --blue: #3a8fd8;
  --gold: #f5b82e;
  --miss: #e2534a;
  --font: 'M PLUS Rounded 1c', 'Hiragino Maru Gothic ProN', 'Hiragino Sans', sans-serif;
  --hand: 'Yomogi', 'Klee One', 'Hiragino Maru Gothic ProN', sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: #9dd3f2 url(../assets/bg.jpg) center/cover no-repeat;
  color: var(--ink);
  font-family: var(--font);
  font-weight: 700;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
button { font-family: inherit; font-weight: 800; cursor: pointer; color: inherit; }
.hand { font-family: var(--hand); font-weight: 400; }
[hidden] { display: none !important; }

.view { display: none; }
body.is-pc #pc { display: block; }
body.is-sp #sp { display: flex; }

/* ============================================================
   PC：1536×1024 の固定キャンバスを画面に合わせて拡大縮小
   ============================================================ */
body.is-pc { background: #cfe9f7 url(../assets/bg.jpg) center/cover no-repeat; }
body.is-pc::before { content: ''; position: fixed; inset: 0; backdrop-filter: blur(14px) brightness(1.05); }
#pc { position: fixed; inset: 0; }
#stage {
  position: absolute; left: 50%; top: 50%;
  width: 1536px; height: 1024px;
  transform: translate(-50%, -50%) scale(var(--s, 1));
  overflow: hidden;
  border-radius: 6px;
  box-shadow: 0 10px 40px rgba(40, 60, 80, .25);
}
#stage > * { position: absolute; }
#stage .bg { inset: 0; width: 100%; height: 100%; object-fit: cover; }

/* 右上：言葉の応募ボタン */
.apply-btn {
  right: 26px; top: 22px; z-index: 6; display: grid; grid-template-columns: auto 1fr; column-gap: 12px; align-items: center;
  padding: 14px 26px 14px 20px; border-radius: 22px; text-decoration: none; color: #fff; font-size: 24px;
  background: linear-gradient(#ff9a3c, #f0741f); box-shadow: 0 6px 0 #c55a12, 0 10px 20px rgba(200, 90, 20, .3);
  transition: transform .12s, box-shadow .12s;
}
.apply-btn span { grid-row: span 2; font-size: 34px; }
.apply-btn small { font-size: 13px; font-weight: 500; opacity: .95; }
.apply-btn:hover { transform: translateY(-2px); }
.apply-btn:active { transform: translateY(3px); box-shadow: 0 3px 0 #c55a12; }
.sp-apply {
  position: absolute; right: 12px; top: 8px; text-decoration: none; color: #fff; font-size: 13px; padding: 7px 14px; border-radius: 99px;
  background: linear-gradient(#ff9a3c, #f0741f); box-shadow: 0 3px 0 #c55a12;
}

/* 左上のゲーム名 */
.logo {
  left: 22px; top: 18px; z-index: 5; padding: 10px 22px 12px; border-radius: 16px;
  background: rgba(255, 250, 240, .95); box-shadow: 0 4px 14px rgba(40, 50, 70, .2);
  font-size: 26px; line-height: 1.15; color: var(--ink); letter-spacing: .02em;
}
.logo small { display: block; font-size: 15px; color: var(--orange); }
.unofficial {
  right: 14px; bottom: 8px; z-index: 9; font-size: 13px; font-weight: 500; color: #6d5a48;
  background: rgba(255, 250, 240, .85); padding: 3px 10px; border-radius: 99px;
}

/* 紙のメモ */
.paper {
  background: #fdf7e6;
  background-image: linear-gradient(transparent 0 96%, rgba(0,0,0,.03) 96%), radial-gradient(circle at 20% 10%, #fff 0, transparent 60%);
  color: #4a3a2c;
  box-shadow: 2px 5px 10px rgba(60, 40, 20, .25);
  line-height: 1.45;
}
.catch { left: 470px; top: 38px; width: 330px; padding: 16px 22px; font-size: 25px; transform: rotate(-5deg); border-radius: 3px; }
.catch::before { content: ''; position: absolute; right: -8px; top: 44px; width: 110px; height: 2px; background: #b99c7b; transform: rotate(-10deg); transform-origin: left; }
.side { left: 990px; top: 236px; width: 200px; padding: 14px 16px; font-size: 18px; transform: rotate(6deg); text-align: center; z-index: 3; }
.side::before, .catch::after {
  content: ''; position: absolute; left: 50%; top: -8px; width: 60px; height: 18px; margin-left: -30px;
  background: rgba(246, 222, 150, .75); transform: rotate(-3deg);
}

/* ガラス風カード */
.card-glass {
  background: rgba(255, 253, 247, .92);
  border-radius: 16px;
  box-shadow: 0 4px 16px rgba(40, 50, 70, .18);
}
.profile { left: 1045px; top: 12px; width: 466px; height: 94px; display: flex; align-items: center; padding: 0 22px 0 14px; gap: 14px; z-index: 5; }
.avatar { width: 70px; height: 70px; border-radius: 50%; background: #fff3d6; border: 3px solid #f2c262; overflow: hidden; flex: none; }
.avatar img { width: 132%; margin: -4px 0 0 -16%; }
.pf-main { flex: 1; }
.pf-name { font-size: 20px; cursor: pointer; }
.pf-lv { font-size: 18px; display: flex; align-items: center; gap: 8px; margin-top: 4px; color: var(--ink-soft); }
.xpbar { display: inline-block; width: 128px; height: 13px; background: #7a7c80; border-radius: 99px; overflow: hidden; }
.xpbar i { display: block; height: 100%; width: 30%; background: linear-gradient(#ffd54f, #f5b400); border-radius: 99px; transition: width .6s; }
.pf-sep { width: 2px; height: 64px; background: #e7dcc8; }
.pf-money { display: grid; gap: 6px; font-size: 21px; min-width: 110px; }
.pf-money > div { display: flex; align-items: center; gap: 10px; }
.coin { display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; background: radial-gradient(circle at 35% 30%, #ffe27a, #f2a91c); border: 2px solid #d38a0e; color: #a3610a; font-size: 14px; font-weight: 800; flex: none; }
.gem { display: inline-block; width: 28px; height: 22px; flex: none; background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 28 22'%3E%3Cpath d='M6 1h16l5 6-13 14L1 7z' fill='%2344a8f0' stroke='%231c6fb8' stroke-width='1.5'/%3E%3Cpath d='M1 7h26M9 1l-3 6 8 14 8-14-3-6M6 7h16' fill='none' stroke='%23bfe4ff' stroke-width='1.2'/%3E%3C/svg%3E") center/contain no-repeat; }

/* ステージ看板（左） */
.stage-board { left: 22px; top: 128px; width: 232px; z-index: 4; }
.sb-head {
  position: relative; z-index: 2; margin: 0 auto -6px; width: 92%; text-align: center;
  color: #fff; font-size: 19px; padding: 8px 0 10px; border-radius: 10px 10px 4px 4px;
  background: linear-gradient(#8a5a2e, #6c4220); box-shadow: inset 0 2px 0 rgba(255,255,255,.2), 0 3px 6px rgba(0,0,0,.25);
}
.sb-body {
  position: relative; z-index: 1;
  background: var(--cream2); border: 7px solid var(--wood); border-radius: 12px; padding: 16px 14px 14px;
  box-shadow: inset 0 0 0 2px #e8d6b4, 0 6px 14px rgba(60, 40, 20, .3);
}
.sb-current { display: flex; align-items: center; gap: 8px; font-size: 19px; margin-bottom: 10px; }
.sb-current small { display: block; font-size: 12px; color: var(--ink-soft); font-weight: 500; }
.star-badge { width: 30px; height: 30px; flex: none; background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 30 30'%3E%3Cpath d='M15 1l3.2 4.1 5-1.3.3 5.2 4.7 2.4-2.9 4.3 2 4.8-5.1 1-1.4 5-4.8-2L11 28l-2.3-4.6-5.2-.4.8-5.1L0 14.6l3.9-3.5-.8-5.1 5.2-.4L11 1z' fill='%235cbf6b'/%3E%3Cpath d='M15 8l2.1 4.3 4.7.7-3.4 3.3.8 4.7-4.2-2.2-4.2 2.2.8-4.7-3.4-3.3 4.7-.7z' fill='%23ffe066' stroke='%23d9a400' stroke-width='.8'/%3E%3C/svg%3E") center/contain no-repeat; }
.sb-list { list-style: none; margin: 0; padding: 0 0 0 22px; position: relative; }
.sb-list::before { content: ''; position: absolute; left: 8px; top: 14px; bottom: 14px; width: 3px; background: #9aa0a4; border-radius: 2px; }
.sb-list li { position: relative; margin: 7px 0; }
.sb-list li::before { content: ''; position: absolute; left: -21px; top: 50%; width: 13px; height: 13px; margin-top: -8px; border-radius: 50%; background: #fff; border: 3px solid #8c9398; }
.sb-list li.cleared::before { background: var(--green); border-color: var(--green-d); }
.sb-list li.current::before { background: var(--gold); border-color: #d99500; }
.sb-list button small { display: block; font-size: 11px; font-weight: 500; opacity: .8; line-height: 1.2; }
.sb-list button > span { display: block; }
.sb-list button {
  width: 100%; text-align: left; border: 0; font-size: 17px; padding: 8px 10px; border-radius: 9px;
  background: #ece6dc; color: #8b8378; display: flex; align-items: center; gap: 8px;
}
.sb-list li.open button { background: #fff7e2; color: var(--ink); box-shadow: 0 1px 0 #e0cfae; }
.sb-list li.current button { background: #ffe9a8; color: var(--ink); box-shadow: 0 0 0 2px #f2b830; }
.sb-list button:disabled { cursor: default; }
.lock { width: 22px; height: 22px; border-radius: 50%; background: #c9c2b7; display: inline-grid; place-items: center; flex: none; }
.lock::before { content: ''; width: 9px; height: 7px; border-radius: 1px; background: #fff; box-shadow: 0 -5px 0 -2px transparent; position: relative; top: 2px; }
.lock::after { content: ''; position: absolute; width: 7px; height: 7px; border: 2px solid #fff; border-bottom: 0; border-radius: 5px 5px 0 0; margin-top: -7px; }
.ok-mark { width: 22px; height: 22px; border-radius: 50%; background: var(--green); color: #fff; display: inline-grid; place-items: center; font-size: 13px; flex: none; }
.sb-post { position: relative; left: 50%; width: 16px; height: 70px; margin-left: -8px; background: linear-gradient(90deg, #6e4320, #9a6434, #6e4320); z-index: 0; }

/* 木の看板 */
.wood-banner {
  left: 488px; top: 200px; width: 560px; height: 80px; z-index: 3;
  display: flex; align-items: center; justify-content: center; gap: 10px;
  color: #fff; font-size: 38px; letter-spacing: .02em;
  text-shadow: 0 2px 0 #5a3515, 0 0 6px rgba(60, 30, 10, .4);
  background:
    repeating-linear-gradient(178deg, rgba(255,255,255,.05) 0 3px, transparent 3px 11px),
    linear-gradient(#b27a45, #8d5a2c 60%, #7a4b22);
  border: 4px solid #5e3a19; border-radius: 16px 12px 18px 12px;
  box-shadow: inset 0 3px 0 rgba(255,255,255,.25), 0 6px 12px rgba(60, 30, 10, .35);
  transform: rotate(-1deg);
}
.wood-banner::before, .wood-banner::after { content: ''; position: absolute; top: 50%; width: 10px; height: 10px; margin-top: -5px; border-radius: 50%; background: #4a2c10; box-shadow: inset 1px 1px 0 rgba(255,255,255,.3); }
.wood-banner::before { left: 14px; } .wood-banner::after { right: 14px; }
.leaf { width: 58px; height: 46px; flex: none; margin-left: -20px; background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 58 46'%3E%3Crect x='2' y='8' width='40' height='30' rx='8' fill='%23f7e9c8' stroke='%235e3a19' stroke-width='3'/%3E%3Cpath d='M22 30c2-10 10-18 26-22-2 14-10 22-26 22z' fill='%236cc26a' stroke='%23357a35' stroke-width='2'/%3E%3Cpath d='M24 28c6-6 12-12 20-16' stroke='%23357a35' stroke-width='1.5' fill='none'/%3E%3C/svg%3E") center/contain no-repeat; }

/* 問題カード */
.qcard {
  left: 382px; top: 292px; width: 772px; height: 364px; z-index: 2;
  background: linear-gradient(#c8955c, #a87441);
  border-radius: 26px; padding: 12px;
  box-shadow: 0 10px 24px rgba(60, 40, 20, .35), inset 0 2px 0 rgba(255,255,255,.35);
}
.qcard-inner {
  position: relative; height: 100%; border-radius: 18px; background: var(--cream);
  box-shadow: inset 0 0 0 2px #efe3cb; padding: 22px 34px 40px; overflow: hidden;
  display: flex; flex-direction: column; align-items: center;
}
.qtop { width: 100%; display: flex; align-items: center; gap: 22px; }
.pbar { flex: 1; height: 22px; background: #ece7df; border-radius: 99px; overflow: hidden; box-shadow: inset 0 1px 2px rgba(0,0,0,.08); }
.pbar i { display: block; height: 100%; width: 0; background: linear-gradient(#72d17e, #4cb35c); border-radius: 99px; transition: width .35s; }
.qcount { font-size: 26px; color: #6f6a62; white-space: nowrap; }
.qtext {
  margin-top: 18px; font-size: var(--qfs, 42px); line-height: 1.55; text-align: center; color: #2e2a26;
  min-height: 150px; display: grid; place-items: center; width: 100%; flex: none; letter-spacing: .02em;
  max-width: 100%; word-break: normal; overflow-wrap: anywhere; line-break: strict; text-wrap: pretty;
}
.qtext .qt-in { display: block; max-width: 100%; }
.qtext .done { color: #c8bca9; }
.qtext ruby rt { font-size: .38em; color: var(--orange); opacity: 0; transition: opacity .2s; }
body.furigana .qtext ruby rt { opacity: 1; }
.qromaji {
  margin-top: 8px; font-size: var(--rfs, 22px); letter-spacing: .04em; color: #a39c93; text-align: center;
  font-family: 'M PLUS Rounded 1c', ui-monospace, monospace; font-weight: 700; line-height: 1.35;
  max-width: 100%; overflow-wrap: anywhere; flex: none;
}
.qromaji .typed { color: var(--green-d); }
.qromaji .cur { color: #2e2a26; background: #ffe58a; border-radius: 4px; padding: 0 1px; }
.qromaji .missed { color: #fff; background: var(--miss); }
.qline { width: 88%; height: 2px; background: #d9d2c6; margin-top: 10px; }
.qtools { position: absolute; left: 16px; bottom: 10px; display: flex; gap: 6px; }
.mini { border: 0; background: #f3ecdf; color: #8a7d6c; font-size: 12px; padding: 4px 10px; border-radius: 99px; }
.mini:hover { background: #ffe9a8; color: var(--ink); }
.mini.on { background: #ffe9a8; color: var(--ink); }
.by { position: absolute; right: 22px; bottom: 12px; font-size: 13px; color: #a39c93; }
.qcard.shake .qcard-inner { animation: shake .25s; }
@keyframes shake { 0%,100% { transform: translateX(0); } 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }
.qcard.clear .qcard-inner { animation: pop .35s; }
@keyframes pop { 50% { transform: scale(1.02); box-shadow: inset 0 0 0 4px #9fe0a8; } }

/* オーバーレイ（スタート） */
.overlay {
  position: absolute; inset: 12px; border-radius: 18px; z-index: 5;
  background: rgba(255, 250, 240, .94);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px;
}
.ov-stage { font-size: 26px; color: var(--ink-soft); }
.ov-stage b { color: var(--ink); font-size: 32px; }
.ov-hint { font-size: 15px; color: #9a8f80; }
.btn-start {
  border: 0; font-size: 28px; padding: 14px 64px; border-radius: 99px; color: #fff;
  background: linear-gradient(#ff9a3c, #f0741f); box-shadow: 0 5px 0 #c55a12, 0 8px 16px rgba(200, 90, 20, .3);
  transition: transform .1s;
}
.btn-start:active { transform: translateY(3px); box-shadow: 0 2px 0 #c55a12; }
.btn-sub { border: 0; font-size: 20px; padding: 12px 30px; border-radius: 99px; background: #efe6d6; color: var(--ink); box-shadow: 0 4px 0 #d3c3a6; }
.btn-post { font-size: 15px; color: var(--blue); text-decoration: none; }
.btn-post:not([href]) { display: none; }
.countdown { position: absolute; inset: 0; display: none; place-items: center; font-size: 150px; color: var(--orange); text-shadow: 0 6px 0 #fff, 0 8px 18px rgba(0,0,0,.2); z-index: 6; pointer-events: none; }
.countdown.show { display: grid; animation: cd .9s; }
@keyframes cd { from { transform: scale(1.6); opacity: 0; } 30% { transform: scale(1); opacity: 1; } }

/* キーボード */
.kb-wrap { left: 408px; top: 668px; width: 720px; height: 300px; perspective: 900px; z-index: 3; }
.kb {
  width: 100%; height: 100%; transform: rotateX(16deg); transform-origin: 50% 0;
  background: url(../assets/kb_frame.png) 0 0 / 100% 100% no-repeat;
  padding: 34px 30px 30px; filter: drop-shadow(0 14px 14px rgba(70, 40, 15, .3));
}
.kb-row { display: flex; gap: 7px; margin-bottom: 8px; }
.kb-row:nth-child(2) { padding-left: 22px; }
.kb-row:nth-child(3) { padding-left: 30px; }
.kb-row:nth-child(4) { padding-left: 150px; }
/* 木のキー（画像を9分割で伸ばすので、角の丸みと厚みがどの幅でも崩れない） */
.key {
  width: 52px; height: 50px; flex: none; position: relative;
  border: 14px solid transparent; border-bottom-width: 17px;
  border-image: url(../assets/key.png) 44 44 52 44 fill / 14px 14px 17px 14px stretch;
  color: #7b5433; font-size: 22px; font-weight: 800; line-height: 1;
  display: grid; place-items: center; text-shadow: 0 1px 0 rgba(255, 255, 255, .7);
  transition: transform .06s, filter .1s;
  font-family: 'M PLUS Rounded 1c', sans-serif;
}
.key.next { color: #c2410c; transform: translateY(-3px); filter: drop-shadow(0 0 7px rgba(255, 190, 30, .95)) drop-shadow(0 0 2px rgba(255, 170, 0, .9)) brightness(1.07); }
.key.press { transform: translateY(3px); filter: brightness(.9) sepia(.2); }
.key.bad { color: var(--miss); filter: drop-shadow(0 0 6px rgba(226, 83, 74, .9)); }
.key.enter {
  width: 96px; font-size: 17px; color: #fff4e0; text-shadow: 0 1px 2px rgba(50, 25, 5, .6);
  border-image-source: url(../assets/key_dark.png);
}
.key.enter.next { color: #ffe08a; }
.key.space {
  width: 340px; font-size: 18px;
  border-image: url(../assets/key_wide.png) 40 60 50 60 fill / 14px 18px 17px 18px stretch;
}
.key.wide { width: 70px; }

/* 手 */
img.thand { left: 483px; top: 808px; width: 570px; z-index: 4; filter: drop-shadow(0 6px 8px rgba(60, 40, 20, .18)); transition: transform .08s; pointer-events: none; }
.hand-l { clip-path: inset(0 50% 0 0); }
.hand-r { clip-path: inset(0 0 0 50%); }
.thand.tap { transform: translateY(7px); }

/* 右のステータス */
.stats {
  left: 1256px; top: 300px; width: 254px; z-index: 3;
  background: var(--cream); border: 7px solid var(--wood); border-radius: 18px; padding: 10px 18px;
  box-shadow: inset 0 0 0 2px #e8d6b4, 0 8px 18px rgba(60, 40, 20, .3);
}
.st-row { display: flex; align-items: center; gap: 12px; padding: 12px 0; }
.st-row + .st-row, .tbar + .st-row { border-top: 2px solid #efe5d3; }
.st-label { font-size: 16px; color: var(--ink-soft); }
.st-time { font-size: 40px; line-height: 1.1; font-variant-numeric: tabular-nums; }
.st-time.low { color: var(--miss); animation: blink .6s infinite alternate; }
@keyframes blink { to { opacity: .55; } }
.st-val { font-size: 30px; font-variant-numeric: tabular-nums; }
.st-combo { font-size: 17px; color: var(--orange); white-space: nowrap; }
.st-combo b { font-size: 32px; }
.st-combo.bump b { display: inline-block; animation: bump .25s; }
@keyframes bump { 50% { transform: scale(1.35); } }
.tbar { height: 10px; background: #efe8da; border-radius: 99px; overflow: hidden; margin: -4px 0 10px; }
.tbar i { display: block; height: 100%; width: 100%; background: linear-gradient(90deg, #ffcf3f, #f5b400); border-radius: 99px; transition: width .25s linear; }
.tbar.low i { background: linear-gradient(90deg, #ff8a70, var(--miss)); }
.ic-watch { width: 48px; height: 52px; flex: none; background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 48 52'%3E%3Crect x='18' y='1' width='12' height='6' rx='2' fill='%235a4636'/%3E%3Ccircle cx='24' cy='29' r='20' fill='%23fff' stroke='%235a4636' stroke-width='4'/%3E%3Cpath d='M24 29V17M24 29l7 5' stroke='%235a4636' stroke-width='3.5' stroke-linecap='round'/%3E%3Cpath d='M38 10l4 4' stroke='%235a4636' stroke-width='4' stroke-linecap='round'/%3E%3C/svg%3E") center/contain no-repeat; }
.ic-star { width: 46px; height: 46px; flex: none; background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 46 46'%3E%3Cpath d='M23 3l6 13 14 1.6-10.5 9.6 3 14L23 34l-12.5 7.2 3-14L3 17.6 17 16z' fill='%23ffc93a' stroke='%23c98a00' stroke-width='2.5' stroke-linejoin='round'/%3E%3C/svg%3E") center/contain no-repeat; }
.ic-fire { font-size: 40px; width: 46px; text-align: center; flex: none; }

/* 机とこもの */
.desk {
  display: none; left: 0; right: 0; bottom: 0; height: 210px; z-index: 1;
  background:
    repeating-linear-gradient(0deg, rgba(120, 70, 30, .07) 0 2px, transparent 2px 13px),
    linear-gradient(#d9a870, #c28a50 40%, #a9733d);
  box-shadow: 0 -4px 0 #e6bd88, 0 -10px 24px rgba(60, 40, 20, .2);
}
.plant { left: 1100px; top: 560px; width: 190px; z-index: 1; filter: drop-shadow(0 6px 8px rgba(60, 40, 20, .2)); }
.books { left: -10px; bottom: 30px; width: 170px; z-index: 6; display: flex; flex-direction: column; }
.book {
  height: 50px; margin-top: -2px; border-radius: 8px 4px 4px 8px; color: #fff; font-size: 26px; padding-left: 20px; line-height: 50px;
  text-shadow: 0 2px 0 rgba(0,0,0,.2); box-shadow: inset 0 -5px 0 rgba(0,0,0,.14), inset -16px 0 0 #fbf1dc, inset -18px 0 0 rgba(0,0,0,.1), 0 2px 3px rgba(0,0,0,.2);
  transform: rotate(-2deg);
}
.b1 { background: #3f8fb7; width: 150px; } .b2 { background: #3d8f5a; width: 160px; transform: rotate(1deg); }
.b3 { background: #e39632; width: 150px; } .b4 { background: #d8574a; width: 158px; transform: rotate(2deg); } .b5 { background: #3a67a8; width: 150px; }
.lion { left: 20px; top: 518px; width: 370px; clip-path: inset(0 0 5.4% 0); z-index: 5; filter: drop-shadow(0 6px 8px rgba(60, 40, 20, .25)); transform-origin: 50% 90%; }
.lion.jump { animation: jump .45s; }
@keyframes jump { 40% { transform: translateY(-18px) rotate(-3deg); } }
.laptop {
  left: 190px; top: 760px; width: 200px; height: 130px; z-index: 6;
  background: linear-gradient(135deg, #8e949c, #6c727a); border-radius: 12px 12px 6px 6px;
  transform: skewY(-10deg) rotate(6deg); box-shadow: inset 0 0 0 4px #a7adb4, 0 8px 12px rgba(0,0,0,.25);
}
.laptop::after { content: ''; position: absolute; left: 50%; top: 50%; width: 30px; height: 34px; margin: -17px 0 0 -15px; border-radius: 50% 50% 45% 45%; background: #5a6068; }
.mug { left: 170px; top: 818px; width: 190px; z-index: 7; filter: drop-shadow(0 6px 8px rgba(60, 40, 20, .25)); }
.penguin { left: 1180px; top: 716px; width: 270px; z-index: 5; filter: drop-shadow(0 6px 8px rgba(60, 40, 20, .2)); transform-origin: 50% 100%; }
.penguin.nod { animation: nod .5s; }
@keyframes nod { 50% { transform: rotate(-5deg) translateY(-6px); } }
.bubble {
  left: 1330px; top: 640px; width: 184px; min-height: 84px; z-index: 6; padding: 14px 10px; border-radius: 50%;
  background: #fff; text-align: center; font-size: 19px; line-height: 1.35; display: grid; place-items: center;
  box-shadow: 0 4px 10px rgba(0,0,0,.15); transition: transform .2s;
}
.bubble::after { content: ''; position: absolute; left: 34px; bottom: -14px; border: 10px solid transparent; border-top: 18px solid #fff; transform: rotate(20deg); }
.bubble.pop { animation: pop2 .3s; }
@keyframes pop2 { 50% { transform: scale(1.1); } }
.memo {
  left: 1210px; top: 882px; width: 260px; height: 190px; z-index: 6; padding: 20px 24px; font-size: 22px; line-height: 1.3;
  background: #fffdf6; transform: rotate(-8deg); box-shadow: 0 6px 12px rgba(0,0,0,.2);
}
.memo > div { display: flex; gap: 10px; align-items: flex-start; margin-bottom: 8px; }
.chk { width: 22px; height: 22px; border: 2px solid #555; border-radius: 3px; flex: none; margin-top: 4px; position: relative; }
.chk.on::after { content: ''; position: absolute; left: 3px; top: -6px; width: 9px; height: 18px; border: solid #e2534a; border-width: 0 4px 4px 0; transform: rotate(40deg); }
.pencil { left: 1460px; top: 900px; width: 16px; height: 170px; z-index: 6; background: linear-gradient(90deg, #f3c34a, #ffd966, #e0a92a); transform: rotate(-30deg); border-radius: 3px; }
.pencil::before { content: ''; position: absolute; left: 0; top: -22px; border: 8px solid transparent; border-bottom: 22px solid #f2d9b0; border-top: 0; }

/* ============================================================
   スマホ
   ============================================================ */
body.is-sp { background: #f3eadb url(../assets/bg-sp.jpg) center/cover; }
#sp {
  position: fixed; left: 0; right: 0; top: 0; height: var(--vh, 100dvh); max-width: 600px; margin: 0 auto;
  flex-direction: column; overflow: hidden;
  background: #9fd5f3 url(../assets/bg-sp.jpg) 14% 100% / cover no-repeat;
  padding-top: env(safe-area-inset-top);
}
.sp-top { display: flex; align-items: center; gap: 6px; padding: 8px 8px 4px; flex: none; }
.sp-back { width: 36px; height: 36px; flex: none; border-radius: 50%; border: 0; background: rgba(255,255,255,.92); font-size: 26px; line-height: 1; padding-bottom: 4px; box-shadow: 0 2px 6px rgba(0,0,0,.12); }
.sp-chip { display: flex; align-items: center; gap: 6px; background: rgba(255,255,255,.93); border-radius: 99px; padding: 4px 10px 4px 5px; box-shadow: 0 2px 6px rgba(0,0,0,.12); min-width: 0; }
.sp-chip small { display: block; font-size: 10px; color: var(--ink-soft); line-height: 1.1; }
.sp-chip b { display: block; font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sp-stage { flex: 1 1 auto; }
.sp-stage .star-badge { width: 26px; height: 26px; }
.sp-lv img { width: 30px; height: 30px; border-radius: 50%; object-fit: cover; object-position: 50% 15%; background: #fff3d6; border: 2px solid #f2c262; }
.sp-lv .xpbar { width: 48px; height: 7px; }
.sp-money { font-size: 12px; background: rgba(255,255,255,.93); border-radius: 12px; padding: 3px 8px; box-shadow: 0 2px 6px rgba(0,0,0,.12); display: grid; gap: 1px; flex: none; }
.sp-money > div { display: flex; align-items: center; gap: 4px; }
.sp-money .coin { width: 15px; height: 15px; font-size: 9px; border-width: 1px; }
.sp-money .gem { width: 16px; height: 13px; }
.sp-sky { flex: 1 1 60px; min-height: 44px; display: flex; align-items: flex-end; justify-content: center; gap: 10px; padding: 0 12px 10px; position: relative; }
.sp-dots { display: flex; align-items: center; background: rgba(255,255,255,.35); border-radius: 99px; padding: 4px 8px; }
.sp-dots i { width: 14px; height: 14px; border-radius: 50%; background: #fff; border: 3px solid #8c9398; position: relative; }
.sp-dots i + i { margin-left: 18px; }
.sp-dots i + i::before { content: ''; position: absolute; right: 100%; top: 50%; width: 21px; height: 3px; margin-top: -1.5px; background: #8c9398; }
.sp-dots i.cleared { background: var(--green); border-color: var(--green-d); }
.sp-dots i.current { width: 22px; height: 22px; border: 0; background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 22 22'%3E%3Ccircle cx='11' cy='11' r='10' fill='%23ffd54f' stroke='%23d99500' stroke-width='2'/%3E%3Cpath d='M11 5l1.8 3.8 4 .5-3 2.8.8 4-3.6-2-3.6 2 .8-4-3-2.8 4-.5z' fill='%23f59e00'/%3E%3C/svg%3E") center/contain; }
.sp-count { position: absolute; right: 12px; bottom: 10px; background: rgba(255,255,255,.92); border-radius: 99px; padding: 3px 10px; font-size: 13px; color: var(--ink-soft); }
.sp-card {
  flex: none; position: relative; margin: 0 12px; background: var(--cream); border-radius: 18px; padding: 12px 16px 12px;
  border: 5px solid #e9d6b0; box-shadow: 0 6px 16px rgba(60, 40, 20, .2);
}
.sp-card .pbar { height: 14px; }
.sp-mini { display: flex; justify-content: space-between; font-size: 12px; color: var(--ink-soft); margin-top: 6px; }
.sp-mini b { color: var(--ink); font-variant-numeric: tabular-nums; }
.sp-mini .low { color: var(--miss); }
.sp-card .qtext { margin-top: 8px; font-size: var(--qfs, 21px); min-height: 64px; line-height: 1.6; }
.sp-card .qromaji { font-size: var(--rfs, 14px); margin-top: 2px; letter-spacing: .04em; }
.sp-card .by { position: static; text-align: right; font-size: 11px; margin-top: 4px; }
.sp-card .by:empty { display: none; }
.sp-btns { display: flex; justify-content: space-between; margin-top: 10px; }
.pill { border: 2px solid #eadbbf; background: #fff; border-radius: 99px; padding: 5px 14px; font-size: 13px; color: var(--ink-soft); }
.pill.on { background: #fff4cf; border-color: #f2c262; color: var(--ink); }
.sp-card .overlay { inset: 0; border-radius: 13px; gap: 12px; }
.sp-card .ov-stage { font-size: 15px; } .sp-card .ov-stage b { font-size: 20px; }
.sp-card .btn-start { font-size: 22px; padding: 10px 48px; }
.sp-card .ov-hint { font-size: 12px; text-align: center; padding: 0 10px; }
.sp-card .countdown { font-size: 90px; }
.sp-scene { flex: 1 1 120px; min-height: 70px; position: relative; overflow: hidden;
  background: radial-gradient(ellipse 58% 34% at 46% 100%, rgba(236, 214, 170, .85) 0 60%, transparent 62%);
}
.sp-walk { position: absolute; left: 50%; bottom: 0; height: 88%; max-height: 190px; transform: translateX(-54%); }
.sp-walk.walking { animation: bob .5s infinite alternate ease-in-out; }
@keyframes bob { to { transform: translateX(-54%) translateY(-4px); } }
.sp-sign {
  position: absolute; right: 8px; bottom: 10px; font-size: 13px; line-height: 1.3; padding: 8px 10px; color: #4a2c10; transform: rotate(5deg);
  background: linear-gradient(#e6c08a, #cf9f63); border: 3px solid #8d5a2c; border-radius: 6px; box-shadow: 0 3px 6px rgba(0,0,0,.2);
}
.sp-bubble { position: absolute; left: 10px; top: 10px; background: #fff; border-radius: 16px; padding: 6px 10px; font-size: 12px; line-height: 1.35; box-shadow: 0 2px 6px rgba(0,0,0,.15); max-width: 42%; }
.sp-bubble.pop { animation: pop2 .3s; }
.sp-input { flex: none; position: relative; display: grid; padding: 8px 12px calc(8px + env(safe-area-inset-bottom)); background: #f3eadb; border-top: 2px solid #e5d6bb; }
.sp-input .sp-in, .sp-input .sp-echo { grid-area: 1 / 1; }
/* 本物の入力欄の文字は透明にして、今の問題の分だけ .sp-echo で見せる */
.sp-input .sp-in { color: transparent; -webkit-text-fill-color: transparent; caret-color: transparent; }
.sp-input .sp-in::placeholder { color: #a39c93; -webkit-text-fill-color: #a39c93; }
.sp-input.has-text .sp-in::placeholder { color: transparent; -webkit-text-fill-color: transparent; }
.sp-echo {
  pointer-events: none; align-self: center; padding: 0 17px; font-size: 18px; font-weight: 700; color: var(--ink);
  white-space: nowrap; overflow: hidden;
}
.sp-input.has-text .sp-echo::after { content: ''; display: inline-block; width: 2px; height: 1.1em; margin-left: 2px; vertical-align: -3px; background: var(--orange); animation: blink .8s infinite alternate; }
.sp-input.miss .sp-in { border-color: var(--miss); background: #fff1ef; }
.sp-input input {
  width: 100%; font-size: 18px; font-family: var(--font); font-weight: 700; padding: 10px 14px; border-radius: 12px;
  border: 3px solid #e2cfa9; background: #fff; color: var(--ink); outline: none;
}
.sp-input input:focus { border-color: var(--orange); }

/* ============================================================
   モーダル（結果・ステージ選択）
   ============================================================ */
.modal { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; background: rgba(40, 30, 20, .45); padding: 16px; }
.modal-box {
  width: min(560px, 100%); max-height: 100%; overflow: auto; background: var(--cream); border-radius: 24px; border: 8px solid var(--wood);
  box-shadow: inset 0 0 0 2px #e8d6b4, 0 16px 40px rgba(0,0,0,.35); padding: 28px 28px 22px; text-align: center; animation: pop2 .35s;
}
.modal-box h2 { margin: 0 0 16px; font-size: 24px; }
.rs-ribbon {
  display: inline-block; font-size: 30px; color: #fff; padding: 8px 40px; margin: -4px 0 14px;
  background: linear-gradient(#ff9a3c, #f0741f); border-radius: 12px; box-shadow: 0 4px 0 #c55a12;
}
.rs-ribbon.fail { background: linear-gradient(#8fb4d8, #5f8fc0); box-shadow: 0 4px 0 #3f6c9a; }
.rs-rank small { display: block; color: var(--ink-soft); font-size: 14px; }
.rs-rank b { font-size: 28px; color: var(--orange); }
.rs-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 18px 0 14px; }
.rs-grid > div { background: #fff; border-radius: 14px; padding: 10px 4px; box-shadow: 0 2px 0 #eadbbf; }
.rs-grid b small { display: inline; font-size: 13px; color: var(--ink-soft); }
.rs-grid > div > small { display: block; font-size: 12px; color: var(--ink-soft); }
.rs-grid b { font-size: 24px; font-variant-numeric: tabular-nums; }
.rs-reward { display: flex; justify-content: center; gap: 18px; font-size: 18px; margin-bottom: 8px; flex-wrap: wrap; }
.rs-reward span { display: inline-flex; align-items: center; gap: 6px; }
.rs-reward .lvup { color: var(--orange); }
.rs-msg { font-size: 15px; color: var(--ink-soft); min-height: 22px; margin-bottom: 14px; }
.rs-btns { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }
.rs-btns .btn-start { font-size: 22px; padding: 12px 34px; }
.rs-hint { font-size: 12px; color: #a39c93; margin-top: 12px; }
body.is-sp .rs-hint { display: none; }
.sp-title { margin-left: auto; text-align: right; font-size: 13px; line-height: 1.15; background: rgba(255,255,255,.93); border-radius: 12px; padding: 5px 10px; box-shadow: 0 2px 6px rgba(0,0,0,.12); flex: none; }
.sp-title small { display: block; font-size: 10px; color: var(--orange); }
.sp-unofficial { position: absolute; left: 8px; bottom: 6px; right: auto; font-size: 10px; padding: 2px 8px; z-index: 2; }
body.is-sp .modal-box { padding: 20px 14px 16px; border-width: 6px; }
body.is-sp .rs-grid b { font-size: 19px; }
body.is-sp .rs-grid b small { display: inline; font-size: 11px; }
body.is-sp .rs-rank b { font-size: 21px; }
body.is-sp .rs-btns .btn-start { font-size: 18px; padding: 10px 22px; }
body.is-sp .btn-sub { font-size: 16px; padding: 10px 18px; }
body.is-sp .rs-grid { gap: 6px; }
body.is-sp .rs-ribbon { font-size: 22px; padding: 6px 26px; }
.stage-grid { list-style: none; padding: 0; margin: 0 0 16px; display: grid; gap: 8px; }
.stage-grid button { width: 100%; border: 0; border-radius: 14px; padding: 12px 14px; font-size: 17px; display: flex; align-items: center; gap: 10px; background: #ece6dc; color: #8b8378; text-align: left; }
.stage-grid li.open button { background: #fff; color: var(--ink); box-shadow: 0 2px 0 #eadbbf; }
.stage-grid li.current button { background: #ffe9a8; box-shadow: 0 0 0 2px #f2b830; }
.stage-grid .no { width: 28px; height: 28px; border-radius: 50%; background: var(--wood-l); color: #fff; display: grid; place-items: center; font-size: 14px; flex: none; }
.stage-grid .best { margin-left: auto; font-size: 12px; color: var(--ink-soft); }
.btn-close { border: 0; background: #efe6d6; border-radius: 99px; padding: 10px 30px; font-size: 16px; }

.toast {
  position: fixed; left: 50%; top: 18px; z-index: 60; transform: translate(-50%, -200%); transition: transform .3s, visibility .3s; visibility: hidden;
  background: #3b2a1e; color: #fff; padding: 10px 20px; border-radius: 99px; font-size: 15px; box-shadow: 0 4px 14px rgba(0,0,0,.25);
  max-width: calc(100% - 32px); text-align: center;
}
.toast.show { transform: translate(-50%, 0); visibility: visible; }

/* 紙吹雪 */
.confetti { position: fixed; top: -20px; width: 10px; height: 14px; z-index: 55; pointer-events: none; animation: fall linear forwards; }
@keyframes fall { to { transform: translateY(110vh) rotate(720deg); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* キーボードが出て下の景色が小さくなったら、看板を隠してキャラを見せる */
.sp-scene { container-type: size; }
@container (max-height: 120px) { .sp-sign { display: none; } }
.sp-sky { container-type: size; }
@container (max-height: 90px) { .sp-apply { display: none; } }
