/* Permiz responsive layer — loaded after page-specific styles. */
img,
svg,
video,
canvas {
  max-width: 100%;
}

/* Keep every game and every answer inside the viewport. */
.game-modal,
.module-dialog {
  height: min(820px, calc(100dvh - 24px));
  max-height: calc(100dvh - 24px);
  overflow: hidden;
}

.game-modal[open],
.module-dialog[open] {
  display: flex;
  flex-direction: column;
}

.game-modal .modal-top,
.module-dialog .module-dialog-top {
  flex: 0 0 auto;
  min-width: 0;
}

.game-modal .modal-progress,
.module-dialog .dialog-progress {
  min-width: 0;
}

.game-modal .game-body,
.module-dialog .module-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  scrollbar-gutter: stable;
}

.random-quiz-modal {
  overflow: hidden;
}

.level-answer,
.answer-btn,
.tile-btn {
  max-width: 100%;
  overflow-wrap: anywhere;
  white-space: normal;
  line-height: 1.45;
}

.level-answer > span:last-child {
  min-width: 0;
}

/* The complete prompt and every answer stay visible before validation. */
@media (min-width: 701px) {
  .module-body:has(.question-view:not(.answered)) {
    overflow: hidden;
    padding: 20px 28px 24px;
  }

  .module-body .question-view:not(.answered) {
    display: grid;
    grid-template-columns: minmax(230px, 0.9fr) minmax(320px, 1.1fr);
    grid-template-rows: auto auto auto auto 1fr auto;
    column-gap: 26px;
    align-content: center;
    height: 100%;
    min-height: 0;
  }

  .module-body .question-view:not(.answered) > .question-scene,
  .module-body .question-view:not(.answered) > .random-sign,
  .module-body .question-view:not(.answered) > .real-sign,
  .module-body .question-view:not(.answered) > .random-marking {
    grid-column: 1;
    grid-row: 1 / -1;
    align-self: center;
    width: 100%;
    max-height: min(50dvh, 420px);
    margin: 0;
    object-fit: contain;
  }

  .module-body .question-view:not(.answered) > :not(.question-scene):not(.random-sign):not(.real-sign):not(.random-marking) {
    grid-column: 2;
  }

  .module-body .question-view:not(.answered) .quiz-question {
    margin: 6px 0 12px;
    font-size: clamp(20px, 2.4vw, 27px);
  }

  .module-body .question-view:not(.answered) .level-answers {
    gap: 7px;
  }

  .module-body .question-view:not(.answered) .level-answer {
    min-height: 44px;
    padding: 9px 11px;
    line-height: 1.3;
  }

  /* After validation, keep the scene, choices and coach verdict in one game board. */
  .module-body:has(.question-view.answered) {
    padding: 16px 24px 18px;
  }

  .module-body .question-view.answered {
    display: grid;
    grid-template-columns: minmax(180px, .72fr) minmax(340px, 1.28fr);
    grid-template-rows: auto auto auto auto 1fr auto;
    column-gap: 20px;
    align-content: start;
    min-height: 100%;
  }

  .module-body .question-view.answered > .question-scene,
  .module-body .question-view.answered > .random-sign,
  .module-body .question-view.answered > .real-sign,
  .module-body .question-view.answered > .random-marking {
    grid-column: 1;
    grid-row: 1 / 7;
    align-self: start;
    width: 100%;
    max-height: min(29dvh, 220px);
    margin: 0;
    object-fit: contain;
  }

  .module-body .question-view.answered > :not(.question-scene):not(.random-sign):not(.real-sign):not(.random-marking):not(#feedbackArea) {
    grid-column: 2;
  }

  .module-body .question-view.answered .quiz-question {
    margin: 5px 0 9px;
    font-size: clamp(18px, 2vw, 24px);
  }

  .module-body .question-view.answered .level-answers {
    gap: 6px;
  }

  .module-body .question-view.answered .level-answer {
    min-height: 40px;
    padding: 7px 10px;
  }

  .module-body .question-view.answered #feedbackArea {
    grid-column: 1 / -1;
  }
}

.question-view.answered #feedbackArea,
.question-view.answered #randomFeedback,
.question-view.answered #feedback {
  scroll-margin-bottom: 12px;
}

