:root {
  --gold: #d4a017;
  --gold-dark: #8a5b00;
  --cream: #fdf8eb;
  --cream-strong: #fff8e8;
  --ink: #2f2419;
  --success: #4c8a3f;
  --shadow: rgba(67, 46, 10, 0.16);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: Arial, Helvetica, sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at top, rgba(212, 160, 23, 0.16), transparent 30%),
    linear-gradient(135deg, #fffef9 0%, var(--cream) 100%);
}

.start-screen {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  z-index: 1000;
  background: #efe24f;
  display: grid;
  place-items: center;
}

.start-screen__bg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  z-index: 1;
}

.start-screen__content {
  position: relative;
  z-index: 2;
  width: 1080px;
  height: 537px;
  padding: 0;
}

.start-screen__left,
.start-screen__right {
  position: absolute;
  display: flex;
  align-items: center;
  justify-content: center;
}

.start-screen__left {
  z-index: 3;
}

.start-screen__left img,
.start-screen__right img {
  width: 100%;
  max-width: none;
  max-height: none;
  object-fit: contain;
}

.start-screen__center {
  position: absolute;
  z-index: 2;
  left: 33.45%;
  top: 11.8%;
  width: 35.35%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.start-screen__card-wrapper {
  position: relative;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.start-screen__card-branco {
  width: 100%;
  max-width: none;
  max-height: none;
  object-fit: contain;
}

.start-screen__card-content {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  padding: 0;
}

.start-screen__card-content img:first-child {
  position: absolute;
  left: 50%;
  top: 16.8%;
  transform: translateX(-50%);
  width: 52%;
  max-width: none;
  max-height: none;
  object-fit: contain;
  margin-top: 0;
}

.start-screen__logo-imbeta {
  position: absolute;
  left: 50%;
  bottom: 6.8%;
  transform: translateX(-50%);
  width: 14.5%;
  max-width: none;
  max-height: none;
  object-fit: contain;
  margin-top: 0;
}

.start-button {
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 0;
  position: absolute;
  left: 50%;
  top: 59%;
  width: 63.5%;
  transform: translateX(-50%);
}

.start-button__img,
.start-button__img-hover {
  max-width: none;
  max-height: none;
  object-fit: contain;
  transition: opacity 0.2s ease;
}

button#startButton > img.start-button__img {
  width: 214px;
  position: absolute;
  left: 12px;
}

button#startButton > img.start-button__img-hover {
  width: 214px;
  left: 118px;
}

.start-button__img-hover {
  position: absolute;
  top: 0;
  left: 0;
  opacity: 0;
}

.start-screen__left {
  left: 3.6%;
  bottom: 4.2%;
  width: 36%;
}

.start-screen__right {
  right: 3.8%;
  bottom: 5.6%;
  width: 35.4%;
}

.start-button:hover .start-button__img {
  opacity: 0;
}

.start-button:hover .start-button__img-hover {
  opacity: 1;
}

