@import url('https://fonts.googleapis.com/css2?family=DM+Mono:wght@400;500&family=Space+Grotesk:wght@400;500;600;700&display=swap');

:root {
  --bg: #0b0b0b;
  --panel: #11110f;
  --line: rgba(238, 232, 216, .16);
  --text: #eee8d8;
  --muted: #918d82;
  --accent: #d8c78f;
  --accent-2: #f1e8c7;
  --danger: #c96e58;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: "Space Grotesk", system-ui, sans-serif;
}

body {
  min-height: 100vh;
  overflow-x: hidden;
  background:
    radial-gradient(circle at 50% -10%, rgba(216,199,143,.09), transparent 35%),
    #0b0b0b;
}

.grain {
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: .045;
  z-index: 20;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 180 180' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.7'/%3E%3C/svg%3E");
}

.app {
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 44px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
}

.brand-mark {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border: 1px solid var(--accent);
  color: var(--accent);
  font-weight: 700;
  letter-spacing: -.05em;
}

.brand-name {
  font-size: 13px;
  letter-spacing: .19em;
  font-weight: 700;
}

.brand-sub, .modal-code, .eyebrow, .stat-label, .hint {
  font-family: "DM Mono", monospace;
  letter-spacing: .13em;
}

.brand-sub {
  margin-top: 3px;
  font-size: 8px;
  color: var(--muted);
}

.reset-btn {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  padding: 10px 14px;
  font: 10px "DM Mono", monospace;
  letter-spacing: .12em;
  cursor: pointer;
  transition: .2s ease;
}

.reset-btn:hover {
  color: var(--text);
  border-color: rgba(238,232,216,.4);
}

.hero {
  text-align: center;
  padding: 52px 0 28px;
}

.eyebrow {
  font-size: 9px;
  color: var(--accent);
  margin: 0 0 13px;
}

h1 {
  font-size: clamp(36px, 6vw, 66px);
  line-height: .95;
  letter-spacing: -.055em;
  margin: 0;
  font-weight: 600;
}

h1 span {
  color: var(--accent);
  font-style: italic;
}

.intro {
  max-width: 520px;
  margin: 17px auto 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.65;
}

.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  border: 1px solid var(--line);
  margin-bottom: 18px;
}

.stat {
  padding: 13px 16px;
  border-right: 1px solid var(--line);
}

.stat:last-child { border-right: 0; }

.stat-label {
  display: block;
  color: var(--muted);
  font-size: 8px;
  margin-bottom: 5px;
}

.stat strong {
  font: 500 15px "DM Mono", monospace;
  color: var(--text);
}

.board-wrap {
  padding: 16px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,.018);
}

.board {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  perspective: 1200px;
}

.card {
  position: relative;
  aspect-ratio: 1 / 1.12;
  border: 0;
  padding: 0;
  background: transparent;
  cursor: pointer;
  perspective: 900px;
}

.card-inner {
  position: absolute;
  inset: 0;
  transform-style: preserve-3d;
  transition: transform .48s cubic-bezier(.2,.7,.2,1);
}

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

.face {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  overflow: hidden;
  border: 1px solid rgba(238,232,216,.2);
}

.card-front {
  display: grid;
  place-items: center;
  background:
    linear-gradient(135deg, rgba(216,199,143,.08), transparent 55%),
    #121210;
}

.card-front::before,
.card-front::after {
  content: "";
  position: absolute;
  border: 1px solid rgba(216,199,143,.22);
}

.card-front::before { inset: 10px; }
.card-front::after {
  inset: 22px;
  transform: rotate(45deg);
}

.front-d {
  position: relative;
  z-index: 1;
  font-size: 32px;
  color: var(--accent);
  font-weight: 500;
}

.front-code {
  position: absolute;
  bottom: 9px;
  left: 10px;
  font: 7px "DM Mono", monospace;
  color: var(--muted);
  letter-spacing: .14em;
}

.card-back {
  transform: rotateY(180deg);
  background: #1b1a17;
}

