/* 홈 本音 데모의 긴 문구와 스와이프가 페이지 너비를 늘리지 않게 한다. */
#moodDemo { overflow-x: clip; }
#moodDemo .md-deck { grid-template-columns: minmax(0, 1fr); }
#moodDemo .md-chips { grid-template-columns: repeat(2, minmax(0, 1fr)); }
#moodDemo .md-chips b { overflow-wrap: anywhere; }

/* 홈 카드와 게임 공통 화면 */
.mg-cards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-2); }
.mg-card {
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: var(--space-1);
  padding: var(--space-2);
  color: var(--text);
  border: 1px solid var(--mg-key-line);
  border-top-color: var(--ivory-6);
  border-radius: var(--r-card);
  background: var(--surface-2);
  box-shadow: var(--shadow-plum-card);
  text-align: start;
}
.mg-card-art {
  position: relative;
  display: grid;
  place-items: end center;
  height: 100px;
  border-radius: var(--r-art);
  background: radial-gradient(ellipse at 50% 42%, var(--mg-key-line), var(--mg-key-wash));
  overflow: hidden;
}
.mg-card-stage, .mg-card-art:has(.mg-card-stage)::after { position: absolute; inset: 0; }
.mg-card-stage { width: 100%; height: 100%; object-fit: cover; }
.mg-card-art:has(.mg-card-stage)::after {
  content: '';
  background: linear-gradient(to bottom, rgb(25 14 27 / .12), rgb(25 14 27 / .52));
}
.mg-card-art .mg-doki { position: relative; z-index: 1; width: 100%; height: 96px; object-fit: contain; object-position: center bottom; }
.mg-card strong {
  margin-block-start: var(--space-1);
  font: var(--weight-title) var(--text-md)/var(--line-height-title) var(--font-ui-title);
  overflow-wrap: break-word;
  line-break: strict; /* 장음 「ー」·작은 가나가 줄 맨 앞에 오지 않게 */
  text-wrap: balance;
}
.mg-card[data-game="honne"] strong { font-size: clamp(13px, 3.65vw, 16px); }
.mg-card[data-game="honne"] strong span { white-space: nowrap; display: inline-block; }
.mg-card small {
  color: var(--text-muted);
  font-size: var(--text-xs);
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2;
  overflow: hidden; overflow-wrap: anywhere; line-height: 1.4;
}
.mg-card-stats {
  display: grid;
  gap: var(--space-1);
  margin-block-start: auto;
  padding-block-start: var(--space-1);
  font-size: var(--text-xs);
}
.mg-reward-summary { color: var(--text-muted); font: 700 var(--text-xs)/1.35 var(--f-ja); }
.mg-card-best { color: var(--text-muted); }
.mg-card-best b { color: var(--text); font-variant-numeric: tabular-nums; }
.mg-soon {
  min-height: 50px; display: grid; place-items: center; border: 1px dashed var(--status-success);
  border-radius: var(--r-md); color: var(--ink-muted); background: var(--paper-1); font-size: var(--text-xs); font-weight: 700;
}
.mg-card:focus-visible, .mg-dialog button:focus-visible { outline: 2px solid var(--rose); outline-offset: 3px; }
body.mg-open { overflow: hidden; }
.mg-dialog {
  position: fixed; inset: 0; width: 100%; height: 100%; max-width: none; max-height: none;
  margin: var(--space-0); padding: var(--space-0); border: 0; overflow: hidden; color: var(--ivory); background: var(--surface-1);
  font-family: var(--f-ja);
  --mg-edge: var(--line-strong); --mg-muted: var(--text-muted); --mg-warning: var(--accent-2);
  --mg-digits: 'EP Sans KR', ui-monospace, monospace;
}
.mg-dialog [hidden] { display: none; }
.mg-viewport { width: 100%; height: 100%; overflow: clip; }
.mg-card, .mg-dialog {
  --mg-key: var(--rose-l);
  --mg-key-line: color-mix(in srgb, var(--mg-key) 46%, var(--surface-2));
  --mg-key-wash: color-mix(in srgb, var(--mg-key) 10%, var(--surface-3));
}
:is(.mg-card, .mg-dialog)[data-game="cafe"] { --mg-key: #e9b782; }
:is(.mg-card, .mg-dialog)[data-game="honne"] { --mg-key: #d4b8f5; }
:is(.mg-card, .mg-dialog)[data-game="sound"] { --mg-key: #a1ddca; }
:is(.mg-card, .mg-dialog)[data-game="train"] { --mg-key: #acc9f7; }
.mg-shell {
  position: relative; width: min(100%, var(--cinema-width)); height: 100%; margin: var(--space-0) auto; display: flex; flex-direction: column;
  background: var(--surface-1);
}
@media (min-width: 640px) {
  .mg-dialog { background: radial-gradient(ellipse at 50% 24%, var(--mg-key-wash), var(--surface-1) 68%); }
  .mg-shell { box-shadow: var(--shadow-plum-raised), 0 0 0 1px var(--ivory-6); }
}
.mg-top {
  padding: calc(var(--safe-t) + var(--space-1)) var(--space-3) var(--space-1); display: grid; grid-template-columns: 44px 1fr 44px;
  position: relative; z-index: 1; align-items: center; gap: var(--space-1);
  min-height: calc(56px + var(--safe-t));
}
.mg-top::after {
  content: ''; position: absolute; inset: 100% 0 auto; height: var(--space-2);
  background: linear-gradient(var(--surface-1), transparent); pointer-events: none;
}
.mg-top h2 { margin: var(--space-0); text-align: center; font: 700 17px/1.3 var(--font-ui-title); }
.mg-heading:has(.mg-stage-chip:not([hidden])) {
  display: flex; justify-content: center; align-items: center; gap: 6px; min-width: 0;
}
.mg-heading:has(.mg-stage-chip:not([hidden])) h2 { font-size: clamp(13px, 4.4vw, 17px); white-space: nowrap; }
.mg-stage-chip {
  flex: none; white-space: nowrap; padding: 3px 7px; border: 1px solid var(--mg-key-line);
  border-radius: var(--r-pill); background: var(--mg-key-wash); color: var(--mg-key);
  font: 800 12px/1.2 var(--mg-digits);
}
.mg-icon {
  width: 44px; min-height: 44px; border-radius: var(--r-pill); background: var(--surface-2); color: var(--ivory);
  display: grid; place-items: center; font: 700 var(--text-lg)/1 system-ui;
}
.mg-back { font-size: var(--text-2xl); }
.mg-scroll { padding: var(--space-3) var(--space-4) var(--space-4); flex: 1; min-height: 0; overflow: auto; overscroll-behavior: contain; }
.mg-shell:has(.mg-coach[hidden]) .mg-scroll { padding-bottom: calc(var(--space-4) + var(--safe-b)); }
.mg-scroll:has(> .mg-view > :is(.train-round, .cafe-board, .honne-round, .sound-round)) {
  display: flex; flex-direction: column;
}
.mg-scroll:has(> .mg-view > :is(.train-round, .cafe-board, .honne-round, .sound-round)) > .mg-hud { flex: none; }
.mg-view:not([hidden]):has(> :is(.train-round, .cafe-board, .honne-round, .sound-round)) { display: flex; flex: 1; flex-direction: column; }
.mg-view > :is(.train-round, .cafe-board, .honne-round, .sound-round) { flex: 1; }
.mg-view:focus { outline: none; }
.mg-hud { margin-bottom: var(--space-2); }
.mg-metrics {
  display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center; gap: var(--space-1); min-height: 38px;
}
.mg-time-label { display: flex; align-items: baseline; gap: var(--space-1); color: var(--mg-muted); font-size: var(--text-xs); font-weight: 700; }
.mg-seconds { color: var(--mg-key); font: 800 var(--text-2xl)/1 var(--mg-digits); font-variant-numeric: tabular-nums; }
.mg-hud:not([data-timed]) :is(.mg-time-label, .mg-meter) { visibility: hidden; }
.mg-progress { grid-column: 2; color: var(--mg-muted); font: 800 var(--text-sm)/1 var(--mg-digits); }
.mg-score-group { grid-column: 3; display: flex; align-items: center; justify-content: flex-end; gap: var(--space-1); }
.mg-score {
  color: var(--ivory); background: var(--surface-2); border: 1px solid var(--mg-edge); border-radius: var(--r-pill); padding: var(--space-1) var(--space-2);
  font: 800 var(--text-md)/1.25 var(--mg-digits); font-variant-numeric: tabular-nums;
}
.mg-combo { color: var(--mg-key); background: var(--mg-key-wash); padding: var(--space-1); border-radius: var(--r-pill); font-size: var(--text-xs); font-weight: 900; white-space: nowrap; }
.mg-meter { height: 8px; margin-top: var(--space-1); overflow: hidden; background: var(--surface-3); border-radius: var(--r-pill); }
.mg-meter i { display: block; height: 100%; background: var(--mg-key); border-radius: inherit; transform-origin: left; }
.mg-urgent .mg-seconds, .mg-urgent .mg-time-label { color: #ff7676; }
.mg-urgent .mg-meter i { background: #ff7676; }
.mg-primary, .mg-secondary {
  width: 100%; min-height: 52px; padding: var(--space-2) var(--space-2); border-radius: var(--r-pill); font: 700 var(--text-md)/1.3 var(--font-ui-title);
  touch-action: manipulation;
}
.mg-primary { color: var(--on-accent); background: var(--accent); box-shadow: var(--shadow-primary); }
.mg-secondary { color: var(--ivory); background: var(--surface-2); border: 1px solid var(--mg-edge); }
.mg-start { display: block; width: min(100%, 360px); margin-inline: auto; }
.mg-dialog button:disabled, .mg-dialog button[aria-disabled="true"] { cursor: default; }
.mg-dialog :is(.mg-primary, .bomb-pad .bomb-submit):disabled {
  color: var(--text-muted); background: var(--surface-2); border-color: var(--line); box-shadow: none; animation: none;
}
.mg-cover {
  position: absolute; inset: 0; z-index: 1; background: var(--ink-90);
  display: grid; place-content: center; justify-items: center; gap: var(--space-4); padding: var(--space-4);
}
.mg-vibration { border: 1px solid var(--rose); }
.mg-vibration[aria-pressed="false"] { border-color: var(--mg-edge); filter: grayscale(1); }
.mg-flash {
  position: absolute; inset: 0 0 calc(68px + var(--safe-b)); background: var(--accent-2); pointer-events: none; z-index: 1;
  animation: mg-white-flash 300ms ease-out both;
}
.mg-screen-light, .mg-danger-edge {
  position: absolute; inset: 0; z-index: 2; pointer-events: none; opacity: 0;
}
.mg-danger-edge {
  box-shadow: inset 0 0 28px #ff3535b0, inset 0 0 88px #ff303060;
}
.mg-danger-edge[data-bomb-urgent] {
  box-shadow: inset 0 0 25px #ff3038, inset 0 0 90px #e8002fc2;
}
@media (min-width: 640px) {
  .mg-danger-edge[data-bomb-urgent]::after {
    content: ''; display: block; width: var(--cinema-width); height: 100%; margin: auto;
    box-shadow: inset 0 0 27px #ff2e38, inset 0 0 75px #e8002f8f;
  }
}
.mg-dialog:has(.mg-paused) :is(.mg-screen-light, .mg-danger-edge) { visibility: hidden; }
.mg-shake { animation: mg-shake 360ms ease-out both; }
.mg-paused.mg-shake, .mg-paused .mg-flash { animation-play-state: paused; }
@keyframes mg-white-flash { from { opacity: .30; } to { opacity: 0; } }
@keyframes mg-shake {
  0%, 100% { transform: none; }
  15% { transform: translateX(-7px); }
  33% { transform: translateX(6px); }
  55% { transform: translateX(-4px); }
  75% { transform: translateX(2px); }
}
.mg-resume { width: 88px; min-height: 88px; border-radius: 50%; background: var(--rose); color: var(--color-plum-black); font-size: var(--text-2xl); }
.mg-exit { min-width: 174px; }
.mg-results { text-align: center; display: grid; gap: var(--space-2); padding-block: var(--space-2) calc(var(--space-5) + var(--safe-b)); }
.mg-result-score { font: 850 var(--text-display)/1 var(--mg-digits); color: var(--ivory); font-variant-numeric: tabular-nums; }
.mg-result-stats { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-2); margin: var(--space-2) var(--space-0); }
.mg-result-stats > div { padding: var(--space-3) var(--space-1); border: 1px solid var(--mg-edge); background: var(--surface-2); border-radius: var(--r-card); box-shadow: var(--shadow-plum-card); }
.mg-result-stats dt { font-weight: 700; font-size: var(--text-xs); color: var(--mg-muted); }
.mg-result-stats dd { margin: var(--space-1) var(--space-0) var(--space-0); font: 800 var(--text-xl)/1.1 var(--mg-digits); }
.mg-result-stats .mg-record { border-color: var(--mg-key-line); }
.mg-dialog .mg-results .mg-result-score { font-size: var(--text-display); }
.mg-dialog .mg-results .mg-result-stats dt { font-size: var(--text-xs); }
.mg-dialog .mg-results .mg-result-stats dd { font-size: var(--text-xl); }
.mg-result-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-2); }
.mg-result-actions > button { min-height: 48px; }

/* 규칙 카드, 카운트다운, 플레이 하단과 결과 */
.mg-intro-actions { margin: var(--space-3) auto 0; width: min(100%, 360px); }
.mg-shell:has(.mg-rules) .mg-heading { opacity: 0; }
.mg-rules { display: grid; justify-items: stretch; gap: var(--space-2); text-align: center; padding-bottom: var(--safe-b); }
.mg-rules h3 { margin: 0 0 var(--space-2); font: 700 var(--text-xl)/1.25 var(--font-ui-title); outline: 0; }
.mg-doki { display: block; object-fit: contain; user-select: none; }
.mg-rule-host { height: clamp(96px, 16vh, 144px); display: grid; place-items: center; background: radial-gradient(ellipse at center, var(--mg-key-wash), transparent 57%); }
.mg-rule-host .mg-doki { height: 100%; width: auto; max-height: clamp(96px, 16vh, 144px); }
.mg-rule-track {
  display: flex; min-width: 0; overflow-x: auto; overscroll-behavior-inline: contain;
  scroll-snap-type: x mandatory; scrollbar-width: none; border-radius: var(--r-card);
  box-shadow: var(--shadow-plum-raised);
}
.mg-rule-track::-webkit-scrollbar { display: none; }
.mg-rule-card {
  box-sizing: border-box; flex: 0 0 100%; min-width: 0; min-height: 220px;
  padding: var(--space-3); display: grid; grid-template-rows: minmax(156px, 20vh) auto; gap: var(--space-2);
  border: 1px solid var(--mg-edge); border-top-color: var(--ivory-6); border-radius: var(--r-card);
  background: var(--surface-2); scroll-snap-align: start;
}
.mg-rule-preview {
  position: relative; display: grid; place-items: center; overflow: hidden;
  border: 1px solid var(--mg-key-line); border-radius: 16px; color: var(--mg-key);
  background: radial-gradient(ellipse at 50% 0, var(--mg-key-wash), var(--surface-1) 85%);
}
.mg-rule-card p {
  align-self: center; justify-self: center; max-width: 22em; margin: var(--space-1) 0;
  font: 700 15px/1.5 var(--font-ui-title); text-wrap: balance; word-break: auto-phrase; line-break: strict;
}
.mg-rule-dots { display: flex; justify-content: center; }
.mg-rule-dots button {
  width: 44px; height: 44px; display: grid; place-items: center; border-radius: var(--r-pill);
  background: none; touch-action: manipulation;
}
.mg-rule-dots button::before {
  content: ''; width: 8px; height: 8px; border-radius: var(--r-pill);
  border: 1px solid var(--mg-key-line); background: var(--surface-3);
}
.mg-rule-dots button[aria-current="true"]::before { width: 17px; background: var(--mg-key); border-color: var(--mg-key); }
.mg-skip { justify-self: center; width: auto; min-width: 116px; }
@media (max-height: 640px) {
  .mg-rules { gap: 6px; }
  .mg-rules h3 { margin-bottom: 3px; }
  .mg-rule-host, .mg-rule-host .mg-doki { max-height: 80px; }
  .mg-rule-card { min-height: 192px; grid-template-rows: minmax(136px, 20vh) auto; }
}
.mg-demo-row, .mg-demo-stack { display: flex; align-items: center; justify-content: center; gap: var(--space-4); }
.mg-demo-stack { flex-direction: column; gap: var(--space-2); }
.mg-demo-row strong[lang="ko"] { font: 800 var(--text-xl)/1.25 var(--f-ko); }
.mg-demo-clock { font: 850 var(--text-display)/1 var(--mg-digits); font-variant-numeric: tabular-nums; }
.mg-demo-wave {
  width: 6px; height: 34px; border-radius: var(--r-pill); background: currentColor;
  box-shadow: -10px 0 0 -1px currentColor, 10px 0 0 -1px currentColor;
  margin-inline: 12px;
}
.mg-demo-cup { font-size: 38px; }
.mg-demo-pad, .mg-demo-options { display: grid; grid-auto-flow: column; gap: var(--space-2); }
.mg-demo-pad { grid-template-columns: repeat(3, 36px); grid-auto-flow: row; gap: var(--space-1); }
:is(.mg-demo-pad, .mg-demo-options) b {
  display: grid; place-items: center; min-height: 30px; padding: var(--space-1) var(--space-2);
  border-radius: var(--r-pill); border: 1px solid var(--mg-key-line); background: var(--surface-3);
}
.mg-demo-options b { min-width: 56px; min-height: 48px; color: var(--ivory); }
.mg-demo-lives, .mg-demo-route { font-weight: 850; letter-spacing: .16em; }
.mg-demo-patience { display: grid; gap: var(--space-2); width: min(64%, 180px); }
.mg-demo-patience span { display: block; height: 8px; border-radius: var(--r-pill); background: var(--surface-3); overflow: hidden; }
.mg-demo-patience i { display: block; height: 100%; background: var(--mg-key); border-radius: inherit; }
.mg-demo-patience span:nth-child(2) i { width: 62%; }
.mg-demo-patience span:nth-child(3) i { width: 24%; }
.mg-scroll:has(.mg-count-in) { position: relative; overflow: hidden; }
.mg-count-in {
  --count-tone: #ffdc6e;
  --count-glow: #ff9e29;
  --count-halo: .12em;
  position: absolute; inset: 0; overflow: hidden; container-type: inline-size; outline: 0;
  background: radial-gradient(ellipse at center, var(--mg-key-wash), transparent 59%);
}
.mg-count-in[data-beat="2"] { --count-tone: #ffad52; --count-glow: #ff6d2b; --count-halo: .18em; }
.mg-count-in[data-beat="1"] { --count-tone: #ff6760; --count-glow: #ff342c; --count-halo: .24em; }
.mg-count-in[data-beat="go"] { --count-tone: #ffc46a; --count-glow: #ff792e; --count-halo: .22em; }
.mg-count-stage, .mg-count-stage::after { position: absolute; inset: 0; }
.mg-count-stage::after { content: ''; background: rgb(0 0 0 / .6); pointer-events: none; }
.mg-count-stage > .train-vestibule { height: 100%; border: 0; border-radius: 0; }
.mg-count-face {
  position: absolute; inset-inline: 0; top: 50%; translate: 0 -50%;
  display: grid; grid-template-columns: minmax(0, 1fr); justify-items: center; align-items: center;
}
.mg-count-face .mg-doki { position: absolute; bottom: 100%; width: min(19cqw, 80px); height: auto; z-index: 1; }
.mg-count-in strong {
  grid-area: 2 / 1; position: relative; z-index: 1; width: max-content;
  color: #fffdf7; font: 950 45cqw/1 system-ui, sans-serif;
  -webkit-text-stroke: 1.5px var(--count-tone); paint-order: stroke fill;
  text-shadow: 0 0 .055em var(--count-tone), 0 0 var(--count-halo) var(--count-glow), 0 .035em .065em #2e0c19;
}
.mg-count-in[data-beat="go"] strong { scale: .5 1; letter-spacing: -.075em; }
.mg-count-effect {
  grid-area: 2 / 1; width: 55cqw; aspect-ratio: 1; position: absolute; opacity: 0; border-radius: 50%;
  border: 2px solid var(--count-tone); box-shadow: 0 0 16px var(--count-glow), inset 0 0 10px var(--count-glow);
}
.mg-count-in[data-beat="go"] .mg-count-effect {
  width: 108cqw; border: 0; box-shadow: none;
  background: repeating-conic-gradient(from 14deg, transparent 0deg 13deg, #fff7c928 14deg, #ffab578c 16deg, transparent 19deg 30deg);
  mask-image: radial-gradient(circle, transparent 12%, #000 29%, transparent 69%);
}
@media (prefers-reduced-motion: reduce) {
  .mg-count-effect { display: none; }
  .mg-count-in strong { text-shadow: 0 0 .07em var(--count-glow); }
}
.mg-coach {
  display: flex; align-items: center; justify-content: flex-end; gap: var(--space-2);
  flex: none; min-height: calc(72px + var(--safe-b)); padding: 0 var(--space-4) calc(var(--space-2) + var(--safe-b));
  pointer-events: none;
}
.mg-coach .mg-doki { flex: none; }
.mg-speech {
  padding: var(--space-2) var(--space-3); width: max-content; max-width: 100%; border: 1px solid var(--ivory-6);
  border-radius: var(--r-pill); background: var(--surface-3); color: var(--ivory);
  font: 700 var(--text-sm)/1.25 var(--font-ui-title);
}
.mg-coach .mg-speech { min-height: 32px; padding-block: 7px; font-size: var(--text-caption); }
.mg-coach [data-kind="hit"] { border-color: var(--mg-key-line); background: var(--mg-key-wash); }
.mg-coach [data-kind="miss"] { border-color: var(--accent-2); }
.mg-speech:empty { opacity: 0; }
.mg-result-hero {
  display: grid; justify-items: center; gap: var(--space-2); padding: var(--space-3);
  border: 1px solid var(--mg-edge); border-top-color: var(--ivory-6);
  border-radius: var(--r-card); background: radial-gradient(ellipse at 50% 0, var(--mg-key-wash), var(--surface-2) 76%);
  box-shadow: var(--shadow-plum-card);
}
.mg-result-doki { display: flex; align-items: center; justify-content: center; min-width: 0; }
.mg-result-doki .mg-speech { margin-left: -12px; z-index: 1; }
.mg-stars { display: flex; gap: var(--space-2); color: var(--text-subtle); font: 850 44px/1 system-ui; }
.mg-stars .is-earned {
  color: var(--mg-key); background: linear-gradient(var(--status-warning), var(--mg-key));
  background-clip: text; -webkit-text-fill-color: transparent;
  animation: mg-star-pop 320ms var(--ease-spring-pop) both;
}
.mg-stars .is-earned:nth-child(2) { animation-delay: 150ms; }
.mg-stars .is-earned:nth-child(3) { animation-delay: 300ms; }
@keyframes mg-star-pop {
  0% { transform: scale(.4); opacity: 0; }
  68% { transform: scale(1.15); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}
.mg-best-badge, .mg-reward-badge {
  border: 1px solid var(--mg-key-line); border-radius: var(--r-pill);
  padding: var(--space-1) var(--space-3); color: var(--mg-key); background: var(--surface-3);
  font: 700 var(--text-sm)/1.3 var(--font-ui-title); white-space: nowrap;
}
.mg-reward-badge {
  display: inline-flex; align-items: center; gap: var(--space-1); min-height: 36px;
  color: var(--accent-soft); border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 16%, var(--surface-2));
}
.mg-reward-badge img { width: 18px; height: 18px; }
.mg-dialog button:not(:disabled):is(.mg-primary, .mg-secondary, [data-key], [data-choice], [data-cafe-field]) {
  transition: scale 220ms var(--ease-spring-press);
}
.mg-dialog button:not(:disabled):is(.mg-primary, .mg-secondary, [data-key], [data-choice], [data-cafe-field]):active { scale: .97; }
@media (prefers-reduced-motion: reduce) {
  .mg-dialog .mg-stars .is-earned { animation: none; }
  .mg-dialog button:not(:disabled):is(.mg-primary, .mg-secondary, [data-key], [data-choice], [data-cafe-field]) { transition: none; }
}


@media (prefers-reduced-motion: reduce) {
  .mg-flash, .mg-shake { animation: none; }
  .mg-flash { opacity: 0; }
}

/* Shared skill mirror. Each game's stage positions this element. */
.mg-mirror {
  position: relative;
  width: var(--mg-mirror-size, 128px);
  aspect-ratio: 1;
  pointer-events: none;
}
.mg-mirror-motion, .mg-mirror-motion > img, .mg-mirror-effects {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}
.mg-mirror-motion { transform-origin: 50% 88%; }
.mg-mirror-motion > img {
  object-fit: contain;
  opacity: 0;
  transition: opacity .12s ease;
}
.mg-mirror-motion > .is-current { opacity: 1; }
.mg-mirror[data-mirror="host"] .mg-mirror-motion { animation: mg-mirror-breathe 3s ease-in-out infinite; }
.mg-mirror[data-mirror="focus"] .mg-mirror-motion { animation: mg-mirror-focus .68s ease-in-out infinite; }
.mg-mirror[data-mirror="fluster"] .mg-mirror-motion { animation: mg-mirror-fluster 1.4s ease-in-out infinite; }
.mg-mirror:is([data-mirror="cheer"], [data-mirror="oops"]) .mg-mirror-motion {
  animation: mg-mirror-spring .62s cubic-bezier(.2,.8,.25,1) both;
}
.mg-mirror-effects::before, .mg-mirror-effects::after { position: absolute; }
.mg-mirror[data-mirror="focus"] .mg-mirror-effects::before {
  content: '✦';
  top: 12%;
  right: 6%;
  color: var(--status-warning);
  font: 900 18px/1 system-ui;
  animation: mg-mirror-glint .68s ease-in-out infinite alternate;
}
.mg-mirror[data-mirror="focus"] .mg-mirror-effects::after {
  content: '';
  top: 43%;
  left: 4%;
  width: 15px;
  height: 2px;
  border-radius: 9px;
  background: var(--status-warning);
  box-shadow: -4px 6px var(--status-warning), 1px 12px var(--status-warning);
  animation: mg-mirror-glint .62s ease-in-out infinite alternate-reverse;
}
.mg-mirror[data-mirror="fluster"] .mg-mirror-effects::before,
.mg-mirror[data-mirror="fluster"] .mg-mirror-effects::after {
  content: '';
  top: 22%;
  right: 11%;
  width: 7px;
  height: 11px;
  border-radius: 65% 35% 70% 45%;
  background: #a5eafb;
  animation: mg-mirror-drop .7s ease-in infinite;
}
.mg-mirror[data-mirror="fluster"] .mg-mirror-effects::after {
  top: 32%;
  right: 3%;
  animation-delay: -.35s;
}
.mg-paused .mg-mirror * { animation-play-state: paused !important; }
@keyframes mg-mirror-breathe { 0%,100% { scale: 1; } 50% { scale: 1.02; } }
@keyframes mg-mirror-focus { 0%,100% { translate: 0; } 50% { translate: 0 -3px; } }
@keyframes mg-mirror-fluster {
  0%,25%,50%,75%,100% { transform: translateX(-10px); }
  12.5%,37.5%,62.5% { transform: translateX(10px); }
  76% { transform: translateX(-10px) scaleX(-1); }
  87.5% { transform: translateX(10px) scaleX(-1); }
  99% { transform: translateX(-10px) scaleX(-1); }
}
@keyframes mg-mirror-spring {
  0% { transform: scale(.94,1.04); }
  28% { transform: translateY(-13px) scale(1.07,.96); }
  57% { transform: translateY(2px) scale(.99,1.04); }
  78% { transform: translateY(-3px); }
  100% { transform: none; }
}
@keyframes mg-mirror-glint { from { opacity: .35; } to { opacity: 1; } }
@keyframes mg-mirror-drop {
  from { transform: translateY(-4px) rotate(25deg); opacity: 1; }
  to { transform: translateY(12px) rotate(25deg); opacity: 0; }
}
@media (prefers-reduced-motion: reduce) {
  .mg-mirror-motion { animation: none !important; }
  .mg-mirror-motion > img { transition: none; }
  .mg-mirror-effects { display: none; }
}

.mg-view[data-mg-phase="hold"] { position: relative; }
.mg-view[data-mg-phase="hold"]::after {
  content: ''; position: absolute; z-index: 8; inset: 0; pointer-events: none; background: #18111e3d;
}
@media (prefers-reduced-motion: no-preference) {
  .mg-view[data-mg-phase="transition"] :is(.bomb-console, .sound-rails) {
    animation: mg-question-out .38s ease-in both;
  }
}
@keyframes mg-question-out { to { transform: translateX(-9px); opacity: .64; } }
.mg-results { position: relative; isolation: isolate; }
.mg-results .mg-stars { color: var(--game-star-empty); }
.mg-results .mg-stars .is-earned {
  color: var(--game-star-earned);
  background: none;
  -webkit-text-fill-color: currentColor;
  text-shadow: 0 0 6px #ffd36a4d;
  animation: mg-result-star .36s var(--mg-star-delay, 0ms) cubic-bezier(.22,.7,.3,1) both; }
.mg-results :is(.mg-result-doki img, .sound-result-doki, .train-result-doki, .cafe-result-doki, .honne-result-doki) {
  animation: mg-result-hop .58s cubic-bezier(.24,.7,.3,1) both;
}
.mg-results .mg-best-badge { position: relative; overflow: hidden; justify-self: center; }
.mg-results .mg-best-badge::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(110deg, transparent 30%, #fff9 50%, transparent 70%);
  animation: mg-record-shine .8s .3s ease-out both;
}
@keyframes mg-result-star {
  0% { transform: scale(1.6) translateY(-11px); opacity: 0; }
  52% { transform: scale(.91); opacity: 1; }
  74% { transform: scale(1.14); }
  100% { transform: none; opacity: 1; }
}
@keyframes mg-result-hop {
  0% { transform: translateY(8px) scale(.91); opacity: .55; }
  42% { transform: translateY(-13px) scale(1.03); opacity: 1; }
  72% { transform: translateY(2px) scale(1); }
  100% { transform: none; }
}
@keyframes mg-record-shine { from { transform: translateX(-110%); } to { transform: translateX(110%); } }
@media (prefers-reduced-motion: reduce) {
  .mg-results :is(.mg-result-doki img, .sound-result-doki, .train-result-doki, .cafe-result-doki, .honne-result-doki),
  .mg-results .mg-best-badge::after, .mg-results .mg-stars { color: var(--game-star-empty); }
.mg-results .mg-stars .is-earned {
  color: var(--game-star-earned);
  background: none;
  -webkit-text-fill-color: currentColor;
  text-shadow: 0 0 6px #ffd36a4d;
  animation: none; }
}

.mg-difficulty { display: grid; gap: 4px; width: 100%; text-align: center; }
.mg-difficulty-options {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 4px;
  padding: 3px;
  border: 1px solid var(--mg-edge);
  border-radius: var(--r-md);
  background: var(--surface-2);
}
.mg-difficulty-options button {
  min-height: 44px;
  border: 1px solid transparent;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--text);
  font: 800 var(--text-sm)/1.25 var(--f-ja);
}
.mg-difficulty-options button[aria-pressed="true"] {
  border-color: var(--mg-key-line);
  background: var(--mg-key-wash);
  color: var(--mg-key);
}
.mg-difficulty-options button[data-locked] { color: var(--text-muted); }
.mg-difficulty-lock { margin-inline-end: .3em; font-size: 12px; }
.mg-difficulty-reward {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  width: max-content;
  margin: 1px auto 0;
  padding: 1px 6px;
  border-radius: 12px;
  background: var(--mg-key-wash);
  color: var(--mg-key);
  font-size: 12px;
}
.mg-difficulty-reward .mg-shortening-clock { margin: 0; }
.mg-difficulty p { display: flex; flex-wrap: wrap; justify-content: center; gap: 2px 8px; margin: 0; font-size: 12px; color: var(--ivory); }
.mg-shortening {
  display: grid;
  justify-items: center;
  gap: 3px;
  padding: 8px 10px;
  border: 1px solid var(--mg-key-line);
  border-radius: var(--r-md);
  background: var(--mg-key-wash);
  color: var(--text);
  font: 700 var(--text-xs)/1.3 var(--f-ja);
}
.mg-shortening strong { font-size: var(--text-sm); }
.mg-shortening-detail { display: flex; flex-wrap: wrap; justify-content: center; gap: 2px 9px; }
.mg-shortening[data-status="awarded"] strong {
  display: flex;
  align-items: center;
  gap: .2em;
  color: var(--mg-key);
  font-size: var(--text-lg);
}
.mg-shortening-clock {
  position: relative;
  flex: none;
  width: 1em;
  height: 1em;
  margin-inline-end: .2em;
  border: 2px solid currentColor;
  border-radius: 50%;
}
.mg-shortening-clock::after {
  content: '';
  position: absolute;
  top: 21%;
  left: 44%;
  width: 29%;
  height: 32%;
  border: solid currentColor;
  border-width: 0 0 2px 2px;
}
.train-mission:has(.train-replay) { grid-template-columns: minmax(0, 1fr) auto; }
.train-replay { grid-column: 2; grid-row: 1 / 3; min-height: 44px; align-self: center; }
@media (max-height: 720px) {
  .train-results:has(.mg-shortening) .train-carriage { max-height: max(125px, calc(100dvh - 541px)); }
  .train-results:has(.mg-shortening) .train-result-doki { --mg-mirror-size: 103px; }
}
