/* Iris rhythm room — 4 lanes, 60 seconds, one random song per round. */

#irisPlayground {
  grid-column: 1 / -1;
  width: min(880px, 100%);
  margin: 8px auto 0;
}

.mg {
  --mg-ink: #fff1d7;
  --mg-dim: #d9c3a6;
  --mg-wine: #6b3a44;
  --mg-cream: #f2d5ab;
  --mg-gold: #ffe3a0;
  --mg-teal: #8ce7df;
  margin: 34px 0 8px;
  padding-top: 30px;
  border-top: 1px solid #87535a44;
  text-align: center;
  color: var(--mg-ink);
}

.mg-kicker {
  display: block;
  font-size: 11px;
  letter-spacing: .18em;
  color: #8d6f63;
  text-transform: uppercase;
}

.mg h3 {
  margin: 10px 0 6px;
  font-size: clamp(28px, 4vw, 36px);
  color: #55343b;
  font-weight: 500;
}

.mg-sub {
  margin: 0 0 18px;
  font-size: 13px;
  color: #8a6f67;
  letter-spacing: .04em;
}

.mg-meta {
  display: flex;
  justify-content: center;
  gap: 14px;
  align-items: baseline;
  margin-bottom: 12px;
  min-height: 24px;
  font-size: 13px;
  color: #6f4a45;
}

.mg-song {
  font-style: italic;
}

.mg-song b {
  font-style: normal;
  font-weight: 600;
}

.mg-bpm {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
  letter-spacing: .08em;
  color: #9a7a6c;
}

/* board ------------------------------------------------------------------ */

