:root {
  --bg-top: #f4efe8;
  --bg-bottom: #e2ebe3;
  --panel: #fcfbf8;
  --line: rgba(55, 66, 63, 0.14);
  --text: #25302e;
  --muted: #5c6864;
  --accent: #7a6530;
  --accent-dark: #5d4b22;
  --shadow: 0 14px 34px rgba(33, 48, 58, 0.1);
  --radius: 26px;
  --board-radius: 32px;
  --card-size: min(13.5vh, 126px);
  --font-main: "Trebuchet MS", "Segoe UI", Tahoma, sans-serif;
  --font-display: Georgia, "Times New Roman", serif;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  margin: 0;
  width: 100%;
  height: 100%;
  font-family: var(--font-main);
  color: var(--text);
  background: linear-gradient(180deg, var(--bg-top), var(--bg-bottom));
}

body {
  min-height: 100vh;
  overflow: hidden;
}

.reload-hotspot {
  position: fixed;
  top: 0;
  right: 0;
  width: 96px;
  height: 96px;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  opacity: 0.01;
  z-index: 20;
}

.page-shell {
  width: min(1920px, 100vw);
  min-height: 100vh;
  margin: 0 auto;
  padding: 10px 10px 82px;
}

.layout {
  display: grid;
  grid-template-columns: minmax(315px, 390px) minmax(0, 1fr);
  gap: 12px;
  min-height: calc(100vh - 32px);
}

.panel-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
  padding: 16px;
}

.side-panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow: auto;
}

.side-main {
  display: grid;
  gap: 12px;
  align-content: start;
}

.eyebrow {
  margin: 0 0 10px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--accent-dark);
  font-size: 0.85rem;
  font-weight: 700;
}

.brand-block h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(2.7rem, 4vw, 4.5rem);
  line-height: 0.9;
}

button {
  border: none;
  border-radius: 18px;
  font-family: inherit;
  font-size: 1.05rem;
  font-weight: 700;
  cursor: pointer;
  padding: 15px 16px;
  transition: transform 0.14s ease, box-shadow 0.14s ease, filter 0.14s ease;
}

button:hover,
button:focus-visible {
  transform: translateY(-1px);
  filter: brightness(1.02);
  outline: none;
}

.primary-button {
  background: linear-gradient(180deg, var(--accent), var(--accent-dark));
  color: #fff;
  box-shadow: 0 16px 26px rgba(122, 101, 48, 0.25);
}

.secondary-button {
  background: #ffffff;
  color: var(--text);
  border: 1px solid var(--line);
  box-shadow: 0 8px 18px rgba(33, 48, 58, 0.06);
}

.exit-link {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: auto;
  min-height: 66px;
  border-radius: 18px;
  background: linear-gradient(180deg, #455560, #29353d);
  color: #ffffff;
  text-decoration: none;
  font-size: 1.15rem;
  font-weight: 700;
  box-shadow: 0 12px 22px rgba(33, 48, 58, 0.2);
}

.exit-link:hover,
.exit-link:focus-visible {
  filter: brightness(1.04);
  outline: none;
}

.actions-block {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.action-wide {
  grid-column: 1 / -1;
}

.stats-card h2,
.info-card h2 {
  font-size: 1.1rem;
  margin: 0 0 8px;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.stat-box {
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #ffffff;
  padding: 10px 12px;
  min-width: 0;
}

.stat-label {
  display: block;
  color: var(--muted);
  margin-bottom: 4px;
}

.stat-box strong {
  font-size: 1.45rem;
  line-height: 1;
}

.info-card p,
.status-message {
  margin: 0;
  color: var(--muted);
  line-height: 1.4;
}

.info-card p + p {
  margin-top: 8px;
}

.board-panel {
  display: grid;
  place-items: center;
  overflow: hidden;
}

.board-wrap {
  display: grid;
  place-items: center;
  width: 100%;
  min-height: 100%;
}

.board {
  display: grid;
  grid-template-columns: repeat(4, var(--card-size));
  gap: 12px;
  justify-content: center;
  padding: 18px;
  border-radius: var(--board-radius);
  background: linear-gradient(180deg, #5b7f72, #3f6459);
  border: 4px solid rgba(255, 255, 255, 0.16);
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.07);
}

.board.hard {
  grid-template-columns: repeat(6, var(--card-size));
}

.memory-card {
  width: var(--card-size);
  height: var(--card-size);
  padding: 0;
  border-radius: 22px;
  background: transparent;
  perspective: 800px;
}

.card-inner {
  position: relative;
  display: block;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  transition: transform 0.28s ease;
}

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

.card-face {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  border-radius: 22px;
  backface-visibility: hidden;
  border: 1px solid rgba(37, 48, 46, 0.16);
  box-shadow: 0 12px 22px rgba(18, 34, 29, 0.18);
}

.card-back {
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.2) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.2) 50%, rgba(255, 255, 255, 0.2) 75%, transparent 75%, transparent),
    linear-gradient(180deg, #f5eee0, #d8c494);
  background-size: 22px 22px, auto;
  color: rgba(93, 75, 34, 0.65);
  font-size: 2.1rem;
}

.card-front {
  transform: rotateY(180deg);
  background: #ffffff;
  font-size: clamp(2.8rem, 7vh, 4.9rem);
  line-height: 1;
}

.symbol-sun { color: #d99b18; }
.symbol-moon { color: #5c6fb5; }
.symbol-star { color: #d8b322; }
.symbol-heart { color: #c63a4b; }
.symbol-leaf { color: #328f55; }
.symbol-wave { color: #2479a7; }
.symbol-key { color: #8462a9; }
.symbol-cup { color: #b0642d; }
.symbol-bell { color: #c27f28; }
.symbol-book { color: #3f6f88; }
.symbol-home { color: #7b6a35; }
.symbol-flag { color: #b74769; }

.memory-card.matched .card-front {
  background: linear-gradient(180deg, #fff2bd, #f0d978);
}

.memory-card.hint .card-back {
  outline: 5px solid #ffe28a;
  outline-offset: 3px;
  animation: hintPulse 0.8s ease-in-out infinite;
}

@keyframes hintPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.04); }
}

@media (max-width: 1280px) {
  :root {
    --card-size: min(12.2vh, 104px);
  }
}

@media (max-width: 1080px) {
  body {
    overflow: auto;
  }

  .layout {
    grid-template-columns: 1fr;
    min-height: auto;
  }

  .actions-block,
  .stat-grid {
    grid-template-columns: 1fr;
  }

  :root {
    --card-size: min(16vw, 104px);
  }
}

@media (max-width: 720px) {
  :root {
    --card-size: min(20vw, 82px);
  }

  .page-shell {
    width: min(100%, calc(100% - 16px));
    padding: 10px 8px;
  }

  .panel-card {
    padding: 16px;
  }

  .board,
  .board.hard {
    grid-template-columns: repeat(4, var(--card-size));
    gap: 8px;
    padding: 12px;
  }
}
