:root {
  --bg: #101417;
  --panel: #172025;
  --panel-strong: #202b31;
  --line: rgba(255, 255, 255, 0.12);
  --text: #f6fbf6;
  --muted: #9fb2ac;
  --mint: #49d49d;
  --gold: #f3c85a;
  --coral: #ff6f61;
  --ink: #0b0f11;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(135deg, rgba(73, 212, 157, 0.12), transparent 34%),
    linear-gradient(225deg, rgba(243, 200, 90, 0.13), transparent 38%),
    var(--bg);
  color: var(--text);
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
a {
  font: inherit;
}

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

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 22px;
}

.hub-link {
  color: var(--gold);
  text-decoration: none;
  font-weight: 900;
  letter-spacing: 0.12em;
}

.wallet {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(11, 15, 17, 0.72);
}

.wallet span,
.score-strip span {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.08em;
}

.wallet strong {
  color: var(--mint);
  font-size: 1rem;
}

.game-layout {
  display: grid;
  gap: 18px;
}

.title-block {
  display: grid;
  gap: 4px;
}

.eyebrow {
  margin: 0;
  color: var(--mint);
  font-size: 0.76rem;
  font-weight: 900;
  letter-spacing: 0.16em;
}

h1 {
  margin: 0;
  font-size: clamp(2.2rem, 5vw, 4.4rem);
  line-height: 1;
  letter-spacing: 0;
}

.score-strip {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 10px;
}

.score-strip div {
  min-height: 72px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(23, 32, 37, 0.82);
  display: grid;
  align-content: center;
  gap: 6px;
}

.score-strip strong {
  font-size: 1.45rem;
  line-height: 1;
}

.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.mode-button,
.primary-button {
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 16px;
  color: var(--text);
  background: var(--panel);
  cursor: pointer;
}

.mode-button.active {
  border-color: rgba(73, 212, 157, 0.8);
  color: var(--ink);
  background: var(--mint);
  font-weight: 900;
}

.mode-button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.primary-button {
  color: var(--ink);
  background: var(--gold);
  border-color: rgba(243, 200, 90, 0.8);
  font-weight: 900;
}

.memory-board {
  --cols: 4;
  display: grid;
  grid-template-columns: repeat(var(--cols), minmax(0, 1fr));
  gap: 10px;
  width: min(760px, 100%);
}

.memory-card {
  aspect-ratio: 1;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  background: var(--panel-strong);
  color: var(--text);
  display: grid;
  place-items: center;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  transition: transform 140ms ease, border-color 140ms ease, background 140ms ease;
}

.memory-card:focus-visible {
  outline: 3px solid var(--gold);
  outline-offset: 2px;
}

.memory-card:hover {
  transform: translateY(-2px);
  border-color: rgba(73, 212, 157, 0.7);
}

.memory-card::before {
  content: "NY";
  color: rgba(255, 255, 255, 0.62);
  font-size: clamp(1rem, 4vw, 2.4rem);
  font-weight: 950;
}

.memory-card span {
  display: none;
  font-size: clamp(1.8rem, 7vw, 3.8rem);
}

.memory-card.flipped,
.memory-card.matched {
  background: #f7f4e6;
  color: #182125;
  border-color: rgba(243, 200, 90, 0.95);
  transform: translateY(-1px);
}

.memory-card.flipped::before,
.memory-card.matched::before {
  display: none;
}

.memory-card.flipped span,
.memory-card.matched span {
  display: block;
}

.memory-card.matched {
  background: #d8f7e8;
  border-color: rgba(73, 212, 157, 0.95);
}

.memory-card.danger {
  border-color: rgba(255, 111, 97, 0.75);
  box-shadow: inset 0 0 0 2px rgba(255, 111, 97, 0.16);
}

.memory-card:disabled {
  cursor: default;
}

.result {
  min-height: 44px;
  padding: 12px 0;
  color: var(--gold);
  font-weight: 800;
}

@media (max-width: 700px) {
  .app-shell {
    width: min(100% - 20px, 620px);
    padding-top: 12px;
  }

  .topbar {
    align-items: flex-start;
  }

  .score-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .score-strip div {
    min-height: 64px;
    padding: 12px;
  }

  .memory-board {
    gap: 7px;
  }
}
