:root {
  --ink: #192c25;
  --green: #20483a;
  --paper: #f7f4ea;
  --line: #dddfd1;
  --muted: #526359;
  --accent: #c6da91;
  font-family: system-ui, sans-serif;
  color: var(--ink);
  background: var(--paper);
}
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; }
a { color: var(--green); text-underline-offset: .18em; }
a:focus-visible, button:focus-visible, select:focus-visible, [tabindex]:focus-visible {
  outline: 3px solid #257b67; outline-offset: 3px;
}
button, select { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; }
h1, h2, h3, p { margin: 0; }
p { line-height: 1.55; }
h1, h2 { font-family: Georgia, serif; font-weight: 700; }
h1 { font-size: clamp(3.3rem, 9vw, 6.5rem); line-height: .95; letter-spacing: -.065em; }
h2 { font-size: 1.6rem; letter-spacing: -.03em; }
.arcade-width { width: min(1100px, calc(100% - 2rem)); margin-inline: auto; }
.arcade-header { background: #1d392f; color: #fbf9ee; }
.header-inner { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: .55rem 1.3rem; min-height: 68px; padding-block: .65rem; }
.arcade-header a { color: inherit; text-decoration: none; }
.brand-name { font: 1.2rem Georgia, serif; white-space: nowrap; }
.brand-name strong { color: #d2e5a5; }
.arcade-header nav { display: flex; align-items: center; flex-wrap: wrap; gap: .25rem 1.1rem; font-size: .87rem; }
.arcade-header nav a { padding-block: .28rem; }
.arcade-header a:hover, .arcade-header [aria-current] { text-decoration: underline; }
.lobby { padding-block: clamp(2rem, 7vw, 5rem); }
.lobby-intro { border-bottom: 1px solid var(--line); padding-bottom: 1.75rem; margin-bottom: 1.55rem; }
.lobby-intro p, .game-intro p { color: var(--muted); max-width: 40ch; margin-top: 1rem; }
.game-catalog { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1.1rem; }
.catalog-card { min-width: 0; display: flex; flex-direction: column; border: 1px solid var(--line); background: #fffdf7; border-radius: 1.05rem; overflow: hidden; box-shadow: 0 10px 30px #213b3310; }
.catalog-card > img { width: 100%; height: auto; aspect-ratio: 3 / 2; object-fit: cover; display: block; background: #d8e0bd; }
.catalog-content { display: flex; flex: 1; flex-direction: column; align-items: flex-start; gap: .75rem; padding: 1.15rem; }
.catalog-content p { color: var(--muted); margin-bottom: .3rem; }
.catalog-content .button { margin-top: auto; }
.button { display: inline-flex; justify-content: center; align-items: center; gap: .75rem; border-radius: .65rem; padding: .6rem .85rem; min-height: 44px; border: 1px solid transparent; text-decoration: none; font-weight: 680; font-size: .92rem; line-height: 1.25; }
.primary { color: white; background: var(--green); }
.primary:hover:not(:disabled) { background: #2f6751; }
.secondary { background: #fbfaf3; border-color: #c7d2c4; color: var(--green); }
.secondary:hover:not(:disabled) { background: #ecf1e3; }
.button:disabled { opacity: .57; }
.compact { padding-inline: .6rem; }
.game-intro { position: relative; display: grid; grid-template-columns: 1fr minmax(200px, .78fr); align-items: center; gap: 1rem; margin: 1.35rem 0; border-radius: 1.15rem; overflow: hidden; background: #e3e9cd; }
.game-intro > div { padding: clamp(1rem, 4vw, 2.8rem); }
.game-intro h1 { font-size: clamp(2.6rem, 7vw, 5.4rem); }
.intro-iq { background: #f2e5bc; }
.game-intro img { width: 100%; height: 100%; max-height: 250px; object-fit: cover; }
.back-link { display: inline-flex; font-size: .83rem; margin-bottom: .7rem; }
.arcade-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(245px, .47fr); gap: 1rem; align-items: start; }
.game-panel { min-width: 0; border: 1px solid var(--line); background: #fffdf7; border-radius: .9rem; padding: clamp(.82rem, 3vw, 1.4rem); }
.game-aside { display: grid; gap: 1rem; }
.game-heading { display: flex; align-items: center; gap: 1rem; justify-content: space-between; }
.setup { display: flex; align-items: center; flex-wrap: wrap; gap: .6rem; margin-block: .9rem; }
.setup label { font-weight: 650; }
.setup select { min-height: 44px; padding: .4rem .55rem; border-radius: .6rem; border: 1px solid #b9c7b9; background: #fbfaf3; color: var(--ink); }
.controls { display: flex; flex-wrap: wrap; gap: .55rem; }
.game-status, .ranks p, #level-progress { color: var(--muted); font-size: .89rem; margin-block: .65rem; }
.metrics { display: grid; grid-template-columns: repeat(3, 1fr); gap: .42rem; margin: .85rem 0 .6rem; }
.metrics div { padding: .55rem .65rem; border: 1px solid #e4e7d9; border-radius: .65rem; background: #f1f2e6; }
.metrics dt { font-size: .78rem; color: var(--muted); }
.metrics dd { margin: 0; font-size: clamp(1.05rem, 3.6vw, 1.45rem); font-weight: 720; font-variant-numeric: tabular-nums; white-space: nowrap; }
progress { width: 100%; height: 7px; accent-color: #3a7859; }
.topic { margin: .65rem 0 .25rem; font-size: .8rem; letter-spacing: .035em; font-weight: 680; color: var(--muted); }
#question-text { font-size: clamp(1.08rem, 4vw, 1.4rem); margin-bottom: .8rem; }
.answers { display: grid; gap: .45rem; }
.answer { width: 100%; text-align: left; min-height: 45px; padding: .55rem .72rem; border-radius: .6rem; color: var(--ink); border: 1px solid #cbd7c6; background: #fbfaf3; }
.answer:not(:disabled):hover { background: #eef3dc; }
.answer.correct { border-color: #4d845f; background: #e2efd7; }
.answer.incorrect { border-color: #a96b56; background: #f9e8e0; }
.feedback { padding: .8rem; border-radius: .65rem; background: #eef1de; border: 1px solid #d8e2c7; margin-block: .75rem; }
.feedback p { margin-block: .32rem; }
.feedback a { display: inline-block; margin-top: .25rem; font-size: .9rem; }
.ranks a { display: block; margin-bottom: .65rem; }
.ranks ol { padding-left: 1.45rem; margin: .8rem 0 0; }
.ranks li { padding: .36rem 0; border-bottom: 1px solid var(--line); overflow-wrap: anywhere; }
.ranks li.yours { font-weight: 700; }
.level-picker { display: grid; grid-template-columns: repeat(5, 1fr); gap: .28rem; }
.level-picker button { min-height: 44px; border-radius: .45rem; border: 1px solid #cbd5c6; background: #f6f8ed; color: var(--ink); padding: .15rem; }
.level-picker button[aria-current] { background: var(--green); color: white; }
.level-picker button:disabled { color: #546158; background: #edeee7; }
.level-stars { display: block; font-size: .52rem; line-height: 1.1; }
.match-board { display: grid; grid-template-columns: repeat(var(--columns, 3), minmax(0, 1fr)); gap: clamp(3px, 1.2vw, 8px); max-width: 580px; margin: auto; }
.match-card-button { position: relative; aspect-ratio: 1; background: linear-gradient(145deg, #45765d, #2b5143); border: 1px solid #2f5a46; border-radius: clamp(.35rem, 1vw, .75rem); color: #f4f7db; display: grid; place-items: center; padding: 0; min-width: 0; touch-action: manipulation; }
.match-card-button::after { content: "✧"; font-size: clamp(.95rem, 4vw, 1.7rem); color: #dce9a5; }
.match-card-button img { width: 85%; height: 85%; object-fit: contain; position: absolute; inset: 7.5%; display: none; }
.match-card-button.is-open, .match-card-button.is-match { background: #faf3d9; border-color: #b7c999; }
.match-card-button.is-open::after, .match-card-button.is-match::after { content: none; }
.match-card-button.is-open img, .match-card-button.is-match img { display: block; animation: reveal .24s ease-out; }
.match-card-button.is-match { background: #e5eed6; }
.match-card-button:not(:disabled):hover { filter: brightness(1.11); }
@keyframes reveal { from { transform: scale(.76) rotateY(50deg); opacity: .25; } to { transform: none; opacity: 1; } }
.board-controls { margin-top: .8rem; }
.arcade-footer { display: flex; justify-content: space-between; flex-wrap: wrap; gap: .8rem; font-size: .87rem; padding-block: 1.4rem; margin-top: 1rem; border-top: 1px solid var(--line); }
@media (max-width: 750px) {
  .game-catalog { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .arcade-layout { grid-template-columns: minmax(0, 1fr); }
  .game-aside { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 525px) {
  .arcade-width { width: calc(100% - 1rem); }
  .lobby { padding-inline: .2rem; }
  .game-catalog, .game-aside { grid-template-columns: minmax(0, 1fr); }
  .catalog-card > img { aspect-ratio: 16 / 9; }
  .game-intro { grid-template-columns: minmax(0, 1fr) minmax(92px, .43fr); gap: 0; }
  .game-intro p { font-size: .86rem; margin-top: .6rem; }
  .arcade-header nav { gap: .15rem .65rem; }
}
@media (prefers-reduced-motion: reduce) {
  .match-card-button img { animation: none !important; }
}

.featured-game { border-color: #8baf75; }
.catalog-content .featured-label {
  margin: 0;
  color: #2f6144;
  font-size: .78rem;
  font-weight: 750;
}
