:root {
  --ink: #393322;
  --mustard: #c5a044;
  --mustard-dark: #755916;
  --paper: #fffdf7;
  --muted: #706b5f;
  --line: #ded8c8;
  --shadow: 0 28px 70px rgba(57, 51, 34, .12);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(circle at 14% 8%, rgba(197, 160, 68, .13), transparent 24rem),
    linear-gradient(180deg, #fbf9f2 0%, #eee9db 100%);
  font-family: "Segoe UI", Arial, sans-serif;
}
button, a, input { font: inherit; }
button { color: inherit; }
a:focus-visible, input:focus-visible { outline: 3px solid var(--mustard-dark); outline-offset: 3px; }
.page-shell { width: min(1180px, calc(100% - 44px)); margin: 0 auto; }
.site-header {
  min-height: 80px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  border-bottom: 1px solid var(--line);
}
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--ink);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .16em;
  line-height: 1.5;
  text-decoration: none;
}
.brand-mark {
  display: grid;
  width: 38px;
  height: 38px;
  flex-shrink: 0;
  place-items: center;
  color: var(--ink);
  background: var(--mustard);
  border: 2px solid var(--mustard-dark);
  border-radius: 50%;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 23px;
  letter-spacing: 0;
}
.arcade-link {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .08em;
  text-decoration: none;
  text-transform: uppercase;
}
.arcade-link:hover { color: var(--mustard-dark); }
.best-badge { display: flex; align-items: center; gap: 14px; color: var(--muted); font-size: 11px; letter-spacing: .12em; }
.best-badge strong {
  min-width: 64px;
  padding: 7px 11px;
  color: var(--ink);
  background: rgba(57, 51, 34, .04);
  border: 1px solid var(--line);
  border-radius: 4px;
  font-size: 14px;
  letter-spacing: .05em;
  text-align: center;
}
main { padding: 24px 0 30px; }
.game-panel {
  overflow: hidden;
  max-width: 800px;
  margin: 0 auto;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}
