:root {
  --ink: #1b2437;
  --night: #24345a;
  --paper: #fffaf0;
  --gold: #ffc857;
  --coral: #ff8a5b;
  --sky: #7fd7ff;
  --mint: #3dcea0;
  --dawn: 0;
  --r: 22px;
  --font: 'M PLUS Rounded 1c', 'Hiragino Maru Gothic ProN', 'Hiragino Sans', sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  font-family: var(--font);
  font-weight: 800;
  color: var(--ink);
  background: var(--night);
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  touch-action: manipulation;
  overscroll-behavior: none;
}
button { font: inherit; color: inherit; cursor: pointer; touch-action: manipulation; }
button:disabled { cursor: default; }
svg { display: block; width: 100%; height: 100%; overflow: visible; }

#app {
  position: fixed;
  inset: 0;
  overflow: hidden;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

/* ---------- 背景（クリスタルが増えるほど夜明けになる） ---------- */
.bg { position: absolute; inset: 0; z-index: 0; background: linear-gradient(#1a2547, #2f4677 60%, #48629a); }
.bg::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(#8fd0ff, #ffd9b0 70%, #ffe9c9);
  opacity: var(--dawn);
  transition: opacity 1.2s;
}
.sun {
  position: absolute;
  z-index: 1;
  width: 26vmin;
  height: 26vmin;
  left: 50%;
  bottom: calc(14vh + (1 - var(--dawn)) * -10vmin);
  transform: translateX(-50%);
  border-radius: 50%;
  background: radial-gradient(circle at 40% 40%, #fff6d0, #ffc857 60%, #ff9a5b);
  box-shadow: 0 0 60px 20px rgba(255, 200, 87, calc(.15 + var(--dawn) * .4));
  opacity: calc(.35 + var(--dawn) * .65);
  transition: all 1.2s;
}
.cloud {
  position: absolute;
  z-index: 1;
  width: 30vmin;
  height: 9vmin;
  border-radius: 99px;
  background: rgba(255, 255, 255, calc(.25 + var(--dawn) * .55));
  animation: drift 40s linear infinite;
}
.cloud::before, .cloud::after { content: ''; position: absolute; border-radius: 50%; background: inherit; }
.cloud::before { width: 12vmin; height: 12vmin; left: 4vmin; top: -6vmin; }
.cloud::after { width: 15vmin; height: 15vmin; left: 12vmin; top: -8vmin; }
.cloud.c1 { top: 14vh; left: -30vmin; }
.cloud.c2 { top: 30vh; left: -30vmin; animation-duration: 58s; animation-delay: -26s; transform: scale(.7); }
@keyframes drift { to { left: 110vw; } }
.sea {
  position: absolute;
  z-index: 2;
  left: -5%;
  right: -5%;
  bottom: 0;
  height: 18vh;
  background: linear-gradient(#3a7cc7, #1f4c8a);
  border-radius: 50% 50% 0 0 / 30px 30px 0 0;
}

/* ---------- 画面 ---------- */
.screen {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: none;
  flex-direction: column;
  padding: max(12px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
}
.screen.on { display: flex; animation: fadein .35s ease-out; }
@keyframes fadein { from { opacity: 0; transform: translateY(8px); } }

/* ---------- ボタン ---------- */
.toy {
  border: 4px solid var(--ink);
  border-radius: 999px;
  background: var(--gold);
  padding: 14px 30px;
  font-size: clamp(20px, 4.6vmin, 32px);
  box-shadow: 0 6px 0 var(--ink);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  transition: transform .08s, box-shadow .08s;
}
.toy:active { transform: translateY(5px); box-shadow: 0 1px 0 var(--ink); }
.toy.xl { font-size: clamp(26px, 6.4vmin, 46px); padding: 18px 46px; }
.toy.alt { background: #fff; }
.toy svg { width: 1.4em; height: 1.4em; }
.toy.beam { background: linear-gradient(#ffe27a, #ffb13a); animation: glow 1.1s ease-in-out infinite; }
@keyframes glow {
  50% { box-shadow: 0 6px 0 var(--ink), 0 0 0 10px rgba(255, 200, 87, .45), 0 0 40px 14px rgba(255, 220, 120, .7); }
}

.iconbtn {
  width: clamp(52px, 11vmin, 70px);
  height: clamp(52px, 11vmin, 70px);
  flex: none;
  border: 4px solid var(--ink);
  border-radius: 50%;
  background: #fff;
  padding: 7px;
  box-shadow: 0 4px 0 var(--ink);
}
.iconbtn:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }

.top { display: flex; align-items: center; gap: 12px; }
.top-title { flex: 1; text-align: center; color: #fff; font-size: clamp(24px, 6vmin, 38px); text-shadow: 0 3px 0 var(--ink); }
.count {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-right: auto;
  background: #fff;
  border: 4px solid var(--ink);
  border-radius: 999px;
  padding: 4px 18px 4px 8px;
  font-size: clamp(22px, 5vmin, 32px);
}
.count svg { width: 1.6em; height: 1.6em; }
.top-title + .count { margin-right: 0; }

/* ---------- タイトル ---------- */
#title { align-items: center; justify-content: center; gap: 4vh; text-align: center; }
.brand p { margin: 0; color: #fff; font-size: clamp(22px, 5vmin, 36px); letter-spacing: .2em; text-shadow: 0 3px 0 var(--ink); }
.brand h1 {
  margin: 0;
  color: var(--gold);
  font-size: clamp(48px, 13vmin, 110px);
  line-height: 1.1;
  -webkit-text-stroke: 3px var(--ink);
  paint-order: stroke fill;
  text-shadow: 0 6px 0 var(--ink);
}
.title-row { display: flex; gap: 2vmin; justify-content: center; }
.title-row svg { width: clamp(80px, 20vmin, 160px); height: auto; aspect-ratio: 160 / 210; animation: bob 2.4s ease-in-out infinite; }
.title-row svg:nth-child(2) { animation-delay: -.8s; }
.title-row svg:nth-child(3) { animation-delay: -1.6s; }
@keyframes bob { 50% { transform: translateY(-10px); } }

/* ---------- しま（マップ） ---------- */
.map-mid { display: flex; align-items: center; justify-content: center; gap: 4vmin; flex: 1; min-height: 0; padding: 1vh 0; }
.map-hero { height: min(26vh, 34vw); aspect-ratio: 160 / 210; animation: bob 2.4s ease-in-out infinite; }
.portals {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: clamp(8px, 2vmin, 16px);
  width: min(100%, 640px);
  margin: 0 auto 2vh;
}
.portal {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 8px 4px 10px;
  border: 4px solid var(--ink);
  border-radius: var(--r);
  background: var(--paper);
  box-shadow: 0 5px 0 var(--ink);
}
.portal:active { transform: translateY(4px); box-shadow: 0 1px 0 var(--ink); }
.portal .disc { width: clamp(44px, 10vmin, 72px); height: clamp(44px, 10vmin, 72px); }
.portal .nm { font-size: clamp(16px, 3.8vmin, 24px); }
.portal.lock { background: #b8c2d8; opacity: .85; }
.portal.now { background: #fff1c4; outline: 5px solid var(--gold); outline-offset: 2px; }
.lpips { display: flex; gap: 3px; }
.lpips i { width: 9px; height: 9px; border-radius: 50%; border: 2px solid var(--ink); background: #fff; }
.lpips i.on { background: var(--gold); }

/* ---------- なかま ---------- */
.teamgrid {
  flex: 1;
  overflow-y: auto;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(clamp(110px, 24vmin, 170px), 1fr));
  gap: 14px;
  padding: 16px 4px 30px;
  align-content: start;
}
.mate {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 10px 6px;
  border: 4px solid var(--ink);
  border-radius: var(--r);
  background: var(--paper);
  box-shadow: 0 5px 0 var(--ink);
}
.mate-art { width: 80%; aspect-ratio: 160 / 210; }
.mate .nm { font-size: clamp(16px, 3.6vmin, 22px); }
.mate.on { background: #fff1c4; outline: 5px solid var(--gold); outline-offset: 2px; }
.mate.lock .mate-art { filter: brightness(0) opacity(.35); }
.mate.lock { background: #c6cee0; }
.cost {
  position: absolute;
  top: 8px;
  right: 8px;
  display: flex;
  align-items: center;
  gap: 2px;
  background: #fff;
  border: 3px solid var(--ink);
  border-radius: 999px;
  padding: 0 8px 0 2px;
  font-size: 16px;
}
.cost svg { width: 24px; height: 24px; }

/* ---------- あそぶ ---------- */
#play { padding: 0; }
.battle {
  position: relative;
  flex: none;
  height: 30vh;
  min-height: 150px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  padding: 0 6vw 2vh;
}
.battle .home { position: absolute; top: max(10px, env(safe-area-inset-top)); left: max(10px, env(safe-area-inset-left)); z-index: 5; }
.actor { height: 82%; aspect-ratio: 1; display: flex; align-items: flex-end; justify-content: center; }
.actor svg { width: auto; height: 100%; }
#bHero svg { animation: bob 2.4s ease-in-out infinite; }
.actor.foe svg { animation: sway 3s ease-in-out infinite; }
@keyframes sway { 50% { transform: rotate(-4deg) translateY(-4px); } }
.kaiju-svg.dizzy { animation: dizzy .9s ease-in-out infinite !important; }
@keyframes dizzy { 25% { transform: rotate(-6deg); } 75% { transform: rotate(6deg); } }
.kaiju-svg.happy { animation: hop .6s ease-in-out infinite !important; }
@keyframes hop { 50% { transform: translateY(-12px); } }
.timer-light { animation: blink 1.6s ease-in-out infinite; }
@keyframes blink { 50% { opacity: .55; } }

.pips {
  position: absolute;
  top: max(18px, env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 8px;
}
.pip {
  width: clamp(22px, 5vmin, 34px);
  height: clamp(22px, 5vmin, 34px);
  border-radius: 50%;
  border: 4px solid var(--ink);
  background: rgba(255, 255, 255, .35);
  transition: background .25s, transform .25s;
}
.pip.on { background: radial-gradient(circle at 35% 30%, #fff, var(--sky) 55%); transform: scale(1.12); box-shadow: 0 0 14px rgba(127, 215, 255, .9); }

.beamfx {
  position: absolute;
  left: 22%;
  right: 22%;
  bottom: 48%;
  height: 18px;
  border-radius: 99px;
  background: linear-gradient(90deg, #fff, #bff0ff 40%, var(--sky));
  box-shadow: 0 0 20px 8px rgba(127, 215, 255, .8);
  transform: scaleX(0);
  transform-origin: left;
  opacity: 0;
  pointer-events: none;
}
.battle.firing .beamfx { animation: fire .65s ease-out forwards; }
@keyframes fire {
  0% { transform: scaleX(0); opacity: 1; }
  70% { transform: scaleX(1); opacity: 1; }
  100% { transform: scaleX(1); opacity: 0; }
}
.battle.firing .actor.foe { animation: shake .5s .3s; }
@keyframes shake { 20%, 60% { transform: translateX(10px); } 40%, 80% { transform: translateX(-10px); } }

.sheet {
  position: relative;
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: var(--paper);
  border-top: 5px solid var(--ink);
  border-radius: 34px 34px 0 0;
  padding: 12px max(14px, env(safe-area-inset-right)) max(14px, env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left));
}
.prompt { display: flex; align-items: center; gap: 12px; min-height: 64px; }
#promptText { flex: 1; font-size: clamp(22px, 5.2vmin, 36px); line-height: 1.3; }
.area { position: relative; flex: 1; min-height: 0; display: flex; }
.area[hidden], .finale[hidden] { display: none; }
.finale { flex: 1; display: flex; align-items: center; justify-content: center; }
.finale .toy.xl { font-size: clamp(34px, 9vmin, 64px); padding: 22px 60px; }

/* ---------- ゲーム共通 ---------- */
.game {
  position: relative;
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-evenly;
  gap: 2vh;
  min-height: 0;
  width: 100%;
}
.digit {
  font-size: clamp(40px, 10vmin, 72px);
  line-height: 1;
  color: var(--ink);
  background: #fff;
  border: 4px solid var(--ink);
  border-radius: 18px;
  min-width: 1.4em;
  padding: 4px 10px;
  text-align: center;
}
.slots { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.slot {
  width: clamp(48px, 10vmin, 72px);
  height: clamp(48px, 10vmin, 72px);
  border: 4px dashed #8a97ad;
  border-radius: 50%;
  background: #eef2f8;
  padding: 2px;
}
.orb, .orbs .orb, .supply .orb {
  width: clamp(56px, 12vmin, 84px);
  height: clamp(56px, 12vmin, 84px);
  border: none;
  background: none;
  padding: 0;
  transition: transform .1s;
}
.orb:active { transform: scale(.88); }
.orbs, .supply { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; max-width: 640px; }

.piece {
  width: clamp(80px, 18vmin, 130px);
  height: clamp(80px, 18vmin, 130px);
  padding: 10px;
  border: 4px solid var(--ink);
  border-radius: var(--r);
  background: #fff;
  box-shadow: 0 5px 0 var(--ink);
  transition: transform .08s, box-shadow .08s, opacity .2s;
}
.piece:active { transform: translateY(4px); box-shadow: 0 1px 0 var(--ink); }
.piece:disabled { opacity: .3; box-shadow: 0 2px 0 var(--ink); }
.piece.wide { width: clamp(110px, 24vmin, 180px); height: auto; aspect-ratio: 4 / 3; padding: 6px; }
.piece.tiny svg { transform: scale(.6); }
.tray { display: flex; flex-wrap: wrap; justify-content: center; gap: clamp(10px, 3vmin, 22px); }

.good { background: #d6ffe9 !important; outline: 6px solid var(--mint); animation: pop .4s; }
@keyframes pop { 50% { transform: scale(1.12); } }
.wobble { animation: wob .45s; }
@keyframes wob { 20% { transform: translateX(-9px) rotate(-4deg); } 40% { transform: translateX(8px) rotate(3deg); } 60% { transform: translateX(-6px); } 80% { transform: translateX(4px); } }
.hintpulse { animation: hint 1s ease-in-out infinite; outline: 6px solid var(--gold); outline-offset: 3px; }
@keyframes hint { 50% { transform: scale(1.08); } }

.hand {
  position: absolute;
  width: 56px;
  height: 56px;
  right: -14px;
  bottom: -26px;
  pointer-events: none;
  z-index: 4;
  animation: tap 1.1s ease-in-out infinite;
}
@keyframes tap { 50% { transform: translate(-8px, -10px); } }
.orb, .piece, .slot, .card, .colbtn, .toy, .dpad button { position: relative; }

.flash {
  position: absolute;
  inset: 0;
  z-index: 6;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 250, 240, .96);
  border-radius: var(--r);
  animation: fadein .2s;
}
.flash > svg { width: min(60vmin, 300px); height: min(30vh, 220px); }
.flash-in { display: flex; align-items: center; gap: 4vmin; }
.flash-in > svg { width: min(46vmin, 280px); height: min(26vh, 180px); }

/* ひかり */
.timer-board {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 12px 18px;
  border: 4px solid var(--ink);
  border-radius: 28px;
  background: #24345a;
}
.timer-board .slot { background: rgba(255, 255, 255, .12); border-color: #8fb4e8; }

/* みち */
.spin { display: flex; align-items: center; gap: 16px; }
.spin > svg { width: clamp(70px, 15vmin, 110px); height: clamp(70px, 15vmin, 110px); background: #fff; border: 4px solid var(--ink); border-radius: 18px; padding: 6px; }
.track { position: relative; width: min(92%, 760px); padding-top: clamp(70px, 14vmin, 110px); }
.ticks { display: flex; justify-content: space-between; position: relative; }
.ticks::before { content: ''; position: absolute; left: 0; right: 0; top: 50%; height: 10px; transform: translateY(-50%); background: #e0c49a; border-radius: 9px; }
.tick {
  position: relative;
  width: clamp(28px, 6.4vmin, 50px);
  height: clamp(28px, 6.4vmin, 50px);
  border: 3px solid var(--ink);
  border-radius: 50%;
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  font-size: clamp(14px, 3.4vmin, 24px);
}
button.tick { box-shadow: 0 3px 0 var(--ink); }
.tick.on { background: var(--gold); }
.token, .goalmark {
  position: absolute;
  top: 0;
  transform: translateX(-50%);
  transition: left .35s ease-out;
}
.track { --tw: clamp(28px, 6.4vmin, 50px); }
.track .token, .track .goalmark { left: calc(var(--tw) / 2 + (100% - var(--tw)) * var(--t, 0)); }
.token { width: clamp(52px, 10vmin, 84px); height: clamp(66px, 13vmin, 106px); z-index: 2; }
.goalmark { width: clamp(40px, 8vmin, 64px); height: clamp(40px, 8vmin, 64px); top: clamp(26px, 5vmin, 42px); }
.toy.go { font-size: clamp(24px, 5.4vmin, 38px); }
.godots svg { width: auto; height: 1.6em; }
.godots:empty { display: none; }

/* くらべる */
.duo { display: flex; gap: 4vmin; justify-content: center; width: 100%; }
.card {
  flex: 1;
  max-width: 320px;
  min-height: clamp(140px, 30vmin, 240px);
  border: 4px solid var(--ink);
  border-radius: var(--r);
  background: #fff;
  box-shadow: 0 6px 0 var(--ink);
  padding: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.card:active { transform: translateY(4px); box-shadow: 0 2px 0 var(--ink); }
.card > svg { width: 70%; height: auto; max-height: 200px; }
.pile { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; align-content: center; }
.mini { display: inline-block; width: clamp(30px, 6.5vmin, 46px); height: clamp(30px, 6.5vmin, 46px); }
.mini.lg { width: clamp(46px, 10vmin, 70px); height: clamp(46px, 10vmin, 70px); }
.bar { display: block; height: 34px; border: 4px solid var(--ink); border-radius: 99px; background: linear-gradient(90deg, var(--coral), var(--gold)); align-self: center; margin-right: auto; }
.card:has(.bar) { justify-content: flex-start; }
.lane { position: relative; width: 100%; height: clamp(80px, 16vmin, 130px); border-bottom: 6px solid #e0c49a; }
.lane .who { position: absolute; bottom: 0; width: 26%; height: 100%; transform: translateX(-50%); }
.lane .goal { position: absolute; right: 0; bottom: 6px; width: 24%; aspect-ratio: 1; }
.numeral { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.numeral b { font-size: clamp(64px, 16vmin, 120px); line-height: 1; }
.minidots { width: clamp(60px, 14vmin, 100px); height: clamp(60px, 14vmin, 100px); }

/* ならび */
.train { display: flex; gap: clamp(4px, 1.4vmin, 10px); flex-wrap: wrap; justify-content: center; }
.car {
  width: clamp(54px, 12vmin, 92px);
  height: clamp(54px, 12vmin, 92px);
  border: 4px solid var(--ink);
  border-radius: 16px;
  background: #fff;
  padding: 6px;
  transition: transform .15s, background .15s;
}
.car.hole { border-style: dashed; background: #eef2f8; }
.car.on { transform: translateY(-10px); background: #fff1c4; }
.oddrow { display: flex; gap: clamp(10px, 3vmin, 22px); flex-wrap: wrap; justify-content: center; }

/* かくれんぼ */
.total { display: flex; align-items: center; gap: 12px; }
.total > svg { width: auto; height: clamp(44px, 9vmin, 70px); }
.total .digit { font-size: clamp(30px, 7vmin, 52px); }
.panes { display: flex; gap: 3vmin; justify-content: center; width: 100%; }
.pane {
  flex: 1;
  max-width: 320px;
  min-height: clamp(120px, 26vmin, 200px);
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  justify-content: center;
  align-content: center;
  border: 4px solid var(--ink);
  border-radius: var(--r);
  background: #fff;
  padding: 10px;
}
.pane.hid { background: #ece4ff; flex-direction: column; flex-wrap: nowrap; }
.pane.hid > svg { width: 60%; max-width: 140px; height: auto; }

/* かたち */
.door {
  width: clamp(110px, 26vmin, 190px);
  height: clamp(110px, 26vmin, 190px);
  border: 5px dashed #8a97ad;
  border-radius: var(--r);
  background: #eef2f8;
  padding: 10px;
}
.build { display: flex; flex-direction: column; align-items: center; }
.build .roof, .build .wall {
  width: clamp(100px, 22vmin, 160px);
  height: clamp(100px, 22vmin, 160px);
  border: 4px dashed #8a97ad;
  background: #eef2f8;
}
.build .roof { clip-path: polygon(50% 0, 100% 100%, 0 100%); border: none; background: #d8e0ec; }
.build .wall { border-radius: 8px; margin-top: -6px; }
.build .roof.flip { clip-path: polygon(0 0, 100% 0, 50% 100%); }
.build .in { background: none; border-color: transparent; clip-path: none; }
.build .roof.in svg { transform: scale(1.25); }
.build .wall.in svg { transform: scale(1.47); }

/* じかん */
.jikan .slots { gap: clamp(8px, 2vmin, 16px); }
.slot.pic {
  width: clamp(90px, 20vmin, 150px);
  height: auto;
  aspect-ratio: 4 / 3;
  border-radius: 16px;
  padding: 3px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* つみき */
.goalframe {
  height: clamp(120px, 24vh, 220px);
  padding: 10px 16px;
  border: 4px dashed #8a97ad;
  border-radius: var(--r);
  background: #eef2f8;
}
.goalframe svg { width: auto; height: 100%; }
.cols { display: flex; gap: clamp(10px, 3vmin, 22px); }
.colbtn {
  width: clamp(80px, 18vmin, 130px);
  height: clamp(130px, 26vh, 220px);
  border: 4px solid var(--ink);
  border-radius: var(--r);
  background: #fff;
  box-shadow: 0 5px 0 var(--ink);
  padding: 8px;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.colbtn:active { transform: translateY(4px); box-shadow: 0 1px 0 var(--ink); }
.colbtn svg { width: 100%; height: auto; max-height: 100%; }

/* めいろ */
.meiro { flex-direction: row; flex-wrap: wrap; gap: 4vmin; }
.maze {
  display: grid;
  grid-template-columns: repeat(var(--n), 1fr);
  width: min(52vh, 86vw, 420px);
  aspect-ratio: 1;
  border: 5px solid var(--ink);
  border-radius: 18px;
  overflow: hidden;
  background: #fff;
}
.cell { position: relative; border: 1px solid #dde4ee; display: flex; align-items: center; justify-content: center; }
.cell > svg { width: 70%; height: 70%; }
.cell.wall { background: #6b7c96; background-image: repeating-linear-gradient(45deg, rgba(255,255,255,.12) 0 6px, transparent 6px 12px); }
.pawn { position: absolute; inset: 4%; display: block; }
.dpad { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.dpad-mid { display: flex; gap: clamp(60px, 13vmin, 92px); }
.dpad button {
  width: clamp(64px, 13vmin, 92px);
  height: clamp(64px, 13vmin, 92px);
  border: 4px solid var(--ink);
  border-radius: 20px;
  background: var(--gold);
  box-shadow: 0 5px 0 var(--ink);
  padding: 6px;
}
.dpad button:active { transform: translateY(4px); box-shadow: 0 1px 0 var(--ink); }

/* ---------- けっか ---------- */
#result { align-items: center; justify-content: center; gap: 2vh; text-align: center; }
.res-hero { height: min(30vh, 40vw); aspect-ratio: 160 / 210; animation: bob 2s ease-in-out infinite; }
.res-title {
  color: var(--gold);
  font-size: clamp(44px, 11vmin, 90px);
  -webkit-text-stroke: 3px var(--ink);
  paint-order: stroke fill;
  text-shadow: 0 5px 0 var(--ink);
}
.res-crystals { display: flex; gap: 10px; min-height: clamp(60px, 13vmin, 100px); }
.res-crystals i { width: clamp(60px, 13vmin, 100px); height: clamp(60px, 13vmin, 100px); animation: drop .45s cubic-bezier(.3, 1.6, .5, 1); }
@keyframes drop { from { transform: translateY(-60px) scale(.4); opacity: 0; } }
.res-extra:empty { display: none; }
.unlock {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 22px;
  border: 4px solid var(--ink);
  border-radius: var(--r);
  background: var(--paper);
  animation: pop .5s;
  max-width: calc(100vw - 32px);
  flex-wrap: wrap;
  justify-content: center;
}
.unlock > svg { width: clamp(60px, 12vmin, 90px); height: clamp(70px, 14vmin, 110px); }
.unlock p { margin: 0; font-size: clamp(16px, 4vmin, 26px); white-space: nowrap; }
.unlock b { font-size: clamp(22px, 5vmin, 32px); color: var(--coral); white-space: nowrap; }
.res-actions { display: flex; gap: 16px; flex-wrap: wrap; justify-content: center; }

/* ---------- 花火 ---------- */
#fx { position: fixed; left: 50%; top: 45%; z-index: 20; pointer-events: none; }
.bit {
  position: absolute;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid var(--ink);
  animation: burst .9s ease-out forwards;
}
@keyframes burst {
  from { transform: rotate(var(--a)) translateX(0) scale(1); opacity: 1; }
  to { transform: rotate(var(--a)) translateX(32vmin) scale(.3); opacity: 0; }
}

/* 横向き（タブレット・PC）：バトル欄を少し低く */
@media (orientation: landscape) and (max-height: 600px) {
  .battle { height: 26vh; min-height: 110px; }
  .prompt { min-height: 50px; }
  .map-hero { height: 22vh; }
}

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