.game-screen {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

.game-screen.visible {
  display: block;
}

.game-screen.is-complete > .game-screen__bg,
.game-screen.is-complete > .game-screen__content,
.game-screen.is-complete > .message {
  filter: blur(10px);
}

.game-screen.is-complete > .game-screen__content,
.game-screen.is-complete > .message {
  pointer-events: none;
}

.game-screen__bg {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  z-index: 1;
}

.game-screen__content {
  position: relative;
  z-index: 2;
  display: flex;
  width: 100%;
  height: 100%;
  padding: 2rem;
  gap: 2rem;
}

.game-screen__left {
  flex: 0 0 35%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.5rem;
}

.game-screen__right {
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  justify-content: center;
}

.game-screen__logo {
  max-width: 80%;
  max-height: 25vh;
  object-fit: contain;
}

.game-screen__robo {
  max-width: 70%;
  max-height: 35vh;
  object-fit: contain;
}

.game-screen__stats {
  display: flex;
  flex-direction: row;
  gap: 0.75rem;
  width: 100%;
  max-width: 400px;
  justify-content: space-between;
}

.game-screen__stat {
  position: relative;
  width: calc((100% - 1.5rem) / 3);
  height: 90px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.25rem;
}

.game-screen__stat-bg {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  z-index: 1;
}

.game-screen__stat-label {
  position: relative;
  z-index: 2;
  font-family: monospace;
  color: white;
  font-size: 0.7rem;
  text-transform: uppercase;
  font-weight: bold;
  letter-spacing: 0.04em;
}

.game-screen__stat-value {
  position: relative;
  z-index: 2;
  font-family: monospace;
  color: white;
  font-size: 1.8rem;
  font-weight: bold;
  line-height: 1;
}

.restart-button {
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 0;
  position: relative;
  width: 100%;
  max-width: 400px;
}

.restart-button__img,
.restart-button__img-hover {
  width: 100%;
  max-width: 400px;
  object-fit: contain;
  transition: opacity 0.2s ease;
}

.restart-button__img-hover {
  position: absolute;
  top: 0;
  left: 0;
  opacity: 0;
}

.restart-button:hover .restart-button__img {
  opacity: 0;
}

.restart-button:hover .restart-button__img-hover {
  opacity: 1;
}

.message {
  position: relative;
  z-index: 2;
}

.game-complete-modal {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
}

.game-complete-modal[hidden] {
  display: none;
}

.game-complete-modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(16, 20, 55, 0.12);
}

.game-complete-modal__dialog {
  position: relative;
  width: min(92vw, 665px);
  aspect-ratio: 665 / 883;
}

.game-complete-modal__card {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.game-complete-modal__content {
  position: absolute;
  inset: 0;
  padding: 0;
}

.game-complete-modal__sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.game-complete-modal__stats {
  position: absolute;
  left: 50%;
  top: 26%;
  transform: translateX(-50%);
  display: flex;
  justify-content: center;
  gap: 1.4rem;
  width: calc(100% - 120px);
}

.game-complete-modal__stat {
  position: relative;
  width: min(100%, 182px);
  height: 112px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.3rem;
}

.game-complete-modal__stat-bg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: fill;
}

.game-complete-modal__stat-label,
.game-complete-modal__stat-value {
  position: relative;
  z-index: 1;
  font-family: monospace;
  font-weight: 700;
  text-transform: uppercase;
  color: #ffffff;
}

.game-complete-modal__stat-label {
  font-size: 0.92rem;
  letter-spacing: 0.04em;
}

.game-complete-modal__stat-value {
  font-size: 2.15rem;
  line-height: 1;
}

.game-complete-modal__actions {
  position: absolute;
  left: 50%;
  bottom: 13.5%;
  transform: translateX(-50%);
  width: calc(100% - 128px);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.3rem;
}

.game-complete-modal__button {
  width: min(100%, 545px);
  padding: 0;
  border: none;
  background: transparent;
  cursor: pointer;
}

.game-complete-modal__button img {
  width: 100%;
  height: auto;
  object-fit: contain;
}

.game-board {
  display: grid;
  grid-template-columns: repeat(4, minmax(100px, 1fr));
  gap: 1rem;
  width: 100%;
  max-width: 800px;
}

.memory-card {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  border: none;
  border-radius: 1rem;
  padding: 0;
  cursor: pointer;
  background: transparent;
  perspective: 1000px;
}

.card-face {
  position: absolute;
  inset: 0;
  border-radius: 1rem;
  overflow: hidden;
  background-size: cover;
  background-position: center;
  backface-visibility: hidden;
  transition: transform 0.45s ease;
}

.card-front {
  transform: rotateY(180deg);
}

.card-back {
  background-image: url("../assets/card-interrogacao.png");
  transform: rotateY(0deg);
}

.memory-card.is-flipped .card-front,
.memory-card.is-matched .card-front {
  transform: rotateY(0deg);
}

.memory-card.is-flipped .card-back,
.memory-card.is-matched .card-back {
  transform: rotateY(-180deg);
}

.memory-card.is-matched {
  cursor: default;
}

img {
  max-width: 100%;
  display: block;
}

