.mq-shell {
  --mq-gold: #e9c46a;
  --mq-gold-soft: #f6e3b2;
  --mq-line: rgba(233, 196, 106, 0.3);
  --mq-ink: #f3f5ff;
  --mq-muted: #b4bde6;
  --mq-ok: #3fcf98;
  --mq-no: #ee5a50;
  --mq-accent: #6aa9e9;
  --mq-panel: rgba(9, 13, 36, 0.72);
  position: relative;
  width: min(100%, 760px);
  margin: 0 auto;
  padding: 8px 0 14px;
  color: var(--mq-ink);
  font-family: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  box-sizing: border-box;
}

.mq-shell *,
.mq-shell *::before,
.mq-shell *::after {
  box-sizing: border-box;
}

.mq-shell [hidden] {
  display: none !important;
}

.mq-c-greek { --mq-accent: #7db6f2; }
.mq-c-norse { --mq-accent: #52d6bd; }
.mq-c-egyptian { --mq-accent: #f0b84e; }
.mq-c-hindu { --mq-accent: #ff8a52; }
.mq-c-japanese { --mq-accent: #ff7fa6; }

.mq-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.mq-stats {
  display: flex;
  gap: 6px;
  min-width: 0;
}

.mq-stat {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 44px;
  min-width: 62px;
  padding: 4px 10px;
  border: 1px solid var(--mq-line);
  border-radius: 12px;
  background: linear-gradient(180deg, #1f2b66, #111a45);
  box-shadow: 0 4px 12px rgba(10, 15, 50, 0.25);
}

.mq-stat span {
  font: 700 9.5px/1 "Trebuchet MS", "Segoe UI", system-ui, sans-serif;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  color: var(--mq-muted);
}

.mq-stat strong {
  margin-top: 2px;
  font-size: 18px;
  line-height: 1.1;
  color: var(--mq-gold-soft);
  font-variant-numeric: tabular-nums;
}

.mq-stat strong.mq-hot {
  color: #ffb14a;
  text-shadow: 0 0 10px rgba(255, 150, 60, 0.7);
}

.mq-actions {
  display: flex;
  gap: 6px;
  flex: 0 0 auto;
}

.mq-btn {
  min-height: 44px;
  min-width: 44px;
  padding: 0 18px;
  border: 1px solid var(--mq-line);
  border-radius: 12px;
  background: linear-gradient(180deg, #1f2b66, #111a45);
  color: var(--mq-gold-soft);
  font: 700 15px "Trebuchet MS", "Segoe UI", system-ui, sans-serif;
  cursor: pointer;
  touch-action: manipulation;
  transition: transform 0.1s ease, border-color 0.15s ease, filter 0.15s ease;
}

.mq-btn:hover { border-color: var(--mq-gold); filter: brightness(1.12); }
.mq-btn:active { transform: translateY(1px) scale(0.98); }

.mq-btn:focus-visible,
.mq-opt:focus-visible,
.mq-close:focus-visible,
.mq-seg-btn:focus-visible,
.mq-stage:focus-visible {
  outline: 3px solid var(--mq-accent);
  outline-offset: 2px;
}

.mq-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.mq-icon svg {
  width: 22px;
  height: 22px;
  display: block;
}

.mq-primary {
  background: linear-gradient(180deg, #f3d488, #c79a3c);
  border-color: #f6e3b2;
  color: #1b1330;
  box-shadow: 0 6px 18px rgba(233, 196, 106, 0.35);
}

.mq-stage {
  position: relative;
  height: clamp(500px, calc(100dvh - 290px), 720px);
  overflow: hidden;
  border: 1px solid var(--mq-line);
  border-radius: 22px;
  background: #0b1236;
  box-shadow: 0 18px 44px rgba(8, 12, 40, 0.42), inset 0 0 0 1px rgba(255, 255, 255, 0.05);
  isolation: isolate;
}

.mq-fx {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
}

.mq-flash {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  opacity: 0;
}

.mq-flash-good { animation: mq-flash 0.6s ease-out; background: radial-gradient(circle at 50% 60%, rgba(120, 255, 190, 0.4), transparent 70%); }
.mq-flash-bad { animation: mq-flash 0.6s ease-out; background: radial-gradient(circle at 50% 60%, rgba(255, 80, 70, 0.42), transparent 72%); }

@keyframes mq-flash {
  0% { opacity: 1; }
  100% { opacity: 0; }
}

.mq-play {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  gap: 8px;
  height: 100%;
  padding: 12px;
}

.mq-crest {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 30px;
  font-family: "Trebuchet MS", "Segoe UI", system-ui, sans-serif;
}

.mq-crest-name {
  padding: 4px 12px;
  border: 1px solid var(--mq-accent);
  border-radius: 999px;
  background: rgba(8, 12, 34, 0.7);
  color: var(--mq-accent);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.mq-crest-num {
  flex: 1;
  font-size: 13px;
  font-weight: 700;
  color: #fff;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.7);
}

.mq-timer-num {
  min-width: 42px;
  padding: 3px 9px;
  border-radius: 999px;
  background: rgba(8, 12, 34, 0.7);
  font-size: 13px;
  font-weight: 800;
  text-align: center;
  color: #fff;
  font-variant-numeric: tabular-nums;
}

.mq-timer-num.mq-low {
  background: var(--mq-no);
  animation: mq-beat 0.5s ease-in-out infinite alternate;
}

@keyframes mq-beat {
  to { transform: scale(1.12); }
}

.mq-timer {
  height: 9px;
  border-radius: 999px;
  background: rgba(6, 9, 28, 0.7);
  overflow: hidden;
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.5);
}

.mq-timer-fill {
  height: 100%;
  width: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--mq-accent), var(--mq-gold));
  box-shadow: 0 0 10px var(--mq-accent);
  transition: background 0.2s;
}

.mq-timer-fill.mq-low {
  background: linear-gradient(90deg, #ff6a5a, #ffb14a);
  box-shadow: 0 0 12px #ff5a4a;
}

.mq-pips {
  display: flex;
  gap: 4px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.mq-pip {
  flex: 1;
  height: 6px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.22);
  transition: background 0.2s;
}

.mq-pip-ok { background: var(--mq-ok); box-shadow: 0 0 8px rgba(63, 207, 152, 0.7); }
.mq-pip-no { background: var(--mq-no); }
.mq-pip-now { background: var(--mq-gold); }

.mq-shell .mq-q {
  margin: 4px 0 0;
  padding: 14px 16px;
  border: 1px solid var(--mq-line);
  border-radius: 16px;
  background: var(--mq-panel);
  backdrop-filter: blur(6px);
  color: #fff;
  font: 700 clamp(19px, 2.4vw + 11px, 26px) / 1.3 "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  text-align: center;
  text-wrap: balance;
  letter-spacing: 0;
  text-transform: none;
  animation: mq-in 0.35s ease-out;
}

@keyframes mq-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

.mq-options {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-auto-rows: 1fr;
  gap: 8px;
}

.mq-opt {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 56px;
  padding: 8px 12px;
  border: 1px solid rgba(233, 196, 106, 0.35);
  border-radius: 14px;
  background: var(--mq-panel);
  backdrop-filter: blur(6px);
  color: #fff;
  font: 600 clamp(15px, 1.2vw + 11px, 18px) / 1.25 "Trebuchet MS", "Segoe UI", system-ui, sans-serif;
  text-align: left;
  cursor: pointer;
  touch-action: manipulation;
  transition: transform 0.12s ease, border-color 0.15s ease, background 0.2s ease, opacity 0.25s ease;
  animation: mq-in 0.35s ease-out backwards;
}

.mq-opt:nth-child(2) { animation-delay: 0.05s; }
.mq-opt:nth-child(3) { animation-delay: 0.1s; }
.mq-opt:nth-child(4) { animation-delay: 0.15s; }

.mq-opt:hover { border-color: var(--mq-accent); transform: translateY(-1px); }
.mq-opt:active { transform: scale(0.98); }

.mq-key {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 9px;
  background: linear-gradient(180deg, var(--mq-gold), #b98a32);
  color: #1b1330;
  font-size: 14px;
  font-weight: 800;
}

.mq-opt-text {
  flex: 1;
  min-width: 0;
  overflow-wrap: anywhere;
}

.mq-opt-ok {
  border-color: var(--mq-ok);
  background: linear-gradient(180deg, rgba(30, 130, 90, 0.92), rgba(14, 84, 60, 0.92));
  box-shadow: 0 0 0 2px var(--mq-ok), 0 0 24px rgba(63, 207, 152, 0.55);
  animation: mq-pulse 0.5s ease-out;
}

.mq-opt-ok .mq-key { background: var(--mq-ok); }

.mq-opt-ok::after {
  content: '';
  flex: 0 0 auto;
  width: 22px;
  height: 22px;
  background: no-repeat center / contain url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M4 12.500l5 5L20 6.500' fill='none' stroke='%23fff' stroke-width='3.500' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}

.mq-opt-no {
  border-color: var(--mq-no);
  background: linear-gradient(180deg, rgba(150, 40, 40, 0.92), rgba(100, 24, 30, 0.92));
  box-shadow: 0 0 0 2px var(--mq-no);
}

.mq-opt-no .mq-key { background: var(--mq-no); color: #fff; }

.mq-opt-dim {
  opacity: 0.5;
}

.mq-good .mq-opt,
.mq-bad .mq-opt {
  pointer-events: none;
}

@keyframes mq-pulse {
  0% { transform: scale(1); }
  40% { transform: scale(1.04); }
  100% { transform: scale(1); }
}

.mq-shake {
  animation: mq-shake 0.45s ease;
}

@keyframes mq-shake {
  20% { transform: translateX(-7px); }
  40% { transform: translateX(6px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(3px); }
}

.mq-feedback {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 64px;
  padding: 8px 8px 8px 14px;
  border: 1px solid var(--mq-line);
  border-radius: 14px;
  background: var(--mq-panel);
  backdrop-filter: blur(6px);
  font: 500 14px/1.35 "Trebuchet MS", "Segoe UI", system-ui, sans-serif;
  color: var(--mq-muted);
}

.mq-fb {
  text-align: left;
  flex: 1;
  min-width: 0;
}

.mq-fb b { color: #fff; }

.mq-fb-good { border-color: var(--mq-ok); color: #d8fff0; }
.mq-fb-bad { border-color: var(--mq-no); color: #ffe3e0; }

.mq-next {
  flex: 0 0 auto;
  padding: 0 18px;
  background: linear-gradient(180deg, #f3d488, #c79a3c);
  color: #1b1330;
  border-color: #f6e3b2;
}

.mq-card {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 20px 18px;
  text-align: center;
  background: radial-gradient(ellipse at 50% 45%, rgba(6, 9, 30, 0.72), rgba(6, 9, 30, 0.35) 70%);
}

.mq-chips {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.mq-chip {
  padding: 4px 11px;
  border: 1px solid var(--mq-accent);
  border-radius: 999px;
  background: rgba(8, 12, 34, 0.75);
  color: var(--mq-accent);
  font: 800 11px/1.2 "Trebuchet MS", "Segoe UI", system-ui, sans-serif;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.mq-card-title {
  font: 700 clamp(34px, 6vw + 10px, 54px) / 1.05 "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  color: var(--mq-gold);
  text-shadow: 0 3px 18px rgba(0, 0, 0, 0.7), 0 0 26px rgba(233, 196, 106, 0.45);
}

.mq-card-body {
  max-width: 34ch;
  margin: 0;
  font: 500 17px/1.4 "Trebuchet MS", "Segoe UI", system-ui, sans-serif;
  color: #fff;
  text-shadow: 0 1px 6px rgba(0, 0, 0, 0.8);
}

.mq-card-note {
  margin: 0;
  font: 700 14px/1.35 "Trebuchet MS", "Segoe UI", system-ui, sans-serif;
  color: var(--mq-gold-soft);
  text-shadow: 0 1px 6px rgba(0, 0, 0, 0.8);
}

.mq-card-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  margin-top: 4px;
}

.mq-card-actions .mq-btn {
  min-width: 130px;
}

.mq-kicker {
  font: 800 12px/1 "Trebuchet MS", "Segoe UI", system-ui, sans-serif;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--mq-gold-soft);
  text-shadow: 0 1px 6px rgba(0, 0, 0, 0.8);
}

.mq-card-score {
  font: 700 clamp(56px, 12vw, 88px) / 1 "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  color: var(--mq-gold);
  text-shadow: 0 4px 22px rgba(0, 0, 0, 0.7), 0 0 30px rgba(233, 196, 106, 0.5);
}

.mq-bars {
  width: min(100%, 340px);
  display: grid;
  gap: 5px;
  padding: 10px 12px;
  border: 1px solid var(--mq-line);
  border-radius: 14px;
  background: var(--mq-panel);
  font: 700 12px/1 "Trebuchet MS", "Segoe UI", system-ui, sans-serif;
}

.mq-bar {
  display: grid;
  grid-template-columns: 68px 1fr 30px;
  align-items: center;
  gap: 8px;
  text-align: left;
  color: #fff;
}

.mq-bar i {
  height: 8px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.2);
  overflow: hidden;
}

.mq-bar b {
  display: block;
  height: 100%;
  background: var(--mq-accent);
  box-shadow: 0 0 8px var(--mq-accent);
}

.mq-bar em {
  font-style: normal;
  text-align: right;
  color: var(--mq-muted);
}

.mq-pop {
  position: absolute;
  z-index: 3;
  pointer-events: none;
  font: 800 26px/1 "Trebuchet MS", "Segoe UI", system-ui, sans-serif;
  transform: translate(-50%, -50%);
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.8);
  animation: mq-float 1s ease-out forwards;
}

.mq-pop-good { color: #9dffd2; }
.mq-pop-bad { color: #ff9a92; }

@keyframes mq-float {
  0% { opacity: 0; transform: translate(-50%, -30%) scale(0.6); }
  20% { opacity: 1; transform: translate(-50%, -70%) scale(1.15); }
  100% { opacity: 0; transform: translate(-50%, -190%) scale(1); }
}

.mq-below {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 10px;
}

.mq-seg {
  display: inline-flex;
  padding: 3px;
  border: 1px solid var(--mq-line);
  border-radius: 14px;
  background: linear-gradient(180deg, #1f2b66, #111a45);
}

.mq-seg-btn {
  min-height: 44px;
  min-width: 88px;
  padding: 0 16px;
  border: 0;
  border-radius: 11px;
  background: transparent;
  color: var(--mq-muted);
  font: 700 15px "Trebuchet MS", "Segoe UI", system-ui, sans-serif;
  cursor: pointer;
  touch-action: manipulation;
}

.mq-seg-btn[aria-pressed='true'] {
  background: linear-gradient(180deg, #f3d488, #c79a3c);
  color: #1b1330;
}

.mq-note {
  margin: 0;
  flex: 1;
  min-width: 0;
  text-align: right;
  color: #5b6491;
  font: 500 13px/1.3 "Trebuchet MS", "Segoe UI", system-ui, sans-serif;
}

.mq-modal {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(4, 6, 20, 0.72);
}

.mq-modal-card {
  position: relative;
  width: min(100%, 480px);
  max-height: 88dvh;
  overflow: auto;
  padding: 22px 20px 18px;
  border: 1px solid var(--mq-line);
  border-radius: 20px;
  background: linear-gradient(180deg, #1c2760, #0e1546);
  color: var(--mq-ink);
  font: 500 15px/1.5 "Trebuchet MS", "Segoe UI", system-ui, sans-serif;
}

.mq-modal-card h2 {
  margin: 0 0 8px;
  color: var(--mq-gold);
  font: 700 24px "Iowan Old Style", Georgia, serif;
}

.mq-rules {
  margin: 0 0 10px;
  padding-left: 20px;
}

.mq-close {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: var(--mq-gold-soft);
  font-size: 28px;
  cursor: pointer;
}

@media (max-width: 559px) {
  .mq-stage {
    height: clamp(500px, calc(100dvh - 300px), 720px);
    border-radius: 18px;
  }

  .mq-options {
    grid-template-columns: 1fr;
    gap: 6px;
  }

  .mq-opt {
    min-height: 48px;
    padding: 6px 10px;
  }

  .mq-shell .mq-q {
    padding: 10px 12px;
  }

  .mq-feedback {
    min-height: 58px;
    font-size: 13px;
  }

  .mq-stat {
    min-width: 0;
    padding: 4px 8px;
  }

  .mq-note {
    display: none;
  }

  .mq-seg {
    width: 100%;
  }

  .mq-seg-btn {
    flex: 1;
  }
}

@media (prefers-reduced-motion: reduce) {
  .mq-opt,
  .mq-shell .mq-q,
  .mq-pop,
  .mq-shake,
  .mq-timer-num.mq-low {
    animation: none;
  }
}
