:root {
  --bg-top: #fcf8e5;
  --bg-bottom: #ecf7e6;
  --panel: #fffffa;
  --ink: #363e2d;
  --text: #40463a;
  --muted: #697460;
  --button: #fcc052;
  --button-hover: #ffd370;
  --button-edge: #9a6223;
  --card-back: #4ca97e;
  --card-back-dark: #1f705e;
  --card-edge: #e5cc97;
  --success: #47aa5f;
  --warning: #d2563c;
  --shadow: 0 16px 34px rgba(87, 76, 46, 0.18);
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  background:
    radial-gradient(circle at 7% 14%, rgba(255, 224, 136, 0.9) 0 44px, transparent 45px),
    radial-gradient(circle at 92% 13%, rgba(245, 118, 93, 0.85) 0 54px, transparent 55px),
    linear-gradient(180deg, var(--bg-top), var(--bg-bottom));
  color: var(--ink);
  font-family: Inter, Arial, sans-serif;
}

button,
a {
  font: inherit;
}

.game-shell {
  width: min(1120px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 24px 0 40px;
}

.hero {
  display: grid;
  justify-items: center;
  gap: 8px;
  position: relative;
  margin-bottom: 24px;
}

.back-link {
  position: absolute;
  left: 0;
  top: 10px;
  color: var(--muted);
  font-weight: 800;
  text-decoration: none;
}

.logo {
  width: min(520px, 90vw);
  max-height: 190px;
  object-fit: contain;
}

.hero p {
  margin: 0;
  color: var(--muted);
  font-size: 1.1rem;
  font-weight: 700;
}

.menu {
  display: grid;
  grid-template-columns: minmax(230px, 0.8fr) minmax(280px, 0.9fr) minmax(260px, 0.8fr);
  gap: 18px;
  align-items: start;
}

.panel,
.hud {
  background: var(--panel);
  border: 2px solid var(--card-edge);
  border-radius: 18px;
  box-shadow: var(--shadow);
}

.panel {
  padding: 24px;
}

.eyebrow {
  margin: 0 0 16px;
  color: var(--button-edge);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.difficulty-options,
.menu-actions,
.victory-actions {
  display: grid;
  gap: 12px;
}

button {
  min-height: 48px;
  padding: 0 18px;
  background: var(--button);
  border: 2px solid var(--button-edge);
  border-radius: 16px;
  color: #392b18;
  cursor: pointer;
  font-weight: 800;
  box-shadow: 0 5px 0 rgba(205, 137, 52, 0.9);
}

button:hover {
  background: var(--button-hover);
  transform: translateY(-2px);
}

button.active,
.primary {
  background: var(--button-hover);
}

.ranking-panel ol,
.victory ol {
  display: grid;
  gap: 10px;
  margin: 0;
  padding-left: 22px;
  color: var(--text);
  font-weight: 700;
}

.empty-ranking {
  color: var(--muted);
  font-weight: 700;
}

.hud {
  display: grid;
  grid-template-columns: repeat(3, minmax(120px, 1fr)) auto auto;
  gap: 12px;
  align-items: center;
  margin-bottom: 20px;
  padding: 14px 18px;
}

.hud span {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.hud strong {
  font-size: 1.25rem;
}

.board {
  display: grid;
  gap: 14px;
  justify-content: center;
}

.card {
  width: min(122px, 18vw);
  aspect-ratio: 0.82;
  position: relative;
  display: grid;
  place-items: center;
  background: var(--card-back-dark);
  border: 0;
  border-radius: 20px;
  box-shadow: 0 8px 0 rgba(195, 181, 139, 0.9);
  cursor: pointer;
  overflow: hidden;
  transition: transform 180ms ease, filter 180ms ease;
}

.card::before {
  content: "";
  position: absolute;
  inset: 8px;
  background:
    radial-gradient(circle at 50% 50%, #b9efc0 0 12px, transparent 13px),
    radial-gradient(circle at 28% 50%, #ffdf74 0 8px, transparent 9px),
    radial-gradient(circle at 72% 50%, #ffdf74 0 8px, transparent 9px),
    var(--card-back);
  border-radius: 16px;
}

.card:hover {
  filter: brightness(1.05);
  transform: translateY(-3px);
}

.card.revealed,
.card.matched {
  background: var(--card-edge);
  cursor: default;
}

.card.revealed::before,
.card.matched::before {
  inset: 7px;
  background: #fffffa;
}

.card.matched {
  outline: 4px solid var(--success);
}

.fruit {
  width: 62%;
  height: 62%;
  z-index: 1;
  object-fit: contain;
}

.fruit-name {
  z-index: 1;
  position: absolute;
  bottom: 12px;
  left: 8px;
  right: 8px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  text-align: center;
}

.instructions,
.victory {
  width: min(700px, 100%);
  margin: 0 auto;
}

.instructions h1,
.victory h1 {
  margin: 0 0 18px;
  font-size: clamp(2rem, 5vw, 3.5rem);
}

.instructions li {
  margin: 12px 0;
  color: var(--text);
  font-weight: 700;
}

.victory p {
  color: var(--text);
  font-size: 1.1rem;
  font-weight: 700;
}

.hidden {
  display: none;
}

@media (max-width: 820px) {
  .menu,
  .hud {
    grid-template-columns: 1fr;
  }

  .back-link {
    position: static;
    justify-self: start;
  }

  .card {
    width: min(98px, 21vw);
  }
}