.card-back img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  filter: saturate(.78) contrast(1.04);
}

.card.matched .card-back {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 2px rgba(216,199,143,.22), 0 0 24px rgba(216,199,143,.12);
}

.card.matched .card-back::after {
  content: "MATCH";
  position: absolute;
  top: 8px;
  right: 8px;
  padding: 4px 6px;
  background: rgba(11,11,11,.78);
  color: var(--accent-2);
  font: 7px "DM Mono", monospace;
  letter-spacing: .12em;
}

.card.shake .card-inner {
  animation: shake .34s ease;
}

@keyframes shake {
  20% { transform: rotateY(180deg) translateX(-5px); }
  40% { transform: rotateY(180deg) translateX(5px); }
  60% { transform: rotateY(180deg) translateX(-4px); }
  80% { transform: rotateY(180deg) translateX(3px); }
}

.hint {
  text-align: center;
  color: #5f5c54;
  font-size: 8px;
  margin: 18px 0 0;
}

.overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(6,6,6,.88);
  backdrop-filter: blur(12px);
  opacity: 0;
  visibility: hidden;
  transition: opacity .35s ease, visibility .35s ease;
}

.overlay.visible {
  opacity: 1;
  visibility: visible;
}

.modal {
  width: min(460px, 100%);
  padding: 42px 36px 36px;
  text-align: center;
  border: 1px solid rgba(216,199,143,.32);
  background:
    linear-gradient(145deg, rgba(216,199,143,.08), transparent 50%),
    #11110f;
  box-shadow: 0 30px 100px rgba(0,0,0,.55);
}

.modal-code {
  font-size: 8px;
  color: var(--accent);
}

.modal-symbol, .success-symbol {
  margin: 28px auto 16px;
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(216,199,143,.5);
  color: var(--accent);
  font-size: 24px;
}

.success-symbol {
  border-radius: 50%;
  color: #d9d4c4;
}

.modal h2 {
  font-size: 38px;
  line-height: .9;
  letter-spacing: -.05em;
  margin: 0;
}

.modal h2 span {
  color: var(--accent);
  font-style: italic;
}

.modal p {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
  margin: 18px 0 24px;
}

.primary-btn {
  width: 100%;
  padding: 15px 18px;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #11110f;
  font: 600 10px "DM Mono", monospace;
  letter-spacing: .13em;
  cursor: pointer;
  transition: .2s ease;
}

.primary-btn:hover {
  background: var(--accent-2);
  transform: translateY(-1px);
}

.primary-btn span {
  margin-left: 8px;
  font-size: 15px;
}

.results {
  display: grid;
  grid-template-columns: 1fr 1fr;
  margin: 24px 0 6px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.results div {
  padding: 14px;
  border-right: 1px solid var(--line);
}

.results div:last-child { border-right: 0; }

.results span {
  display: block;
  color: var(--muted);
  font: 8px "DM Mono", monospace;
  letter-spacing: .12em;
  margin-bottom: 6px;
}

.results strong {
  font: 500 16px "DM Mono", monospace;
}

@media (max-width: 700px) {
  .app { width: min(100% - 18px, 560px); padding-top: 16px; }
  .hero { padding: 38px 0 22px; }
  .board-wrap { padding: 9px; }
  .board { gap: 7px; }
  .card { aspect-ratio: 1 / 1.08; }
  .card-front::before { inset: 6px; }
  .card-front::after { inset: 13px; }
  .front-d { font-size: 23px; }
  .front-code { font-size: 5px; bottom: 6px; left: 7px; }
  .stats { margin-bottom: 10px; }
  .stat { padding: 10px 8px; }
  .stat-label { font-size: 6px; }
  .stat strong { font-size: 11px; }
  .intro { font-size: 12px; padding: 0 8px; }
  .modal { padding: 34px 24px 26px; }
}

@media (max-width: 390px) {
  h1 { font-size: 34px; }
  .brand-name { font-size: 11px; }
  .reset-btn { padding: 8px 9px; font-size: 8px; }
  .board { gap: 5px; }
}
