@import url('https://fonts.googleapis.com/css2?family=M+PLUS+Rounded+1c:wght@700;800;900&display=swap');

/* ── Variables ── */
:root {
  --bg: #fef9ef;
  --panel: #fffdf8;
  --ink: #1d3018;
  --muted: #5d7a58;
  --line: #ddd6c2;
  --grass: #52b788;
  --grass-dark: #2d6a4f;
  --sky: #74c7ec;
  --coral: #ff6b35;
  --yellow: #ffb703;
  --blue: #4895ef;
  --shadow: 0 24px 56px rgba(20, 55, 15, 0.15);
  --radius: 18px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  min-height: 100vh;
  overflow: hidden;
  background:
    radial-gradient(ellipse at 12% 0%, rgba(255,183,3,0.16) 0%, transparent 48%),
    radial-gradient(ellipse at 92% 8%,  rgba(116,199,236,0.2) 0%, transparent 44%),
    var(--bg);
  color: var(--ink);
  font-family: 'M PLUS Rounded 1c', 'Yu Gothic UI', 'Hiragino Sans', 'Meiryo', system-ui, sans-serif;
}

button, input, select { font-family: inherit; font-size: inherit; }
h1, h2, h3, p { margin: 0; }

/* ── App shell ── */
.app-shell {
  width: min(1200px, calc(100vw - 24px));
  height: 100vh;
  margin: 0 auto;
  padding-bottom: 12px;
  display: flex;
  flex-direction: column;
}

/* ── Topbar ── */
.topbar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 18px 2px 16px;
}

.app-title {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 20px;
  font-weight: 900;
  color: var(--grass-dark);
  letter-spacing: 0;
  line-height: 1.25;
}

.app-title span { font-size: 26px; }

