:root {
  --ink: #f8ead0;
  --muted: #cdbb96;
  --shadow: #090b0e;
  --stone: #2a302e;
  --stone-lit: #59615a;
  --parchment: #d8ba7d;
  --gold: #f2c15c;
  --bronze: #a76b35;
  --teal: #2a9a91;
  --teal-dark: #123d43;
  --danger: #d55336;
  --poison: #59c95b;
  color-scheme: dark;
  font-family: "Avenir Next", "Hiragino Sans", "Yu Gothic", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  display: grid;
  place-items: center;
  overflow-x: hidden;
  background:
    radial-gradient(circle at 50% 0%, rgba(242, 193, 92, 0.16), transparent 34rem),
    linear-gradient(135deg, rgba(42, 154, 145, 0.18), transparent 24rem),
    repeating-linear-gradient(45deg, rgba(255, 255, 255, 0.025) 0 1px, transparent 1px 8px),
    #0b1114;
  color: var(--ink);
}

button {
  font: inherit;
  color: inherit;
}

.phone-shell {
  position: relative;
  width: min(100%, 430px);
  max-width: 100dvw;
  min-height: min(100vh, 920px);
  padding: 16px;
  display: grid;
  gap: 12px;
  background:
    linear-gradient(180deg, rgba(18, 61, 67, 0.82), rgba(14, 20, 22, 0.94)),
    radial-gradient(circle at 20% 12%, rgba(216, 186, 125, 0.18), transparent 11rem);
  border: 1px solid rgba(242, 193, 92, 0.38);
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.58), inset 0 0 0 5px rgba(9, 11, 14, 0.52);
  grid-template-columns: minmax(0, 1fr);
  overflow: hidden;
}

.phone-shell::before {
  content: "";
  position: absolute;
  inset: 8px;
  pointer-events: none;
  border: 1px solid rgba(216, 186, 125, 0.2);
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.025) 1px, transparent 1px);
  background-size: 18px 18px;
  mix-blend-mode: screen;
}

.title-band,
.hud,
.plan-strip,
.how-to-panel,
.status-ribbon,
.palette-panel {
  position: relative;
  z-index: 1;
  min-width: 0;
  max-width: 100%;
}

.title-band {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 14px 12px;
  background:
    linear-gradient(180deg, rgba(216, 186, 125, 0.16), rgba(167, 107, 53, 0.1)),
    rgba(10, 14, 15, 0.72);
  border: 1px solid rgba(242, 193, 92, 0.35);
  border-radius: 8px;
}

.kicker,
.label {
  margin: 0;
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1 {
  margin: 2px 0 0;
  color: #ffe5a5;
  font-family: Georgia, "Yu Mincho", serif;
  font-size: 24px;
  line-height: 1.05;
  text-shadow: 0 2px 0 #4a2b16, 0 0 18px rgba(242, 193, 92, 0.32);
}

.icon-button,
.command-row button {
  border: 1px solid rgba(242, 193, 92, 0.38);
  background: linear-gradient(180deg, rgba(42, 154, 145, 0.32), rgba(11, 28, 31, 0.84));
  border-radius: 8px;
  min-height: 42px;
  box-shadow: inset 0 1px rgba(255, 255, 255, 0.12), 0 8px 18px rgba(0, 0, 0, 0.28);
}

.icon-button {
  width: 44px;
  font-size: 24px;
}

.hud {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 0.9fr) minmax(0, 1fr) minmax(0, 0.7fr);
  gap: 8px;
}

.hud-cell,
.plan-strip article,
.status-ribbon,
.palette-panel {
  border: 1px solid rgba(216, 186, 125, 0.28);
  background:
    linear-gradient(180deg, rgba(255, 237, 188, 0.08), rgba(0, 0, 0, 0.12)),
    rgba(13, 22, 23, 0.8);
  border-radius: 8px;
}

.hud-cell {
  min-width: 0;
  padding: 9px 8px;
  text-align: center;
}

.hud-cell strong {
  display: block;
  margin-top: 2px;
  color: #fff2c7;
  font-size: 18px;
  line-height: 1.05;
}

.plan-strip {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1.1fr);
  gap: 6px;
}

.plan-strip article {
  min-width: 0;
  padding: 7px 8px;
}

.plan-strip strong {
  display: block;
  margin-top: 2px;
  color: #fff2c7;
  font-size: 12px;
  line-height: 1.05;
  white-space: nowrap;
}

