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

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

.game-card {
  width: min(100%, 1040px);
  padding: 34px;
  border: 1px solid var(--line);
  border-radius: 34px;
  background: linear-gradient(135deg, var(--surface), #f6f0e2);
  box-shadow: var(--shadow);
}

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

.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: 10px;
  text-align: center;
  font-size: 3.35rem;
  line-height: 1;
}

h2 {
  margin-bottom: 10px;
  font-size: 2rem;
  line-height: 1.08;
}

.game-card > .eyebrow {
  display: flex;
  justify-content: center;
}

.intro {
  max-width: 720px;
  margin: 0 auto 28px;
  color: #3e4142;
  text-align: center;
  font-size: 1.05rem;
  line-height: 1.55;
}

.level-screen {
  text-align: center;
}

.difficulty-options {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-top: 18px;
  text-align: left;
}

.difficulty-option {
  display: grid;
  gap: 8px;
  min-height: 164px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--navy);
  background: rgba(255, 253, 246, 0.9);
  cursor: pointer;
  text-align: left;
  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:focus-visible,
.lane-button:focus-visible {
  outline: 3px solid var(--gold-2);
  outline-offset: 3px;
}

.difficulty-option:nth-child(2) {
  border-color: #b8c3ac;
  background: linear-gradient(135deg, #fffdf6, #edf4ee);
}

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

.difficulty-option span,
.section-label {
  color: var(--gold-dark);
  font: 900 0.72rem var(--sans);
  text-transform: uppercase;
}

.difficulty-option:nth-child(3) span {
  color: #e8d883;
}

.difficulty-option strong {
  color: inherit;
  font: 800 2.3rem/1 var(--serif);
}

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

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

.play-screen[hidden],
.level-screen[hidden] {
  display: none;
}

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

.selected-level {
  display: inline-flex;
  margin-bottom: 8px;
  padding: 7px 11px;
  border: 1px solid #d4c889;
  border-radius: 999px;
  color: var(--navy);
  background: var(--gold-soft);
  font: 800 0.78rem var(--sans);
  text-transform: uppercase;
}

.play-actions,
.result-dialog__actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}

.button {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  padding: 11px 17px;
  border-radius: 999px;
  text-decoration: none;
  cursor: pointer;
  transition: transform 180ms ease, background 180ms ease, box-shadow 180ms ease;
}

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

.button-primary {
  color: #071523;
  background: var(--gold-2);
  box-shadow: 0 6px 12px rgba(114, 93, 25, 0.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);
}

.button-tertiary {
  border-color: transparent;
  color: var(--navy);
  background: transparent;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.game-status {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 16px;
}

.game-status p,
.result-stats p {
  margin: 0;
  padding: 11px 8px;
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--muted);
  background: rgba(255, 253, 246, 0.78);
  font: 800 0.72rem var(--sans);
  text-align: center;
  text-transform: uppercase;
}

.game-status strong,
.result-stats strong {
  display: block;
  margin-top: 2px;
  color: var(--navy);
  font-size: 1rem;
}

.stage-layout {
  display: grid;
  grid-template-columns: minmax(300px, 420px) minmax(260px, 1fr);
  gap: 18px;
  align-items: stretch;
}

.canvas-shell {
  min-width: 0;
}

#game-canvas {
  display: block;
  width: 100%;
  max-width: 420px;
  height: auto;
  aspect-ratio: 7 / 10;
  border: 1px solid rgba(6, 27, 49, 0.5);
  border-radius: 20px;
  background: var(--navy);
  box-shadow: 0 16px 32px rgba(6, 27, 49, 0.22);
}

.lane-touch {
  display: none;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin-top: 10px;
}

.lane-button {
  min-height: 54px;
  border: 1px solid rgba(6, 27, 49, 0.35);
  border-radius: 14px;
  color: var(--navy);
  cursor: pointer;
  font: 900 1.1rem var(--sans);
}

.lane-button--one {
  background: #d8c76b;
}

.lane-button--two {
  background: #93b399;
}

.lane-button--three {
  background: #d8a76b;
}

.lane-button--four {
  background: #8eaebd;
}

.rhythm-panel {
  display: flex;
  min-width: 0;
  flex-direction: column;
  justify-content: space-between;
  gap: 18px;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(145deg, rgba(255, 253, 246, 0.9), #edf4ee);
}

.rhythm-panel h2 {
  margin-bottom: 14px;
}

.key-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.key-row span {
  display: grid;
  min-height: 58px;
  border: 1px solid #c8ba78;
  border-radius: 14px;
  place-items: center;
  color: var(--navy);
  background: var(--surface);
  box-shadow: inset 0 -5px 0 rgba(168, 149, 76, 0.14);
  font: 900 1.2rem var(--sans);
}

.rhythm-progress {
  display: grid;
  gap: 8px;
}

.time-heading {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font: 800 0.76rem var(--sans);
  text-transform: uppercase;
}

.time-heading strong {
  color: var(--navy);
}

.time-track {
  height: 11px;
  overflow: hidden;
  border-radius: 999px;
  background: #e7dfcb;
}

.time-bar {
  display: block;
  width: var(--time-progress, 100%);
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--gold-2), #93b399);
  transition: width 120ms linear, background 180ms ease;
}

.time-bar.is-urgent {
  background: #b05742;
}

.game-message {
  min-height: 3.8rem;
  margin: 0;
  padding: 14px 16px;
  border: 1px solid #d4c889;
  border-radius: 16px;
  color: #4f514c;
  background: rgba(255, 253, 246, 0.8);
  font: 800 0.95rem/1.4 var(--sans);
}

.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.8);
}

.result-dialog__content {
  padding: 34px;
  text-align: center;
}

.result-dialog__content .eyebrow {
  justify-content: center;
}

.result-dialog__content h2 {
  font-size: 2.2rem;
}

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

.result-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 20px;
}

.result-dialog__actions {
  justify-content: center;
}

@media (max-width: 860px) {
  .game-card {
    width: min(100%, 720px);
  }

  .difficulty-options,
  .stage-layout {
    grid-template-columns: 1fr;
  }

  #game-canvas {
    margin: 0 auto;
  }

  .rhythm-panel {
    padding: 18px;
  }
}

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

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

  .game-navigation,
  .play-heading {
    flex-direction: column-reverse;
    align-items: center;
    text-align: center;
  }

  h1 {
    font-size: 2.45rem;
  }

  h2 {
    font-size: 1.65rem;
  }

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

  .play-actions,
  .result-dialog__actions {
    width: 100%;
    justify-content: center;
  }

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

  .lane-touch {
    display: grid;
  }

  .rhythm-panel {
    gap: 14px;
  }

  .result-stats {
    grid-template-columns: 1fr;
  }
}