.mg-board {
  position: relative;
  height: 440px;
  border-radius: 16px;
  overflow: hidden;
  background:
    radial-gradient(120% 90% at 50% 108%, #4a3345 0%, #2a2233 45%, #211d29 100%);
  box-shadow: inset 0 0 0 1px #ffffff12, 0 18px 40px -24px #2a1620;
  touch-action: manipulation;
  outline: none;
}

.mg-board:focus-visible {
  box-shadow: 0 0 0 3px #8ce7df88, inset 0 0 0 1px #ffffff12;
}

.mg-lanes {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
}

.mg-lane {
  position: relative;
  border: 0;
  border-right: 1px solid #ffffff16;
  background: linear-gradient(to bottom, #ffffff04, transparent 70%);
  padding: 0;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.mg-lane:last-child { border-right: 0; }

.mg-lane::after {
  content: "";
  position: absolute;
  inset: 0;
  opacity: 0;
  background: linear-gradient(to top, #ffe3a01f, transparent 60%);
  transition: opacity .16s ease;
}

.mg-lane.is-down::after { opacity: 1; }

.mg-judge {
  position: absolute;
  left: 0;
  right: 0;
  top: 84%;
  height: 0;
  pointer-events: none;
  z-index: 3;
}

.mg-judge::before {
  content: "";
  position: absolute;
  left: 3%;
  right: 3%;
  top: -1px;
  height: 2px;
  border-radius: 2px;
  background: linear-gradient(to right, transparent, #ffe3a0bb 14%, #ffe3a0bb 86%, transparent);
  box-shadow: 0 0 16px #ffe3a044;
}

.mg-receptors {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  transform: translateY(-50%);
}

.mg-receptor {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 54px;
  height: 54px;
  margin: 0 auto;
  border-radius: 50%;
  border: 2px solid #ffe3a077;
  background: #2c2333e6;
  color: #ffe3a088;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 15px;
  letter-spacing: .04em;
  box-shadow: 0 0 0 6px #00000018;
  transition: border-color .12s, color .12s, box-shadow .12s, transform .12s;
}

.mg-receptor.is-down {
  border-color: var(--mg-teal);
  color: var(--mg-teal);
  box-shadow: 0 0 0 6px #8ce7df22, 0 0 22px #8ce7df55;
  transform: scale(1.06);
}

.mg-receptor.is-perfect {
  border-color: var(--mg-gold);
  color: var(--mg-gold);
  box-shadow: 0 0 0 8px #ffe3a033, 0 0 34px #ffe3a088;
}

.mg-notes {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
}

.mg-note {
  position: absolute;
  width: 36px;
  height: 36px;
  margin-left: -18px;
  border-radius: 50%;
  background: var(--mg-gold);
  border: 2px solid #fff7e0;
  box-shadow: 0 0 0 5px #35243eaa, 0 0 18px #ffdc9055;
  will-change: top, transform;
}

.mg-note.is-hold {
  height: auto;
  border-radius: 22px;
  background: linear-gradient(to bottom, #ffe3a0 0%, #ffd489 55%, #f0b96f 100%);
}

.mg-note.is-hold::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 6px;
  width: 12px;
  height: 12px;
  margin-left: -6px;
  border-radius: 50%;
  background: #fff7e0;
  box-shadow: 0 0 12px #ffe3a0cc;
}

.mg-note.is-hold::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 0;
  bottom: 0;
  width: 2px;
  margin-left: -1px;
  background: #fff2d5aa;
}

.mg-note.is-held {
  box-shadow: 0 0 0 5px #8ce7df44, 0 0 26px #8ce7df88;
  filter: brightness(1.06);
}

.mg-note.is-hit {
  animation: mg-pop .22s ease-out forwards;
}

.mg-note.is-miss {
  animation: mg-fade .22s ease-out forwards;
}

@keyframes mg-pop {
  to { transform: scale(1.7); opacity: 0; }
}

@keyframes mg-fade {
  to { opacity: 0; transform: translateY(14px) scale(.8); }
}

/* HUD -------------------------------------------------------------------- */

.mg-hud {
  position: absolute;
  inset: 14px 18px auto;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  z-index: 4;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  letter-spacing: .08em;
  color: #ffe3a0cc;
  pointer-events: none;
}

.mg-hud b {
  display: block;
  font-size: 22px;
  font-weight: 500;
  color: var(--mg-ink);
  letter-spacing: .02em;
}

.mg-combo {
  text-align: center;
  opacity: 0;
  transform: translateY(-4px);
  transition: opacity .2s, transform .2s;
}

.mg-combo.is-on { opacity: 1; transform: none; }

.mg-combo b { font-size: 30px; color: var(--mg-teal); }

.mg-time {
  text-align: right;
  min-width: 74px;
}

.mg-bar {
  margin-top: 8px;
  width: 86px;
  height: 3px;
  border-radius: 2px;
  background: #ffffff22;
  overflow: hidden;
}

.mg-bar i {
  display: block;
  height: 100%;
  width: 0%;
  background: linear-gradient(to right, #8ce7df, #ffe3a0);
}

/* judgement text --------------------------------------------------------- */

.mg-feedback {
  position: absolute;
  left: 50%;
  top: 58%;
  transform: translate(-50%, -50%);
  z-index: 5;
  pointer-events: none;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  letter-spacing: .12em;
  opacity: 0;
}

.mg-feedback.is-on {
  animation: mg-judge .46s ease-out;
}

.mg-feedback[data-judge="perfect"] {
  font-size: 40px;
  color: var(--mg-gold);
  text-shadow: 0 0 22px #ffe3a0aa;
}

.mg-feedback[data-judge="good"] {
  font-size: 26px;
  color: #ffeccd;
  text-shadow: 0 0 12px #ffe3a066;
}

.mg-feedback[data-judge="miss"] {
  font-size: 22px;
  color: #b9a3a8;
  text-shadow: none;
}

@keyframes mg-judge {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(.82); }
  22% { opacity: 1; transform: translate(-50%, -50%) scale(1.04); }
  100% { opacity: 0; transform: translate(-50%, -62%) scale(1); }
}

/* cat companion ---------------------------------------------------------- */

/* overlay ---------------------------------------------------------------- */

.mg-overlay {
  position: absolute;
  inset: 0;
  z-index: 6;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 24px;
  background: #1d1925f2;
  color: var(--mg-ink);
}

.mg-overlay[hidden] { display: none; }

.mg-overlay b {
  font-size: clamp(24px, 4vw, 34px);
  font-style: italic;
  font-weight: 500;
}

.mg-overlay span {
  font-size: 13px;
  color: #e2cdb4;
  letter-spacing: .04em;
  max-width: 34em;
  line-height: 1.8;
}

.mg-overlay .mg-primary {
  margin-top: 8px;
  font: inherit;
  font-size: 14px;
  padding: 11px 24px;
  border-radius: 999px;
  border: 1px solid #ffe3a055;
  background: var(--mg-gold);
  color: #3b2530;
  cursor: pointer;
}

.mg-overlay .mg-primary:disabled { opacity: .5; cursor: default; }

.mg-result {
  display: flex;
  gap: 26px;
  margin-top: 4px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

.mg-result div { text-align: center; }

.mg-result b { display: block; font-size: 26px; font-style: normal; color: var(--mg-gold); }

.mg-result small { font-size: 10px; letter-spacing: .14em; color: #c9b39f; }

/* controls --------------------------------------------------------------- */

.mg-controls {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin: 16px 0 4px;
}

.mg-controls button {
  font: inherit;
  font-size: 13px;
  color: #55343b;
  border: 1px solid #87535a66;
  border-radius: 8px;
  background: #e9d9c2;
  padding: 9px 16px;
  cursor: pointer;
}

.mg-controls button:disabled { opacity: .45; cursor: default; }

.mg-hint {
  font-size: 11px;
  color: #9a7a6c;
  letter-spacing: .06em;
}

.mg-status {
  min-height: 22px;
  margin: 4px 0 0;
  font-size: 12px;
  color: #8a6f67;
}

.mg-status:empty { display: none; }

@media (max-width: 620px) {
  .mg-meta { flex-direction: column; gap: 4px; align-items: center; }
  .mg-song { font-size: 12px; line-height: 1.5; padding: 0 10px; }
  .mg-board { height: 380px; }
  .mg-note { width: 32px; height: 32px; margin-left: -16px; }
  .mg-receptor { width: 46px; height: 46px; font-size: 13px; }
  .mg-feedback[data-judge="perfect"] { font-size: 32px; }
}

@media (prefers-reduced-motion: reduce) {
  .mg-note.is-hit, .mg-note.is-miss, .mg-feedback.is-on { animation-duration: .01s; }
}

/* the cat that runs across the whole page ------------------------------- */
.mg-runner {
  position: fixed;
  left: 0;
  top: 0;
  width: 84px;
  height: 84px;
  z-index: 9998;
  pointer-events: none;
  background-image: url(assets/running-cats.png);
  background-size: 400% 200%;
  background-position: 33.333% 0;
  opacity: 0;
  transition: opacity .25s ease;
  filter: drop-shadow(0 6px 7px #2a162033);
  will-change: transform;
}

.mg-runner.is-on { opacity: 1; }
.mg-runner[data-row="1"] { background-position-y: 100%; }
.mg-runner.is-run { animation: mg-cat-sprite .42s steps(4) infinite; }

@keyframes mg-cat-sprite {
  from { background-position-x: 0%; }
  to { background-position-x: 133.333%; }
}

.mg-trail {
  position: fixed;
  inset: 0;
  z-index: 9997;
  pointer-events: none;
  opacity: 0;
  transition: opacity .3s ease;
}

.mg-trail.is-on { opacity: 1; }

@media (max-width: 620px) {
  .mg-runner { width: 64px; height: 64px; }
}

@media (prefers-reduced-motion: reduce) {
  .mg-runner.is-run { animation-duration: 1s; }
}

/* cat picker ------------------------------------------------------------- */
.mg-cats {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin: 0 0 14px;
}

.mg-cat-pick {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px 6px 6px;
  border-radius: 999px;
  border: 1px solid #87535a33;
  background: #efe3d0aa;
  color: #5c3a40;
  font: inherit;
  font-size: 12px;
  cursor: pointer;
}

.mg-cat-pick em { font-style: normal; letter-spacing: .02em; }

.mg-cat-pick[aria-pressed="true"] {
  border-color: #b98a4a;
  background: #fff6e4;
  box-shadow: 0 0 0 3px #ffe3a033;
}

.mg-cat-thumb {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background-color: #fff;
  background-image: url(assets/running-cats.png);
  background-size: 400% 200%;
  background-position: 33.333% 0;
  border: 2px solid #ffffff99;
}

.mg-cat-thumb[data-row="1"] { background-position-y: 100%; }

.mg-runner.is-dash {
  filter: drop-shadow(0 0 10px #ffe3a099) brightness(1.05);
}

.mg-runner.is-walk {
  animation: mg-cat-sprite 1s steps(4) infinite;
  opacity: .94;
}

.mg-credit {
  margin: 10px 0 0;
  font-size: 11px;
  letter-spacing: .02em;
  color: #9a7a6c;
}

.mg-credit a { color: #8a5f52; }

@media (max-width: 620px) {
  .mg-cat-pick { font-size: 11px; padding: 5px 10px 5px 5px; }
  .mg-cat-thumb { width: 30px; height: 30px; }
}