.plan-strip article.ready strong {
  color: #baff9d;
}

.plan-strip article.short strong {
  color: #ffd78b;
}

.how-to-panel {
  display: grid;
  gap: 8px;
}

.objective-card,
.how-to-steps,
.combo-sheet {
  border: 1px solid rgba(216, 186, 125, 0.3);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255, 237, 188, 0.1), rgba(0, 0, 0, 0.16)),
    rgba(13, 22, 23, 0.84);
}

.objective-card {
  padding: 11px 12px;
}

.objective-card strong {
  display: block;
  margin-top: 3px;
  color: #ffe7a0;
  font-size: 15px;
  line-height: 1.25;
}

.objective-card p {
  margin: 5px 0 0;
  color: #f1dfbd;
  font-size: 12px;
  line-height: 1.35;
}

.how-to-steps {
  padding: 11px 12px 12px;
}

.how-to-steps ol {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 7px;
  margin: 9px 0 0;
  padding: 0;
  list-style: none;
}

.how-to-steps li {
  min-width: 0;
  padding: 8px 7px;
  border: 1px solid rgba(242, 193, 92, 0.24);
  border-radius: 8px;
  background: rgba(9, 11, 14, 0.38);
}

.how-to-steps li::before {
  display: inline-grid;
  place-items: center;
  width: 20px;
  height: 20px;
  margin-bottom: 5px;
  border-radius: 50%;
  color: #1d1209;
  font-size: 11px;
  font-weight: 900;
  background: var(--gold);
  content: counter(list-item);
}

.how-to-steps strong,
.how-to-steps span {
  display: block;
}

.combo-sheet {
  display: grid;
  gap: 5px;
  padding: 10px 12px;
  color: #f1dfbd;
  font-size: 11px;
}

.combo-sheet strong {
  color: #ffe7a0;
}

.how-to-steps strong {
  color: #fff2c7;
  font-size: 12px;
  line-height: 1.15;
}

.how-to-steps span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.3;
}

.how-to-panel.compact {
  display: none;
}

.board-wrap {
  position: relative;
  z-index: 1;
  width: 100%;
  aspect-ratio: 1;
  padding: 11px;
  border: 2px solid rgba(242, 193, 92, 0.46);
  border-radius: 8px;
  background:
    radial-gradient(circle at 50% 50%, rgba(42, 154, 145, 0.18), transparent 62%),
    linear-gradient(145deg, #1b201f, #0b0d0d);
  box-shadow: inset 0 0 22px rgba(0, 0, 0, 0.74), 0 18px 36px rgba(0, 0, 0, 0.34);
}

.board-guide {
  position: absolute;
  inset: 11px;
  z-index: 5;
  pointer-events: none;
}

.board-guide span {
  position: absolute;
  display: block;
  padding: 3px 6px;
  border: 1px solid rgba(255, 231, 173, 0.5);
  border-radius: 999px;
  color: #201407;
  font-size: 9px;
  font-weight: 900;
  background: rgba(242, 193, 92, 0.86);
  box-shadow: 0 5px 12px rgba(0, 0, 0, 0.34);
}

.board-guide span:first-child {
  left: 2%;
  bottom: 2%;
}

.board-guide span:nth-child(2) {
  left: 50%;
  top: 2%;
  transform: translateX(-50%);
}

.board-guide span:last-child {
  right: 2%;
  top: 2%;
}

.game-board {
  position: relative;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  grid-template-rows: repeat(5, 1fr);
  gap: 5px;
  width: 100%;
  height: 100%;
}

.cell {
  position: relative;
  display: grid;
  place-items: center;
  min-width: 0;
  border: 1px solid rgba(255, 231, 173, 0.18);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.12), transparent 32%),
    radial-gradient(circle at 60% 70%, rgba(0, 0, 0, 0.28), transparent 52%),
    linear-gradient(145deg, var(--stone-lit), var(--stone) 62%, #181b1a);
  cursor: pointer;
  box-shadow: inset 0 -5px rgba(0, 0, 0, 0.24), 0 2px 0 #090b0e;
  transition: transform 140ms ease, border-color 140ms ease;
}