@media (min-width: 1024px) and (max-width: 1440px), (min-width: 1024px) and (max-height: 900px) {
  .start-screen__content {
    width: min(960px, 92vw);
    height: auto;
    aspect-ratio: 1080 / 537;
  }

  .start-screen__center {
    left: 33.2%;
    top: 11.2%;
    width: 35.8%;
  }

  .start-screen__left {
    left: 2.6%;
    bottom: 3.6%;
    width: 37.5%;
  }

  .start-screen__right {
    right: 2.9%;
    bottom: 4.7%;
    width: 36.8%;
  }

  .start-button {
    top: 58.4%;
    width: 63%;
  }

  button#startButton > img.start-button__img,
  button#startButton > img.start-button__img-hover {
    width: 190px;
  }

  button#startButton > img.start-button__img {
    left: 10px;
  }

  button#startButton > img.start-button__img-hover {
    left: 104px;
  }

  .game-screen__content {
    padding: 1.3rem 1.5rem;
    gap: 1.2rem;
  }

  .game-screen__left {
    flex-basis: 34%;
    gap: 1rem;
  }

  .game-screen__logo {
    max-height: 20vh;
  }

  .game-screen__robo {
    max-height: 28vh;
  }

  .game-screen__stats,
  .restart-button,
  .restart-button__img,
  .restart-button__img-hover {
    max-width: 340px;
  }

  .game-screen__stat {
    height: 82px;
  }

  .game-screen__stat-label {
    font-size: 0.62rem;
  }

  .game-screen__stat-value {
    font-size: 1.58rem;
  }

  .game-board {
    max-width: 680px;
    gap: 0.8rem;
  }

  .game-complete-modal__dialog {
    width: min(78vw, 560px);
  }

  .game-complete-modal__stats {
    top: 27%;
    width: calc(100% - 96px);
    gap: 1rem;
  }

  .game-complete-modal__stat {
    width: min(100%, 156px);
    height: 98px;
  }

  .game-complete-modal__stat-label {
    font-size: 0.78rem;
  }

  .game-complete-modal__stat-value {
    font-size: 1.8rem;
  }

  .game-complete-modal__actions {
    width: calc(100% - 100px);
    bottom: 12.8%;
    gap: 1rem;
  }

  .game-complete-modal__button {
    width: min(100%, 455px);
  }
}

@media (max-width: 900px) {
  .game-screen__content {
    flex-direction: column;
  }

  .game-screen__left {
    flex: 0 0 auto;
    flex-direction: row;
    flex-wrap: wrap;
  }

  .game-screen__stats {
    flex-direction: row;
    flex-wrap: wrap;
  }

  .game-board {
    grid-template-columns: repeat(4, minmax(80px, 1fr));
  }
}

/* ===============================================
   MOBILE ONLY REDESIGN - GAME SCREEN
   =============================================== */
