* { box-sizing: border-box; }

@font-face {
  font-family: Inter;
  src: url("/fonts/inter-latin.woff2") format("woff2");
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
}
@font-face {
  font-family: "Space Grotesk";
  src: url("/fonts/space-grotesk-latin.woff2") format("woff2");
  font-weight: 600 700;
  font-display: swap;
}

body {
  margin: 0;
  background: #0b0f19;
  color: #f8fafc;
  font: 1.125rem/1.5 Inter, system-ui, sans-serif;
}

a { color: #a7d2ff; }
a:focus, button:focus { outline: 3px solid #a7d2ff; outline-offset: 4px; }
@supports selector(:focus-visible) {
  a:focus:not(:focus-visible), button:focus:not(:focus-visible) { outline: none; }
}
button { font: inherit; cursor: pointer; }

.arcade-header { background: #0b0f19; border-bottom: 1px solid #394862; }
.arcade-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 1280px;
  margin: auto;
  padding: 8px 32px;
}

.action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 56px;
  padding: 10px 16px;
  border: 1px solid #46516a;
  border-radius: 12px;
  background: #1b2232;
  color: #f8fafc;
  font-size: 1rem;
  font-weight: 600;
  touch-action: manipulation;
}
.action:hover { background: #242d40; border-color: #657188; }

.brand {
  display: inline-flex;
  align-items: center;
  min-height: 52px;
  color: #f8fafc;
  font: 800 24px/1 Inter, sans-serif;
  letter-spacing: -1px;
  text-decoration: none;
  white-space: nowrap;
}
.brand-icon {
  display: block;
  flex-shrink: 0;
  width: 38px;
  height: 38px;
  margin-right: 9px;
  transform: rotate(-6deg);
}
.brand-wordmark > span {
  color: #4580f1;
  color: color-mix(in srgb, #0755ec 75%, white);
}
.nav-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  margin-left: 12px;
  padding: 8px 16px;
  border: 1px solid #30394c;
  border-radius: 12px;
  background: #1b2232;
  color: #f8fafc;
  font: 500 14px/1.25 Inter, sans-serif;
  text-decoration: none;
  white-space: nowrap;
}
.nav-link:hover, .nav-link:focus { background: #242d40; border-color: #657188; }

@media (max-width: 1100px) {
  .arcade-nav { padding-right: 24px; padding-left: 24px; }
}
@media (max-width: 700px) {
  .brand { font-size: 21px; }
  .brand-icon { width: 32px; height: 32px; margin-right: 7px; }
}
@media (max-width: 600px) {
  .arcade-nav { padding-right: 16px; padding-left: 16px; }
}
@media (max-width: 380px) {
  .brand { font-size: 16px; }
  .brand-icon { width: 26px; height: 26px; margin-right: 6px; }
  .nav-link { padding-right: 12px; padding-left: 12px; }
}

main { max-width: 1040px; margin: auto; padding: 28px 5% 36px; }
h1 { margin: 0; font: 700 2.25rem/1.15 "Space Grotesk", Inter, sans-serif; }
.arcade-title::before, .game-heading h1::before {
  display: inline-block;
  width: 10px;
  height: 10px;
  margin-right: 12px;
  border-radius: 3px;
  background: #0755ec;
  transform: rotate(-12deg);
  vertical-align: 0.12em;
  content: "";
}
.intro { color: #b5bed0; margin: 10px 0 22px; }

.game-page {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
}
.game-main, .play-area {
  display: flex;
  flex: 1 0 auto;
  flex-direction: column;
}
.game-main {
  width: 100%;
  max-width: none;
  margin: 0;
  padding: 12px 16px 8px;
  padding-right: clamp(16px, 2.5vw, 48px);
  padding-left: clamp(16px, 2.5vw, 48px);
}
.game-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  margin: 0 -6px 6px;
}
.game-toolbar > * { margin: 4px 6px; }
.game-heading { margin-right: auto; }
.game-heading h1 { font-size: 1.65rem; font-size: clamp(1.5rem, 3vw, 2.25rem); }
.game-heading .intro { margin: 4px 0 0; font-size: 1rem; }
.scoreboard {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  padding: 6px 10px;
  border: 1px solid #30394c;
  border-radius: 12px;
  background: #111827;
  font-size: 0.875rem;
  font-variant-numeric: tabular-nums;
  line-height: 1.35;
}
.scoreboard > div { margin: 2px 8px; }
.scoreboard small, .scoreboard time { color: #c0cde3; font-size: 0.75rem; }
.scoreboard small, .scoreboard time:not([hidden]) { display: block; }
.game-board { flex: 1 0 auto; }
.memory-board { display: flex; flex-wrap: wrap; margin: -5px; }
.memory-card {
  width: calc(25% - 10px);
  height: 72px;
  margin: 5px;
  padding: 0;
  border: 1px solid #52678c;
  border-radius: 10px;
  background: #263851;
  color: #f4f7ff;
  font-size: 2rem;
  touch-action: manipulation;
}
.memory-card[aria-pressed="true"] { background: #d9eaff; color: #101725; }
.memory-card.matched { background: #b6efca; color: #152c22; cursor: default; }
.game-result { min-height: 1.5em; margin: 6px 0 0; color: #b6efca; }

@supports (display: grid) {
  .memory-board {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    grid-template-rows: repeat(3, minmax(64px, 1fr));
    gap: 8px;
    margin: 0;
  }
  .memory-card {
    width: 100%;
    height: auto;
    margin: 0;
    font-size: clamp(1.75rem, 7vmin, 5rem);
  }
}
