:root {
  --bg: #070709;
  --ink: #f4f0e6;
  --mute: #9aa0b0;
  --red: #e50914;
  --red-hot: #ff2a2a;
  --cyan: #5ce1e6;
  --green: #39ff88;
  --paper: #f6f3ea;
  --card-back: #121218;
  --font: "Barlow", system-ui, "Segoe UI", sans-serif;
  --display: "Bebas Neue", "Arial Narrow", Impact, sans-serif;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
}

body {
  min-height: 100dvh;
  background:
    radial-gradient(90% 70% at 50% -10%, rgba(229, 9, 20, 0.22), transparent 55%),
    radial-gradient(70% 50% at 100% 100%, rgba(92, 225, 230, 0.08), transparent 50%),
    radial-gradient(50% 40% at 0% 80%, rgba(229, 9, 20, 0.1), transparent 45%),
    var(--bg);
}

[hidden] { display: none !important; }

.skip {
  position: absolute;
  left: 12px;
  top: -48px;
  z-index: 40;
  padding: 8px 12px;
  background: var(--cyan);
  color: #041018;
  font-weight: 700;
}
.skip:focus { top: 12px; }

.fx-vignette,
.fx-scan,
.fx-grain {
  pointer-events: none;
  position: fixed;
  inset: 0;
}

.fx-vignette {
  z-index: 0;
  box-shadow: inset 0 0 120px 24px rgba(0, 0, 0, 0.72);
}

.fx-scan {
  z-index: 1;
  opacity: 0.12;
  background: repeating-linear-gradient(
    to bottom,
    transparent 0,
    transparent 2px,
    rgba(0, 0, 0, 0.55) 3px
  );
}

.fx-grain {
  z-index: 1;
  opacity: 0.05;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%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='.85'/%3E%3C/svg%3E");
}

.app {
  position: relative;
  z-index: 2;
  width: min(720px, calc(100% - 28px));
  margin: 0 auto;
  padding: calc(18px + var(--safe-top)) 0 calc(28px + var(--safe-bottom));
}

.brand {
  margin: 0;
  color: var(--cyan);
  letter-spacing: 0.28em;
  text-transform: uppercase;
  font-size: 0.72rem;
  font-weight: 600;
}

.back {
  margin: 6px 0 0;
}

.back a {
  color: var(--mute);
  text-decoration: none;
  font-size: 0.92rem;
}

.back a:hover,
.back a:focus-visible {
  color: var(--ink);
}

h1 {
  margin: 18px 0 6px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
}

.title-main {
  font-family: var(--display);
  font-size: clamp(2.6rem, 9vw, 4.4rem);
  line-height: 0.9;
  letter-spacing: 0.08em;
  color: var(--red-hot);
  text-shadow:
    0 0 8px rgba(229, 9, 20, 0.95),
    0 0 28px rgba(229, 9, 20, 0.7),
    0 0 64px rgba(229, 9, 20, 0.35);
}

.title-sub {
  font-family: var(--display);
  font-size: clamp(1.2rem, 4vw, 1.8rem);
  letter-spacing: 0.34em;
  color: var(--cyan);
  text-shadow: 0 0 16px rgba(92, 225, 230, 0.55);
}

.tagline,
.hint {
  margin: 0 0 14px;
  color: var(--mute);
}

.hint { font-size: 0.95rem; }

.hud {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 10px;
  margin: 18px 0 20px;
  align-items: stretch;
}

.stat {
  background: rgba(18, 18, 24, 0.85);
  border: 1px solid rgba(92, 225, 230, 0.22);
  border-radius: 12px;
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  box-shadow: 0 0 18px rgba(92, 225, 230, 0.08);
}

.stat span {
  font-size: 0.72rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--mute);
}

.stat strong {
  font-family: var(--display);
  font-size: 1.7rem;
  letter-spacing: 0.08em;
  color: var(--ink);
}