@media (max-width: 768px) {
  /* Hide desktop layout */
  .start-screen__left,
  .start-screen__right {
    display: none !important;
  }

  /* Game screen layout - Mobile version */
  .game-screen {
    background: linear-gradient(135deg, #efe24f 0%, #f0e84a 50%, #6b7fbd 100%);
    overflow: hidden;
  }

  .game-screen__bg {
    opacity: 0.3;
  }

  .game-screen__content {
    position: relative;
    flex-direction: column;
    padding: 0.5rem 0.25rem 140px 0.25rem;
    gap: 0.1rem;
    height: 100%;
    width: 100%;
    overflow-y: auto;
  }

  /* Header with logo */
  .game-screen__left {
    flex: 0 0 auto;
    flex-direction: column;
    gap: 0;
    width: 100%;
    padding: 0.25rem;
    justify-content: flex-start;
  }

  .game-screen__logo {
    display: block;
    width: 100%;
    max-width: 240px;
    max-height: 75px;
    margin: 0 auto;
    object-fit: contain;
  }

  .game-screen__robo {
    display: none;
  }

  /* Stats positioning - Bottom section */
  .game-screen__stats {
    position: fixed !important;
    bottom: 70px;
    left: 0;
    right: 0;
    flex-direction: row;
    gap: 0.4rem;
    width: calc(100% - 1rem);
    max-width: none;
    margin: 0;
    padding: 0 0.5rem;
    justify-content: space-between;
    display: flex !important;
    z-index: 10;
  }

  .game-screen__stat {
    width: calc((100% - 0.8rem) / 3);
    height: 65px;
    flex: 1;
  }

  .game-screen__stat-label {
    font-size: 0.6rem;
  }

  .game-screen__stat-value {
    font-size: 1.3rem;
  }

  /* Restart button - Bottom */
  .restart-button {
    position: fixed;
    bottom: 0.5rem;
    left: 0.5rem;
    right: 0.5rem;
    width: calc(100% - 1rem);
    max-width: none;
    height: auto;
    padding: 0;
    z-index: 10;
  }

  .restart-button__img,
  .restart-button__img-hover {
    width: 100%;
    max-width: none;
    object-fit: contain;
  }

  /* Game board - Center section */
  .game-screen__right {
    flex: 1;
    width: 100%;
    padding: 0;
    margin: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 400px;
  }

  .game-board {
    display: grid;
    grid-template-columns: repeat(4, 1fr) !important;
    gap: 0.3rem;
    width: 100%;
    max-width: 100% !important;
    height: fit-content;
    padding: 0;
  }

  .memory-card {
    border-radius: 0.7rem;
  }

  .card-face {
    border-radius: 0.7rem;
  }

  .game-complete-modal__dialog {
    width: min(90vw, 500px);
    aspect-ratio: auto;
  }

  .game-complete-modal__stats {
    position: relative;
    left: 0;
    top: 0;
    transform: none;
    width: 100%;
    padding: 1.5rem 1rem 1rem;
    flex-direction: row;
    gap: 1rem;
  }

  .game-complete-modal__stat {
    width: 100%;
    height: 80px;
  }

  .game-complete-modal__stat-label {
    font-size: 0.75rem;
  }

  .game-complete-modal__stat-value {
    font-size: 1.5rem;
  }

  .game-complete-modal__actions {
    position: relative;
    left: 0;
    bottom: 0;
    transform: none;
    width: 100%;
    padding: 1rem;
    gap: 0.8rem;
  }

  .game-complete-modal__button {
    width: 100%;
  }
}

@media (max-width: 600px) {
  .game-board {
    grid-template-columns: repeat(3, 1fr);
    gap: 0.6rem;
  }

  .memory-card {
    border-radius: 0.6rem;
  }

  .card-face {
    border-radius: 0.6rem;
  }

  .game-screen__content {
    padding: 0.75rem;
  }

  .game-screen__left {
    gap: 0.75rem;
  }

  .game-screen__robo {
    max-width: 30%;
  }

  .game-screen__stat {
    height: 60px;
  }

  .game-screen__stat-label {
    font-size: 0.55rem;
  }

  .game-screen__stat-value {
    font-size: 1.2rem;
  }

  .restart-button {
    max-width: 120px;
  }

  .restart-button__img,
  .restart-button__img-hover {
    max-width: 120px;
  }
}

@media (max-height: 600px) and (max-width: 900px) {
  .game-screen__robo {
    max-width: 25%;
    max-height: 15vh;
  }

  .game-board {
    max-height: 400px;
  }
}

/* ===============================================
   MOBILE ONLY REDESIGN - START SCREEN
   =============================================== */
@media (max-width: 768px) {
  .start-screen {
    background: linear-gradient(135deg, #efe24f 0%, #f0e84a 50%, #6b7fbd 100%);
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .start-screen__bg {
    opacity: 0.3;
  }

  .start-screen__content {
    position: relative;
    width: 85vw;
    max-width: 400px;
    height: auto;
    padding: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
  }

  /* Hide desktop elements */
  .start-screen__left,
  .start-screen__right {
    display: none !important;
  }

  .start-screen__center {
    position: relative;
    left: 0;
    top: 0;
    width: 100%;
    transform: none;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .start-screen__card-wrapper {
    position: relative;
    width: 100%;
    aspect-ratio: 9 / 11;
    background: white;
    border-radius: 40px;
    border: 8px solid #4a5b9a;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 30px 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  }

  .start-screen__card-branco {
    display: none;
  }

  .start-screen__card-content {
    position: relative;
    width: 100%;
    height: 100%;
    padding: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    top: 0;
    left: 0;
  }

  .start-screen__card-content img:first-child {
    position: relative;
    left: 0;
    top: 0;
    transform: none;
    width: 80%;
    max-width: 280px;
    height: auto;
    object-fit: contain;
    margin-top: 20px;
  }

  .start-screen__logo-imbeta {
    position: relative;
    left: 0;
    bottom: 0;
    transform: none;
    width: 50px;
    height: auto;
    object-fit: contain;
    margin-top: 0;
    margin-bottom: 15px;
  }

  .start-button {
    position: relative;
    left: 0;
    top: 0;
    width: 85%;
    max-width: 320px;
    transform: none;
    margin: 30px auto 0;
    padding: 0;
    border: none;
    background: transparent;
    cursor: pointer;
  }

  button#startButton > img.start-button__img,
  button#startButton > img.start-button__img-hover {
    width: 100%;
    position: relative;
    left: 0 !important;
    max-width: 320px;
  }

  button#startButton > img.start-button__img {
    display: block;
  }

  button#startButton > img.start-button__img-hover {
    position: absolute;
    opacity: 0;
  }

  .start-button:hover .start-button__img {
    opacity: 0;
  }

  .start-button:hover .start-button__img-hover {
    opacity: 1;
  }
}

@media (max-width: 600px) {
  .start-screen__card-wrapper {
    width: 90vw;
    max-width: 380px;
  }

  .start-screen__card-content img:first-child {
    width: 75%;
  }
}

/* Mobile layout approved for the portrait experience.
   Kept at the end of the file so no desktop rule is changed. */
@media (max-width: 768px) {
  .start-screen,
  .game-screen {
    width: 100%;
    height: 100%;
    height: 100dvh;
    min-height: 100%;
    overflow: hidden;
    background: #ffed4f;
  }

  .start-screen__bg,
  .game-screen__bg {
    width: 100%;
    height: 100%;
    opacity: 1;
    object-fit: fill;
  }

  /* The reference uses the curved blue/white artwork on both mobile screens. */
  .game-screen__bg {
    content: url("../assets/bg.png");
  }

  /* Start screen */
  .start-screen__content {
    position: relative;
    width: 100%;
    max-width: none;
    height: 100%;
    padding: 0;
    display: block;
  }

  .start-screen__center {
    position: absolute;
    left: 50%;
    top: 50%;
    width: min(68vw, 520px);
    transform: translate(-50%, -50%);
    display: block;
  }

  .start-screen__card-wrapper {
    position: relative;
    width: 100%;
    max-width: none;
    aspect-ratio: auto;
    padding: 0;
    display: block;
    overflow: visible;
    background: transparent;
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }

  .start-screen__card-branco {
    display: block;
    width: 100%;
    height: auto;
  }

  .start-screen__card-content {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    display: block;
  }

  .start-screen__card-content img:first-child {
    position: absolute;
    left: 50%;
    top: 16.8%;
    width: 52%;
    max-width: none;
    height: auto;
    margin: 0;
    transform: translateX(-50%);
  }

  .start-button {
    position: absolute;
    left: 50%;
    top: 59%;
    width: 63.5%;
    max-width: none;
    height: auto;
    margin: 0;
    transform: translateX(-50%);
  }

  button#startButton > img.start-button__img,
  button#startButton > img.start-button__img-hover {
    position: relative;
    left: 0 !important;
    top: 0;
    width: 100%;
    max-width: none;
    height: auto;
  }

  button#startButton > img.start-button__img-hover {
    position: absolute;
  }

  .start-screen__logo-imbeta {
    position: absolute;
    left: 50%;
    bottom: 6.8%;
    width: 14.5%;
    height: auto;
    margin: 0;
    transform: translateX(-50%);
  }

  /* Game screen */
  .game-screen__content {
    position: relative;
    width: 100%;
    height: 100%;
    padding: 0;
    display: block;
    overflow: hidden;
  }

  .game-screen__left,
  .game-screen__right {
    position: static;
    width: auto;
    height: auto;
    padding: 0;
    margin: 0;
    display: block;
  }

  .game-screen__logo {
    position: absolute;
    z-index: 2;
    left: 50%;
    top: 6.2%;
    width: 30%;
    max-width: 260px;
    max-height: none;
    margin: 0;
    transform: translateX(-50%);
  }

  .game-screen__robo {
    display: none;
  }

  .game-board {
    position: absolute;
    z-index: 2;
    left: 50%;
    top: 22%;
    width: 78%;
    max-width: 620px !important;
    padding: 0;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
    gap: clamp(3px, 0.8vw, 8px);
    transform: translateX(-50%);
  }

  .memory-card,
  .card-face {
    border-radius: clamp(5px, 1.5vw, 14px);
  }

  .game-screen__stats {
    position: absolute !important;
    z-index: 2;
    left: 50%;
    right: auto;
    bottom: auto;
    top: 72.5%;
    width: 69%;
    max-width: 560px;
    padding: 0;
    margin: 0;
    display: flex !important;
    flex-wrap: nowrap;
    gap: 2.8%;
    transform: translateX(-50%);
  }

  .game-screen__stat {
    flex: 1 1 0;
    width: auto;
    height: auto;
    aspect-ratio: 232 / 142;
    gap: 2%;
  }

  .game-screen__stat-bg {
    object-fit: fill;
  }

  .game-screen__stat-label {
    font-size: clamp(0.48rem, 2.1vw, 0.9rem);
  }

  .game-screen__stat-value {
    font-size: clamp(1rem, 4.5vw, 2rem);
  }

  .restart-button {
    position: absolute;
    z-index: 2;
    left: 50%;
    right: auto;
    bottom: auto;
    top: 81.2%;
    width: 69%;
    max-width: 560px;
    height: auto;
    padding: 0;
    transform: translateX(-50%);
  }

  .restart-button__img,
  .restart-button__img-hover {
    width: 100%;
    max-width: none;
  }

  /* Completion card: keep every control aligned to the artwork. */
  .game-complete-modal {
    position: fixed;
    inset: 0;
    padding: max(16px, env(safe-area-inset-top)) 16px
      max(16px, env(safe-area-inset-bottom));
  }

  .game-complete-modal__dialog {
    position: relative;
    width: min(88vw, 430px);
    max-height: 88dvh;
    aspect-ratio: 665 / 883;
  }

  .game-complete-modal__card {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
  }

  .game-complete-modal__content {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    padding: 0;
  }

  .game-complete-modal__stats {
    position: absolute;
    left: 50%;
    top: 26%;
    width: 69%;
    padding: 0;
    display: flex;
    flex-direction: row;
    gap: 5%;
    transform: translateX(-50%);
  }

  .game-complete-modal__stat {
    flex: 1 1 0;
    width: auto;
    height: auto;
    aspect-ratio: 182 / 112;
    gap: 2%;
  }

  .game-complete-modal__stat-label {
    font-size: clamp(0.55rem, 2.3vw, 0.78rem);
  }

  .game-complete-modal__stat-value {
    font-size: clamp(1.2rem, 5vw, 1.8rem);
  }

  .game-complete-modal__actions {
    position: absolute;
    left: 50%;
    bottom: 13.5%;
    width: 81%;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: clamp(8px, 2.5vw, 14px);
    transform: translateX(-50%);
  }

  .game-complete-modal__button {
    width: 100%;
  }
}

/* Keep all controls visible on unusually short phones and landscape mobile. */
@media (max-width: 768px) and (max-aspect-ratio: 1 / 2) {
  .game-board {
    top: 20%;
  }

  .game-screen__stats {
    top: 69%;
  }

  .restart-button {
    top: 78%;
  }
}