.cell::before {
  content: attr(data-route);
  position: absolute;
  left: 5px;
  top: 5px;
  display: grid;
  place-items: center;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 999px;
  color: #1d1209;
  font-size: 9px;
  font-weight: 900;
  background: rgba(242, 193, 92, 0.82);
  opacity: 0;
  transform: translateY(-2px);
  transition: opacity 140ms ease, transform 140ms ease;
}

.cell:hover {
  transform: translateY(-1px);
  border-color: rgba(242, 193, 92, 0.7);
}

.cell.on-route {
  border-color: rgba(242, 193, 92, 0.52);
}

.cell.on-route::before {
  opacity: 1;
  transform: none;
}

.cell.on-route::after {
  content: "";
  position: absolute;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--gold);
  box-shadow: 0 0 12px var(--gold);
}

.cell.off-route {
  opacity: 0.45;
}

.cell.off-route:hover {
  border-color: rgba(213, 83, 54, 0.62);
}

.cell.locked {
  cursor: not-allowed;
}

.cell.locked::before {
  content: attr(data-badge);
  min-width: 34px;
  background: rgba(11, 17, 20, 0.82);
  color: #ffe7a0;
  border: 1px solid rgba(242, 193, 92, 0.5);
}

.cell.start-cell {
  box-shadow: inset 0 -5px rgba(0, 0, 0, 0.24), 0 0 0 2px rgba(42, 154, 145, 0.46), 0 2px 0 #090b0e;
}

.cell.goal-cell {
  box-shadow: inset 0 -5px rgba(0, 0, 0, 0.24), 0 0 0 2px rgba(242, 193, 92, 0.6), 0 2px 0 #090b0e;
}

.cell.resolved {
  animation: impact 460ms ease;
}

.tile-art {
  position: relative;
  display: block;
  width: 72%;
  height: 72%;
}

.tile-art.floor::before {
  content: "";
  position: absolute;
  inset: 18% 10%;
  border-top: 2px solid rgba(255, 231, 173, 0.2);
  border-bottom: 2px solid rgba(0, 0, 0, 0.2);
}