.game-toolbar {
  min-height: 80px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 16px;
  padding: 0 28px;
  border-bottom: 1px solid var(--line);
}
.round-label { display: flex; align-items: center; gap: 11px; }
.status-dot { width: 8px; height: 8px; flex-shrink: 0; background: var(--mustard); border-radius: 50%; box-shadow: 0 0 0 4px rgba(197, 160, 68, .15); }
.round-label div, .timer-wrap, .progress-text { display: flex; flex-direction: column; }
.round-label span:not(.status-dot), .timer-wrap span, .progress-text span { color: var(--muted); font-size: 10px; font-weight: 700; letter-spacing: .13em; }
.round-label strong { margin-top: 3px; font-size: 12px; letter-spacing: .06em; }
.timer-wrap { align-items: center; }
.timer-wrap strong { margin-top: 1px; font-size: 25px; font-variant-numeric: tabular-nums; letter-spacing: .08em; }
.timer-wrap.danger strong { color: #a42b26; }
.icon-button {
  justify-self: end;
  min-height: 44px;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 10px 14px;
  color: var(--paper);
  background: var(--ink);
  border: 2px solid var(--mustard);
  border-radius: 4px;
  box-shadow: 0 5px 14px rgba(57, 51, 34, .15);
  cursor: pointer;
  transition: background 160ms, transform 160ms;
}
.icon-button:hover { background: var(--mustard-dark); transform: translateY(-1px); }
.icon-button:focus-visible { outline: 3px solid var(--mustard-dark); outline-offset: 3px; }
.icon-button:disabled { opacity: .55; cursor: wait; }
.icon-button span { font-size: 11px; font-weight: 700; letter-spacing: .07em; white-space: nowrap; }
.icon-button svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 2; }
.board-wrap { position: relative; min-height: 610px; padding: 28px; }
.board { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; max-width: 630px; margin: 0 auto; }
.matches-panel { max-width: 630px; margin: 20px auto 0; padding: 18px; background: rgba(57, 51, 34, .025); border: 1px solid var(--line); border-radius: 5px; }
.matches-heading { display: flex; flex-direction: column; padding-bottom: 12px; border-bottom: 1px solid var(--line); }
.matches-heading span { color: var(--muted); font-size: 9px; font-weight: 700; letter-spacing: .16em; }
.matches-heading strong { margin-top: 3px; font-size: 12px; letter-spacing: .07em; }
.matches-empty { margin: 16px 0 0; color: var(--muted); font-size: 12px; line-height: 1.5; }
.matches-list { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; margin: 14px 0 0; padding: 0; list-style: none; }
.matches-list li { display: flex; flex-direction: column; justify-content: center; min-width: 0; min-height: 54px; padding: 6px 9px; background: var(--paper); border: 1px solid var(--line); border-radius: 4px; }
.matches-list li strong { color: var(--mustard-dark); font-size: 15px; overflow-wrap: anywhere; }
.matches-list li span { color: var(--ink); font-size: 11px; overflow-wrap: anywhere; }
.card {
  position: relative;
  min-width: 0;
  min-height: 86px;
  aspect-ratio: 2.25;
  padding: 0;
  border: 0;
  background: transparent;
  perspective: 700px;
  cursor: pointer;
  user-select: none;
  touch-action: manipulation;
  transition: opacity 220ms, transform 220ms, visibility 0s 220ms;
}
.card:focus-visible { outline: 3px solid var(--mustard-dark); outline-offset: 3px; border-radius: 5px; }
.card-inner { position: absolute; inset: 0; transform-style: preserve-3d; transition: transform 440ms cubic-bezier(.2, .72, .25, 1); }
.card.is-flipped .card-inner, .card.is-matched .card-inner { transform: rotateY(180deg); }
.card-face { position: absolute; inset: 0; display: grid; place-items: center; overflow: hidden; padding: 8px; border-radius: 5px; backface-visibility: hidden; }
.card-front {
  color: #332b17;
  background:
    linear-gradient(135deg, transparent 46%, rgba(255,255,255,.1) 46%, rgba(255,255,255,.1) 48%, transparent 48%),
    var(--mustard);
  border: 1px solid #ab8732;
  box-shadow: inset 0 0 0 3px rgba(255,255,255,.09), 0 3px 7px rgba(117, 89, 22, .18);
}
.card-front::before { content: ""; position: absolute; inset: 7px; border: 1px solid rgba(255, 253, 247, .4); border-radius: 2px; }
.card-number { font-family: Georgia, "Times New Roman", serif; font-size: clamp(24px, 4vw, 36px); }
.card-back {
  transform: rotateY(180deg);
  color: var(--ink);
  background: #fffefa;
  border: 1px solid #bfb49b;
  box-shadow: inset 0 0 0 4px #f2eddc;
  font-size: clamp(15px, 2.5vw, 21px);
  font-weight: 600;
  line-height: 1.25;
  overflow-wrap: anywhere;
  text-align: center;
}
.card-back.is-russian { color: var(--mustard-dark); font-size: clamp(16px, 2.7vw, 23px); }
.card-back.is-english { font-size: clamp(14px, 2.3vw, 19px); }
.card-back.is-decoy { color: var(--mustard-dark); padding: 4px 8px 12px; font-size: 64px; line-height: 1; }
.card.is-matched { cursor: default; }
.card.is-cleared { visibility: hidden; opacity: 0; transform: scale(.88); }
.card.is-matched .card-back { color: #28513d; background: #f3faf4; border: 3px solid #518164; animation: match-flash 500ms ease-in-out 2; }
@keyframes match-flash {
  0%, 100% { box-shadow: inset 0 0 0 3px rgba(81, 129, 100, .12), 0 0 0 0 rgba(81, 129, 100, .3); }
  50% { box-shadow: inset 0 0 0 3px rgba(81, 129, 100, .2), 0 0 0 5px rgba(81, 129, 100, .2); }
}
.start-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  flex-direction: column;
  padding: 28px;
  background: rgba(255, 253, 247, .96);
  text-align: center;
  opacity: 1;
  overflow-y: auto;
  transition: opacity 220ms, visibility 220ms;
  backdrop-filter: blur(7px);
}
.start-overlay.is-hidden { visibility: hidden; opacity: 0; }
.start-overlay h1 { margin: 0 0 12px; font-family: Georgia, "Times New Roman", serif; font-size: 30px; line-height: 1.2; font-weight: 500; }
.start-overlay p { max-width: 490px; margin: 0 0 20px; color: var(--muted); font-size: 14px; line-height: 1.6; }
.vocabulary-reference { width: min(650px, 100%); margin: 0 0 12px; padding: 14px; background: rgba(197, 160, 68, .045); border: 1px solid var(--line); border-radius: 5px; }
.vocabulary-reference label, .round-matches > span { color: var(--muted); font-size: 10px; font-weight: 700; letter-spacing: .14em; }
.vocabulary-reference input { display: block; width: 100%; min-height: 40px; margin: 12px 0; padding: 9px 12px; color: var(--ink); background: var(--paper); border: 1px solid #bfb49b; border-radius: 4px; font-size: 14px; }
.vocabulary-reference ol { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; max-height: 252px; margin: 10px 0 0; padding: 2px 8px 2px 2px; overflow-y: auto; scrollbar-color: var(--mustard) #efe9d9; scrollbar-width: thin; list-style: none; }
.vocabulary-reference li { display: flex; flex-direction: column; justify-content: center; gap: 3px; min-width: 0; min-height: 58px; padding: 8px 10px; background: var(--paper); border: 1px solid var(--line); border-radius: 3px; text-align: left; overflow-wrap: anywhere; }
.vocabulary-reference li strong { color: var(--mustard-dark); font-size: 16px; }
.vocabulary-reference li span { color: var(--muted); font-size: 13px; }
.round-matches { width: min(540px, 100%); margin: 0 0 20px; padding: 14px; background: rgba(197, 160, 68, .05); border: 1px solid var(--line); border-radius: 5px; }
.round-matches ol { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin: 10px 0 0; padding: 0; list-style: none; }
.round-matches li { display: flex; flex-direction: column; gap: 4px; min-height: 60px; padding: 9px 14px; background: var(--paper); border: 1px solid var(--line); border-radius: 3px; text-align: left; overflow-wrap: anywhere; }
.round-matches li strong { color: var(--mustard-dark); font-size: 17px; }
.round-matches li span { color: var(--muted); font-size: 14px; }
.game-footer { min-height: 62px; display: flex; align-items: center; gap: 24px; padding: 12px 28px; border-top: 1px solid var(--line); color: var(--muted); font-size: 10px; }
.game-footer p { display: flex; align-items: center; gap: 7px; margin: 0; }
.legend-card, .legend-decoy { display: grid; width: 20px; height: 20px; flex-shrink: 0; place-items: center; color: var(--ink); background: #ecdbac; border-radius: 2px; font-size: 12px; }
.progress-text { align-items: flex-end; margin-left: auto; white-space: nowrap; }
.progress-text strong { color: var(--ink); font-size: 13px; }
footer { display: flex; align-items: center; gap: 18px; padding: 20px 0 30px; color: var(--muted); font-size: 9px; font-weight: 600; letter-spacing: .15em; }
.footer-line { flex: 1; height: 1px; background: var(--line); }
.noscript-message { text-align: center; padding: 20px; }

@media (max-width: 700px) {
  .page-shell { width: calc(100% - 24px); }
  .site-header { min-height: 76px; flex-wrap: wrap; gap: 12px; padding: 10px 0; }
  .brand { font-size: 10px; }
  .arcade-link { order: 3; width: 100%; justify-content: center; font-size: 10px; }
  .best-badge > span { display: none; }
  main { padding-top: 14px; }
  .game-toolbar { min-height: 70px; padding: 0 14px; gap: 8px; }
  .round-label span:not(.status-dot) { display: none; }
  .round-label strong { font-size: 10px; }
  .status-dot { display: none; }
  .timer-wrap strong { font-size: 22px; }
  .icon-button { padding: 8px; gap: 5px; }
  .icon-button span { font-size: 9px; letter-spacing: .02em; }
  .icon-button svg { width: 16px; height: 16px; }
  .board-wrap { padding: 14px; }
  .board { gap: 7px; }
  .card { aspect-ratio: auto; min-height: 94px; }
  .card-face { padding: 7px; }
  .matches-panel { padding: 14px; }
  .matches-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .vocabulary-reference ol { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .game-footer { padding: 12px 16px; }
  .game-footer p { display: none; }
  .progress-text { margin: auto; align-items: center; }
  footer { gap: 10px; letter-spacing: .08em; }
  footer span:not(.footer-line) { white-space: nowrap; font-size: 8px; }
}

@media (max-width: 380px) {
  .start-overlay { padding: 22px 14px; }
  .start-overlay h1 { font-size: 26px; }
  .card { min-height: 108px; }
  .card-back.is-russian { font-size: 15px; }
  .card-back.is-english { font-size: 13px; }
  .icon-button svg { display: none; }
}

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