body {
  min-width: 320px;
  min-height: 100vh;
}

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

.game-card {
  width: min(100%, 900px);
  padding: clamp(26px, 5vw, 46px);
  border: 1px solid var(--line);
  border-radius: 34px;
  background: linear-gradient(135deg, var(--surface), #f7f1e4);
  box-shadow: var(--shadow);
  text-align: center;
}

.game-navigation {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 34px;
}

.game-navigation .brand-lock {
  gap: 8px;
  text-align: left;
}

.game-navigation .brand-mark {
  width: 38px;
  height: 38px;
}

.game-navigation .brand-name {
  font-size: 1.05rem;
}

.game-navigation .brand-name small {
  font-size: 0.53rem;
}

.back-link {
  color: var(--navy);
  font: 800 0.82rem var(--sans);
  text-decoration: none;
}

.back-link:hover {
  color: var(--gold-dark);
  text-decoration: underline;
}

h1,
h2,
p {
  margin-top: 0;
}

h1,
h2 {
  color: var(--navy);
  font-family: var(--serif);
}

h1 {
  margin-bottom: 12px;
  font-size: clamp(2.3rem, 7vw, 4rem);
  line-height: 1;
}

h2 {
  font-size: clamp(1.8rem, 5vw, 2.6rem);
  line-height: 1.08;
}

.intro {
  max-width: 500px;
  margin: 0 auto 28px;
  color: #3e4142;
  font-size: 1.08rem;
  line-height: 1.58;
}

.start-screen .button-primary {
  min-width: min(100%, 300px);
  min-height: 56px;
  font-size: 1rem;
}

.level-instruction {
  margin-bottom: 12px;
  color: var(--gold-dark);
  font: 800 0.84rem var(--sans);
}

.difficulty-options {
  display: grid;
  gap: 10px;
  max-width: 520px;
  margin: 0 auto;
  text-align: left;
}

.difficulty-option {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 3px 14px;
  min-height: 72px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--navy);
  background: rgba(255, 253, 246, 0.88);
  cursor: pointer;
  text-align: left;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition: border-color 180ms ease, box-shadow 180ms ease, transform 180ms ease;
}

.difficulty-option:hover {
  border-color: var(--gold);
  box-shadow: var(--soft);
  transform: translateY(-2px);
}

.difficulty-option:nth-child(2) {
  background: linear-gradient(135deg, var(--gold-soft), #fffaf0);
  border-color: #c8ba78;
}

.difficulty-option:nth-child(3) {
  color: var(--white);
  background: linear-gradient(145deg, var(--navy), var(--navy-3));
  border-color: var(--navy-3);
}

.difficulty-option span {
  font: 900 0.76rem var(--sans);
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.difficulty-option strong {
  grid-column: 2;
  grid-row: 1 / span 2;
  align-self: center;
  font: 800 1.15rem var(--serif);
}

.difficulty-option small {
  color: var(--muted);
  font: 0.86rem var(--serif);
}

.difficulty-option:nth-child(3) small {
  color: #dbe4eb;
}

.button {
  min-height: 48px;
  padding: 12px 20px;
  border-radius: 999px;
  cursor: pointer;
  transition: background 180ms ease, transform 180ms ease;
}

.button:hover {
  transform: translateY(-2px);
}

.button-primary {
  color: #071523;
  background: var(--gold-2);
}

.button-primary:hover {
  background: var(--gold);
}

.button-secondary {
  border-color: var(--line);
  color: var(--navy);
  background: var(--surface);
}

.button-secondary:hover {
  background: var(--navy-soft);
}

.game-interface[hidden],
.start-screen[hidden] {
  display: none;
}

.game-status {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  max-width: 360px;
  margin: 0 auto 16px;
}

.game-status p {
  margin: 0;
  padding: 13px 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 253, 246, 0.78);
  color: var(--muted);
  font: 800 0.72rem var(--sans);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.game-status strong {
  color: var(--navy);
  font-size: 1.15rem;
}

.game-message {
  min-height: 24px;
  margin-bottom: 16px;
  color: var(--gold-dark);
  font: 800 0.92rem var(--sans);
}

.selected-level {
  display: inline-flex;
  margin: 0 0 10px;
  padding: 7px 11px;
  border: 1px solid #d4c889;
  border-radius: 999px;
  color: var(--navy);
  background: var(--gold-soft);
  font: 800 0.7rem var(--sans);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.brain-board {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: clamp(4px, 0.8vw, 8px);
  width: min(100%, 700px);
  margin: 0 auto 24px;
  padding: clamp(10px, 2vw, 16px);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 253, 246, 0.55);
  touch-action: manipulation;
}

.brain-cell {
  display: grid;
  aspect-ratio: 1;
  padding: 0;
  border: 1px solid rgba(215, 208, 190, 0.8);
  border-radius: 10px;
  color: transparent;
  background: var(--white);
  cursor: pointer;
  place-items: center;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition: background 130ms ease, border-color 130ms ease, transform 130ms ease;
}

.brain-cell:hover {
  border-color: var(--gold-2);
}

.brain-cell.is-active {
  border-color: var(--gold);
  color: var(--navy);
  background: var(--gold-soft);
  box-shadow: 0 0 0 3px rgba(168, 149, 76, 0.12);
  transform: scale(1.06);
}

.brain-target {
  width: 68%;
  height: 68%;
  stroke: currentColor;
  fill: none;
}

.brain-cell.is-hit {
  background: var(--gold-2);
  transform: scale(0.92);
}

.brain-cell:focus-visible {
  position: relative;
  z-index: 1;
  outline: 3px solid var(--gold-2);
  outline-offset: 2px;
}

.result-dialog {
  width: min(calc(100% - 32px), 500px);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.result-dialog::backdrop {
  background: rgba(3, 12, 22, 0.78);
}

.result-dialog__content {
  padding: clamp(28px, 6vw, 42px);
  text-align: center;
}

.result-dialog__content > p:not(.eyebrow) {
  margin-bottom: 22px;
  color: #3e4142;
  font-size: 1.05rem;
  line-height: 1.55;
}

.result-dialog__actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
}

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

  .game-card {
    border-radius: 22px;
  }

  .game-navigation {
    flex-direction: column-reverse;
    align-items: center;
    margin-bottom: 26px;
  }

  .brain-board {
    gap: 4px;
    padding: 9px;
  }

  .brain-cell {
    min-height: 44px;
    border-radius: 9px;
  }

  body.game-in-progress .page-shell {
    min-height: 100dvh;
    padding: 0;
    place-items: stretch;
  }

  body.game-in-progress .game-card {
    width: 100%;
    min-height: 100dvh;
    padding: 16px;
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }

  body.game-in-progress .game-navigation {
    display: none;
  }

  body.game-in-progress .game-interface {
    display: flex;
    min-height: calc(100dvh - 32px);
    flex-direction: column;
    justify-content: center;
  }

  body.game-in-progress .game-message {
    margin-bottom: 12px;
  }

  body.game-in-progress .brain-board {
    width: 100%;
    margin-bottom: 16px;
  }

  body.game-in-progress #stop-button {
    align-self: center;
    min-height: 42px;
    padding: 8px 16px;
    font-size: 0.82rem;
  }

  .result-dialog__actions .button {
    width: 100%;
  }
}

@media (max-width: 340px) {
  body.game-in-progress .brain-board {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }
}