/* ── Main grid ── */
.main-grid {
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

/* ── Panels ── */
.practice-panel {
  min-height: 0;
  height: 100%;
  display: grid;
  grid-template-rows: minmax(260px, 1fr) auto auto auto auto auto;
  background: var(--panel);
  border: 1.5px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.settings-panel {
  background: var(--panel);
  border: 1.5px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 0;
}

.admin-sidebar {
  position: fixed;
  top: 50%;
  right: 12px;
  transform: translateY(-50%);
  z-index: 30;
  width: 58px;
  height: 58px;
  max-height: calc(100vh - 92px);
  display: grid;
  grid-template-columns: 58px minmax(0, 0fr);
  overflow: hidden;
  transition: width 0.22s ease, grid-template-columns 0.22s ease;
}

.admin-sidebar.open {
  top: 76px;
  transform: none;
  width: min(360px, calc(100vw - 24px));
  height: auto;
  grid-template-columns: 58px minmax(0, 1fr);
}

.admin-toggle {
  width: 58px;
  height: 58px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 8px;
  border: 0;
  border-right: 1.5px solid var(--line);
  background: #f4f8f0;
  color: var(--grass-dark);
  font-weight: 900;
  cursor: pointer;
}

.admin-sidebar.open .admin-toggle {
  height: auto;
  min-height: 100%;
}

.admin-toggle span {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: #e0f5d4;
  border: 1.5px solid #93d681;
}

.admin-toggle strong {
  display: none;
  writing-mode: vertical-rl;
  letter-spacing: 0.12em;
  font-size: 13px;
}

.admin-sidebar.open .admin-toggle strong { display: block; }

.admin-panel-body {
  min-width: 0;
  max-height: calc(100vh - 92px);
  padding: 20px;
  overflow: auto;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease;
}

.admin-sidebar.open .admin-panel-body {
  opacity: 1;
  pointer-events: auto;
}

/* ── Scene ── */
.scene {
  position: relative;
  min-height: 0;
  height: 100%;
  overflow: hidden;
  border-radius: var(--radius) var(--radius) 0 0;
  background:
    /* sun glow */
    radial-gradient(circle at 80% 15%, rgba(255,220,60,0.55) 0%, transparent 22%),
    /* sky */
    linear-gradient(180deg, #4eabda 0%, #7fcbee 36%, #b8e8f8 50%, #cdf0d8 50%, #5ab348 100%);
}

/* distant hills */
.scene::before {
  content: '';
  position: absolute;
  bottom: 49%;
  left: -8%;
  width: 116%;
  height: 90px;
  background: rgba(130,210,110,0.32);
  border-radius: 50% 60% 50% 40% / 80px 90px 0 0;
  z-index: 1;
}

/* ground shadow layer */
.scene::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 50%;
  background: linear-gradient(180deg, #5ab348 0%, #459438 50%, #357a2d 100%);
  z-index: 0;
}

.sky-bubbles span {
  position: absolute;
  height: 24px;
  border-radius: 999px;
  background: rgba(255,255,255,0.75);
  z-index: 2;
}
.sky-bubbles span:nth-child(1) { width: 82px;  top: 26px; left: 7%; }
.sky-bubbles span:nth-child(2) { width: 114px; top: 48px; right: 20%; }
.sky-bubbles span:nth-child(3) { width: 58px;  top: 82px; left: 43%; }

.target-cloud {
  position: absolute;
  top: 32px;
  left: clamp(18px, 5vw, 58px);
  z-index: 5;
  padding: 16px 26px 20px;
  border-radius: 26px;
  background: rgba(255,255,255,0.95);
  border: 2px solid rgba(255,255,255,1);
  box-shadow: 0 14px 44px rgba(20,70,20,0.18), inset 0 1px 0 #fff;
}

.target-cloud strong {
  display: block;
  font-size: clamp(58px, 10vw, 110px);
  line-height: 0.9;
  font-weight: 900;
  color: var(--ink);
  letter-spacing: -0.02em;
}

.count-pill {
  position: absolute;
  top: 16px;
  right: 16px;
  z-index: 6;
  min-width: 76px;
  text-align: center;
  background: rgba(255,255,255,0.94);
  color: var(--grass-dark);
  border: 2px solid rgba(82,183,136,0.55);
  border-radius: 999px;
  font-size: 19px;
  font-weight: 900;
  padding: 7px 13px;
  box-shadow: 0 4px 14px rgba(20,70,20,0.12);
}

.dino-stage {
  position: absolute;
  right: clamp(22px, 7vw, 96px);
  bottom: 52px;
  width: 210px;
  height: 206px;
  z-index: 4;
}

.dino-xp-badge {
  position: absolute;
  top: -8px;
  right: -6px;
  z-index: 3;
  min-width: 82px;
  padding: 7px 12px 8px;
  border: 2px solid #e8c030;
  border-radius: 999px;
  background: #fff3b8;
  color: #6a4800;
  font-size: 18px;
  font-weight: 900;
  line-height: 1;
  text-align: center;
  box-shadow: 0 4px 0 #e8c030, 0 8px 18px rgba(80,58,0,0.14);
}

/* ground shadow under dino */
.dino-stage::after {
  content: '';
  position: absolute;
  bottom: -6px;
  left: 50%;
  transform: translateX(-50%);
  width: 68%;
  height: 14px;
  background: rgba(15,60,15,0.22);
  border-radius: 50%;
  filter: blur(7px);
}

.creature-asset {
  position: absolute;
  right: 0; bottom: 0;
  width: 100%; height: 100%;
  object-fit: contain;
  filter: drop-shadow(0 14px 18px rgba(15,60,15,0.22));
  transform-origin: center bottom;
  transition: transform 0.35s ease;
}

.creature-emoji {
  position: absolute;
  right: 0; bottom: 0;
  width: 100%; height: 100%;
  display: none;
  font-size: 128px;
  line-height: 1;
  align-items: flex-end;
  justify-content: center;
  filter: drop-shadow(0 14px 18px rgba(15,60,15,0.22));
  transform-origin: center bottom;
  transition: transform 0.35s ease;
}

/* ── Rating Burst ── */
.rating-burst {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  padding: 32px;
  background: rgba(255,252,238,0.86);
  backdrop-filter: blur(6px);
  opacity: 0;
  pointer-events: none;
  transform: scale(0.94);
  transition: opacity 0.16s ease, transform 0.16s ease;
}

.rating-burst.show {
  opacity: 1;
  transform: scale(1);
}

.rating-burst strong {
  display: block;
  text-align: center;
  font-size: clamp(66px, 13vw, 148px);
  line-height: 0.9;
  font-weight: 900;
  color: #1a8044;
  text-shadow: 0 5px 0 rgba(255,255,255,0.85);
  letter-spacing: -0.02em;
}

.rating-burst span {
  display: block;
  margin-top: 16px;
  text-align: center;
  font-size: clamp(20px, 4vw, 40px);
  font-weight: 900;
  color: var(--ink);
}

.rating-burst.good  strong { color: #b86f10; }
.rating-burst.retry strong { color: #2568a0; }
.rating-burst.fight strong { color: #7a8c7a; }

.ground-dots span {
  position: absolute;
  bottom: 20px;
  width: 12px; height: 12px;
  border-radius: 50%;
  background: rgba(20,85,15,0.22);
  z-index: 3;
}
.ground-dots span:nth-child(1) { left: 22%; }
.ground-dots span:nth-child(2) { left: 50%; bottom: 34px; }
.ground-dots span:nth-child(3) { left: 70%; }
.ground-dots span:nth-child(4) { left: 86%; bottom: 44px; }

/* ── Recorder Dock ── */
.recorder-dock {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 16px;
  padding: 18px 20px 0;
}

/* big round record button */
.record-button {
  width: 128px;
  height: 128px;
  border-radius: 50%;
  border: 0;
  cursor: pointer;
  background: var(--coral);
  color: white;
  font-family: inherit;
  font-weight: 900;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  box-shadow:
    0 6px 0 #c44a18,
    0 12px 32px rgba(255,107,53,0.42);
  transition: transform 0.1s ease, box-shadow 0.1s ease;
  position: relative;
  flex-shrink: 0;
}

.record-button:active {
  transform: translateY(4px);
  box-shadow: 0 2px 0 #c44a18, 0 6px 16px rgba(255,107,53,0.28);
}

#recordIcon {
  font-size: 30px;
  line-height: 1;
  display: block;
}

#recordLabel {
  font-size: 13px;
  font-weight: 900;
  letter-spacing: 0.02em;
}

.record-button.recording {
  background: #e63946;
  box-shadow:
    0 6px 0 #a8222d,
    0 12px 32px rgba(230,57,70,0.44);
  animation: recordPulse 1.6s ease-in-out infinite;
}

.record-button.waiting {
  background: var(--blue);
  box-shadow:
    0 6px 0 #2966c2,
    0 12px 32px rgba(72,149,239,0.38);
  animation: none;
}

@keyframes recordPulse {
  0%,100% {
    box-shadow: 0 6px 0 #a8222d, 0 12px 32px rgba(230,57,70,0.44), 0 0 0 0 rgba(230,57,70,0.36);
  }
  55% {
    box-shadow: 0 6px 0 #a8222d, 0 12px 32px rgba(230,57,70,0.44), 0 0 0 22px rgba(230,57,70,0);
  }
}

/* ── Feedback ── */
.feedback {
  width: 100%;
  display: grid;
  grid-template-columns: 118px 1fr;
  gap: 10px;
  align-items: center;
  padding: 12px 14px;
  border-radius: 14px;
  background: #fff8e0;
  color: #8a6010;
  font-weight: 900;
  border: 1.5px solid #edd878;
}

.feedback strong {
  display: grid;
  min-height: 42px;
  place-items: center;
  border-radius: 999px;
  background: rgba(255,255,255,0.88);
  color: #8a6010;
  font-size: 16px;
}

.feedback.great { background: #e8f8e0; color: #267535; border-color: #9ad88a; }
.feedback.good  { background: #fff8e0; color: #8a6010; border-color: #edd878; }
.feedback.retry { background: #e4f0ff; color: #245ea8; border-color: #96bef8; }
.feedback.fight { background: #f2f2ee; color: #6a7a6a; border-color: #cacec8; }
.feedback.great strong { color: #267535; }
.feedback.good  strong { color: #8a6010; }
.feedback.retry strong { color: #245ea8; }
.feedback.fight strong { color: #6a7a6a; }

/* ── Wait Timer ── */
.wait-timer {
  width: 100%;
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: #e4ddd0;
  opacity: 0;
  transition: opacity 0.18s ease;
  margin: 0 20px;
  width: calc(100% - 40px);
}

.wait-timer.active { opacity: 1; }

.wait-timer span {
  display: block;
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--yellow), var(--coral));
}

.wait-timer.active span {
  animation: waitFill 2s linear forwards;
}

@keyframes waitFill {
  from { width: 0%; }
  to   { width: 100%; }
}

/* ── Self Rate Dock ── */
.self-rate-dock {
  width: 100%;
  padding: 10px 20px 0;
}

.self-rate-label {
  margin: 0 0 10px;
  text-align: center;
  color: var(--muted);
  font-size: 14px;
  font-weight: 900;
}

.self-play-button {
  width: 100%;
  min-height: 50px;
  margin-top: 10px;
  border: 2px solid #96c0f8;
  border-radius: 14px;
  background: #e4f0ff;
  color: #245ea8;
  font-size: 16px;
  font-family: inherit;
  font-weight: 900;
  cursor: pointer;
  box-shadow: 0 4px 0 #6898e0;
  transition: transform 0.1s ease, box-shadow 0.1s ease, background 0.18s ease, border-color 0.18s ease;
}

.self-play-button[data-state="recording"] {
  border-color: #ef8c7b;
  background: #ffe3dc;
  color: #9f2f24;
  box-shadow: 0 4px 0 #d95f50;
}

.self-play-button[data-state="stopping"] {
  border-color: #e8c248;
  background: #fff4c8;
  color: #7a550a;
  box-shadow: 0 4px 0 #c8a030;
}

.self-play-button[data-state="playing"] {
  border-color: #70a9ef;
  background: #d7eaff;
  color: #174f98;
  box-shadow: 0 4px 0 #4f85cc;
  animation: selfPlayPulse 1s ease-in-out infinite;
}

.self-play-button[data-state="replay"] {
  border-color: #b69ae8;
  background: #f0e8ff;
  color: #61369c;
  box-shadow: 0 4px 0 #9270cf;
}

.self-play-button:disabled {
  opacity: 1;
  cursor: wait;
}

.self-play-button:focus-visible {
  outline: 4px solid rgba(36, 94, 168, 0.24);
  outline-offset: 3px;
}

.self-play-button:not(:disabled):active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 currentColor;
}

@keyframes selfPlayPulse {
  0%, 100% { filter: brightness(1); }
  50% { filter: brightness(1.08); }
}

@media (prefers-reduced-motion: reduce) {
  .self-play-button[data-state="playing"] {
    animation: none;
  }
}

.self-rate-buttons {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.self-rate-buttons[hidden] { display: none; }

.self-rate-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 92px;
  border: 0;
  border-radius: 16px;
  font-size: 40px;
  font-weight: 900;
  font-family: inherit;
  cursor: pointer;
  gap: 5px;
  line-height: 1;
  transition: transform 0.1s ease, box-shadow 0.1s ease;
}

.self-rate-btn:active { transform: translateY(3px); }

.self-rate-btn span { font-size: 13px; font-weight: 900; }

.sr-great {
  background: #e0f6d2; color: #236830;
  border: 2px solid #90d07a;
  box-shadow: 0 5px 0 #6aaa58, 0 8px 20px rgba(36,104,48,0.14);
}
.sr-good {
  background: #fff4c8; color: #8a5e08;
  border: 2px solid #e8c248;
  box-shadow: 0 5px 0 #c8a030, 0 8px 20px rgba(138,94,8,0.12);
}
.sr-retry {
  background: #e4f0ff; color: #245ea8;
  border: 2px solid #96c0f8;
  box-shadow: 0 5px 0 #6898e0, 0 8px 20px rgba(36,94,168,0.12);
}

.sr-great:active { box-shadow: 0 2px 0 #6aaa58; }
.sr-good:active  { box-shadow: 0 2px 0 #c8a030; }
.sr-retry:active { box-shadow: 0 2px 0 #6898e0; }

/* ── Meters ── */
.meters {
  display: block;
  padding: 8px 20px 0;
}

.meters summary {
  cursor: pointer;
  color: var(--muted);
  font-size: 13px;
  font-weight: 900;
  margin-bottom: 10px;
  list-style: none;
}

.meters summary::before { content: '▶ '; font-size: 11px; }
.meters[open] summary::before { content: '▼ '; }

.meters[open] {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.meters[open] summary { grid-column: 1 / -1; }

.meter {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #f8f7f2;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px;
}

.meter p { font-size: 13px; font-weight: 900; margin-bottom: 5px; }

.meter-icon {
  width: 40px; height: 40px;
  flex: 0 0 auto;
  display: grid; place-items: center;
  border-radius: 50%;
  background: #ddeeff;
  color: #245ea8;
  font-size: 12px;
  font-weight: 900;
}

.bar {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: #e4ddd0;
}

.bar span {
  display: block;
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--sky), var(--grass));
  transition: width 0.35s ease;
}

/* ── Controls ── */
.controls {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  padding: 8px 20px 0;
}

/* ── XP Block ── */
.exp-block {
  padding: 8px 20px 14px;
}

.exp-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 900;
}

.exp-bar {
  height: 14px;
  border-radius: 999px;
  background: #e4ddd0;
  overflow: hidden;
  box-shadow: inset 0 2px 5px rgba(0,0,0,0.1);
}

.exp-bar span {
  display: block;
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--yellow), #ff9400);
  box-shadow: 0 2px 8px rgba(255,148,0,0.45);
  transition: width 0.4s ease;
}

/* ── Buttons ── */
.secondary-button {
  min-height: 50px;
  border: 2px solid var(--line);
  border-radius: 12px;
  background: #f2f9ee;
  color: var(--grass-dark);
  font-weight: 900;
  cursor: pointer;
  box-shadow: 0 4px 0 #b8d8b0, 0 6px 16px rgba(20,80,20,0.08);
  transition: transform 0.1s ease, box-shadow 0.1s ease;
}

.secondary-button:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 #b8d8b0;
}

.secondary-button:disabled {
  color: #a8b2a8;
  background: #f0f0ec;
  border-color: #ddd;
  box-shadow: none;
  cursor: not-allowed;
}

.ghost-button {
  padding: 10px 18px;
  border: 1.5px solid var(--line);
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  font-weight: 900;
  cursor: pointer;
}

.book-button {
  padding: 12px 18px;
  border: 2px solid var(--line);
  border-radius: 14px;
  background: var(--panel);
  color: var(--grass-dark);
  font-weight: 900;
  font-size: 15px;
  cursor: pointer;
  box-shadow: 0 4px 0 var(--line), 0 8px 24px rgba(20,70,20,0.1);
  transition: transform 0.1s ease, box-shadow 0.1s ease;
}

.book-button:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 var(--line);
}

.tiny-button {
  padding: 8px 12px;
  border: 1.5px solid var(--line);
  border-radius: 8px;
  background: #f4f8f0;
  color: var(--grass-dark);
  font-weight: 900;
  cursor: pointer;
  white-space: nowrap;
}

.collection-start-control {
  padding: 12px;
  border: 1.5px solid #b8d8ae;
  border-radius: 12px;
  background: #f3faef;
}

.collection-start-control .field-label {
  margin-top: 0;
}

.setting-help {
  margin: 7px 0 10px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.5;
}

.restore-button {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border: 1.5px solid #76c866;
  border-radius: 10px;
  background: #e0f5d4;
  color: var(--grass-dark);
  font-weight: 900;
  cursor: pointer;
  box-shadow: 0 3px 0 #76c866;
}

.restore-button:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 #76c866;
}

.restore-button:focus-visible {
  outline: 3px solid rgba(69, 139, 56, 0.25);
  outline-offset: 2px;
}

.danger-button {
  width: 100%;
  padding: 11px;
  border: 1.5px solid #f0b4b4;
  border-radius: 10px;
  background: #fff0f0;
  color: #b83030;
  font-weight: 900;
  cursor: pointer;
  margin-top: 10px;
  transition: background 0.15s ease;
}

.danger-button:hover { background: #ffe4e4; }

/* ── Settings Panel ── */
h2 { font-size: 17px; font-weight: 900; }

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
}

.field-label {
  display: block;
  color: var(--muted);
  font-weight: 900;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  margin: 16px 0 8px;
}

.kana-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
}

.kana-grid button {
  min-height: 50px;
  border: 2px solid var(--line);
  border-radius: 12px;
  background: #fafaf5;
  color: var(--ink);
  font-size: 22px;
  font-weight: 900;
  font-family: inherit;
  cursor: pointer;
  box-shadow: 0 4px 0 var(--line);
  transition: transform 0.1s ease, box-shadow 0.1s ease;
}

.kana-grid button:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 var(--line);
}

.kana-grid button.active {
  background: #e0f5d4;
  border-color: #76c866;
  color: var(--grass-dark);
  box-shadow: 0 4px 0 #76c866;
}

select, input {
  width: 100%;
  border: 1.5px solid var(--line);
  border-radius: 10px;
  background: white;
  color: var(--ink);
  padding: 10px 12px;
  font-family: inherit;
}

.custom-word {
  display: grid;
  grid-template-columns: 1fr 70px auto;
  gap: 7px;
  align-items: center;
  margin-top: 8px;
}

.stepper {
  display: grid;
  grid-template-columns: 46px 1fr 46px;
  gap: 8px;
}

.stepper button {
  border: 2px solid var(--line);
  border-radius: 10px;
  background: #fafaf5;
  font-size: 20px;
  font-weight: 900;
  font-family: inherit;
  min-height: 44px;
  cursor: pointer;
  box-shadow: 0 3px 0 var(--line);
  transition: transform 0.1s ease, box-shadow 0.1s ease;
}

.stepper button:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 var(--line);
}

.stepper input { text-align: center; font-weight: 900; }

.mode-control {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 7px;
}

.mode-control button {
  min-height: 46px;
  border: 2px solid var(--line);
  border-radius: 10px;
  background: #fafaf5;
  color: var(--ink);
  font-weight: 900;
  font-family: inherit;
  cursor: pointer;
  box-shadow: 0 4px 0 var(--line);
  transition: transform 0.1s ease, box-shadow 0.1s ease;
}

.mode-control button:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 var(--line);
}

.mode-control button.active {
  background: #fff3b8;
  border-color: #e8c030;
  color: #6a4800;
  box-shadow: 0 4px 0 #e8c030;
}

.mode-control button[data-mode="self"].active {
  background: #ece4ff;
  border-color: #9878e8;
  color: #3e20a8;
  box-shadow: 0 4px 0 #9878e8;
}

.support-note {
  margin-top: 14px;
  border: 1.5px dashed var(--line);
  border-radius: 10px;
  background: #fafaf5;
  padding: 10px 12px;
}

.toggle-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 14px;
  padding: 10px 12px;
  border: 1.5px solid var(--line);
  border-radius: 10px;
  background: #fafaf5;
  color: var(--grass-dark);
  font-size: 13px;
  font-weight: 900;
}

.toggle-row input {
  width: 20px;
  height: 20px;
  flex: 0 0 auto;
  accent-color: var(--grass);
}

.support-note summary {
  cursor: pointer;
  color: var(--muted);
  font-weight: 900;
  font-size: 13px;
  list-style: none;
}

.support-note summary::before { content: '▶ '; font-size: 11px; }
.support-note[open] summary::before { content: '▼ '; }

.support-note dl { margin: 10px 0 0; }

.support-note div {
  display: grid;
  grid-template-columns: 68px 1fr;
  gap: 8px;
  padding: 4px 0;
}

.support-note dt { color: var(--muted); font-size: 12px; font-weight: 900; }
.support-note dd { margin: 0; font-weight: 900; font-size: 13px; }

.settings-panel section + section {
  margin-top: 20px;
  padding-top: 18px;
  border-top: 1.5px solid var(--line);
}

.history h2, .data-section h2 { margin-bottom: 10px; }

.badge-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.badge {
  padding: 6px 12px;
  border-radius: 999px;
  background: #e4f0ff;
  color: #245ea8;
  font-size: 13px;
  font-weight: 900;
  border: 1.5px solid #b0cef8;
}

/* ── Library Dialog ── */
.library-dialog {
  width: min(900px, calc(100vw - 24px));
  border: 1.5px solid var(--line);
  border-radius: 22px;
  padding: 24px;
  background: var(--panel);
  box-shadow: 0 36px 90px rgba(10,40,10,0.24);
}

.library-dialog::backdrop {
  background: rgba(8,28,8,0.52);
  backdrop-filter: blur(4px);
}

.dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}