.btn {
  appearance: none;
  border: 0;
  cursor: pointer;
  font-family: var(--font);
  font-weight: 700;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  border-radius: 12px;
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.btn:focus-visible {
  outline: 2px solid var(--cyan);
  outline-offset: 3px;
}

.btn-ghost {
  background: rgba(18, 18, 24, 0.85);
  color: var(--ink);
  border: 1px solid rgba(229, 9, 20, 0.45);
  padding: 0 16px;
  min-height: 58px;
  font-size: 0.88rem;
}

.btn-ghost[aria-pressed="true"] {
  box-shadow: 0 0 16px rgba(229, 9, 20, 0.35);
}

.btn-primary {
  width: 100%;
  min-height: 52px;
  background: var(--red);
  color: #fff;
  font-family: var(--display);
  font-size: 1.45rem;
  letter-spacing: 0.12em;
  box-shadow: 0 0 24px rgba(229, 9, 20, 0.45);
}

.btn-primary:hover { transform: translateY(-1px); }

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

.card {
  position: relative;
  width: 100%;
  aspect-ratio: 3 / 4;
  min-height: 132px;
  perspective: 1100px;
  appearance: none;
  -webkit-appearance: none;
  background: transparent;
  border: 0;
  padding: 0;
  margin: 0;
  font: inherit;
  color: inherit;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.card:focus-visible {
  outline: 2px solid var(--cyan);
  outline-offset: 3px;
  border-radius: 14px;
}

.card-inner {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  transition: transform 0.55s cubic-bezier(0.2, 0.8, 0.2, 1);
}

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

.face {
  position: absolute;
  inset: 0;
  border-radius: 14px;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.face-back {
  background:
    radial-gradient(circle at 50% 38%, #1c1c28 0%, #0c0c12 68%);
  border: 2px solid rgba(229, 9, 20, 0.85);
  box-shadow:
    inset 0 0 24px rgba(92, 225, 230, 0.12),
    0 0 0 1px rgba(92, 225, 230, 0.18),
    0 10px 22px rgba(0, 0, 0, 0.35);
}

.card:not(.is-flipped):not(.is-matched):hover .face-back {
  box-shadow:
    inset 0 0 24px rgba(92, 225, 230, 0.18),
    0 0 18px rgba(229, 9, 20, 0.45);
}

.bolt,
.mark {
  width: 44%;
  max-width: 48px;
  fill: var(--red-hot);
  filter: drop-shadow(0 0 8px rgba(229, 9, 20, 0.95));
}

.face-front {
  background: var(--paper);
  color: #16161c;
  transform: rotateY(180deg);
  padding: 10px 8px;
  border: 2px solid #ddd6c6;
}

.lang-tag {
  position: absolute;
  top: 8px;
  left: 8px;
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  color: #7a7568;
}

.word {
  font-weight: 700;
  font-size: clamp(1rem, 3.1vw, 1.45rem);
  line-height: 1.15;
  text-align: center;
  text-wrap: balance;
  padding: 0 6px;
}

.word.is-long,
.face-front.is-ru .word.is-long {
  font-size: clamp(0.86rem, 2.5vw, 1.12rem);
}

.face-front.is-ru .word {
  font-size: clamp(0.95rem, 2.8vw, 1.28rem);
}

.card.is-matched .face-front {
  border-color: var(--green);
  box-shadow:
    0 0 0 2px var(--green),
    0 0 22px rgba(57, 255, 136, 0.7);
}

.card.is-wrong .face-front {
  border-color: var(--red-hot);
  box-shadow:
    0 0 0 2px var(--red-hot),
    0 0 22px rgba(255, 42, 42, 0.7);
}

.modal {
  width: min(440px, calc(100% - 28px));
  max-height: min(88dvh, 40rem);
  overflow: auto;
  border: 1px solid rgba(229, 9, 20, 0.55);
  border-radius: 18px;
  padding: 28px 22px 22px;
  background:
    radial-gradient(90% 60% at 50% 0%, rgba(229, 9, 20, 0.2), transparent 55%),
    #101018;
  color: var(--ink);
  box-shadow: 0 0 48px rgba(229, 9, 20, 0.28);
}

.modal::backdrop {
  background: rgba(4, 4, 6, 0.78);
  backdrop-filter: blur(8px);
}

.modal-kicker {
  margin: 0 0 6px;
  color: var(--cyan);
  letter-spacing: 0.22em;
  text-transform: uppercase;
  font-size: 0.72rem;
  text-align: center;
}

.modal h2 {
  margin: 0 0 18px;
  font-family: var(--display);
  font-size: clamp(1.8rem, 6vw, 2.4rem);
  letter-spacing: 0.06em;
  word-spacing: 0.18em;
  text-align: center;
  color: var(--red-hot);
  text-shadow: 0 0 18px rgba(229, 9, 20, 0.7);
  line-height: 1.1;
}

.modal-stats {
  margin: 0 0 18px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.modal-stats div {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(92, 225, 230, 0.2);
  border-radius: 12px;
  padding: 10px;
  text-align: center;
}

.modal-stats dt {
  font-size: 0.7rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--mute);
}

.modal-stats dd {
  margin: 4px 0 0;
  font-family: var(--display);
  font-size: 1.7rem;
  letter-spacing: 0.08em;
}

.lead {
  margin-top: 18px;
  padding: 14px 12px 12px;
  border-radius: 14px;
  background: linear-gradient(180deg, rgba(229, 9, 20, 0.16), rgba(92, 225, 230, 0.08));
  border: 1px solid rgba(229, 9, 20, 0.4);
}

.lead p {
  margin: 0 0 12px;
  font-size: 0.95rem;
  line-height: 1.4;
}

.lead-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.btn-share {
  background: #f4f0e6;
  color: #101018;
  box-shadow: none;
}
.share-toast {
  margin: 8px 0 0;
  text-align: center;
  color: var(--green);
  font-size: 0.85rem;
  font-weight: 600;
}

.btn-lead {
  min-height: 46px;
  background: var(--cyan);
  color: #041018;
  font-size: 0.95rem;
  box-shadow: 0 0 18px rgba(92, 225, 230, 0.35);
}

.btn-wa {
  background: #25d366;
  color: #04210d;
  box-shadow: 0 0 18px rgba(37, 211, 102, 0.28);
}

.club-link {
  display: block;
  margin-top: 10px;
  text-align: center;
  color: var(--cyan);
  font-weight: 600;
  font-size: 0.9rem;
}

.noscript {
  position: relative;
  z-index: 2;
  text-align: center;
  color: var(--mute);
}

@media (max-width: 560px) {
  .board {
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
  }

  .hud {
    grid-template-columns: 1fr 1fr;
  }

  .btn-ghost {
    grid-column: 1 / -1;
    min-height: 44px;
  }

  .lead-actions {
    grid-template-columns: 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  .card-inner { transition: none; }
  .btn { transition: none; }
  .fx-scan { display: none; }
}
