:root {
  --ink: #2b2a24;
  --muted: #8a8577;
  --paper: #fbf7ec;
  --panel: #fffdf6;
  --line: #e7dfca;
  --grass-1: #b9d77f;
  --grass-2: #9cc566;
  --deer: #b9824f;
  --deer-dark: #7a5230;
  --accent: #e0673a;
  --ok: #3d9a5b;
  --warn: #d9a21b;
  --pond: #7cc3d9;
  --mono: 'JetBrains Mono', ui-monospace, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: #2f3a26;
  color: var(--ink);
  font-family: 'M PLUS Rounded 1c', system-ui, sans-serif;
  display: flex;
  justify-content: center;
  -webkit-font-smoothing: antialiased;
}

/* 9:16 の縦長ステージ。PC では中央に置き、そのまま画面録画してリールに使える */
.stage {
  width: 100%;
  max-width: calc(100dvh * 9 / 16);
  height: 100dvh;
  background: var(--paper);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 12px 16px 10px;
}
.title { display: flex; flex-direction: column; line-height: 1.15; }
.title-main { font-size: 22px; font-weight: 800; letter-spacing: .02em; }
.title-sub { font-size: 11px; color: var(--muted); }
.hud { display: flex; gap: 8px; align-items: center; font-size: 13px; flex-wrap: wrap; justify-content: flex-end; }
.hud b { font-family: var(--mono); }
.badge {
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 700;
  padding: 3px 7px;
  border-radius: 99px;
  background: var(--ink);
  color: #fff;
}
.badge.mock { background: var(--warn); color: var(--ink); }

/* ---------- 奈良公園（絵は QuiverAI Arrow 2 で生成した SVG） ---------- */
@property --s { syntax: '<number>'; inherits: true; initial-value: 1; }

.field {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  margin: 0 12px;
  border-radius: 18px;
  overflow: hidden;
  container-type: size;
  background: #a8c467;
  box-shadow: inset 0 0 0 3px rgba(0,0,0,.06);
}
.scenery {
  position: absolute;
  inset: 0 0 auto 0;
  width: 100%;
  height: auto;
  display: block;
  pointer-events: none;
}
/* 盤面（7×6）は景色の帯より下の芝生だけ。背景の地平線は幅の約24%の高さにある */
.lawn {
  position: absolute;
  top: 26cqw;
  bottom: 2%;
  left: 3%;
  right: 3%;
}
.pond {
  position: absolute;
  z-index: 1;
  pointer-events: none;
}
.tree {
  position: absolute;
  transform: translate(-50%, -100%);
  pointer-events: none;
}

/* 盤面に立つもの。セルの下端中央に足元を合わせ、奥の段ほど小さく描く（--s） */
.piece {
  position: absolute;
  width: calc(100% / 7);
  height: calc(100% / 6);
  transition-property: left, top, --s;
  transition-timing-function: linear;
  transition-duration: .18s;
}
.piece .sprite {
  position: absolute;
  left: 50%;
  bottom: 6%;
  width: calc(175% * var(--s));
  transform: translateX(-50%);
  pointer-events: none;
}
.goal .sprite { width: calc(150% * var(--s)); animation: bob 1.8s ease-in-out infinite; }
.goal { transition: left .35s ease, top .35s ease, opacity .3s; }

.deer-flip.left .deer-body { transform: scaleX(-1); }
.deer-body {
  display: block;
  width: 100%;
  transform-origin: 50% 100%;
  transition: transform .25s;
  filter: drop-shadow(0 3px 0 rgba(60,40,20,.18));
}
/* SVG は1枚絵なので、歩く・首をかしげる・お辞儀・食べるは体全体の傾きで表す */
.deer-flip { transform-origin: 50% 100%; }
.deer.walking .deer-flip { animation: hop .3s ease-in-out infinite alternate; }
.deer.tilt .deer-flip { transform: translateX(-50%) rotate(-10deg); }
.deer.bow .deer-flip { transform: translateX(-50%) rotate(10deg) scaleY(.95); transform-origin: 75% 100%; }
.deer.bow.deep .deer-flip { transform: translateX(-50%) rotate(18deg) scaleY(.9); }
.deer-flip.left { transform-origin: 50% 100%; }
.deer.bow .deer-flip.left { transform: translateX(-50%) rotate(-10deg) scaleY(.95); transform-origin: 25% 100%; }
.deer.bow.deep .deer-flip.left { transform: translateX(-50%) rotate(-18deg) scaleY(.9); }
.deer.eat .deer-flip { animation: nod .22s 5 alternate; transform-origin: 75% 100%; }
.deer.eat .deer-flip.left { animation-name: nod-left; transform-origin: 25% 100%; }

@keyframes hop {
  from { transform: translateX(-50%) translateY(0) rotate(-2deg); }
  to { transform: translateX(-50%) translateY(-7%) rotate(2deg); }
}
@keyframes nod { from { transform: translateX(-50%) rotate(0); } to { transform: translateX(-50%) rotate(7deg); } }
@keyframes nod-left { from { transform: translateX(-50%) rotate(0); } to { transform: translateX(-50%) rotate(-7deg); } }
@keyframes bob { 50% { transform: translateX(-50%) translateY(-3px); } }