.question-view.answered .level-feedback,
.question-view.answered .feedback-box {
  position: relative;
  margin-top: 12px;
  padding: 12px 14px;
  border: 1px solid rgba(102, 135, 0, .2);
  box-shadow: 0 12px 26px rgba(16, 37, 58, .1);
}

.question-view.answered .level-feedback::before,
.question-view.answered .feedback-box::before {
  content: 'VERDICT DE MIZ';
  position: absolute;
  top: -7px;
  left: 14px;
  padding: 3px 8px;
  border-radius: 99px;
  background: #10243c;
  color: #c8ff2e;
  font-size: 6px;
  font-weight: 950;
  letter-spacing: 1px;
}

.question-view.answered .level-feedback p,
.question-view.answered .feedback-box p {
  margin: 3px 0;
  line-height: 1.4;
}

.question-view.answered .next-question,
.question-view.answered .next-row {
  position: sticky;
  z-index: 4;
  bottom: -1px;
  margin-top: 8px;
  padding: 8px 0 2px;
  background: linear-gradient(180deg, rgba(244, 247, 249, 0), #f4f7f9 35%);
}

.pop-culture-result {
  width: min(560px, 100%);
  margin: 14px auto;
  padding: 13px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  text-align: left;
  border: 1px solid #b8d84d;
  border-radius: 16px;
  background: linear-gradient(135deg, #10243c, #193654);
  color: white;
  box-shadow: 0 14px 30px rgba(16, 36, 60, .18);
}

.pop-culture-result > span {
  flex: 0 0 40px;
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: #c8ff2e;
  font-size: 20px;
}

.pop-culture-result small,
.pop-culture-result strong {
  display: block;
}

.pop-culture-result small {
  margin-bottom: 4px;
  color: #c8ff2e;
  font-size: 7px;
  font-weight: 950;
  letter-spacing: 1.1px;
}

.pop-culture-result strong {
  font-size: 11px;
  line-height: 1.45;
}

.quiz-result,
.result-view {
  scroll-margin-top: 0;
}

/* Results remain inside the game window: summary, sharing and corrections
   are three instant views rather than one long page. */
.quiz-result[data-screen-flow="ready"],
.result-view[data-screen-flow="ready"] {
  height: 100%;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.game-screen-nav {
  order: -1;
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  margin: 0 0 12px;
  padding: 4px;
  border-radius: 13px;
  background: #e4eaf0;
}

.game-screen-tab {
  min-height: 38px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: #526477;
  font-size: 9px;
  font-weight: 950;
  transition: background .18s ease, color .18s ease, transform .18s ease;
}

.game-screen-tab[aria-selected="true"] {
  background: #10243c;
  color: #c8ff2e;
  box-shadow: 0 6px 16px rgba(16, 36, 60, .18);
}

.game-screen-tab:active {
  transform: scale(.97);
}

.game-screen-panels {
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
}

.game-screen-panel {
  height: 100%;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
  animation: gamePanelIn .2s ease both;
}

.game-screen-panel[hidden] {
  display: none;
}

.game-screen-panel > .share-challenge,
.game-screen-panel > .result-recap,
.game-screen-panel > .result-list {
  margin-top: 0;
}

.quiz-result[data-screen-flow="ready"] > .result-buttons {
  flex: 0 0 auto;
  margin-top: 10px;
}

@keyframes gamePanelIn {
  from { opacity: 0; transform: translateY(5px); }
  to { opacity: 1; transform: none; }
}

/* Discovery and random modes also keep the prompt and choices together. */
.game-body .question-view:not(.answered) {
  padding-bottom: 4px;
}

.game-body .question-view:not(.answered) .quiz-question {
  margin: 6px 0 10px;
  font-size: clamp(18px, 2.3vw, 25px);
  line-height: 1.18;
}

.game-body .question-view:not(.answered) .level-answers,
.game-body .question-view:not(.answered) .answers {
  gap: 6px;
}

.game-body .question-view:not(.answered) .level-answer,
.game-body .question-view:not(.answered) .answer {
  min-height: 42px;
  padding: 8px 10px;
  line-height: 1.25;
}

.game-body .question-view:not(.answered) .question-scene,
.game-body .question-view:not(.answered) .game-scene {
  max-height: min(27dvh, 250px);
  object-fit: contain;
}

@media (max-width: 600px) {
  .has-beta-banner .hero {
    padding-top: 155px;
  }

  .hero h1 {
    font-size: clamp(40px, 13vw, 54px);
    letter-spacing: -2.8px;
  }

  .hero-buttons .btn {
    width: 100%;
  }

  .trust span {
    white-space: normal;
  }

  .modal-top {
    gap: 9px;
    padding: 13px 14px;
  }

  .game-modal,
  .module-dialog {
    width: calc(100% - 12px);
    height: calc(100dvh - 12px);
    min-height: 0;
    max-height: calc(100dvh - 12px);
    border-radius: 18px;
  }

  .game-body,
  .module-body {
    padding: 20px 15px 30px;
  }

  .game-body:has(.question-view),
  .module-body:has(.question-view) {
    overflow: hidden;
    padding: 9px 12px 12px;
  }

  .game-body .question-view,
  .module-body .question-view {
    height: 100%;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    scroll-behavior: smooth;
  }

  .random-question .question-scene {
    max-height: 18dvh;
    object-fit: contain;
    background: #dfe5e9;
  }

  .module-body .question-view:not(.answered) > .question-scene {
    display: block;
    width: 100%;
    max-height: 18dvh;
    margin-bottom: 8px;
    object-fit: contain;
  }

  .route-rhythm {
    flex: 0 0 auto;
    margin-bottom: 7px;
  }

  .content-meta {
    flex: 0 0 auto;
    margin: 2px 0 4px;
  }

  .quiz-topic,
  .multi-instruction {
    flex: 0 0 auto;
  }

  .module-body .question-view:not(.answered) .content-meta {
    margin-bottom: 4px;
  }

  .module-body .question-view:not(.answered) .quiz-question {
    margin: 5px 0 9px;
    font-size: clamp(17px, 5vw, 21px);
    line-height: 1.17;
  }

  .module-body .question-view:not(.answered) .level-answers {
    gap: 6px;
  }

  .module-body .question-view:not(.answered) .level-answer {
    min-height: 42px;
    padding: 8px 10px;
    line-height: 1.25;
  }

  .game-body .question-view:not(.answered) .question-scene,
  .game-body .question-view:not(.answered) .game-scene {
    max-height: 17dvh;
  }

  .game-body .question-view:not(.answered) .quiz-question {
    font-size: clamp(17px, 5vw, 21px);
  }

  .question-view.answered > .question-scene,
  .question-view.answered > .game-scene {
    display: none;
  }

  .question-view.answered .quiz-question {
    margin: 4px 0 8px;
    font-size: 18px;
  }

  .question-view.answered .level-answers,
  .question-view.answered .answers {
    gap: 5px;
  }

  .question-view.answered .level-answer,
  .question-view.answered .answer-btn,
  .question-view.answered .tile-btn {
    min-height: 39px;
    padding: 7px 9px;
    font-size: 10px;
  }

  .question-view.answered .level-feedback,
  .question-view.answered .feedback-box {
    grid-template-columns: 30px 1fr;
    gap: 8px;
    padding: 11px;
  }

  .question-view.answered #feedbackArea,
  .question-view.answered #randomFeedback,
  .question-view.answered #feedback {
    padding-bottom: 54px;
  }

  .question-view.answered #feedbackArea,
  .question-view.answered #randomFeedback,
  .question-view.answered #feedback {
    margin-top: auto;
  }

  .question-view.answered .level-feedback img,
  .question-view.answered .feedback-box img {
    width: 30px;
    height: 30px;
  }

  .pop-culture-result {
    padding: 11px 12px;
  }

  .pop-culture-result > span {
    flex-basis: 34px;
    width: 34px;
    height: 34px;
  }

  .arcade-question-hud {
    flex-wrap: wrap;
  }

  .arcade-question-hud > span {
    max-width: 55%;
    line-height: 1.45;
  }

  .level-answer,
  .answer-btn,
  .tile-btn {
    min-height: 48px;
    padding: 12px;
    font-size: 12px;
  }

  .answer-index,
  .answer-letter {
    flex: 0 0 28px;
  }

  .next-question .btn,
  .quiz-actions .btn,
  .next-row .btn,
  .result-buttons .btn {
    width: 100%;
  }

  .game-screen-nav {
    margin-bottom: 7px;
  }

  .game-screen-tab {
    min-height: 36px;
  }

  .game-screen-panel[data-screen-panel="summary"] .completion-badge {
    margin: 0;
    font-size: 28px;
    line-height: 1;
  }

  .game-screen-panel[data-screen-panel="summary"] .eyebrow {
    margin: 4px 0;
  }

  .game-screen-panel[data-screen-panel="summary"] .competition-total {
    width: min(210px, 100%);
    margin: 3px auto;
    padding: 6px 9px;
  }

  .game-screen-panel[data-screen-panel="summary"] .competition-total strong {
    font-size: 21px;
  }

  .game-screen-panel[data-screen-panel="summary"] .result-ring {
    width: 76px;
    height: 76px;
    margin: 4px auto;
  }

  .game-screen-panel[data-screen-panel="summary"] .result-ring::before {
    inset: 8px;
  }

  .game-screen-panel[data-screen-panel="summary"] .result-ring strong {
    font-size: 21px;
  }

  .game-screen-panel[data-screen-panel="summary"] h2 {
    margin: 3px 0;
    font-size: 20px;
    letter-spacing: -1px;
  }

  .game-screen-panel[data-screen-panel="summary"] > p:not(.eyebrow) {
    margin: 4px 0 7px;
    font-size: 10px;
    line-height: 1.4;
  }

  .game-screen-panel[data-screen-panel="summary"] .classic-game-result {
    grid-template-columns: 1fr 1fr;
    gap: 6px;
    margin: 5px 0 7px;
  }

  .game-screen-panel[data-screen-panel="summary"] .classic-game-result > div {
    padding: 8px;
  }

  .game-screen-panel[data-screen-panel="summary"] .classic-game-result b {
    font-size: 14px;
  }

  .game-screen-panel[data-screen-panel="summary"] .arcade-result-stats {
    grid-template-columns: repeat(3, 1fr);
    gap: 5px;
    margin: 7px 0;
  }

  .game-screen-panel[data-screen-panel="summary"] .arcade-result-stats div {
    padding: 6px 3px;
  }

  .game-screen-panel[data-screen-panel="summary"] .arcade-result-stats b {
    font-size: 14px;
  }

  .game-screen-panel[data-screen-panel="summary"] .pop-culture-result {
    margin: 7px auto;
    padding: 8px 10px;
  }

  .game-screen-panel[data-screen-panel="summary"] .unlocked-box,
  .game-screen-panel[data-screen-panel="summary"] .result-cta {
    margin-top: 8px;
    padding: 11px;
  }

  .game-screen-panel[data-screen-panel="summary"] .unlocked-box b {
    margin: 0;
    font-size: 12px;
  }

  .game-screen-panel[data-screen-panel="summary"] .unlocked-box p {
    display: none;
  }

  .game-screen-panel[data-screen-panel="share"] .share-challenge {
    padding: 13px;
  }

  .game-screen-panel[data-screen-panel="answers"] details {
    padding: 7px 9px;
  }

  .game-screen-panel[data-screen-panel="answers"] .result-recap,
  .game-screen-panel[data-screen-panel="answers"] .result-list {
    gap: 4px;
    margin-bottom: 0;
  }

  .game-screen-panel[data-screen-panel="answers"] summary {
    font-size: 9px;
    line-height: 1.25;
  }

  .has-beta-banner .level-hero {
    padding-top: 70px;
  }

  .level-nav {
    gap: 8px;
  }

  .level-stats {
    margin-left: auto;
  }

  .module-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .module-card,
  .module-copy {
    min-width: 0;
  }

  .module-copy h3,
  .module-copy p {
    overflow-wrap: anywhere;
  }

  .auth-header {
    gap: 12px;
    padding-inline: 16px;
  }

  .auth-header > a:last-child {
    text-align: right;
    font-size: 10px;
  }

  .auth-shell {
    width: min(calc(100% - 24px), 1080px);
    min-height: auto;
    gap: 24px;
    padding: 32px 0 55px;
  }

  .has-beta-banner .auth-shell {
    padding-top: 78px;
  }

  .auth-brand h1 {
    font-size: clamp(40px, 13vw, 49px);
    letter-spacing: -3px;
  }

  .auth-brand > p {
    font-size: 13px;
  }

  .auth-card {
    width: 100%;
    border-radius: 20px;
  }

  .auth-tabs button {
    padding: 10px 6px;
    font-size: 11px;
  }

  .player-nav {
    gap: 10px;
    padding-inline: 16px;
  }

  .player-nav > .btn {
    padding: 9px 10px;
    white-space: nowrap;
    font-size: 9px;
  }

  .has-beta-banner .player-hero {
    padding-top: 105px;
  }

  .player-hero {
    gap: 28px;
    padding: 42px 0 32px;
  }

  .player-hero h1 {
    font-size: clamp(42px, 13vw, 58px);
    letter-spacing: -3px;
  }

  .rank-stage {
    width: 190px;
    height: 190px;
  }

  .rank-stage span {
    font-size: 64px;
  }

  .section-head {
    align-items: flex-start;
    flex-direction: column;
    gap: 10px;
  }

  .journey-panel,
  .account-panel,
  .xp-panel,
  .mini-stat {
    padding: 17px;
  }

  .account-actions .btn,
  .account-actions button {
    width: 100%;
  }
}

@media (max-width: 420px) {
  .topbar {
    gap: 10px;
  }

  .top-actions {
    min-width: 0;
  }

  .top-actions .btn {
    white-space: nowrap;
  }

  .hero-stage {
    height: 350px;
  }

  .mascot-orbit {
    width: 270px;
    height: 270px;
  }

  .miz-hero {
    height: 310px;
  }

  .mini-hud {
    width: min(220px, 82vw);
  }

  .stats-strip {
    grid-template-columns: 1fr;
  }

  .stats-strip div {
    padding: 7px 0;
    border-right: 0;
    border-bottom: 1px solid rgba(10, 20, 36, 0.18);
  }

  .stats-strip div:last-child {
    border-bottom: 0;
  }

  .dash-grid {
    grid-template-columns: 1fr;
  }

  .continue-card,
  .leader-card {
    grid-column: auto;
  }

  .footer-main {
    grid-template-columns: 1fr;
  }

  .footer-main > div:first-child,
  .footer-main > div:last-child {
    grid-column: auto;
  }

  .footer-bottom {
    align-items: flex-start;
    flex-direction: column;
  }

  .game-modal,
  .module-dialog {
    width: 100%;
    height: 100dvh;
    max-height: 100dvh;
    border-radius: 0;
  }

  .game-modal .logo.mini {
    display: none;
  }

  .random-quiz-modal .arcade-xp {
    font-size: 7px;
  }

  .route-rhythm {
    grid-template-columns: minmax(0, 1fr) 35px;
    padding: 7px;
  }

  .rhythm-multiplier {
    width: 33px;
    height: 33px;
  }

  .arcade-question-hud > span {
    max-width: 48%;
  }

  .question-view h2 {
    font-size: 20px;
    letter-spacing: -0.5px;
  }

  .tiles {
    grid-template-columns: 1fr;
  }

  .feedback-box,
  .level-feedback {
    grid-template-columns: 34px 1fr;
    gap: 9px;
    padding: 13px;
  }

  .feedback-box img,
  .level-feedback img {
    width: 34px;
    height: 34px;
  }
}

@media (max-width: 600px) and (max-height: 700px) {
  .game-modal .modal-top,
  .module-dialog .module-dialog-top {
    min-height: 52px;
    height: 52px;
    padding-block: 7px;
  }

  .game-body .question-view:not(.answered) .question-scene,
  .module-body .question-view:not(.answered) > .question-scene,
  .game-body .question-view:not(.answered) .game-scene {
    max-height: 15dvh;
  }

  .game-body .question-view:not(.answered) .quiz-question,
  .module-body .question-view:not(.answered) .quiz-question {
    margin: 3px 0 6px;
    font-size: 17px;
  }

  .level-answer,
  .answer-btn,
  .tile-btn {
    min-height: 40px;
    padding: 8px 9px;
    font-size: 10px;
  }

  .question-view.answered .level-feedback,
  .question-view.answered .feedback-box {
    margin-top: 8px;
    padding: 9px;
  }

  .question-view.answered .level-feedback p,
  .question-view.answered .feedback-box p {
    font-size: 9px;
    line-height: 1.3;
  }
}
