.mig-game {
  --mig-ink: #352645;
  --mig-muted: #604c72;
  --mig-purple: #593b80;
  --mig-line: #e0d0ea;
  --mig-lilac: #f2e9fb;
  --mig-cream: #fffaf0;
  --mig-blue: #dbeafd;
  --mig-green: #235b4c;
  max-width: 70rem;
  margin-inline: auto;
  color: var(--mig-ink);
  font-family: inherit;
  line-height: 1.5;
}

.mig-game *, .mig-game *::before, .mig-game *::after { box-sizing: border-box; }
.mig-game [hidden] { display: none; }

.mig-game :is(h1, h2, h3, p, ol) { margin: 0; }

.mig-game button {
  color: inherit;
  font: inherit;
  font-weight: 750;
  cursor: pointer;
}

.mig-game :is(button, a, [tabindex]):focus-visible {
  outline: 3px solid var(--mig-purple);
  outline-offset: 3px;
}

.mig-game .mig-visually-hidden,
.mig-game .mig-feedback:empty,
.mig-game .mig-speech-status:empty {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  border: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.mig-game .mig-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .35rem .85rem;
  margin-block-end: .9rem;
}

.mig-game .mig-header h1 {
  flex-basis: 100%;
  font-size: clamp(1.7rem, 4vw, 2.65rem);
  font-weight: 850;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.mig-game .mig-unit {
  color: var(--mig-muted);
  font-size: .88rem;
  font-weight: 700;
}

.mig-game :is(.mig-exit, .mig-hint-toggle, .mig-listen) {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .45rem;
  min-height: 44px;
  padding: .4rem .85rem;
  border: 1px solid var(--mig-line);
  border-radius: 999px;
  background: #fff;
  color: var(--mig-purple);
  font-size: .9rem;
}

.mig-game :is(.mig-exit, .mig-hint-toggle, .mig-listen):hover { background: var(--mig-lilac); }

.mig-game .mig-progress {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: .4rem;
  padding: 0;
  margin-block-end: .8rem;
  list-style: none;
}

.mig-game .mig-step {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 42px;
  gap: .4rem;
  padding: .35rem .2rem;
  border: 1px solid var(--mig-line);
  border-radius: .8rem;
  background: #fbf7ff;
  color: var(--mig-muted);
  font-size: .875rem;
  font-weight: 750;
  text-align: center;
}

.mig-game .mig-step-marker {
  display: grid;
  place-items: center;
  flex: 0 0 1.45rem;
  height: 1.45rem;
  border-radius: 50%;
  background: #e9ddf6;
  color: #50396b;
  font-size: .79rem;
  line-height: 1;
}

.mig-game .mig-step[aria-current="step"] {
  border-color: #a180c4;
  background: #efe3fb;
  color: var(--mig-ink);
}

.mig-game .mig-step--done {
  border-color: #add7c6;
  background: #edf9f3;
  color: var(--mig-green);
}

.mig-game .mig-step--done .mig-step-marker {
  background: #c4ebdd;
  color: var(--mig-green);
}

.mig-game .mig-layout {
  display: grid;
  grid-template-columns: minmax(0, .82fr) minmax(0, 1.18fr);
  align-items: start;
  gap: 1rem;
}

.mig-game .mig-kitchen, .mig-game .mig-panel {
  min-width: 0;
  border: 1px solid var(--mig-line);
  border-radius: 1.15rem;
  box-shadow: 0 4px 0 #7150940d;
}

.mig-game .mig-kitchen { overflow: hidden; background: #f8f1fd; }

.mig-game .mig-art {
  position: relative;
  isolation: isolate;
  height: clamp(13.5rem, 27vw, 20rem);
  overflow: hidden;
  border-bottom: 2px solid #bdd2f0;
  background:
    radial-gradient(ellipse at 50% 38%, #fffdf8 3%, #fff6e2 53%, #fbefd6 95%);
}

.mig-game .mig-table {
  position: absolute;
  inset: 58% 0 0;
  border-top: 2px solid #b8cdef;
  background:
    repeating-linear-gradient(90deg, #7aa8e43d 0 14px, transparent 14px 28px),
    repeating-linear-gradient(0deg, #7aa8e43d 0 14px, transparent 14px 28px),
    #edf6ff;
}

.mig-game .mig-art-spark {
  position: absolute;
  color: #8f6bbb;
  font-weight: 850;
  line-height: 1;
}

.mig-game .mig-art-spark--left { top: 34%; left: 17%; font-size: 2.1rem; }
.mig-game .mig-art-spark--right { top: 28%; right: 17%; font-size: 1.65rem; }
.mig-game .mig-art-spark--small { top: 44%; right: 11%; color: #bd7561; font-size: 1.05rem; }

.mig-game :is(.mig-plate, .mig-sponge, .mig-cream, .mig-berries, .mig-cake-topper) {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
}

.mig-game .mig-plate {
  bottom: 13%;
  width: 70%;
  max-width: 18.5rem;
  height: 27%;
  border: 2px solid #655394;
  border-bottom: 5px solid #8c76b7;
  border-radius: 50%;
  background: radial-gradient(ellipse, #fff 0 54%, #baa8de 55% 57%, #e8dcfa 58% 100%);
  box-shadow: 0 8px 0 #6b579224;
}

.mig-game .mig-sponge {
  bottom: 25%;
  width: 51%;
  max-width: 13rem;
  height: 30%;
  border: 2px solid #ad724e;
  border-radius: 42% 42% 35% 35% / 18% 18% 26% 26%;
  background:
    radial-gradient(circle, #a7673c69 1px, transparent 1.5px) 0 0 / 13px 11px,
    radial-gradient(circle, #a7673c55 1px, transparent 1.5px) 6px 6px / 13px 11px,
    linear-gradient(#ffedb7 22%, #edb678 89%);
  box-shadow: inset 0 -5px 0 #a5673a24;
}

.mig-game .mig-cream {
  bottom: 43%;
  width: 52%;
  max-width: 13.25rem;
  height: 16%;
  border: 2px solid #c38d92;
  border-radius: 48% 48% 28% 34% / 42% 42% 52% 39%;
  background: linear-gradient(#fffdf5 37%, #fae7df 95%);
  box-shadow: inset 0 -4px 0 #f3d7dc;
}

.mig-game .mig-berries {
  bottom: 54%;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  width: 39%;
  height: 15%;
  gap: 8%;
}

.mig-game .mig-berries i {
  position: relative;
  width: 25%;
  max-width: 1.8rem;
  height: 100%;
  border: 1px solid #a54e77;
  border-radius: 46% 48% 55% 53%;
  background:
    radial-gradient(circle, #ffe2c6 1px, transparent 1.4px) 0 0 / 7px 6px,
    linear-gradient(120deg, #ff9ab3, #d95789);
  transform: rotate(-24deg);
}

.mig-game .mig-berries i::after {
  content: '';
  position: absolute;
  inset: -3px 14% auto;
  height: 27%;
  background: #548e6f;
  clip-path: polygon(0 0, 38% 27%, 50% 0, 65% 31%, 100% 10%, 76% 100%, 46% 77%, 20% 99%);
}

.mig-game .mig-berries i:nth-child(2) { height: 88%; transform: translateY(16%) rotate(12deg); }
.mig-game .mig-berries i:nth-child(3) { height: 91%; transform: rotate(24deg); }

.mig-game .mig-cake-topper {
  bottom: 69%;
  left: 53%;
  font-size: clamp(1.9rem, 4vw, 3.4rem);
  line-height: 1;
  filter: drop-shadow(0 2px 0 #854b5026);
}

.mig-game :is(.mig-cake-topper--star, .mig-decoration-icon--star) {
  color: #a96008;
  text-shadow: 0 1px #fff1b5;
}

.mig-game .mig-dialogue {
  display: flex;
  align-items: flex-start;
  gap: .7rem;
  padding: .8rem .9rem;
}

.mig-game .mig-dialogue strong { font-size: .9rem; color: var(--mig-purple); }
.mig-game .mig-dialogue p { font-size: .96rem; overflow-wrap: anywhere; }

.mig-game .mig-guide {
  position: relative;
  isolation: isolate;
  flex: 0 0 2.7rem;
  height: 2.7rem;
  border: 1px solid #aac6ec;
  border-radius: .95rem;
  background: #e1f0fe;
}

.mig-game .mig-guide i {
  position: absolute;
  inset: 28% 18% 19%;
  border: 1px solid #9884b1;
  border-radius: 58% 58% 48% 48%;
  background:
    radial-gradient(ellipse at 34% 48%, #4e4e75 0 1.3px, transparent 1.7px),
    radial-gradient(ellipse at 66% 48%, #4e4e75 0 1.3px, transparent 1.7px),
    radial-gradient(ellipse at 20% 62%, #fac7df 0 1.4px, transparent 1.9px),
    radial-gradient(ellipse at 80% 62%, #fac7df 0 1.4px, transparent 1.9px),
    #fffdf9;
}

.mig-game .mig-guide::before, .mig-game .mig-guide::after {
  content: '';
  position: absolute;
  z-index: -1;
  inset: 30% auto auto 10%;
  width: 23%;
  height: 52%;
  border: 1px solid #9884b1;
  border-radius: 53% 54% 55% 47%;
  background: #fffdf9;
  transform: rotate(26deg);
}

.mig-game .mig-guide::after { right: 10%; left: auto; transform: rotate(-26deg); }
.mig-game .mig-guide--jester { border-color: #c7a6e2; background: #edddfa; }

.mig-game .mig-guide--jester::before, .mig-game .mig-guide--jester::after {
  top: 13%;
  left: 15%;
  width: 31%;
  height: 58%;
  border-color: #5f4577;
  background: #715195;
  border-radius: 65% 18% 60% 20%;
  transform: rotate(-30deg);
}

.mig-game .mig-guide--jester::after { right: 15%; left: auto; transform: scaleX(-1) rotate(-30deg); }
.mig-game .mig-guide--jester i { border: 3px solid #715195; }

.mig-game .mig-panel {
  display: grid;
  justify-items: start;
  gap: .75rem;
  padding: clamp(1rem, 2.5vw, 1.65rem);
  background: var(--mig-cream);
  overflow-wrap: anywhere;
}

.mig-game .mig-question-number {
  color: var(--mig-muted);
  font-size: .88rem;
  font-weight: 750;
}

.mig-game .mig-panel h2 {
  font-size: clamp(1.35rem, 3.3vw, 2.05rem);
  font-weight: 850;
  line-height: 1.34;
  white-space: pre-line;
}

.mig-game .mig-calendar {
  inline-size: min(100%, 26rem);
  table-layout: fixed;
  border-spacing: 0;
  border: 1px solid #cad8ed;
  border-radius: .85rem;
  overflow: hidden;
  background: #fff;
  font-size: clamp(1.125rem, 2vw, 1.35rem);
  text-align: center;
}

.mig-game .mig-calendar :is(th, td) {
  padding: .35rem .1rem;
  white-space: nowrap;
}

.mig-game .mig-calendar th { background: #f0f7ff; }
.mig-game .mig-calendar td { border-block-start: 1px solid #cad8ed; font-variant-numeric: tabular-nums; }

.mig-game .mig-calendar :is(th, td) + :is(th, td) { border-inline-start: 1px solid #cad8ed; }

/* Balance the space used by the reading so the weekday itself stays centered. */
.mig-game .mig-calendar th zhuyin-text > ruby {
  padding-inline-start: max(.74em, var(--zhuyin-reserved-width));
}

.mig-game .mig-visual {
  display: grid;
  align-self: stretch;
  justify-self: stretch;
  gap: .45rem;
  min-width: 0;
  padding: .45rem;
  border: 1px solid #cad8ed;
  border-radius: .85rem;
  background: #f0f7ff;
}

.mig-game .mig-visual--grouped {
  grid-template-columns: repeat(auto-fit, minmax(min(8rem, 100%), 1fr));
}

.mig-game .mig-set { min-width: 0; padding: .4rem; }

.mig-game .mig-visual--grouped .mig-set {
  border: 1px solid #adc6e7;
  border-radius: .6rem;
  background: #fff;
}

.mig-game .mig-set-label { display: block; margin-bottom: .25rem; font-size: .9rem; }
.mig-game .mig-items { display: flex; flex-wrap: wrap; align-items: center; gap: .19rem; }
.mig-game .mig-item { font-size: 1.22rem; line-height: 1.35; }
.mig-game .mig-empty-set { color: var(--mig-muted); font-size: .9rem; }

.mig-game .mig-diagram {
  display: grid;
  justify-self: stretch;
  place-items: center;
  min-width: 0;
  padding: .45rem;
  border: 1px solid #cad8ed;
  border-radius: .85rem;
  background: #f0f7ff;
}

.mig-game .mig-diagram svg {
  display: block;
  width: min(100%, 11rem);
  height: auto;
}

.mig-game .mig-choices, .mig-game .mig-decorations {
  display: grid;
  width: 100%;
  gap: .5rem;
}

.mig-game .mig-choices { grid-template-columns: repeat(2, minmax(0, 1fr)); }

.mig-game .mig-choice, .mig-game .mig-decorate {
  min-width: 0;
  min-height: 52px;
  padding: .55rem;
  border: 2px solid #cdbce3;
  border-radius: .85rem;
  background: #fff;
  box-shadow: 0 2px 0 #dacee7;
  overflow-wrap: anywhere;
}

.mig-game .mig-choice { font-size: clamp(1rem, 2vw, 1.25rem); }
.mig-game :is(.mig-choice:not(:disabled), .mig-decorate):hover { border-color: #9470ba; background: #f4eafa; }
.mig-game .mig-choice:disabled { opacity: 1; cursor: default; }
.mig-game .mig-choice--retry { border-color: #b07585; background: #fff1f3; }

.mig-game .mig-choice--correct {
  border-color: #72a991;
  background: #e8f7ef;
  color: var(--mig-green);
  box-shadow: 0 2px 0 #b7d8ca;
}

.mig-game .mig-feedback, .mig-game .mig-hint, .mig-game .mig-speech-status:not(:empty) {
  justify-self: stretch;
  padding: .6rem .8rem;
  border: 1px solid #e0c9e9;
  border-radius: .75rem;
  background: #f8f0fc;
  font-size: .98rem;
  white-space: pre-line;
}

.mig-game .mig-feedback--correct { border-color: #a5cebc; background: #edf8f1; }
.mig-game .mig-feedback--correct h3 { color: var(--mig-green); font-size: 1.08rem; }
.mig-game .mig-feedback--retry { border-color: #e5bac6; background: #fff2f5; }

.mig-game .mig-listen::before {
  content: '';
  width: 1em;
  height: 1em;
  background: currentColor;
  clip-path: polygon(0 32%, 23% 32%, 55% 7%, 55% 93%, 23% 68%, 0 68%, 0 32%, 68% 32%, 68% 20%, 79% 25%, 92% 37%, 96% 50%, 92% 65%, 79% 77%, 68% 82%, 68% 69%, 78% 63%, 84% 50%, 78% 38%, 68% 32%);
}

.mig-game .mig-primary {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  gap: .55rem;
  min-height: 48px;
  padding: .65rem 1.1rem;
  border: 2px solid transparent;
  border-radius: .8rem;
  background: var(--mig-purple);
  color: #fff;
  box-shadow: 0 3px 0 #3f275f;
  font-weight: 750;
  text-decoration: none;
}

.mig-game .mig-primary:hover { background: #482b6d; }

.mig-game .mig-panel--decoration, .mig-game .mig-panel--reward {
  min-height: 15rem;
  align-content: center;
}

.mig-game .mig-reward-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .6rem;
}

.mig-game .mig-decorations { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.mig-game .mig-decorate { display: grid; justify-items: center; align-content: center; gap: .4rem; }

.mig-game .mig-decoration-icon {
  display: grid;
  place-items: center;
  width: min(100%, 2.85rem);
  min-height: 2.35rem;
  border-radius: .7rem;
  background: #f1e5fa;
  font-size: 1.45rem;
  line-height: 1;
}

.mig-game .mig-decoration-icon--star { background: #fff0c5; }
.mig-game .mig-decoration-icon--rainbow { background: #e3f0fd; }

@media (max-width: 730px) {
  .mig-game .mig-layout { grid-template-columns: minmax(0, 1fr); gap: .65rem; }
  .mig-game .mig-art { height: clamp(7.3rem, 31vw, 11.5rem); }
  .mig-game .mig-plate { width: 57%; }
  .mig-game :is(.mig-sponge, .mig-cream) { width: 39%; }
  .mig-game .mig-berries { width: 28%; }
  .mig-game .mig-dialogue { padding: .55rem .7rem; }
  .mig-game .mig-panel { padding: .85rem; gap: .6rem; }
  .mig-game :is(.mig-panel--decoration, .mig-panel--reward) { min-height: 10.5rem; }
}