.library-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 12px;
}

.library-card {
  min-height: 152px;
  display: grid;
  place-items: center;
  gap: 8px;
  text-align: center;
  border: 2px solid var(--line);
  border-radius: 16px;
  background: #fafaf5;
  padding: 12px 8px;
  font-weight: 900;
  font-size: 13px;
  box-shadow: 0 5px 0 var(--line), 0 8px 20px rgba(20,60,15,0.07);
}

.library-card small {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.5;
  font-weight: 700;
}

.library-card.locked {
  background: rgba(245,244,238,0.65);
  color: #a4aa9e;
  box-shadow: none;
  border-color: #e0dcd4;
}

.library-card.locked .mini { background: #eae6dc; }

.library-card .mini {
  width: 72px; height: 72px;
  display: grid; place-items: center;
  border-radius: 50%;
  background: #fff3cc;
  overflow: hidden;
}

.library-card .mini img {
  width: 92%; height: 92%;
  object-fit: contain;
}

/* ════════════════════════════════════════════
   みちあそびモード（Path Mode）
   ════════════════════════════════════════════ */

/* ── ビュータブ ── */
.view-tabs {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.view-tab {
  padding: 9px 16px;
  border: 2px solid var(--line);
  border-radius: 12px;
  background: #fafaf5;
  color: var(--muted);
  font-family: inherit;
  font-weight: 900;
  font-size: 14px;
  cursor: pointer;
  box-shadow: 0 3px 0 var(--line);
  transition: transform 0.1s ease, box-shadow 0.1s ease;
  white-space: nowrap;
}

.view-tab-link {
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.view-tab:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 var(--line);
}

.view-tab.active {
  background: #e0f5d4;
  border-color: #76c866;
  color: var(--grass-dark);
  box-shadow: 0 3px 0 #76c866;
}

/* ── みちあそびパネル ── */
/* display 指定が hidden 属性に勝ってしまうのを防ぐ（ビュー切り替え用） */
.practice-panel[hidden],
.path-panel[hidden],
.repeat-panel[hidden] {
  display: none !important;
}

/* ── くりかえしモード ── */
.repeat-panel {
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border: 1.5px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.repeat-scene {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 16px;
  background: radial-gradient(circle at 50% 10%, #fff7ac 0, transparent 30%), linear-gradient(180deg, #a9ddf3, #d9f3dc 72%);
}

.repeat-sound {
  font-size: clamp(56px, 10vw, 96px);
  font-weight: 900;
  line-height: .9;
  color: #245ea8;
  text-shadow: 0 5px 0 #fff;
}

.repeat-dino-hero {
  width: clamp(96px, 13vw, 132px);
  height: clamp(96px, 13vw, 132px);
  object-fit: contain;
  filter: drop-shadow(0 7px 8px rgba(20, 70, 25, .22));
}

.repeat-dino-hero.celebrate { animation: repeatHeroCelebrate .22s ease-in-out 4 alternate; }
@keyframes repeatHeroCelebrate { from { transform: rotate(-7deg) translateY(0); } to { transform: rotate(7deg) translateY(-9px) scale(1.06); } }

.repeat-guide, .repeat-count { font-weight: 900; font-size: 18px; text-align: center; }

.repeat-dots { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; width: min(100%, 440px); }
.repeat-dot { aspect-ratio: 1; border: 4px solid #5c9670; border-radius: 50%; background: #f8fff2; box-shadow: 0 4px 0 #4d7f5e; }
.repeat-dot.current { background: #ffe44d; transform: scale(1.12); }
.repeat-dot.hit { background: #8ee46c; border-color: #3f9e4f; }

.repeat-hit-button, .repeat-start-button {
  min-height: 62px;
  min-width: min(100%, 280px);
  padding: 12px 24px;
  border: 2px solid #4e83c9;
  border-radius: 18px;
  background: #e2f0ff;
  color: #245ea8;
  font: 900 20px inherit;
  cursor: pointer;
  box-shadow: 0 5px 0 #4e83c9;
}
.repeat-hit-button:disabled { display: none; }
.repeat-hit-button:not(:disabled):active, .repeat-start-button:active { transform: translateY(3px); box-shadow: 0 2px 0 #4e83c9; }
.repeat-meter { width: min(100%, 340px); height: 22px; overflow: hidden; border: 2px solid #4b8c5d; border-radius: 99px; background: #eff8ea; }
.repeat-meter span { display: block; width: 0; height: 100%; background: linear-gradient(90deg, #83db69, #ffe44d); transition: width .15s ease; }
.repeat-collection { display: flex; flex-wrap: wrap; justify-content: center; gap: 7px; max-width: 360px; }
.repeat-dino { width: 38px; height: 38px; display: grid; place-items: center; overflow: hidden; border: 2px solid #9aab9c; border-radius: 50%; background: rgba(255,255,255,.7); color: #829184; font-weight: 900; }
.repeat-dino img { width: 100%; height: 100%; object-fit: contain; }
.repeat-dino.found { border-color: #5eac59; }
.repeat-dino.full { animation: repeatDinoWiggle .7s ease-in-out infinite alternate; }
@keyframes repeatDinoWiggle { from { transform: rotate(-7deg) translateY(0); } to { transform: rotate(7deg) translateY(-3px); } }
.repeat-controls { display: flex; flex-direction: column; align-items: center; gap: 10px; width: 100%; }
.repeat-mic-note { padding: 0 20px 16px; color: #8b4a26; font-size: 13px; font-weight: 900; text-align: center; }
.repeat-reset-button { margin-top: 12px; }
.repeat-bpm-control { display: grid; grid-template-columns: 1fr auto auto; align-items: center; gap: 8px; }
.repeat-bpm-control input { min-width: 0; }
.repeat-bpm-control output { min-width: 2.4em; color: var(--grass-dark); font-weight: 900; text-align: right; }

@media (prefers-reduced-motion: reduce) { .repeat-dino.full, .repeat-dino-hero.celebrate { animation: none; } }

.path-panel {
  min-height: 0;
  height: 100%;
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border: 1.5px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

/* ── みちシーン ── */
.path-scene {
  flex: 1 1 auto;
  position: relative;
  min-height: 320px;
  background:
    radial-gradient(circle at 80% 15%, rgba(255,220,60,0.45) 0%, transparent 22%),
    linear-gradient(180deg, #4eabda 0%, #7fcbee 36%, #b8e8f8 50%, #cdf0d8 50%, #5ab348 100%);
  border-radius: var(--radius) var(--radius) 0 0;
  overflow: hidden;
}

/* 遠景の丘 */
.path-scene::before {
  content: '';
  position: absolute;
  bottom: 49%;
  left: -8%;
  width: 116%;
  height: 72px;
  background: rgba(130,210,110,0.28);
  border-radius: 50% 60% 50% 40% / 70px 80px 0 0;
  z-index: 1;
}

/* 地面 */
.path-scene::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 50%;
  background: linear-gradient(180deg, #5ab348 0%, #459438 50%, #357a2d 100%);
  z-index: 0;
}

/* ── 音ラベル（子ども向け） ── */
.path-sound-cloud {
  position: absolute;
  top: 28px;
  left: clamp(18px, 5vw, 58px);
  z-index: 5;
  padding: 14px 24px 18px;
  border-radius: 24px;
  background: rgba(255,255,255,0.95);
  border: 2px solid #fff;
  box-shadow: 0 12px 38px rgba(20,70,20,0.18), inset 0 1px 0 #fff;
}

.path-sound-cloud strong {
  display: block;
  font-size: clamp(52px, 9vw, 100px);
  line-height: 0.9;
  font-weight: 900;
  color: var(--ink);
  letter-spacing: -0.02em;
}

/* ── ゴール演出バースト ── */
.path-goal-burst {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  padding: 32px;
  background: rgba(255,252,238,0.88);
  backdrop-filter: blur(6px);
  opacity: 0;
  pointer-events: none;
  transform: scale(0.94);
  transition: opacity 0.18s ease, transform 0.18s ease;
}

.path-goal-burst.show {
  opacity: 1;
  transform: scale(1);
}

.path-goal-burst strong {
  display: block;
  text-align: center;
  font-size: clamp(66px, 13vw, 148px);
  line-height: 0.9;
  font-weight: 900;
  color: #1a8044;
  text-shadow: 0 5px 0 rgba(255,255,255,0.85);
  letter-spacing: -0.02em;
}

.path-goal-burst span {
  display: block;
  margin-top: 16px;
  text-align: center;
  font-size: clamp(20px, 4vw, 40px);
  font-weight: 900;
  color: var(--ink);
}

/* ── 道エリア ── */
.path-road {
  position: absolute;
  bottom: 56px;
  left: 5%;
  right: 5%;
  z-index: 4;
}

.path-track {
  position: relative;
  height: 90px;
}

/* ドット列（地面上の踏み石） */
.path-dots {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  padding: 0 8px;
}

.path-dot {
  display: block;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: rgba(255,255,255,0.55);
  border: 2px solid rgba(255,255,255,0.8);
  box-shadow: 0 2px 6px rgba(20,80,20,0.18);
  transition: background 0.15s, box-shadow 0.15s;
  flex-shrink: 0;
}

.path-dot.passed {
  background: #ffe44d;
  border-color: #f5c800;
  box-shadow: 0 0 8px rgba(255,220,0,0.7);
}

/* ── 生き物 ── */
.path-creature-wrap {
  position: absolute;
  bottom: 14px;
  left: 0;
  width: 160px;
  height: 160px;
  transition: left 0.12s linear;
  filter: drop-shadow(0 8px 12px rgba(15,60,15,0.24));
}

.path-creature-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  transform-origin: center bottom;
}

.path-creature-wrap.walking .path-creature-img {
  animation: pathWalk 0.28s ease-in-out infinite alternate;
}

@keyframes pathWalk {
  from { transform: rotate(-3deg) translateY(0); }
  to   { transform: rotate(3deg) translateY(-4px); }
}

/* ── ゴール（肉） ── */
.path-goal {
  position: absolute;
  bottom: 8px;
  right: 0;
  width: 104px;
  height: 104px;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.path-meat {
  font-size: 80px;
  line-height: 1;
  filter: drop-shadow(0 6px 10px rgba(15,60,15,0.28));
  transition: transform 0.2s ease;
  display: block;
}

.path-meat.grabbed {
  animation: meatGrab 0.3s ease-in-out 3 alternate;
}

@keyframes meatGrab {
  from { transform: scale(1) rotate(-8deg); }
  to   { transform: scale(1.3) rotate(8deg); }
}

/* ── もういっかいドック ── */
.path-replay-dock {
  padding: 16px 20px;
  display: flex;
  justify-content: center;
}

.path-replay-btn {
  min-height: 56px;
  min-width: 200px;
  border: 2px solid #76c866;
  border-radius: 14px;
  background: #e0f5d4;
  color: var(--grass-dark);
  font-weight: 900;
  font-family: inherit;
  font-size: 18px;
  cursor: pointer;
  box-shadow: 0 5px 0 #76c866, 0 8px 20px rgba(36,104,48,0.14);
  transition: transform 0.1s ease, box-shadow 0.1s ease;
}

.path-replay-btn:active {
  transform: translateY(3px);
  box-shadow: 0 2px 0 #76c866;
}

/* ── 管理: 音グリッド（みちあそび用） ── */
.path-sound-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin-bottom: 4px;
}

.path-sound-grid button {
  min-height: 44px;
  border: 2px solid var(--line);
  border-radius: 10px;
  background: #fafaf5;
  color: var(--ink);
  font-size: 14px;
  font-weight: 900;
  font-family: inherit;
  cursor: pointer;
  box-shadow: 0 3px 0 var(--line);
  transition: transform 0.1s ease, box-shadow 0.1s ease;
}

.path-sound-grid button:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 var(--line);
}

.path-sound-grid button.active {
  background: #e0f5d4;
  border-color: #76c866;
  color: var(--grass-dark);
  box-shadow: 0 3px 0 #76c866;
}

/* ── すすめるボタン ── */
.path-advance-btn {
  display: block;
  width: 100%;
  min-height: 48px;
  margin-top: 10px;
  border: 2px solid #76c866;
  border-radius: 12px;
  background: #e0f5d4;
  color: var(--grass-dark);
  font-weight: 900;
  font-family: inherit;
  cursor: pointer;
  box-shadow: 0 4px 0 #76c866;
  transition: transform 0.1s ease, box-shadow 0.1s ease;
  user-select: none;
  touch-action: none;
}

.path-advance-btn:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 #76c866;
}

/* ── Responsive ── */
@media (max-width: 900px) {
  .main-grid { grid-template-columns: 1fr; }
  .app-shell { width: calc(100vw - 16px); }
  .practice-panel {
    grid-template-rows: minmax(250px, 1fr) auto auto auto auto auto;
  }
  .scene::before { height: 70px; }
  .record-button {
    width: 108px;
    height: 108px;
  }
  .recorder-dock {
    gap: 12px;
    padding: 12px 14px 0;
  }
  .feedback {
    grid-template-columns: 96px 1fr;
    padding: 10px 12px;
  }
  .feedback strong {
    min-height: 36px;
    font-size: 14px;
  }
  .meters {
    padding: 6px 14px 0;
  }
  .controls {
    padding: 6px 14px 0;
  }
  .exp-block {
    padding: 6px 14px 10px;
  }
  .admin-sidebar {
    top: auto;
    right: 8px;
    bottom: 8px;
    max-height: min(72vh, 640px);
  }
  .admin-sidebar.open {
    width: calc(100vw - 16px);
  }
  .admin-panel-body {
    max-height: min(72vh, 640px);
  }
  .controls { grid-template-columns: 1fr 1fr; }
  .library-grid { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 640px) {
  .practice-panel {
    grid-template-rows: minmax(230px, 1fr) auto auto auto auto auto;
  }
  .target-cloud { top: 22px; left: 14px; right: 14px; padding: 12px 18px 15px; }
  .target-cloud strong { font-size: clamp(42px, 15vw, 76px); }
  .count-pill { top: 10px; right: 10px; font-size: 16px; padding: 5px 10px; }
  .dino-stage { right: 4px; bottom: 38px; width: 158px; height: 154px; }
  .dino-xp-badge { top: -4px; right: 0; min-width: 72px; font-size: 15px; padding: 6px 10px 7px; }
  .record-button { width: 92px; height: 92px; }
  #recordIcon { font-size: 24px; }
  #recordLabel { font-size: 12px; }
  .recorder-dock { padding: 8px 10px 0; gap: 10px; }
  .feedback { grid-template-columns: 78px 1fr; font-size: 13px; padding: 8px 10px; }
  .feedback strong { min-height: 32px; font-size: 12px; }
  .controls, .meters[open] { grid-template-columns: 1fr; }
  .custom-word { grid-template-columns: 1fr; }
  .library-grid { grid-template-columns: repeat(2, 1fr); }
  .app-title { font-size: 17px; }
  .app-title span { font-size: 22px; }
}

@media (max-height: 760px) {
  .topbar { padding: 10px 2px 8px; }
  .app-title { font-size: 17px; }
  .app-title span { font-size: 22px; }
  .book-button { padding: 8px 12px; }
  .practice-panel {
    grid-template-rows: minmax(220px, 1fr) auto auto auto auto auto;
  }
  .dino-stage {
    width: 170px;
    height: 166px;
    bottom: 34px;
  }
  .record-button {
    width: 96px;
    height: 96px;
  }
  .recorder-dock {
    padding-top: 8px;
  }
  .meters summary {
    margin-bottom: 4px;
    font-size: 12px;
  }
  .secondary-button {
    min-height: 42px;
  }
  .self-rate-dock {
    padding-top: 6px;
  }
  .self-rate-label {
    margin-bottom: 5px;
    font-size: 12px;
  }
  .self-play-button {
    min-height: 38px;
    margin-top: 7px;
  }
  .self-rate-buttons {
    gap: 7px;
  }
  .self-rate-btn {
    min-height: 64px;
    font-size: 28px;
    border-radius: 12px;
  }
  .self-rate-btn span {
    font-size: 11px;
  }
  .exp-header {
    margin-bottom: 5px;
  }
  .exp-bar {
    height: 11px;
  }
}