.tile-art.poison {
  width: 82%;
  height: 56%;
  border-radius: 52% 48% 42% 58%;
  background:
    radial-gradient(circle at 30% 34%, rgba(245, 255, 183, 0.9) 0 8%, transparent 9%),
    radial-gradient(circle at 70% 64%, rgba(10, 71, 35, 0.95) 0 18%, transparent 20%),
    linear-gradient(135deg, #a5f26e, #258943 64%, #123d22);
  box-shadow: 0 0 14px rgba(89, 201, 91, 0.72), inset 0 -7px rgba(0, 0, 0, 0.22);
}

.tile-art.arrow::before,
.tile-art.arrow::after {
  content: "";
  position: absolute;
  top: 45%;
  left: 8%;
  width: 82%;
  height: 7px;
  background: linear-gradient(90deg, #d8ba7d, #f6e3ae);
  transform: rotate(-24deg);
  box-shadow: 0 2px #432919;
}

.tile-art.arrow::after {
  left: 58%;
  top: 29%;
  width: 24%;
  height: 24%;
  background: #d55336;
  clip-path: polygon(0 0, 100% 50%, 0 100%);
}

.tile-art.spike::before {
  content: "";
  position: absolute;
  inset: 12%;
  background:
    linear-gradient(135deg, transparent 0 32%, #d7d9d2 33% 48%, transparent 49%),
    linear-gradient(45deg, transparent 0 34%, #89918b 35% 52%, transparent 53%),
    radial-gradient(ellipse at center, #0a0a0a 0 46%, transparent 48%);
  border-radius: 50%;
  filter: drop-shadow(0 4px 0 rgba(0, 0, 0, 0.48));
}

.tile-art.mimic {
  width: 78%;
  height: 60%;
  border-radius: 8px 8px 10px 10px;
  background: linear-gradient(180deg, #b36d35 0 43%, #f4d17b 44% 54%, #6a371d 55%);
  border: 2px solid #32190f;
  box-shadow: 0 6px 0 rgba(0, 0, 0, 0.28), 0 0 12px rgba(242, 193, 92, 0.25);
}

.tile-art.mimic::after {
  content: "";
  position: absolute;
  left: 20%;
  right: 20%;
  top: 48%;
  height: 22%;
  background: repeating-linear-gradient(90deg, #fff4c6 0 5px, #33160f 5px 8px);
  clip-path: polygon(0 0, 100% 0, 88% 100%, 12% 100%);
}

.tile-art.slime {
  width: 76%;
  height: 62%;
  border-radius: 54% 46% 38% 42%;
  align-self: end;
  background:
    radial-gradient(circle at 34% 34%, #e7ffd3 0 8%, transparent 9%),
    radial-gradient(circle at 62% 45%, #093d22 0 7%, transparent 8%),
    linear-gradient(180deg, #8df275, #238d57);
  box-shadow: inset 0 -8px rgba(0, 0, 0, 0.22), 0 5px 0 rgba(0, 0, 0, 0.3);
}

.tile-art.skeleton::before {
  content: "";
  position: absolute;
  left: 31%;
  top: 6%;
  width: 38%;
  height: 34%;
  border-radius: 50%;
  background: #e7dfc9;
  box-shadow: 0 22px 0 -4px #d0c3a4, -10px 34px 0 -8px #efe7cf, 10px 34px 0 -8px #efe7cf;
}

.tile-art.skeleton::after {
  content: "";
  position: absolute;
  left: 27%;
  bottom: 6%;
  width: 46%;
  height: 38%;
  background: linear-gradient(90deg, transparent 0 18%, #cfc5aa 19% 29%, transparent 30% 43%, #cfc5aa 44% 56%, transparent 57% 70%, #cfc5aa 71% 81%, transparent 82%);
}

.tile-art.treasure {
  width: 78%;
  height: 62%;
  border-radius: 8px;
  background:
    radial-gradient(circle at 50% 6%, #fff7bd 0 9%, transparent 10%),
    linear-gradient(180deg, #f8dc75 0 38%, #925323 39% 49%, #d89336 50%);
  border: 2px solid #3a2011;
  box-shadow: 0 0 22px rgba(242, 193, 92, 0.82), inset 0 -7px rgba(74, 43, 22, 0.34);
}

.route-layer {
  position: absolute;
  inset: 11px;
  pointer-events: none;
  z-index: 4;
}

.damage-pop {
  position: absolute;
  z-index: 8;
  left: calc(11px + (var(--col) + 0.5) * ((100% - 22px) / 5));
  top: calc(11px + (var(--row) + 0.5) * ((100% - 22px) / 5));
  transform: translate(-50%, -70%);
  pointer-events: none;
  color: #fff7bd;
  font-size: 18px;
  font-weight: 900;
  text-shadow: 0 2px 0 #4a120c, 0 0 16px rgba(213, 83, 54, 0.8);
  animation: damagePop 850ms ease forwards;
}

.route-dot {
  position: absolute;
  width: 7px;
  height: 7px;
  left: calc((var(--col) + 0.5) * 20%);
  top: calc((var(--row) + 0.5) * 20%);
  border-radius: 50%;
  background: #ffe7a0;
  box-shadow: 0 0 12px #f2c15c;
  opacity: 0;
  transform: translate(-50%, -50%);
  animation: routePulse 1.2s ease var(--delay) infinite;
}

.hero-token {
  position: absolute;
  z-index: 6;
  width: 46px;
  height: 56px;
  left: calc(11px + (var(--col, 0) + 0.5) * ((100% - 22px) / 5));
  top: calc(11px + (var(--row, 4) + 0.5) * ((100% - 22px) / 5));
  transform: translate(-50%, -62%);
  transition: left 380ms ease, top 380ms ease;
  pointer-events: none;
  filter: drop-shadow(0 8px 5px rgba(0, 0, 0, 0.55));
}

.hero-head,
.hero-body,
.hero-sword {
  position: absolute;
  display: block;
}

.hero-head {
  left: 11px;
  top: 1px;
  width: 24px;
  height: 24px;
  border-radius: 50% 50% 44% 44%;
  background: linear-gradient(180deg, #f1c48d, #a86445);
  border: 2px solid #3a2011;
}

.hero-head::before {
  content: "";
  position: absolute;
  inset: -7px -5px 10px;
  border-radius: 48% 48% 35% 35%;
  background: linear-gradient(180deg, #9a4c2b, #4a241c);
  z-index: -1;
}

.hero-body {
  left: 8px;
  top: 24px;
  width: 30px;
  height: 27px;
  border-radius: 12px 12px 8px 8px;
  background:
    linear-gradient(90deg, transparent 0 40%, #f2c15c 41% 52%, transparent 53%),
    linear-gradient(180deg, #2a9a91, #13535d);
  border: 2px solid #102b2e;
}

.hero-sword {
  right: -2px;
  top: 21px;
  width: 6px;
  height: 34px;
  background: linear-gradient(180deg, #f7f3dc, #8a9692);
  transform: rotate(-28deg);
  border-radius: 6px;
}

.hero-token.walking {
  animation: bob 420ms ease-in-out infinite alternate;
}

.status-ribbon {
  display: grid;
  grid-template-columns: 68px minmax(0, 1fr) 76px;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
}

.status-ribbon strong {
  color: var(--gold);
  font-size: 20px;
}

.status-ribbon p {
  min-width: 0;
  margin: 0;
  color: #f1dfbd;
  font-size: 12px;
  line-height: 1.35;
}

.palette-panel {
  padding: 12px;
}

.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 9px;
  gap: 10px;
  min-width: 0;
}

.panel-heading h2 {
  min-width: 0;
}

h2 {
  margin: 0;
  color: #ffe4a4;
  font-family: Georgia, "Yu Mincho", serif;
  font-size: 18px;
}

.selected-tool {
  min-width: 100px;
  padding: 6px 8px;
  border: 1px solid rgba(242, 193, 92, 0.28);
  border-radius: 8px;
  text-align: right;
  background: rgba(9, 11, 14, 0.36);
}

.selected-tool strong {
  display: block;
  margin-top: 1px;
  color: #fff2c7;
  font-size: 14px;
}

.palette {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  min-width: 0;
}

.palette-item {
  position: relative;
  min-width: 0;
  min-height: 76px;
  padding: 6px 4px;
  display: grid;
  justify-items: center;
  align-content: center;
  gap: 2px;
  border: 1px solid rgba(216, 186, 125, 0.24);
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(33, 54, 54, 0.96), rgba(12, 18, 18, 0.96));
  transition: border-color 140ms ease, box-shadow 140ms ease, transform 140ms ease;
}

.palette-item:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.palette-item:active {
  transform: translateY(1px);
}

.palette-item.selected {
  border-color: var(--gold);
  box-shadow: 0 0 0 2px rgba(242, 193, 92, 0.18), 0 0 16px rgba(42, 154, 145, 0.35);
}

.palette-item .tile-art {
  width: 34px;
  height: 34px;
}

.palette-item::before {
  content: attr(data-damage);
  position: absolute;
  right: 4px;
  top: 3px;
  min-width: 15px;
  padding: 1px 3px;
  border-radius: 999px;
  color: #1d1209;
  font-size: 8px;
  font-weight: 900;
  background: rgba(242, 193, 92, 0.9);
}

.palette-item strong {
  font-size: 11px;
  line-height: 1.1;
}

.palette-item small {
  color: var(--muted);
  font-size: 9px;
}

.palette-item em {
  color: #f3dcae;
  font-size: 9px;
  font-style: normal;
  line-height: 1.1;
}

.selected-detail {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(0, 1.4fr) minmax(0, 1fr);
  gap: 6px;
  margin-top: 7px;
}

.selected-detail > div {
  min-width: 0;
  padding: 6px;
  border: 1px solid rgba(216, 186, 125, 0.22);
  border-radius: 8px;
  background: rgba(9, 11, 14, 0.32);
}

.selected-detail strong {
  display: block;
  margin-top: 2px;
  color: #fff0bf;
  font-size: 10px;
  line-height: 1.2;
  max-height: 2.4em;
  overflow: hidden;
}

.placement-note {
  margin: 8px 0 0;
  color: #f1dfbd;
  font-size: 11px;
  line-height: 1.35;
}

.command-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 10px;
}

.command-row button {
  padding: 0 8px;
  font-size: 12px;
  font-weight: 800;
}

.command-row .primary,
.result-card .primary {
  background: linear-gradient(180deg, #f4d27a, #a76b35);
  color: #1d1209;
  border-color: #ffe5a5;
}

.command-row .primary {
  grid-column: 1 / -1;
  min-height: 48px;
  font-size: 14px;
  position: relative;
  z-index: 2;
}

.command-row .primary:disabled {
  opacity: 0.64;
}

.ready-pulse {
  animation: readyPulse 700ms ease;
}

.stat-hit {
  animation: statHit 520ms ease;
}

.score-hit {
  animation: scoreHit 520ms ease;
}

.result-panel {
  position: absolute;
  z-index: 12;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(4, 8, 10, 0.72);
  backdrop-filter: blur(8px);
}

.result-panel.hidden {
  display: none;
}

.result-card {
  width: min(100%, 360px);
  padding: 22px;
  text-align: center;
  border: 2px solid rgba(242, 193, 92, 0.62);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(216, 186, 125, 0.23), rgba(18, 61, 67, 0.26)),
    #111817;
  box-shadow: 0 28px 70px rgba(0, 0, 0, 0.58);
}

.seal {
  display: inline-block;
  padding: 5px 10px;
  color: #181009;
  font-size: 11px;
  font-weight: 900;
  background: var(--gold);
  border-radius: 99px;
}

.result-card p {
  color: #ead6b1;
  line-height: 1.55;
}

.result-card dl {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  margin: 18px 0;
}

.result-card dt {
  color: var(--muted);
  font-size: 10px;
  text-transform: uppercase;
}

.result-card dd {
  margin: 3px 0 0;
  color: var(--gold);
  font-weight: 900;
}

.result-card button {
  width: 100%;
  min-height: 46px;
  border-radius: 8px;
  font-weight: 900;
}

@keyframes routePulse {
  0%, 100% { opacity: 0.18; transform: translate(-50%, -50%) scale(0.75); }
  45% { opacity: 1; transform: translate(-50%, -50%) scale(1.25); }
}

@keyframes bob {
  from { margin-top: 0; }
  to { margin-top: -5px; }
}

@keyframes impact {
  0% { filter: brightness(1); }
  38% { filter: brightness(1.8) saturate(1.4); transform: scale(1.04); }
  100% { filter: brightness(1); }
}

@keyframes damagePop {
  0% { opacity: 0; transform: translate(-50%, -40%) scale(0.8); }
  18% { opacity: 1; transform: translate(-50%, -82%) scale(1.08); }
  100% { opacity: 0; transform: translate(-50%, -132%) scale(0.92); }
}

@keyframes readyPulse {
  0%, 100% { box-shadow: inset 0 1px rgba(255, 255, 255, 0.12), 0 8px 18px rgba(0, 0, 0, 0.28); }
  45% { box-shadow: inset 0 1px rgba(255, 255, 255, 0.16), 0 0 0 4px rgba(242, 193, 92, 0.24), 0 10px 24px rgba(242, 193, 92, 0.2); }
}

@keyframes statHit {
  0%, 100% { border-color: rgba(216, 186, 125, 0.28); }
  42% { border-color: rgba(213, 83, 54, 0.9); background-color: rgba(213, 83, 54, 0.18); }
}

@keyframes scoreHit {
  0%, 100% { border-color: rgba(216, 186, 125, 0.28); }
  42% { border-color: rgba(242, 193, 92, 0.86); box-shadow: 0 0 18px rgba(242, 193, 92, 0.2); }
}

@media (min-width: 760px) {
  body {
    padding: 24px;
  }

  .phone-shell {
    min-height: 844px;
  }
}

@media (max-width: 374px) {
  .phone-shell {
    padding: 10px;
    gap: 8px;
  }

  h1 {
    font-size: 20px;
  }

  .hud {
    gap: 5px;
  }

  .how-to-steps ol {
    grid-template-columns: 1fr;
  }

  .hud-cell strong {
    font-size: 15px;
  }

  .palette {
    gap: 5px;
  }

  .palette-item {
    min-height: 68px;
  }

  .palette-item em {
    display: none;
  }
}

/* Compact stage-mode overrides */
body { overflow: hidden; }
.phone-shell {
  height: 100dvh;
  min-height: 0;
  padding: 10px;
  gap: 7px;
  grid-template-rows: auto auto auto minmax(0, 1fr) auto auto;
}
.title-band { padding: 8px 9px; gap: 8px; }
.title-band > div { flex: 1; min-width: 0; }
h1 { font-size: 20px; white-space: nowrap; }
.kicker { font-size: 8px; }
.icon-button { width: 36px; min-height: 34px; font-size: 19px; }
.hud { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 5px; }
.hud-cell { padding: 5px 4px; }
.hud-cell strong { font-size: 16px; }
.board-wrap { align-self: stretch; max-height: min(53dvh, 390px); width: auto; aspect-ratio: 1; margin-inline: auto; padding: 8px; }
.status-ribbon { min-height: 42px; padding: 6px 8px; grid-template-columns: 54px minmax(0, 1fr) 58px; }
.status-ribbon p { font-size: 11px; line-height: 1.2; }
.palette-panel { padding: 7px; }
.panel-heading { margin-bottom: 5px; }
h2 { font-size: 14px; }
.selected-tool { padding: 4px 6px; min-width: 82px; }
.selected-tool strong { font-size: 12px; }
.palette { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 5px; }
.palette-item { min-height: 48px; padding: 4px 3px; }
.palette-item .tile-art { width: 22px; height: 22px; }
.palette-item strong { font-size: 10px; }
.palette-item small { font-size: 9px; }
.palette-item em { display: none; }
.placement-note { margin-top: 5px; font-size: 10px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.command-row { margin-top: 6px; gap: 6px; }
.command-row button { min-height: 34px; font-size: 12px; }
.command-row .primary { min-height: 40px; }
.rules-dialog { width: min(92vw, 390px); border: 1px solid rgba(242, 193, 92, .45); border-radius: 12px; padding: 0; color: var(--ink); background: rgba(9, 13, 15, .96); box-shadow: 0 24px 80px rgba(0,0,0,.7); }
.rules-dialog::backdrop { background: rgba(0,0,0,.58); backdrop-filter: blur(3px); }
.rules-dialog .how-to-panel { display: grid; padding: 12px; }
.rules-dialog .primary { margin-top: 8px; min-height: 40px; border: 1px solid rgba(242,193,92,.42); border-radius: 8px; background: linear-gradient(180deg, rgba(167,107,53,.72), rgba(75,40,18,.94)); }
.rules-dialog .how-to-steps ol { grid-template-columns: 1fr; }
@media (max-height: 760px) {
  .phone-shell { gap: 5px; padding: 8px; }
  .board-wrap { max-height: 48dvh; }
  .hud-cell strong { font-size: 14px; }
  .palette-item { min-height: 42px; }
  .status-ribbon { min-height: 36px; }
}

/* No-scroll tighter pass */
.phone-shell { grid-template-rows: auto auto auto minmax(0, 0.92fr) auto auto; }
.board-wrap { max-height: min(38dvh, 310px); }
.palette { grid-template-columns: repeat(7, minmax(0, 1fr)); }
.palette-item { min-height: 38px; padding: 3px 2px; }
.palette-item .tile-art { width: 18px; height: 18px; }
.palette-item strong { font-size: 9px; }
.palette-item small { font-size: 8px; }
.palette-item em {
  display: block;
  max-width: 100%;
  overflow: hidden;
  font-size: 7px;
  line-height: 1;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.selected-detail { gap: 4px; margin-top: 5px; }
.selected-detail > div { padding: 4px; }
.selected-detail strong { font-size: 9px; }
.status-ribbon { padding: 4px 6px; min-height: 34px; }
.palette-panel { padding: 5px; }
.command-row .primary { min-height: 36px; }
.command-row button { min-height: 30px; }
html, body { width: 100%; height: 100dvh; max-height: 100dvh; overflow: hidden; }
body { min-height: 0; align-items: start; }
.phone-shell { height: 100dvh; max-height: 100dvh; min-height: 0 !important; box-shadow: none; border-left: 0; border-right: 0; }

/* PWA / standalone 起動時に OS ナビバー・ノッチ・ホームインジケータと重ならないよう safe-area inset を尊重する */
.phone-shell {
  --shell-pad: 10px;
  --pwa-bottom-reserve: 0px;
  padding-top: max(var(--shell-pad), env(safe-area-inset-top));
  padding-right: max(var(--shell-pad), env(safe-area-inset-right));
  padding-bottom: max(var(--shell-pad), env(safe-area-inset-bottom), var(--pwa-bottom-reserve));
  padding-left: max(var(--shell-pad), env(safe-area-inset-left));
}
@media (display-mode: standalone) {
  .phone-shell { --pwa-bottom-reserve: 56px; }
}
html.is-standalone .phone-shell {
  --pwa-bottom-reserve: 56px;
}
@media (max-height: 760px) {
  .phone-shell { --shell-pad: 8px; }
  @media (display-mode: standalone) {
    .phone-shell { --pwa-bottom-reserve: 48px; }
  }
  html.is-standalone .phone-shell { --pwa-bottom-reserve: 48px; }
}
