:root {
  --clawd: #D77757;
  --clawd-dark: #b85a3c;
  --cream: #faf6ee;
  --paper: #ffffff;
  --ink: #2b2118;
  --muted: #7a6d62;
  --line: #e7ddd0;
  --green: #4caf50;
  --wood: #b98457;
  --wood-dark: #8b6040;
  --sky: #9fd8f5;
  --gold: #f2b705;
  --red: #e5533d;
  --blue: #3d8be5;
  --radius: 14px;
  --shadow: 0 3px 0 rgba(0, 0, 0, .12);
  --pixel: 'DotGothic16', monospace;
  color-scheme: light;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  margin: 0;
  background: #e9dfd1;
  color: var(--ink);
  font-family: 'M PLUS Rounded 1c', system-ui, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

#app {
  max-width: 480px;
  min-height: 100dvh;
  margin: 0 auto;
  background: var(--cream);
  box-shadow: 0 0 40px rgba(0, 0, 0, .12);
  position: relative;
  overflow-x: hidden;
}

.screen { min-height: 100dvh; padding: 12px 16px 20px; }

button { font: inherit; color: inherit; cursor: pointer; }
code { font-family: var(--pixel); background: #f1e9dd; padding: 0 4px; border-radius: 4px; }
.fine { font-size: 12px; color: var(--muted); text-align: center; }
/* ---------- ボタン ---------- */
.btn {
  border: 2px solid var(--ink);
  background: var(--paper);
  border-radius: 999px;
  padding: 10px 18px;
  font-weight: 700;
  box-shadow: var(--shadow);
  transition: transform .08s;
}
.btn:active:not(:disabled) { transform: translateY(2px); box-shadow: none; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary { background: var(--clawd); color: #fff; border-color: var(--clawd-dark); }
.btn-danger { background: #fff0ee; color: var(--red); border-color: var(--red); }
.btn-big { font-size: 20px; padding: 14px 24px; }
.btn-small { padding: 6px 12px; font-size: 14px; }

/* ---------- Clawd ---------- */
.clawd-svg { display: block; width: 100%; height: auto; overflow: visible; }
.clawd-svg .eye { transform-box: fill-box; transform-origin: center; animation: blink 4s infinite; }
.clawd-svg.walk .legs-a { animation: legs 0.36s steps(1) infinite; }
.clawd-svg.walk .legs-b { animation: legs 0.36s steps(1) infinite reverse; }
@keyframes blink { 0%, 92%, 100% { transform: scaleY(1); } 95% { transform: scaleY(0.1); } }
@keyframes legs { 0% { opacity: 1; } 50% { opacity: 0; } }

/* ---------- タイトル ---------- */
#title { padding: 0; display: flex; flex-direction: column; }
.title-hero {
  position: relative;
  height: 62dvh;
  min-height: 420px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  background-color: #fbf3e4;
  background-image:
    linear-gradient(rgba(215, 119, 87, .1) 1px, transparent 1px),
    linear-gradient(90deg, rgba(215, 119, 87, .1) 1px, transparent 1px);
  background-size: 22px 22px;
}
.term {
  margin-top: 6vh; width: calc(100% - 32px); max-width: 420px; z-index: 1;
  background: #1d1712; border: 3px solid var(--ink); border-radius: 14px; overflow: hidden;
  box-shadow: 0 6px 0 rgba(0, 0, 0, .15);
}
.term-bar { display: flex; align-items: center; gap: 6px; padding: 7px 10px; background: #33291f; }
.term-bar i { width: 10px; height: 10px; border-radius: 50%; background: #e5533d; }
.term-bar i:nth-child(2) { background: var(--gold); }
.term-bar i:nth-child(3) { background: #6fcf62; }
.term-bar span { margin-left: auto; font-family: var(--pixel); font-size: 11px; color: #a89886; }
.term-body { padding: 12px 14px 22px; }
.prompt { font-family: var(--pixel); color: #8fd18a; font-size: 13px; }
.cursor { display: inline-block; width: 8px; height: 14px; background: #8fd18a; margin-left: 4px; vertical-align: -2px; animation: cursor 1s steps(1) infinite; }
@keyframes cursor { 50% { opacity: 0; } }
.logo { text-align: center; margin-top: 14px; }
.logo h1 {
  font-family: var(--pixel);
  font-size: clamp(30px, 10vw, 46px);
  line-height: 1.2;
  margin: 10px 0 0;
  color: #fff;
  text-shadow: 0 4px 0 var(--clawd);
  letter-spacing: 1px;
}
.logo-sub {
  display: inline-block;
  background: var(--clawd);
  color: #fff;
  font-weight: 800;
  padding: 3px 14px;
  border-radius: 999px;
  font-size: 14px;
}
.title-clawd {
  width: 150px;
  position: absolute;
  bottom: 13%;
  z-index: 1;
  animation: titleWalk 9s linear infinite;
}
@keyframes titleWalk {
  0% { transform: translateX(-160px); }
  50% { transform: translateX(160px); }
  50.01% { transform: translateX(160px) scaleX(-1); }
  100% { transform: translateX(-160px) scaleX(-1); }
}
.floor {
  position: absolute; left: 0; right: 0; bottom: 0; height: 16%;
  background: repeating-linear-gradient(90deg, transparent 0 46px, rgba(0, 0, 0, .12) 46px 48px), var(--wood);
  border-top: 4px solid var(--wood-dark);
}
.title-menu { display: flex; flex-direction: column; gap: 12px; padding: 24px 32px 8px; }
.title-sub-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* ---------- HUD ---------- */
.hud { background: var(--ink); color: #fff; border-radius: var(--radius); padding: 8px 12px; }
.hud-row { display: flex; align-items: center; gap: 8px; }
.turn-label { font-family: var(--pixel); font-size: 18px; }
.turn-left { margin-left: auto; font-size: 12px; color: #d9cbbb; }
.goal-label { font-size: 13px; margin-top: 4px; display: flex; flex-wrap: wrap; align-items: center; gap: 4px; }
.goal-label em { font-style: normal; color: var(--gold); font-size: 18px; font-weight: 800; margin: 0 2px; }
.goal-chip { background: var(--clawd); border-radius: 999px; padding: 1px 8px; font-size: 12px; font-weight: 700; margin-left: auto; }
.badge.fast { background: var(--gold); color: var(--ink); border-radius: 999px; padding: 1px 6px; font-size: 12px; }
.fast-toggle { font-size: 14px; padding: 8px 14px; }
.fast-toggle.on { background: #fff1ea; border-color: var(--clawd); color: var(--clawd-dark); }
.badge.camp { background: var(--sky); color: var(--ink); border-radius: 999px; padding: 1px 8px; font-size: 12px; font-weight: 700; }

/* ---------- ステージ ---------- */
.stage {
  position: relative;
  margin: 10px 0 8px;
  height: 170px;
  border-radius: var(--radius);
}
/* 教室（黒板・窓・木の床） */
.room {
  position: relative;
  border: 2px solid var(--ink);
  border-radius: var(--radius);
  overflow: hidden;
  background:
    repeating-linear-gradient(90deg, transparent 0 46px, rgba(0, 0, 0, .12) 46px 48px) bottom / 100% 28% no-repeat,
    linear-gradient(var(--wood), var(--wood)) bottom / 100% 28% no-repeat,
    #f3e6cf;
}
.room::before {
  content: 'if (努力) { 成長(); }';
  position: absolute; left: 12px; top: 12px; width: 36%; height: 42%; z-index: 0;
  background: #2f5d4a; border: 4px solid var(--wood-dark); border-radius: 4px;
  color: rgba(255, 255, 255, .75); font-family: var(--pixel); font-size: 10px; line-height: 1.4; padding: 5px 6px;
}
.room::after {
  content: '';
  position: absolute; right: 14px; top: 12px; width: 22%; height: 40%; z-index: 0;
  border: 4px solid #fff; outline: 2px solid #c9b79c;
  background:
    linear-gradient(#fff, #fff) center / 3px 100% no-repeat,
    linear-gradient(#fff, #fff) center / 100% 3px no-repeat,
    linear-gradient(#a9dcf5, #d9f1fb);
}
.room > * { z-index: 1; }
.clawd-wrap {
  position: absolute; left: 50%; bottom: 22px; width: 150px; margin-left: -75px;
  animation: bob 2.4s ease-in-out infinite;
  cursor: pointer;
}
.clawd-wrap.jump { animation: jump .5s ease-out, bob 2.4s ease-in-out .5s infinite; }
.clawd-wrap.shake { animation: shake .5s, bob 2.4s ease-in-out .5s infinite; }
@keyframes bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-4px); } }
@keyframes jump { 0%, 100% { transform: translateY(0); } 40% { transform: translateY(-40px); } 70% { transform: translateY(0) scaleY(.9); } }
@keyframes shake { 0%, 100% { transform: translateX(0); } 20%, 60% { transform: translateX(-8px); } 40%, 80% { transform: translateX(8px); } }
.bubble {
  position: absolute; top: 10px; left: 50%; transform: translateX(-50%);
  max-width: 88%;
  background: #fff; border: 2px solid var(--ink); border-radius: 14px;
  padding: 6px 12px; font-size: 13px; font-weight: 700; text-align: center; width: max-content;
}
.bubble:empty { display: none; }
.bubble::after {
  content: ''; position: absolute; left: 50%; bottom: -8px; margin-left: -6px;
  border: 6px solid transparent; border-top-color: var(--ink); border-bottom: 0;
}
.bubble.pop { animation: pop .25s ease-out; }
@keyframes pop { from { transform: translateX(-50%) scale(.7); } to { transform: translateX(-50%) scale(1); } }
.mood {
  position: absolute; right: 8px; bottom: 8px;
  background: #fff; border: 2px solid var(--ink); border-radius: 999px; padding: 2px 10px; font-size: 13px; font-weight: 800;
}
.mood-0 { color: #6a5acd; } .mood-1 { color: #3d8be5; } .mood-2 { color: var(--muted); } .mood-3 { color: #e67e22; } .mood-4 { color: #e5533d; }

/* ---------- 体力 ---------- */
.energy { display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 14px; }
.bar { flex: 1; height: 16px; background: #ddd2c4; border: 2px solid var(--ink); border-radius: 999px; overflow: hidden; }
.bar-fill { height: 100%; background: linear-gradient(90deg, #6fcf62, #3bb36c); transition: width .5s; }
.bar-fill.mid { background: linear-gradient(90deg, #f6c445, #eba52b); }
.bar-fill.low { background: linear-gradient(90deg, #f17f60, #e5533d); }
.energy-text { font-family: var(--pixel); min-width: 54px; text-align: right; }

/* ---------- ステータス ---------- */
.stats { display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px; margin: 10px 0; }
.stat {
  position: relative; background: var(--paper); border: 2px solid var(--ink); border-radius: 10px;
  text-align: center; padding: 4px 2px 2px;
}
.stat-label { font-size: 11px; font-weight: 800; color: var(--muted); }
.stat-val { font-family: var(--pixel); font-size: 18px; line-height: 1.2; }
.stat-bar { height: 5px; margin: 2px 6px 0; background: #eadfce; border-radius: 3px; overflow: hidden; }
.stat-bar i { display: block; height: 100%; background: var(--clawd); border-radius: 3px; }
.stat-prev { height: 16px; font-size: 13px; font-weight: 800; color: var(--red); }
.float {
  position: absolute; left: 0; right: 0; top: 0; font-weight: 800; font-size: 18px; pointer-events: none;
  animation: floatUp 1.4s ease-out forwards; text-shadow: 0 0 3px #fff, 0 0 3px #fff;
}
.float.up { color: var(--red); } .float.down { color: var(--blue); }
@keyframes floatUp { from { transform: translateY(0); opacity: 1; } to { transform: translateY(-34px); opacity: 0; } }


/* ---------- 練習カード ---------- */
.trainings { display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px; }
.tcard {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: 2px;
  background: var(--paper); border: 2px solid var(--ink); border-radius: 12px; padding: 6px 2px 4px;
  box-shadow: var(--shadow); min-height: 112px;
}
.tcard.sel { background: #fff1ea; border-color: var(--clawd); outline: 3px solid var(--clawd); transform: translateY(-4px); }
.tcard.has-friend { background: linear-gradient(#fff, #ffe9c4); }
.tcard-lv { font-family: var(--pixel); font-size: 11px; background: var(--ink); color: #fff; border-radius: 6px; padding: 0 5px; }
.tcard-icon { font-size: 24px; line-height: 1.1; }
.tcard-name { font-size: 10.5px; font-weight: 800; white-space: nowrap; }
.tcard-sup { display: flex; flex-wrap: wrap; justify-content: center; gap: 1px; min-height: 22px; }
.sup { position: relative; font-size: 15px; line-height: 1; padding-bottom: 4px; }
.sup i { position: absolute; left: 0; bottom: 0; height: 3px; background: var(--blue); border-radius: 2px; }
.sup.friend i { background: var(--clawd); }
.sup.friend { filter: drop-shadow(0 0 3px var(--gold)); }
.tcard-fail { font-size: 10px; font-weight: 700; color: var(--muted); }
.tcard-fail.mid { color: #e67e22; } .tcard-fail.hi { color: var(--red); }

.confirm {
  margin-top: 10px; display: flex; align-items: center; gap: 8px;
  background: #fff; border: 2px dashed var(--clawd); border-radius: var(--radius); padding: 8px 10px;
}
.confirm-info { flex: 1; display: flex; flex-direction: column; font-size: 12px; }
.confirm-info b { font-size: 14px; }
.friend-msg { color: var(--clawd-dark); font-weight: 800; }
.fail-msg { color: var(--red); font-weight: 800; }

.actions { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-top: 12px; }
.btn.act { border-radius: 12px; padding: 6px 2px; font-size: 12px; display: flex; flex-direction: column; align-items: center; }
.btn.act .ico { font-size: 20px; }
.btn.act small { font-family: var(--pixel); color: var(--clawd-dark); }

/* ---------- 会話 ---------- */
.dialog {
  position: fixed; inset: 0; z-index: 20; background: rgba(30, 20, 10, .25);
  display: flex; justify-content: center; align-items: flex-end;
}
.dialog-inner { width: 100%; max-width: 480px; padding: 12px 12px max(12px, env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 8px; }
.dialog-title {
  align-self: center; background: var(--ink); color: #fff; font-weight: 800; padding: 4px 16px; border-radius: 999px; font-size: 14px;
}
.dialog-changes { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px; }
.dialog-changes:empty { display: none; }
.dialog-choices { display: flex; flex-direction: column; gap: 8px; }
.dialog-choices:empty { display: none; }
.btn.choice { border-radius: 12px; text-align: left; background: #fffbe6; border-color: var(--clawd-dark); animation: pop2 .2s ease-out; }
@keyframes pop2 { from { opacity: 0; transform: translateY(8px); } }
.dialog-box {
  position: relative; display: flex; gap: 10px; align-items: flex-start;
  background: #fff; border: 3px solid var(--ink); border-radius: 16px; padding: 12px; min-height: 120px;
  box-shadow: 0 4px 0 var(--ink); cursor: pointer;
}
.dialog-box.narr { background: #fdf8ef; }
.dialog-portrait:empty { display: none; }
.portrait {
  width: 64px; height: 64px; border-radius: 12px; border: 2px solid var(--pc, var(--ink)); background: color-mix(in srgb, var(--pc, #ccc) 18%, #fff);
  display: grid; place-items: center; font-size: 38px;
}
.clawd-portrait { --pc: var(--clawd); padding: 8px; }
.dialog-main { flex: 1; min-width: 0; }
.dialog-name { display: inline-block; font-weight: 800; color: #fff; background: var(--clawd); border-radius: 6px; padding: 0 8px; margin-bottom: 4px; font-size: 13px; }
.dialog-text { font-size: 16px; line-height: 1.6; font-weight: 700; word-break: break-word; }
.dialog-box.compact .dialog-text { font-size: 14px; line-height: 1.55; }
.dialog-box.compact .dialog-text p { margin: 0 0 4px; }
.dialog-box.compact .dialog-text b { color: var(--clawd-dark); margin-right: 4px; }
.dialog-next { position: absolute; right: 12px; bottom: 6px; color: var(--clawd); animation: nudge .8s infinite; }
@keyframes nudge { 50% { transform: translateY(3px); } }

.chip { display: inline-block; border-radius: 999px; padding: 2px 10px; font-size: 13px; font-weight: 800; background: #fff; border: 2px solid currentColor; margin: 2px; }
.chip.up { color: #d9480f; } .chip.down { color: var(--blue); } .chip.hint { color: #9b59b6; }

/* ---------- モーダル ---------- */
.modal { position: fixed; inset: 0; z-index: 30; background: rgba(30, 20, 10, .45); display: grid; place-items: center; padding: 16px; }
.modal-card { width: 100%; max-width: 440px; max-height: 86dvh; overflow: auto; background: var(--cream); border: 3px solid var(--ink); border-radius: 18px; padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.modal-body h2 { margin: 0 0 8px; font-size: 20px; }
.modal-body ul { padding-left: 20px; line-height: 1.6; font-size: 14px; }
.pts-big { font-family: var(--pixel); color: var(--clawd-dark); font-size: 15px; margin-left: 8px; }
.skills { list-style: none; padding: 0 !important; margin: 0; display: flex; flex-direction: column; gap: 6px; }
.skills li { display: flex; align-items: center; gap: 8px; background: #fff; border: 2px solid var(--line); border-radius: 12px; padding: 8px; }
.skills li.owned { background: #fff7e0; border-color: var(--gold); }
.skill-icon { font-size: 22px; }
.skill-info { flex: 1; line-height: 1.3; }
.skill-info small { color: var(--muted); }
.hint-tag, .owned-tag { font-size: 11px; font-weight: 800; color: #fff; background: #9b59b6; border-radius: 6px; padding: 1px 6px; margin-left: 4px; white-space: nowrap; }
.owned-tag { background: var(--gold); color: var(--ink); }
.menu-list { display: flex; flex-direction: column; gap: 10px; }
.hof { padding: 0 !important; list-style: none; display: flex; flex-direction: column; gap: 6px; }
.hof li { display: flex; gap: 10px; align-items: center; background: #fff; border-radius: 12px; padding: 8px; border: 2px solid var(--line); }

/* ---------- サウンド切替 ---------- */
.sound-toggle {
  position: fixed; z-index: 25; top: 10px; right: max(10px, calc(50% - 240px + 10px));
  width: 38px; height: 38px; border-radius: 50%; border: 2px solid var(--ink); background: #fff;
  font-size: 18px; line-height: 1; display: grid; place-items: center; box-shadow: var(--shadow); padding: 0;
}
.sound-toggle:active { transform: translateY(2px); box-shadow: none; }
.hud { margin-right: 46px; }
.contest-head { padding-right: 46px; }

/* ---------- トースト ---------- */
.toasts { position: fixed; top: 12px; left: 50%; transform: translateX(-50%); z-index: 40; display: flex; flex-direction: column; gap: 6px; align-items: center; pointer-events: none; width: 90%; max-width: 440px; }
.toast { background: #fff; border: 2px solid var(--ink); border-radius: 14px; padding: 4px 14px; text-align: center; color: var(--ink); font-weight: 800; font-size: 14px; animation: toastIn .3s ease-out, toastOut .4s ease-in 2.2s forwards; }
.toast.up { color: #d9480f; } .toast.down { color: var(--blue); } .toast.hint { color: #9b59b6; }
@keyframes toastIn { from { opacity: 0; transform: translateY(-10px); } }
@keyframes toastOut { to { opacity: 0; transform: translateY(-10px); } }

/* ---------- 大会 ---------- */
#contest {
  display: flex; flex-direction: column; gap: 12px;
  background-color: var(--cream);
  background-image:
    linear-gradient(rgba(215, 119, 87, .08) 1px, transparent 1px),
    linear-gradient(90deg, rgba(215, 119, 87, .08) 1px, transparent 1px);
  background-size: 22px 22px;
}
.contest-head { display: flex; gap: 12px; align-items: center; }
.contest-head h2 { margin: 0; font-size: 19px; line-height: 1.3; }
.contest-head p { margin: 2px 0 0; color: var(--muted); font-size: 14px; }
.contest-head.small h2 { font-size: 18px; }
.contest-icon { font-size: 44px; background: #fff; border: 3px solid var(--ink); border-radius: 16px; width: 72px; height: 72px; display: grid; place-items: center; flex: none; }
.contest-head.small .contest-icon { width: 48px; height: 48px; font-size: 28px; }
.contest-info { background: #fff; border: 2px solid var(--ink); border-radius: var(--radius); padding: 10px 12px; display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.contest-info .k { display: inline-block; width: 52px; font-size: 12px; font-weight: 800; color: var(--muted); }
.wchip { display: inline-block; border-radius: 6px; padding: 0 6px; margin: 1px; font-size: 13px; font-weight: 700; background: #eee; }
.wchip.w2 { background: var(--clawd); color: #fff; }
.fav { font-weight: 800; font-size: 18px; }
.fav-1 { color: var(--red); } .fav-2 { color: #e67e22; } .fav-3 { color: var(--blue); } .fav-4 { color: var(--muted); }
.contest-buttons { display: grid; grid-template-columns: 1fr 1.3fr; gap: 10px; margin-top: 14px; align-items: center; }
.contest-buttons .btn { white-space: nowrap; padding-left: 8px; padding-right: 8px; }

.room.waiting { margin-top: 12px; height: 110px; }
.room.waiting::before { width: 30%; height: 34%; }
.room.waiting::before { content: 'GOOD LUCK!'; }
.room.waiting .clawd-svg { position: absolute; bottom: 12px; width: 72px; animation: waiting 6s linear infinite alternate; }
@keyframes waiting { from { left: 40%; } to { left: calc(74% - 72px); } }

/* 進捗ボード */
.board { background: #1d1712; border: 3px solid var(--ink); border-radius: var(--radius); padding: 8px 10px; color: #f3e9dc; }
.board-head { display: flex; justify-content: space-between; font-family: var(--pixel); font-size: 12px; color: #8fd18a; margin-bottom: 6px; }
.board-head span:last-child { color: #a89886; }
.lane { --p: 0; display: grid; grid-template-columns: 28px 84px 1fr 44px; align-items: center; gap: 6px; height: 28px; }
.lane .who { font-size: 18px; text-align: center; line-height: 1; }
.lane .mini-clawd { width: 26px; }
.lane-name { font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: #d9cbbb; }
.pbar { height: 10px; background: #3a3027; border-radius: 5px; overflow: hidden; }
.pbar i { display: block; height: 100%; width: calc(var(--p) * 100%); background: #7f9cc9; border-radius: 5px; }
.lane.done .pbar i { background: #8fd18a; }
.lane.rival .pbar i { background: #9b7be0; }
.lane.me .pbar i { background: var(--clawd); }
.lane.me .lane-name { color: #fff; font-weight: 800; }
.pct { font-family: var(--pixel); font-size: 11px; text-align: right; color: #a89886; white-space: nowrap; }
.lane.done .pct { color: #8fd18a; }
.commentary { margin-top: 8px; background: var(--ink); color: #fff; border-radius: 10px; padding: 8px 12px; font-weight: 700; min-height: 40px; }
.skip { margin-top: 8px; float: right; }
.results { list-style: none; padding: 0; margin: 0; background: #fff; border: 2px solid var(--ink); border-radius: var(--radius); overflow: hidden; }
.results li { display: flex; gap: 10px; align-items: center; padding: 4px 12px; border-bottom: 1px solid var(--line); }
.results li.me { background: #ffe6da; font-weight: 800; }
.results li.rival { color: #7b4fc9; }
.results .pos { font-family: var(--pixel); width: 36px; }
.results .who { display: flex; align-items: center; gap: 6px; }
.mini-clawd { display: inline-block; width: 28px; }

/* ---------- エンディング ---------- */
#ending { background: radial-gradient(circle at 50% 20%, #fff6d8, var(--cream) 60%); }
.ending-card { text-align: center; display: flex; flex-direction: column; align-items: center; }
.ending-card h2 { margin: 8px 0 0; font-size: 22px; }
.ending-card h3 { margin: 18px 0 6px; font-size: 15px; color: var(--muted); }
.ending-sub { font-family: var(--pixel); letter-spacing: 4px; color: var(--clawd-dark); margin: 16px 0 4px; }
.ending-clawd { position: relative; width: 160px; margin-top: 56px; animation: bob 2.4s ease-in-out infinite; }
.crown { position: absolute; top: -40px; left: 50%; transform: translateX(-50%); font-size: 40px; }
.tier-label { margin: 16px 0 0; font-size: 12px; color: var(--muted); font-weight: 800; letter-spacing: 4px; }
.tier-badge {
  font-family: var(--pixel); font-size: 34px; line-height: 1; margin: 6px 0 8px; padding: 14px 28px;
  background: #fff; border: 4px solid currentColor; border-radius: 999px; box-shadow: 0 4px 0 currentColor;
}
.tier-badge.small { font-size: 13px; padding: 4px 10px; border-width: 2px; box-shadow: none; margin: 0; flex: none; white-space: nowrap; }
.t-0, .t-1 { color: #9e9e9e; } .t-2, .t-3 { color: #5aa05a; } .t-4 { color: #3d8be5; } .t-5 { color: #e67e22; }
.t-6 { color: #e5533d; } .t-7, .t-8 { color: #d4a000; } .t-9 { color: #9b59b6; }
.score small { color: var(--muted); }
.ending-stats { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; width: 100%; }
.ending-stats > div { background: #fff; border: 2px solid var(--ink); border-radius: 10px; padding: 6px 2px; display: flex; flex-direction: column; }
.ending-stats span { font-size: 11px; color: var(--muted); font-weight: 800; }
.ending-stats b { font-family: var(--pixel); font-size: 20px; }
.share-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; width: 100%; margin: 6px 0 16px; }
.btn.share-x { background: #000; color: #fff; border-color: #000; }
.history { list-style: none; padding: 0; margin: 0; text-align: left; width: 100%; }
.history li { background: #fff; border-radius: 10px; padding: 6px 10px; margin-bottom: 4px; border: 2px solid var(--line); }
.ending-buttons { display: flex; flex-direction: column; gap: 10px; width: 100%; margin-top: 20px; }

/* ---------- スタッフロール ---------- */
.staffroll { position: fixed; inset: 0; z-index: 35; background: #1d1712; color: #fff; overflow: hidden; cursor: pointer; }
.roll {
  position: absolute; top: 100%; left: 50%; width: min(480px, 100%); margin-left: max(-240px, -50%);
  padding: 0 16px; text-align: center; animation: roll 38s linear forwards;
}
@keyframes roll { to { transform: translateY(calc(-100% - 100dvh)); } }
.credit-title { font-family: var(--pixel); font-size: 34px; line-height: 1.25; color: var(--clawd); margin-bottom: 72px; }
.credit-block { margin-bottom: 52px; }
.credit-block .role { font-size: 13px; color: #c9b8a6; letter-spacing: 2px; margin-bottom: 8px; }
.credit-block .name { font-size: 20px; font-weight: 800; line-height: 1.7; }
.credit-note { font-size: 13px; line-height: 1.8; color: #c9b8a6; margin: 80px 0; }
.credit-end { font-family: var(--pixel); font-size: 30px; line-height: 1.3; color: var(--gold); margin-top: 40vh; }
.credit-made { margin: 16px 0 50vh; font-size: 15px; color: #c9b8a6; }
.roll-clawd { position: absolute; bottom: 20px; width: 64px; left: 0; animation: rollWalk 8s linear infinite alternate; }
@keyframes rollWalk { from { left: 8px; } to { left: calc(100% - 72px); } }
.roll-skip { position: absolute; top: 14px; left: 16px; font-size: 12px; color: #8f8173; }

@media (prefers-reduced-motion: reduce) {
  .staffroll { overflow: auto; }
  .roll { position: static; margin: 0 auto; animation: none; padding: 60px 16px; }
  .credit-end { margin-top: 60px; }
  .credit-made { margin-bottom: 60px; }
}

@media (min-width: 481px) {
  #app { border-left: 2px solid var(--ink); border-right: 2px solid var(--ink); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}