.bubble {
  position: absolute;
  left: 50%;
  bottom: calc(12% + 185% * var(--s)); /* 鹿の頭のすぐ上 */
  transform: translateX(-50%) scale(.6);
  background: #fff;
  border-radius: 14px;
  padding: 4px 10px;
  font-size: 15px;
  font-weight: 800;
  white-space: nowrap;
  opacity: 0;
  transition: opacity .15s, transform .15s;
  box-shadow: 0 3px 0 rgba(0,0,0,.12);
  z-index: 4;
}
.bubble.show { opacity: 1; transform: translateX(-50%) scale(1); }
.tag {
  position: absolute;
  left: 50%;
  top: 96%;
  transform: translateX(-50%);
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 700;
  color: #fff;
  background: rgba(43,42,36,.82);
  padding: 2px 6px;
  border-radius: 6px;
  white-space: nowrap;
  opacity: 0;
  transition: opacity .2s;
}
.tag.show { opacity: 1; }

.heart {
  position: absolute;
  z-index: 60;
  pointer-events: none;
  font-size: 18px;
  animation: floatUp 1s ease-out forwards;
}
@keyframes floatUp { to { transform: translateY(-60px) scale(1.4); opacity: 0; } }

.toast {
  position: absolute;
  inset: auto 0 45% 0;
  text-align: center;
  font-size: 30px;
  font-weight: 800;
  color: #fff;
  text-shadow: 0 3px 0 rgba(0,0,0,.25);
  opacity: 0;
  transform: scale(.8);
  transition: opacity .25s, transform .25s;
  pointer-events: none;
  z-index: 70;
}
.toast.show { opacity: 1; transform: scale(1); }
.toast small { display: block; font-size: 15px; }

/* ---------- 判定パネル ---------- */
.panel {
  flex: 0 0 auto;
  padding: 10px 16px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.heard { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 6px 10px; }
.heard-label { font-size: 10px; color: var(--muted); }
.heard-text { margin: 0; font-size: 17px; font-weight: 800; min-height: 1.4em; line-height: 1.4; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.heard-text .interim { color: var(--muted); }
.muted { color: var(--muted); font-size: 12px; font-weight: 500; }

.judge { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 8px 10px; }
.judge-head { display: flex; justify-content: space-between; font-size: 12px; font-weight: 800; margin-bottom: 4px; }
.judge-head small, .mini-label small { font-family: var(--mono); font-size: 9px; color: var(--muted); font-weight: 500; }
.conf { font-family: var(--mono); font-size: 11px; padding: 1px 6px; border-radius: 6px; background: var(--line); }
.conf.high { background: var(--ok); color: #fff; }
.conf.mid { background: var(--warn); }
.conf.low { background: #c9c2b0; }

.bars { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 3px 12px; }
.bar { white-space: nowrap; display: grid; grid-template-columns: 5.4em 1fr 2.4em; align-items: center; gap: 6px; font-size: 11px; }
.bar-track { height: 9px; background: #efe8d6; border-radius: 99px; overflow: hidden; }
.bar-fill { height: 100%; width: 0; background: #c7bda4; border-radius: 99px; transition: width .18s ease-out; }
.bar.top .bar-fill { background: var(--accent); }
.bar.top { font-weight: 800; }
.bar-pct { font-family: var(--mono); font-size: 10px; text-align: right; color: var(--muted); }

.minis { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 6px; }
.mini-label { font-size: 11px; font-weight: 800; }
.scale { position: relative; height: 9px; margin: 4px 4px 0; background: linear-gradient(90deg, #efe8d6, #e6c9a8); border-radius: 99px; }
.scale-dot { position: absolute; top: 50%; left: 50%; width: 14px; height: 14px; margin: -7px 0 0 -7px; border-radius: 50%; background: var(--accent); border: 2px solid #fff; transition: left .2s; opacity: .3; }
.meter { height: 9px; margin: 4px 4px 0; background: #efe8d6; border-radius: 99px; overflow: hidden; }
.meter-fill { height: 100%; width: 0; background: #e98fa6; transition: width .2s; }
.scale-legend { display: flex; justify-content: space-between; font-size: 9px; color: var(--muted); margin-top: 2px; }

.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.stat { background: var(--ink); color: #fff; border-radius: 10px; padding: 5px 8px; display: flex; flex-direction: column; align-items: center; }
.stat-num { font-family: var(--mono); font-size: 18px; font-weight: 700; }
.stat-label { font-size: 9px; opacity: .7; }

.controls { display: flex; flex-direction: column; gap: 6px; }
.mic {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 0;
  border-radius: 99px;
  padding: 12px;
  font: inherit;
  font-size: 16px;
  font-weight: 800;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  box-shadow: 0 4px 0 #a9461f;
}
.mic:active { transform: translateY(2px); box-shadow: 0 2px 0 #a9461f; }
.mic[aria-pressed="true"] { background: var(--ok); box-shadow: 0 4px 0 #26693b; animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { filter: brightness(1.1); } }
.typein { display: flex; gap: 6px; }
.typein input {
  flex: 1;
  min-width: 0;
  font: inherit;
  font-size: 14px;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
}
.typein button {
  font: inherit;
  font-size: 13px;
  font-weight: 800;
  border: 0;
  border-radius: 10px;
  padding: 0 14px;
  background: var(--ink);
  color: #fff;
  cursor: pointer;
}

@media (max-height: 700px) {
  .title-sub, .scale-legend { display: none; }
  .panel { gap: 6px; }
}
