@font-face {
  font-family: "DM Sans";
  src: url("assets/fonts/DMSans-Variable.woff2") format("woff2");
  font-weight: 400 800;
  font-display: swap;
}

@font-face {
  font-family: "Playfair Display";
  src: url("assets/fonts/PlayfairDisplay-Variable.ttf") format("truetype");
  font-weight: 600 900;
  font-display: swap;
}

:root {
  --cream: #FAF6EF;
  --ink: #1C1A18;
  --gold: #C9922A;
  --gold-d: #A9781D;
  --gold-text: #8B5E10;
  --muted: #636058;
  --line: #E7DFD2;
  --card: #FFFDF8;
  --green: #173D2D;
  --mango: #F26922;
  --mango-text: #A63F0E;
  --white: #FFFFFF;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  font-size: 18px;
  background: var(--cream);
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 14% 8%, rgb(242 105 34 / 12%), transparent 28%),
    radial-gradient(circle at 88% 88%, rgb(201 146 42 / 13%), transparent 32%),
    var(--cream);
  font-family: "DM Sans", system-ui, sans-serif;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

button,
a {
  min-height: 62px;
  font: inherit;
}

button:focus-visible,
a:focus-visible {
  outline: 3px solid var(--gold);
  outline-offset: 4px;
  box-shadow: 0 0 0 9px var(--green);
}

[hidden] {
  display: none !important;
}

.app-shell {
  width: min(100%, 920px);
  min-height: 100vh;
  margin: 0 auto;
  padding: clamp(20px, 4vw, 40px);
}

.screen {
  min-height: calc(100vh - clamp(40px, 8vw, 80px));
}

.screen.is-active {
  display: grid;
}

.screen-attract,
.screen-result {
  align-content: center;
  justify-items: center;
  gap: 18px;
  text-align: center;
}

.logo-plaque {
  width: min(100%, 430px);
  padding: 10px 18px;
  border: 1px solid rgb(28 26 24 / 8%);
  border-radius: 22px;
  background: var(--white);
  box-shadow: 0 16px 38px rgb(28 26 24 / 8%);
}

.summit-logo {
  display: block;
  width: 100%;
  height: auto;
}

.hero-copy {
  max-width: 680px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--gold-text);
  font-weight: 800;
  letter-spacing: .12em;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  color: var(--green);
  font-family: "Playfair Display", Georgia, serif;
  font-weight: 850;
  line-height: 1.05;
  text-wrap: balance;
}

h1 {
  font-size: clamp(2.25rem, 6vw, 4.6rem);
}

h2 {
  font-size: clamp(2rem, 5vw, 3.5rem);
}

.intro {
  max-width: 580px;
  margin: 18px auto 6px;
  color: var(--muted);
  font-size: clamp(1rem, 2.2vw, 1.2rem);
}

.brand-line {
  margin: 4px 0 0;
  color: var(--mango-text);
  font-family: "Playfair Display", Georgia, serif;
  font-size: 1.2rem;
  font-style: italic;
  font-weight: 700;
}

.best-time {
  margin: 0;
  color: var(--green);
  font-weight: 750;
}

.button {
  display: inline-flex;
  min-width: min(100%, 280px);
  align-items: center;
  justify-content: center;
  border-radius: 16px;
  padding: 16px 24px;
  font-weight: 800;
  text-decoration: none;
  cursor: pointer;
}

.button-primary {
  border: 2px solid var(--green);
  color: var(--white);
  background: var(--green);
  box-shadow: 0 12px 26px rgb(23 61 45 / 20%);
}

.button-primary:disabled {
  cursor: wait;
  opacity: .56;
}

.button-secondary {
  border: 2px solid var(--green);
  color: var(--green);
  background: transparent;
}

.load-status,
.draw-note,
.handoff-note {
  max-width: 560px;
  margin: 0;
  color: var(--muted);
}

.game-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 18px;
}

.screen-game.is-active {
  grid-template-rows: auto minmax(0, 1fr);
  gap: 10px;
}

.game-board {
  display: grid;
  height: min(70vh, 610px);
  min-height: 430px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  grid-template-rows: repeat(3, minmax(0, 1fr));
  gap: clamp(10px, 1.8vw, 18px);
}

