:root {
  --color-ink: #111827;
  --color-graphite: #243044;
  --color-blue: #0a3d91;
  --color-blue-dark: #06204f;
  --color-blue-soft: #d9ecff;
  --color-accent: #00a3ff;
  --color-surface: #ffffff;
  --color-page: #eef3f8;
  --color-line: rgba(17, 24, 39, 0.14);
  --shadow-panel: 0 24px 80px rgba(6, 32, 79, 0.16);
  font-family: Arial, Helvetica, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--color-ink);
  background:
    linear-gradient(180deg, rgba(10, 61, 145, 0.08), rgba(255, 255, 255, 0)),
    var(--color-page);
}

button,
a {
  font: inherit;
}

.page-shell {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 32px 20px;
}

.error-panel {
  width: min(1120px, 100%);
  padding: 36px;
  border: 1px solid rgba(10, 61, 145, 0.16);
  border-radius: 8px;
  background: var(--color-surface);
  box-shadow: var(--shadow-panel);
}

.sr-only {
  position: absolute;
  overflow: hidden;
  width: 1px;
  height: 1px;
  padding: 0;
  border: 0;
  margin: -1px;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}

.brand-hero {
  position: relative;
  overflow: hidden;
  margin: -36px -36px 28px;
  padding: 28px 36px 34px;
  border-bottom: 1px solid rgba(10, 61, 145, 0.14);
  background: #ffffff;
}

.brand-hero::before {
  position: absolute;
  inset: 0;
  content: "";
  background-image:
    linear-gradient(
      90deg,
      rgba(255, 255, 255, 0.98) 0%,
      rgba(255, 255, 255, 0.9) 48%,
      rgba(255, 255, 255, 0.74) 100%
    ),
    url("../assets/brand/pattern-80.png");
  background-position: center bottom;
  background-size: cover;
}

.brand-row,
.hero-content {
  position: relative;
  z-index: 1;
}

.brand-row {
  display: flex;
  gap: 24px;
  align-items: flex-start;
  justify-content: space-between;
}

.brand-logo {
  display: block;
  height: auto;
}

.brand-logo-mipt {
  width: clamp(150px, 22vw, 260px);
}

.brand-logo-jubilee {
  width: clamp(150px, 20vw, 236px);
}

.hero-content {
  max-width: 760px;
  margin-top: 24px;
}

.pixel-heading {
  margin: 0;
  color: #123194;
  font-size: 0;
  line-height: 1;
}

.pixel-title-art {
  display: block;
  width: clamp(220px, 37vw, 392px);
  height: auto;
  shape-rendering: crispEdges;
}

.lead {
  max-width: 720px;
  margin: 20px 0 0;
  color: var(--color-graphite);
  font-size: 22px;
  line-height: 1.4;
}

.game-frame {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--color-line);
  border-radius: 8px;
  background: #f8fbff;
}

.sound-toggle {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 5;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border: 1px solid rgba(10, 61, 145, 0.22);
  border-radius: 50%;
  color: var(--color-blue-dark);
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 10px 28px rgba(6, 32, 79, 0.12);
  cursor: pointer;
  font-size: 22px;
  font-weight: 700;
}

.sound-toggle.is-muted {
  color: #52657d;
  background: rgba(255, 255, 255, 0.72);
}

#gameCanvas {
  display: block;
  width: 100%;
  height: clamp(380px, 43.75vw, 440px);
  image-rendering: pixelated;
}

.game-overlay {
  position: absolute;
  inset: 0;
  display: none;
  place-items: center;
  padding: 24px;
  background: rgba(248, 251, 255, 0.86);
}

.game-overlay.is-visible {
  display: grid;
}

.overlay-content {
  width: min(420px, 100%);
  padding: 24px;
  border: 1px solid rgba(10, 61, 145, 0.18);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.92);
  text-align: center;
}

.overlay-content h2 {
  margin: 0 0 10px;
  color: var(--color-blue-dark);
  font-size: 28px;
}

.overlay-content p {
  margin: 0 0 20px;
  color: var(--color-graphite);
  line-height: 1.5;
}

.result-progress {
  color: var(--color-blue-dark);
  font-weight: 700;
}

.result-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: center;
}

.result-actions .text-link {
  flex-basis: 100%;
}

.is-hidden {
  display: none !important;
}

.game-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  align-items: center;
  margin-top: 20px;
}

.primary-button,
.secondary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 700;
  text-decoration: none;
}

.primary-button {
  border: 0;
  padding: 0 24px;
  color: #ffffff;
  background: var(--color-blue);
}

.secondary-button {
  border: 1px solid rgba(10, 61, 145, 0.28);
  padding: 0 18px;
  color: var(--color-blue-dark);
  background: #ffffff;
}

.text-link {
  color: var(--color-blue);
  font-weight: 700;
  text-decoration: none;
}

.text-link:hover {
  text-decoration: underline;
}

@media (max-width: 640px) {
  .page-shell {
    padding: 18px 12px;
  }

  .error-panel {
    padding: 22px 16px;
  }

  .brand-hero {
    margin: -22px -16px 24px;
    padding: 20px 16px 24px;
  }

  .brand-row {
    gap: 16px;
    align-items: center;
  }

  .brand-logo-mipt {
    width: min(42vw, 150px);
  }

  .brand-logo-jubilee {
    width: min(38vw, 138px);
  }

  .hero-content {
    margin-top: 22px;
  }

  .pixel-title-art {
    width: min(78vw, 292px);
  }

  .lead {
    font-size: 17px;
  }

  .overlay-content {
    padding: 18px 16px;
  }

  .game-actions {
    align-items: stretch;
    flex-direction: column;
  }
}