.mango-card {
  position: relative;
  min-width: 60px;
  min-height: 60px;
  padding: 0;
  border: 0;
  border-radius: 18px;
  background: transparent;
  perspective: 900px;
  touch-action: manipulation;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.mango-card:disabled {
  cursor: default;
  opacity: 1;
}

.card-inner {
  position: absolute;
  inset: 0;
  transform-style: preserve-3d;
  transition: transform 220ms ease;
}

.mango-card.is-face-up .card-inner,
.mango-card.is-matched .card-inner {
  transform: rotateY(180deg);
}

.card-front,
.card-back {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  overflow: hidden;
  border: 2px solid var(--line);
  border-radius: 18px;
  backface-visibility: hidden;
  box-shadow: 0 8px 24px rgb(28 26 24 / 12%);
}

.card-back {
  border-color: var(--gold);
  background:
    radial-gradient(circle at 50% 43%, var(--mango) 0 15%, transparent 16%),
    linear-gradient(145deg, #214E3B, var(--green));
}

.card-back::before {
  width: 46%;
  aspect-ratio: 1;
  border: 1px solid rgb(201 146 42 / 78%);
  border-radius: 50%;
  box-shadow:
    0 0 0 7px rgb(23 61 45 / 88%),
    0 0 0 8px rgb(201 146 42 / 34%);
  content: "";
}

.card-back::after {
  position: absolute;
  width: 44%;
  height: 28%;
  border: 2px solid rgb(201 146 42 / 82%);
  border-width: 2px 0 0 2px;
  border-radius: 70% 0 70% 0;
  content: "";
  transform: translate(18%, 30%) rotate(24deg);
}

.card-front {
  grid-template-rows: minmax(0, 7fr) minmax(58px, 3fr);
  padding: 7px;
  border-color: var(--gold);
  background: var(--card);
  transform: rotateY(180deg);
}

.card-front img {
  width: 100%;
  height: 100%;
  min-height: 0;
  border-radius: 12px 12px 8px 8px;
  object-fit: cover;
}

.mango-label {
  position: relative;
  display: grid;
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  padding: 5px 9px 2px;
  overflow: hidden;
  background: var(--card);
  text-align: left;
}

.mango-label::after {
  position: absolute;
  right: -20px;
  bottom: -30px;
  width: 74px;
  height: 74px;
  border: 1px solid rgb(139 94 16 / 28%);
  border-radius: 68% 0 68% 0;
  content: "";
  transform: rotate(-24deg);
}

.mango-copy {
  display: grid;
  min-width: 0;
}

.card-provenance {
  color: var(--gold-text);
  font-size: clamp(.67rem, 1.25vw, .78rem);
  font-weight: 850;
  letter-spacing: .11em;
  line-height: 1;
  text-transform: uppercase;
}

.mango-name {
  min-width: 0;
  color: var(--green);
  font-family: "Playfair Display", Georgia, serif;
  font-size: clamp(1rem, 2.2vw, 1.35rem);
  font-weight: 850;
  line-height: 1.05;
  overflow-wrap: anywhere;
  white-space: normal;
}

.card-number {
  z-index: 1;
  color: var(--gold-text);
  font-family: "Playfair Display", Georgia, serif;
  font-size: clamp(.78rem, 1.6vw, 1rem);
  font-style: italic;
  white-space: nowrap;
}

.mango-card.is-matched .card-front {
  border-color: var(--gold);
  box-shadow: 0 0 0 4px rgb(201 146 42 / 28%);
}

.mango-card.is-matched::after {
  position: absolute;
  z-index: 3;
  top: 8px;
  right: 8px;
  display: grid;
  width: 30px;
  height: 30px;
  place-items: center;
  border-radius: 50%;
  color: var(--white);
  background: var(--green);
  content: "✓";
  font-size: 16px;
  font-weight: 800;
}

.game-stat {
  display: grid;
}

.game-stat span {
  color: var(--muted);
  font-size: 1rem;
  font-weight: 750;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.game-stat strong {
  color: var(--green);
  font-family: "Playfair Display", Georgia, serif;
  font-size: clamp(1.65rem, 4vw, 2.4rem);
}

.game-stat-right {
  text-align: right;
}

.result-mark {
  display: grid;
  width: 76px;
  height: 76px;
  place-items: center;
  border-radius: 50%;
  color: var(--white);
  background: var(--green);
  font-size: 2rem;
  font-weight: 800;
  box-shadow: 0 12px 30px rgb(23 61 45 / 18%);
}

.result-score {
  display: grid;
  margin: 4px 0;
  color: var(--muted);
}

.result-score strong {
  color: var(--mango-text);
  font-family: "Playfair Display", Georgia, serif;
  font-size: clamp(2.2rem, 7vw, 4rem);
  line-height: 1;
}

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

@media (max-width: 1100px) {
  .card-provenance {
    letter-spacing: .08em;
  }

  .mango-name {
    font-size: 1rem;
  }
}

@media (max-width: 520px) {
  .app-shell {
    padding: 18px;
  }

  .logo-plaque {
    width: min(100%, 330px);
  }

  .mango-label {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-rows: auto minmax(0, 1fr);
    gap: 0 4px;
    padding: 3px 6px 2px;
  }

  .mango-copy {
    display: contents;
  }

  .card-provenance {
    grid-row: 1;
    grid-column: 1;
    padding-right: 0;
    font-size: .58rem;
    letter-spacing: .07em;
    white-space: nowrap;
  }

  .mango-name {
    grid-row: 2;
    grid-column: 1 / -1;
    letter-spacing: normal;
    line-height: 1;
    white-space: nowrap;
  }

  .card-number {
    position: static;
    grid-row: 1;
    grid-column: 2;
    align-self: start;
    font-size: .64rem;
  }
}

@media (orientation: portrait) and (max-width: 800px) {
  .game-board {
    height: min(76vh, 730px);
    min-height: 560px;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    grid-template-rows: repeat(4, minmax(0, 1fr));
  }
}

@media (max-width: 520px) {
  .screen-game {
    min-height: calc(100vh - 36px);
  }

  .game-board {
    height: min(83vh, 710px);
    min-height: 0;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-template-rows: repeat(6, minmax(0, 1fr));
    gap: 8px;
  }

  .card-front {
    grid-template-rows: minmax(0, 1fr) 44px;
  }

  .mango-card,
  .card-front,
  .card-back {
    border-radius: 14px;
  }

  .mango-card.is-matched::after {
    top: 5px;
    right: 5px;
    width: 25px;
    height: 25px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: .01ms !important;
    animation-duration: .01ms !important;
  }
}
