@font-face {
  font-family: "Archivo Black";
  src: url("/wp-content/themes/czesc-gizycko/assets/fonts/archivo-black-latin-ext.woff2") format("woff2");
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  unicode-range: U+0100-024F, U+0259, U+1E00-1EFF, U+2020, U+20A0-20AB, U+20AD-20CF, U+2113;
}

@font-face {
  font-family: "Archivo Black";
  src: url("/wp-content/themes/czesc-gizycko/assets/fonts/archivo-black-latin.woff2") format("woff2");
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: "Montserrat";
  src: url("/wp-content/themes/czesc-gizycko/assets/fonts/montserrat-latin-ext.woff2") format("woff2");
  font-style: normal;
  font-weight: 400 900;
  font-display: swap;
  unicode-range: U+0100-024F, U+0259, U+1E00-1EFF, U+2020, U+20A0-20AB, U+20AD-20CF, U+2113;
}

@font-face {
  font-family: "Montserrat";
  src: url("/wp-content/themes/czesc-gizycko/assets/fonts/montserrat-latin.woff2") format("woff2");
  font-style: normal;
  font-weight: 400 900;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  --blue: #0849a2;
  --navy: #0849a2;
  --sky: #d6e9fe;
  --ice: #f7fbff;
  --water: #68c7dd;
  --water-deep: #2b9fc2;
  --sand: #dfcf9c;
  --reed: #547848;
  --white: #fff;
  --ink: #071827;
  --muted: #536674;
  --line: rgba(8, 73, 162, 0.18);
  --display: "Archivo Black", "Arial Black", sans-serif;
  --body: "Montserrat", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  color-scheme: light;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-width: 320px;
  color: var(--ink);
  background: var(--ice);
  font-family: var(--body);
  -webkit-font-smoothing: antialiased;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

button {
  font: inherit;
}

a {
  color: inherit;
}

.skip-link {
  position: fixed;
  z-index: 100;
  top: 0.75rem;
  left: 0.75rem;
  padding: 0.7rem 1rem;
  color: var(--white);
  background: var(--navy);
  transform: translateY(-160%);
}

.skip-link:focus {
  transform: translateY(0);
}

.game-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: min(1320px, calc(100% - clamp(2rem, 6vw, 6rem)));
  min-height: clamp(74px, 7vw, 96px);
  margin: 0 auto;
  border-bottom: 1px solid var(--line);
}

.game-header__brand img {
  display: block;
  width: clamp(138px, 14vw, 188px);
  height: auto;
}

.game-header__back {
  display: inline-flex;
  gap: 0.55rem;
  align-items: center;
  padding-block: 0.55rem;
  color: var(--navy);
  font-size: 0.82rem;
  font-weight: 800;
  text-decoration: none;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.game-header__back span {
  font-size: 1.2rem;
  transition: transform 180ms ease;
}

.game-header__back:hover span,
.game-header__back:focus-visible span {
  transform: translateX(-0.25rem);
}

.game-page {
  width: min(1320px, calc(100% - clamp(2rem, 6vw, 6rem)));
  margin: 0 auto;
  padding: clamp(2.25rem, 5vw, 5.5rem) 0 clamp(4rem, 8vw, 7rem);
}

.game-heading {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(280px, 0.65fr);
  gap: clamp(2rem, 8vw, 8rem);
  align-items: end;
  margin-bottom: clamp(2rem, 4vw, 3.6rem);
}

.game-heading__kicker,
.game-overlay__eyebrow {
  margin: 0 0 0.75rem;
  color: var(--blue);
  font-size: 0.76rem;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.12em;
}

.game-heading h1 {
  margin: 0;
  color: var(--navy);
  font-family: var(--display);
  font-size: clamp(3.15rem, 7.4vw, 7.1rem);
  font-weight: 400;
  line-height: 0.83;
  text-transform: uppercase;
  letter-spacing: -0.045em;
}

.game-heading__lead {
  max-width: 36rem;
  margin: 0 0 0.3rem;
  color: var(--muted);
  font-size: clamp(1rem, 1.25vw, 1.16rem);
  font-weight: 560;
  line-height: 1.65;
}

.game-shell {
  position: relative;
  background: var(--navy);
  box-shadow: 0 28px 70px rgba(8, 73, 162, 0.18);
}

.game-hud {
  display: grid;
  grid-template-columns: repeat(4, minmax(80px, 1fr)) auto;
  color: var(--white);
  background: var(--navy);
  border-bottom: 1px solid rgba(255, 255, 255, 0.14);
}

.hud-item {
  min-height: 68px;
  padding: 0.75rem clamp(0.8rem, 2vw, 1.6rem);
  border-right: 1px solid rgba(255, 255, 255, 0.14);
}

.hud-item--route {
  color: var(--white);
  background: transparent;
  border-top: 0;
  border-bottom: 0;
  border-left: 0;
  cursor: pointer;
  text-align: left;
  transition: color 160ms ease, background 160ms ease;
}

.hud-item--route:hover,
.hud-item--route:focus-visible {
  color: var(--navy);
  background: var(--sky);
  outline: 0;
}

.hud-item--route:hover .hud-item__label,
.hud-item--route:focus-visible .hud-item__label {
  color: var(--blue);
}

.hud-item__label {
  display: block;
  margin-bottom: 0.18rem;
  color: rgba(255, 255, 255, 0.64);
  font-size: 0.65rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.hud-item strong {
  display: block;
  font-family: var(--display);
  font-size: clamp(0.94rem, 1.45vw, 1.25rem);
  font-weight: 400;
  letter-spacing: 0.015em;
}

.sound-button {
  width: 68px;
  min-height: 68px;
  color: var(--white);
  background: transparent;
  border: 0;
  cursor: pointer;
  font-size: 1.4rem;
}

.sound-button[aria-pressed="false"] {
  color: rgba(255, 255, 255, 0.4);
  text-decoration: line-through;
}

.sound-button:hover,
.sound-button:focus-visible {
  color: var(--navy);
  background: var(--sky);
}

.game-stage {
  position: relative;
  overflow: hidden;
  aspect-ratio: 16 / 9;
  background: var(--water);
}

#gameCanvas {
  display: block;
  width: 100%;
  height: 100%;
  outline: none;
  touch-action: none;
}

#gameCanvas:focus-visible {
  box-shadow: inset 0 0 0 4px #fff, inset 0 0 0 7px var(--blue);
}

.game-overlay {
  position: absolute;
  z-index: 5;
  top: 50%;
  left: clamp(1rem, 5vw, 4.25rem);
  width: min(520px, calc(100% - 2rem));
  padding: clamp(1.25rem, 3.3vw, 2.4rem);
  color: var(--ink);
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 14px 18px 0 rgba(8, 73, 162, 0.14);
  transform: translateY(-50%);
  transition: opacity 180ms ease, visibility 180ms ease, transform 180ms ease;
}

.game-overlay.is-hidden {
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
  transform: translateY(calc(-50% + 10px));
}

.game-overlay__flag {
  display: flex;
  width: 78px;
  height: 8px;
  margin-bottom: 1.35rem;
}

.game-overlay__flag span {
  flex: 1;
}

.game-overlay__flag span:nth-child(1),
.game-overlay__flag span:nth-child(3) {
  background: var(--blue);
}

.game-overlay__flag span:nth-child(2) {
  background: var(--sky);
}

.game-overlay h2 {
  margin: 0;
  color: var(--navy);
  font-family: var(--display);
  font-size: clamp(1.75rem, 3.6vw, 3.15rem);
  font-weight: 400;
  line-height: 0.98;
  text-transform: uppercase;
  letter-spacing: -0.035em;
}

.game-overlay > p:not(.game-overlay__eyebrow):not(.game-overlay__hint) {
  margin: 1rem 0 1.35rem;
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 550;
  line-height: 1.55;
}

.game-setup {
  display: grid;
  gap: 0.9rem;
  margin: 1.15rem 0 1.25rem;
}

.game-setup__group {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.game-setup__group legend {
  margin-bottom: 0.45rem;
  padding: 0;
  color: var(--muted);
  font-size: 0.61rem;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.09em;
}

.level-picker,
.difficulty-picker {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1px;
  overflow: hidden;
  background: var(--line);
  border: 1px solid var(--line);
}

.level-picker button,
.difficulty-picker button {
  min-width: 0;
  color: var(--navy);
  background: var(--white);
  border: 0;
  cursor: pointer;
  transition: color 150ms ease, background 150ms ease;
}

.level-picker button {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.55rem;
  align-items: center;
  min-height: 54px;
  padding: 0.55rem 0.65rem;
  text-align: left;
}

.level-picker b {
  position: relative;
  color: var(--blue);
  font-family: var(--display);
  font-size: 1.15rem;
  font-weight: 400;
}

.level-picker span {
  font-size: 0.62rem;
  font-weight: 850;
  line-height: 1.15;
  text-transform: uppercase;
}

.level-picker button.is-complete b::after {
  content: "✓";
  position: absolute;
  top: -0.38rem;
  right: -0.4rem;
  display: grid;
  width: 13px;
  height: 13px;
  place-items: center;
  color: var(--white);
  background: #0f8f70;
  border-radius: 50%;
  font: 900 8px var(--body);
}

.difficulty-picker button {
  min-height: 34px;
  padding: 0.45rem 0.35rem;
  font-size: 0.61rem;
  font-weight: 850;
  text-transform: uppercase;
  letter-spacing: 0.025em;
}

.level-picker button[aria-pressed="true"],
.difficulty-picker button[aria-pressed="true"] {
  color: var(--white);
  background: var(--blue);
}

.level-picker button[aria-pressed="true"] b {
  color: #9eeefe;
}

.level-picker button:hover,
.level-picker button:focus-visible,
.difficulty-picker button:hover,
.difficulty-picker button:focus-visible {
  outline: 3px solid var(--blue);
  outline-offset: -3px;
}

.game-overlay__score {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  margin: 1.1rem 0;
  background: var(--line);
  border: 1px solid var(--line);
}

.game-overlay__score[hidden] {
  display: none;
}

.game-overlay__score span {
  padding: 0.75rem;
  background: var(--ice);
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.game-overlay__score strong {
  display: block;
  margin-top: 0.2rem;
  color: var(--navy);
  font-family: var(--display);
  font-size: 1.25rem;
  font-weight: 400;
}

.primary-button {
  min-height: 50px;
  padding: 0.75rem 1.35rem;
  color: var(--white);
  background: var(--blue);
  border: 0;
  cursor: pointer;
  font-size: 0.78rem;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  transition: color 180ms ease, background 180ms ease;
}

.primary-button:hover,
.primary-button:focus-visible {
  color: var(--navy);
  background: var(--sky);
  outline: 3px solid var(--blue);
  outline-offset: 3px;
}

.game-overlay__hint {
  margin: 0.8rem 0 0 !important;
  color: #758692 !important;
  font-size: 0.72rem !important;
}

.game-message {
  position: absolute;
  z-index: 3;
  left: 50%;
  bottom: clamp(0.7rem, 2vw, 1.3rem);
  max-width: calc(100% - 2rem);
  padding: 0.6rem 0.9rem;
  color: var(--white);
  background: rgba(8, 73, 162, 0.9);
  font-size: clamp(0.68rem, 1.25vw, 0.82rem);
  font-weight: 800;
  text-align: center;
  transform: translate(-50%, 12px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 160ms ease, transform 160ms ease;
}

.game-message.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

.dock-progress {
  position: absolute;
  z-index: 2;
  top: clamp(0.65rem, 2vw, 1.2rem);
  left: 50%;
  display: flex;
  gap: 0.65rem;
  align-items: center;
  min-width: min(280px, calc(100% - 2rem));
  padding: 0.55rem 0.75rem;
  color: var(--white);
  background: rgba(8, 73, 162, 0.82);
  font-size: 0.62rem;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  transform: translateX(-50%);
  opacity: 0;
  transition: opacity 160ms ease;
}

.dock-progress.is-visible {
  opacity: 1;
}

.dock-progress__track {
  flex: 1;
  height: 5px;
  background: rgba(255, 255, 255, 0.24);
}

.dock-progress__track i {
  display: block;
  width: 0;
  height: 100%;
  background: #8aeeff;
  transition: width 90ms linear;
}

.touch-controls {
  display: none;
  grid-template-columns: 1fr 1.7fr 1fr;
  gap: 0.75rem;
  padding: 0.9rem;
  background: var(--navy);
  border-top: 1px solid rgba(255, 255, 255, 0.14);
}

.touch-controls__drive {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

.touch-button {
  min-height: 64px;
  color: var(--white);
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 0;
  cursor: pointer;
  font-family: var(--display);
  font-size: 1.5rem;
  touch-action: none;
  user-select: none;
}

.touch-button small {
  display: block;
  margin-top: 0.1rem;
  font-family: var(--body);
  font-size: 0.52rem;
  font-weight: 900;
  letter-spacing: 0.06em;
}

.touch-button.is-active,
.touch-button:active {
  color: var(--navy);
  background: #8aeeff;
}

.game-manual {
  display: grid;
  grid-template-columns: 0.62fr 1.38fr;
  gap: clamp(2rem, 7vw, 7rem);
  padding-top: clamp(3rem, 6vw, 5.5rem);
}

.game-manual h2 {
  margin: 0;
  color: var(--navy);
  font-family: var(--display);
  font-size: clamp(2rem, 4vw, 4.3rem);
  font-weight: 400;
  line-height: 0.95;
  text-transform: uppercase;
  letter-spacing: -0.04em;
}

.game-manual__rules {
  border-top: 1px solid var(--line);
}

.game-manual__rules p {
  display: grid;
  grid-template-columns: 3.2rem 1fr;
  gap: 1rem;
  margin: 0;
  padding: 1.15rem 0;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.93rem;
  font-weight: 550;
  line-height: 1.55;
}

.game-manual__rules b {
  color: var(--blue);
  font-family: var(--display);
  font-weight: 400;
}

.game-manual__keys {
  grid-column: 2;
  margin: -1rem 0 0;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 2.4;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 28px;
  min-height: 28px;
  margin-inline: 0.2rem;
  padding: 0.2rem 0.4rem;
  color: var(--navy);
  background: var(--white);
  border: 1px solid var(--line);
  box-shadow: 0 2px 0 var(--line);
  font: 800 0.7rem var(--body);
}

.game-footer {
  padding: 1.5rem clamp(1rem, 4vw, 3rem);
  color: rgba(255, 255, 255, 0.64);
  background: var(--navy);
  font-size: 0.72rem;
  font-weight: 650;
  text-align: center;
}

.game-footer p {
  margin: 0;
}

.game-footer a {
  color: var(--white);
  font-weight: 850;
}

@media (hover: none), (pointer: coarse) {
  .touch-controls {
    display: grid;
  }
}

@media (max-width: 760px) {
  .game-header,
  .game-page {
    width: min(100% - 1.25rem, 1320px);
  }

  .game-header__back {
    font-size: 0;
  }

  .game-header__back span {
    font-size: 1.6rem;
  }

  .game-heading {
    grid-template-columns: 1fr;
    gap: 1.5rem;
  }

  .game-heading h1 {
    font-size: clamp(2.55rem, 11.2vw, 4.5rem);
  }

  .game-heading__lead {
    max-width: 31rem;
  }

  .game-hud {
    grid-template-columns: repeat(4, 1fr) 46px;
  }

  .hud-item {
    min-height: 54px;
    padding: 0.58rem 0.48rem;
  }

  .hud-item__label {
    font-size: 0.52rem;
    letter-spacing: 0.04em;
  }

  .hud-item strong {
    font-size: 0.75rem;
  }

  .sound-button {
    width: 46px;
    min-height: 54px;
    font-size: 1.05rem;
  }

  .game-overlay {
    left: 50%;
    width: min(340px, calc(100% - 1.25rem));
    padding: 1rem;
    box-shadow: 8px 9px 0 rgba(8, 73, 162, 0.14);
    transform: translate(-50%, -50%);
  }

  .game-stage.is-menu {
    aspect-ratio: auto;
    min-height: 405px;
  }

  .game-overlay.is-hidden {
    transform: translate(-50%, calc(-50% + 8px));
  }

  .game-overlay__flag {
    height: 5px;
    margin-bottom: 0.7rem;
  }

  .game-overlay__eyebrow {
    margin-bottom: 0.35rem;
    font-size: 0.58rem;
  }

  .game-overlay h2 {
    font-size: clamp(1.45rem, 6.7vw, 2rem);
  }

  .game-overlay > p:not(.game-overlay__eyebrow):not(.game-overlay__hint) {
    margin: 0.55rem 0 0.75rem;
    font-size: 0.68rem;
    line-height: 1.38;
  }

  .game-setup {
    gap: 0.62rem;
    margin: 0.65rem 0 0.75rem;
  }

  .game-setup__group legend {
    margin-bottom: 0.3rem;
    font-size: 0.52rem;
  }

  .level-picker button {
    grid-template-columns: 1fr;
    gap: 0.05rem;
    min-height: 47px;
    padding: 0.38rem 0.25rem;
    text-align: center;
  }

  .level-picker b {
    font-size: 0.95rem;
  }

  .level-picker span {
    font-size: 0.5rem;
  }

  .difficulty-picker button {
    min-height: 30px;
    padding: 0.34rem 0.15rem;
    font-size: 0.49rem;
  }

  .game-overlay__hint {
    display: none;
  }

  .primary-button {
    min-height: 42px;
    padding: 0.6rem 1rem;
    font-size: 0.67rem;
  }

  .game-overlay__score {
    margin: 0.65rem 0;
  }

  .game-overlay__score span {
    padding: 0.45rem;
    font-size: 0.54rem;
  }

  .game-overlay__score strong {
    font-size: 0.94rem;
  }

  .dock-progress {
    top: 0.45rem;
    min-width: 210px;
    padding: 0.4rem 0.55rem;
    font-size: 0.5rem;
  }

  .game-manual {
    grid-template-columns: 1fr;
    gap: 1.8rem;
  }

  .game-manual__keys {
    grid-column: 1;
    margin: -0.5rem 0 0;
  }

  .touch-controls {
    display: grid;
  }
}

@media (max-width: 430px) {
  .game-page {
    padding-top: 1.8rem;
  }

  .game-stage:not(.is-menu) {
    aspect-ratio: 16 / 10;
  }

  .hud-item--route {
    display: block;
    padding-inline: 0.35rem;
    text-align: center;
  }

  .hud-item--route .hud-item__label {
    display: none;
  }

  .hud-item--route strong {
    font-size: 0;
  }

  .hud-item--route strong::after {
    content: "Trasy";
    font-size: 0.7rem;
  }

  .game-hud {
    grid-template-columns: repeat(4, 1fr) 44px;
  }

  .touch-controls,
  .touch-controls__drive {
    gap: 0.45rem;
  }

  .touch-controls {
    padding: 0.6rem;
  }

  .touch-button {
    min-height: 58px;
  }

  .game-overlay > p:not(.game-overlay__eyebrow):not(.game-overlay__hint) {
    max-height: 3.85em;
    overflow: hidden;
  }
}

/* Portal visual alignment v4 */
:root {
  --cg-type-h1: 32px;
  --cg-type-h2: 24px;
  --cg-type-body: 16px;
  --cg-type-h1-line: 0.98;
  --cg-type-h2-line: 1.05;
  --cg-type-body-line: 1.64;
}

@media (min-width: 430px) {
  :root {
    --cg-type-h1: clamp(32px, calc(26.8054px + 1.2081vw), 50px);
    --cg-type-h2: clamp(24px, calc(21.6913px + 0.5369vw), 32px);
    --cg-type-body: clamp(16px, calc(15.7114px + 0.0671vw), 17px);
  }
}

@media (min-width: 961px) {
  :root {
    --cg-type-h1-line: 0.96;
    --cg-type-h2-line: 1.03;
    --cg-type-body-line: 1.68;
  }
}

body {
  color: #111;
  font-size: var(--cg-type-body);
  line-height: var(--cg-type-body-line);
}

.portal-header__top,
.portal-header__masthead,
.portal-nav,
.game-page {
  width: min(calc(100% - 2rem), 1360px);
}

.portal-header__top {
  min-height: 42px;
  font-size: 0.72rem;
  letter-spacing: 0;
}

.portal-header__masthead {
  position: relative;
  min-height: 108px;
}

.portal-header__masthead .portal-header__back {
  position: absolute;
  right: 0;
  display: inline-flex;
  gap: 0.45rem;
  align-items: center;
  color: var(--navy);
  font-size: 0.72rem;
  font-weight: 800;
  text-decoration: none;
  text-transform: uppercase;
}

.portal-header__brand img {
  width: 96px;
}

.portal-nav {
  min-height: 42px;
}

.portal-nav a {
  min-height: 42px;
  padding-inline: clamp(0.85rem, 2vw, 1.65rem);
  font-size: 0.78rem;
  letter-spacing: 0;
}

.game-page {
  padding-top: clamp(2rem, 3.5vw, 3.4rem);
}

.game-heading {
  grid-template-columns: minmax(0, 1.1fr) minmax(250px, 0.55fr);
  gap: clamp(2rem, 6vw, 5rem);
  margin-bottom: clamp(1.5rem, 2.8vw, 2.3rem);
  padding-bottom: clamp(1.25rem, 2.2vw, 1.8rem);
}

.game-heading h1 {
  font-size: var(--cg-type-h1);
  line-height: var(--cg-type-h1-line);
  letter-spacing: -0.02em;
}

.game-heading__lead {
  max-width: 48rem;
  margin-top: 0.75rem;
  color: rgba(17, 17, 17, 0.72);
  font-size: var(--cg-type-body);
  font-weight: 400;
  line-height: var(--cg-type-body-line);
}

.game-heading__facts {
  max-width: 24rem;
  color: var(--blue);
  font-size: 0.76rem;
  font-weight: 800;
  line-height: 1.55;
  letter-spacing: 0;
}

.game-shell {
  border-top-width: 3px;
  box-shadow: none;
}

.hud-item {
  min-height: 64px;
}

.sound-button {
  width: 64px;
  min-height: 64px;
}

.game-overlay {
  width: min(500px, calc(100% - 2rem));
  padding: clamp(1.15rem, 2.5vw, 1.8rem);
  border-top: 0;
  box-shadow: 0 16px 36px rgba(8, 73, 162, 0.16);
}

.game-overlay__flag {
  display: none;
}

.game-overlay__eyebrow {
  margin-bottom: 0.5rem;
  font-size: 0.72rem;
  letter-spacing: 0.04em;
}

.game-overlay h2 {
  font-size: var(--cg-type-h2);
  line-height: var(--cg-type-h2-line);
  letter-spacing: -0.015em;
}

.game-overlay > p:not(.game-overlay__eyebrow):not(.game-overlay__hint) {
  margin: 0.7rem 0 0.95rem;
  font-size: 0.86rem;
  font-weight: 500;
  line-height: 1.5;
}

.difficulty-description {
  margin: 0.42rem 0 0;
  color: #596b78;
  font-size: 0.64rem;
  font-weight: 650;
  line-height: 1.45;
}

.primary-button,
.score-form button {
  min-height: 46px;
  border: 1px solid var(--blue);
  background-color: var(--blue);
  background-image: linear-gradient(90deg, #fff 0 50%, var(--blue) 50% 100%);
  background-size: 220% 100%;
  background-position: 100% 0;
  color: #fff;
  box-shadow: 0 10px 22px rgba(8, 73, 162, 0.22);
  font-family: var(--body);
  font-size: 0.76rem;
  font-weight: 850;
  letter-spacing: 0;
  transition: transform 180ms ease, box-shadow 180ms ease, background-position 220ms ease, color 180ms ease;
}

.primary-button:hover,
.primary-button:focus-visible,
.score-form button:hover,
.score-form button:focus-visible {
  transform: translateY(1px);
  background-position: 0 0;
  color: var(--blue);
  box-shadow: 0 12px 28px rgba(8, 73, 162, 0.18);
  outline: 0;
}

.level-picker button,
.difficulty-picker button {
  font-family: var(--body);
}

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

.score-form input {
  min-height: 46px;
  font-size: 0.82rem;
}

.leaderboard {
  margin-top: clamp(3rem, 5.5vw, 5rem);
}

.leaderboard__header {
  gap: clamp(1.5rem, 4vw, 3.5rem);
  margin-bottom: 1.25rem;
}

.leaderboard__header h2,
.game-manual h2 {
  font-size: var(--cg-type-h2);
  line-height: var(--cg-type-h2-line);
  letter-spacing: -0.015em;
}

.leaderboard__header p {
  max-width: 48rem;
  margin-top: 0.55rem;
  color: rgba(17, 17, 17, 0.72);
  font-size: var(--cg-type-body);
  font-weight: 400;
  line-height: var(--cg-type-body-line);
}

.leaderboard__mark {
  padding-bottom: 0.15rem;
  font-family: var(--body);
  font-size: 0.76rem;
  font-weight: 850;
  letter-spacing: 0;
}

.leaderboard__table-wrap {
  border-top-width: 3px;
}

.leaderboard__filters {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(240px, 0.7fr);
  gap: 1rem;
  margin-bottom: 1rem;
}

.ranking-filter {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.ranking-filter legend {
  margin-bottom: 0.4rem;
  padding: 0;
  color: #596b78;
  font-size: 0.68rem;
  font-weight: 850;
  text-transform: uppercase;
}

.ranking-filter__buttons {
  display: grid;
  gap: 1px;
  padding: 1px;
  background: rgba(8, 73, 162, 0.18);
}

.ranking-filter__buttons--routes {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.ranking-filter__buttons--difficulty {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.ranking-filter button {
  min-height: 42px;
  padding: 0.55rem 0.65rem;
  color: var(--navy);
  background: #fff;
  border: 0;
  cursor: pointer;
  font-family: var(--body);
  font-size: 0.72rem;
  font-weight: 800;
}

.ranking-filter button[aria-pressed="true"] {
  color: #fff;
  background: var(--blue);
}

.ranking-filter button:hover,
.ranking-filter button:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: -2px;
}

.leaderboard table {
  min-width: 540px;
}

.leaderboard th:nth-child(4),
.leaderboard td:nth-child(4) {
  display: table-cell;
}

.leaderboard td {
  font-size: 0.82rem;
}

.leaderboard__empty,
.leaderboard__error {
  padding: clamp(2rem, 4vw, 3.5rem) 1rem;
  background: #fff;
  font-size: 0.86rem;
}

.game-manual {
  grid-template-columns: minmax(210px, 0.4fr) minmax(0, 1.6fr);
  gap: clamp(2rem, 5vw, 5rem);
  margin-top: clamp(3rem, 5.5vw, 5rem);
}

.game-manual__rules p {
  color: rgba(17, 17, 17, 0.72);
  font-size: var(--cg-type-body);
  font-weight: 400;
  line-height: var(--cg-type-body-line);
}

.game-manual__damage {
  grid-column: 2;
  margin: -0.65rem 0 0;
  color: #9a3226;
  font-size: 0.82rem;
  line-height: 1.5;
}

.game-manual__keys {
  margin-top: -0.4rem;
}

@media (max-width: 760px) {
  .portal-header__top,
  .portal-header__masthead,
  .portal-nav,
  .game-page {
    width: min(calc(100% - 1.25rem), 1360px);
  }

  .portal-header__top {
    min-height: 36px;
  }

  .portal-header__masthead {
    min-height: 76px;
  }

  .portal-header__masthead .portal-header__back {
    font-size: 0;
  }

  .portal-header__masthead .portal-header__back span {
    font-size: 1.4rem;
  }

  .portal-header__brand img {
    width: 78px;
  }

  .game-heading {
    grid-template-columns: 1fr;
    gap: 0.75rem;
  }

  .game-heading h1 {
    font-size: 32px;
  }

  .game-heading__lead {
    font-size: 0.9rem;
    line-height: 1.55;
  }

  .game-heading__facts {
    font-size: 0.68rem;
  }

  .game-overlay {
    border-top: 0;
    box-shadow: 0 10px 24px rgba(8, 73, 162, 0.16);
  }

  .game-overlay h2 {
    font-size: 24px;
  }

  .difficulty-description {
    font-size: 0.55rem;
  }

  .primary-button,
  .score-form button {
    min-height: 42px;
    font-size: 0.67rem;
  }

  .leaderboard__header h2,
  .game-manual h2 {
    font-size: 24px;
  }

  .leaderboard__header p {
    font-size: 0.86rem;
    line-height: 1.55;
  }

  .leaderboard__filters {
    grid-template-columns: 1fr;
    gap: 0.75rem;
  }

  .ranking-filter button {
    min-height: 40px;
    padding-inline: 0.35rem;
    font-size: 0.62rem;
  }

  .leaderboard table {
    min-width: 0;
  }

  .leaderboard__mark {
    font-size: 0.68rem;
  }

  .game-manual {
    grid-template-columns: 1fr;
  }

  .game-manual__damage,
  .game-manual__keys {
    grid-column: 1;
  }

  .game-manual__rules p {
    font-size: 0.9rem;
    line-height: 1.6;
  }
}

/* Portal alignment v4 */
:root {
  --cg-type-h1: clamp(32px, calc(26.8054px + 1.2081vw), 50px);
  --cg-type-h2: clamp(24px, calc(21.6913px + 0.5369vw), 32px);
  --cg-type-body: clamp(16px, calc(15.7114px + 0.0671vw), 17px);
  --cg-type-body-line: 1.68;
}

body {
  color: #111;
  background: #fff;
}

.portal-header {
  border-top: 0;
  border-bottom: 1px solid rgba(8, 73, 162, 0.08);
}

.portal-header__top {
  display: flex;
  width: min(calc(100% - 2rem), 1360px);
  min-height: 38px;
  font-size: 0.64rem;
}

.portal-header__masthead {
  width: min(calc(100% - 2rem), 1360px);
  min-height: 112px;
}

.portal-header__brand img {
  width: 100px;
}

.portal-nav {
  width: min(calc(100% - 2rem), 1360px);
  min-height: 46px;
}

.portal-nav a {
  min-height: 46px;
  padding-inline: clamp(0.8rem, 2vw, 1.65rem);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0;
}

.game-page {
  width: min(calc(100% - 2rem), 1360px);
  padding-top: clamp(1.5rem, 3vw, 2.75rem);
}

.game-back {
  display: inline-flex;
  gap: 0.42rem;
  align-items: center;
  margin-bottom: 1.4rem;
  color: var(--blue);
  font-size: 0.78rem;
  font-weight: 750;
  text-decoration: none;
}

.game-back:hover,
.game-back:focus-visible {
  text-decoration: underline;
  text-underline-offset: 3px;
}

.game-heading {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(240px, 0.42fr);
  gap: clamp(2rem, 6vw, 6rem);
  max-width: none;
  align-items: end;
  margin-bottom: clamp(1.5rem, 3vw, 2.5rem);
  padding-bottom: 0;
  border-bottom: 0;
}

.game-heading h1 {
  margin: 0;
  font-size: var(--cg-type-h1);
  line-height: 0.96;
  text-transform: none;
  letter-spacing: -0.02em;
}

.game-heading__lead {
  max-width: 760px;
  margin-top: 0.85rem;
  color: rgba(17, 17, 17, 0.72);
  font-size: var(--cg-type-body);
  font-weight: 400;
  line-height: var(--cg-type-body-line);
}

.game-heading__facts {
  display: block;
  max-width: 320px;
  margin: 0 0 0.2rem;
  color: var(--blue);
  font-size: 0.72rem;
  font-weight: 800;
  line-height: 1.55;
  text-transform: uppercase;
  letter-spacing: 0;
}

.game-shell {
  border-top: 3px solid var(--blue);
  box-shadow: none;
}

.game-overlay {
  width: min(520px, calc(100% - 2rem));
  padding: clamp(1.2rem, 2.5vw, 2rem);
  border: 0;
  background: rgba(255, 255, 255, 0.98);
  box-shadow: 0 12px 30px rgba(8, 73, 162, 0.16);
}

.game-overlay__flag {
  display: none;
}

.game-overlay__eyebrow {
  margin: 0 0 0.5rem;
  color: var(--blue);
  font-size: 0.75rem;
  font-weight: 750;
  text-transform: none;
  letter-spacing: 0;
}

.game-overlay h2 {
  font-size: var(--cg-type-h2);
  line-height: 1.03;
  text-transform: none;
  letter-spacing: -0.015em;
}

.game-overlay > p:not(.game-overlay__eyebrow):not(.game-overlay__hint) {
  margin: 0.72rem 0 1rem;
  color: rgba(17, 17, 17, 0.72);
  font-size: 0.86rem;
  font-weight: 400;
  line-height: 1.55;
}

.game-setup__group legend,
.score-form > label {
  color: rgba(17, 17, 17, 0.72);
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0;
}

.level-picker,
.difficulty-picker {
  background: rgba(8, 73, 162, 0.14);
  border-color: rgba(8, 73, 162, 0.18);
}

.level-picker button,
.difficulty-picker button {
  color: var(--navy);
  background: #fff;
}

.level-picker button[aria-pressed="true"],
.difficulty-picker button[aria-pressed="true"] {
  color: #fff;
  background: var(--blue);
}

.difficulty-description {
  margin: 0.45rem 0 0 !important;
  color: rgba(17, 17, 17, 0.67) !important;
  font-size: 0.68rem !important;
  font-weight: 500 !important;
  line-height: 1.4 !important;
}

.primary-button,
.score-form button {
  min-height: 46px;
  border: 1px solid var(--blue);
  border-radius: 0;
  background-color: var(--blue);
  background-image: linear-gradient(90deg, #fff 0 50%, var(--blue) 50% 100%);
  background-size: 220% 100%;
  background-position: 100% 0;
  color: #fff;
  box-shadow: 0 10px 22px rgba(8, 73, 162, 0.22);
  font-size: 0.76rem;
  font-weight: 850;
  letter-spacing: 0;
  text-transform: uppercase;
  transition: transform 180ms ease, background-position 220ms ease, color 180ms ease, box-shadow 180ms ease;
}

.primary-button:hover,
.primary-button:focus-visible,
.score-form button:hover,
.score-form button:focus-visible {
  color: var(--blue);
  background-position: 0 0;
  box-shadow: 0 12px 28px rgba(8, 73, 162, 0.18);
  outline: 0;
  transform: translateY(1px);
}

.score-form input {
  min-height: 46px;
  border-color: rgba(8, 73, 162, 0.2);
  font-size: 0.82rem;
  font-weight: 500;
}

.score-form p,
.game-overlay__hint {
  color: rgba(17, 17, 17, 0.62) !important;
  font-size: 0.67rem !important;
  font-weight: 500 !important;
}

.leaderboard {
  margin-top: clamp(3rem, 6vw, 5rem);
}

.leaderboard__header {
  display: grid;
  grid-template-columns: minmax(0, 820px) auto;
  gap: 1.5rem;
  max-width: none;
  align-items: end;
  margin-bottom: 1.25rem;
}

.leaderboard__header h2,
.game-manual h2 {
  font-size: var(--cg-type-h2);
  line-height: 1.03;
  text-transform: none;
  letter-spacing: -0.015em;
}

.leaderboard__header p {
  max-width: 760px;
  margin-top: 0.6rem;
  color: rgba(17, 17, 17, 0.72);
  font-size: var(--cg-type-body);
  font-weight: 400;
  line-height: var(--cg-type-body-line);
}

.leaderboard__mark {
  display: block;
  padding-bottom: 0.25rem;
  color: var(--blue);
  font: 850 0.76rem var(--body);
  letter-spacing: 0;
}

.leaderboard__table-wrap {
  border-top-width: 3px;
}

.leaderboard th {
  font-size: 0.67rem;
  letter-spacing: 0;
}

.leaderboard td {
  font-size: 0.82rem;
  font-weight: 500;
}

.leaderboard__empty,
.leaderboard__error {
  padding-block: 2.5rem;
  font-size: 0.86rem;
  font-weight: 500;
}

.leaderboard.has-new-score {
  animation: none;
}

.game-manual {
  grid-template-columns: minmax(180px, 0.38fr) minmax(0, 1.62fr);
  margin-top: clamp(3rem, 6vw, 5rem);
}

.game-manual__rules p {
  color: rgba(17, 17, 17, 0.72);
  font-size: var(--cg-type-body);
  font-weight: 400;
  line-height: var(--cg-type-body-line);
}

.game-manual__damage {
  grid-column: 2;
  margin: -0.8rem 0 0;
  color: #a1392d;
  font-size: 0.82rem;
  font-weight: 550;
  line-height: 1.5;
}

.game-footer {
  color: rgba(255, 255, 255, 0.72);
  font-size: 0.76rem;
}

@media (max-width: 760px) {
  :root {
    --cg-type-h1: 32px;
    --cg-type-h2: 24px;
    --cg-type-body: 16px;
    --cg-type-body-line: 1.64;
  }

  .portal-header__masthead,
  .game-page {
    width: min(calc(100% - 1.25rem), 1360px);
  }

  .portal-header__masthead {
    min-height: 84px;
  }

  .portal-header__brand img {
    width: 82px;
  }

  .game-back {
    margin-bottom: 1rem;
  }

  .game-heading h1 {
    font-size: var(--cg-type-h1);
  }

  .game-heading {
    grid-template-columns: 1fr;
    gap: 0.75rem;
  }

  .game-heading__facts {
    max-width: none;
    font-size: 0.62rem;
  }

  .game-heading__lead {
    font-size: 0.88rem;
    line-height: 1.58;
  }

  .game-overlay {
    border-top: 0;
  }

  .game-overlay__eyebrow {
    font-size: 0.62rem;
  }

  .game-overlay h2 {
    font-size: 1.5rem;
  }

  .difficulty-description {
    font-size: 0.56rem !important;
  }

  .leaderboard__header h2,
  .game-manual h2 {
    font-size: var(--cg-type-h2);
  }

  .leaderboard__header p,
  .game-manual__rules p {
    font-size: 0.86rem;
    line-height: 1.58;
  }

  .game-manual {
    grid-template-columns: 1fr;
  }

  .game-manual__damage {
    grid-column: 1;
    margin-top: -0.6rem;
  }
}

@media (max-width: 430px) {
  .game-heading h1 {
    font-size: 32px;
  }

  .game-stage.is-menu {
    min-height: 480px;
  }

  .game-stage.is-menu:has(.score-form:not([hidden])) {
    min-height: 590px;
  }

  .game-overlay {
    padding: 0.9rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}

/* Portal shell v3 */
body {
  background: #fff;
}

.portal-header {
  color: var(--navy);
  background: #fff;
  border-top: 5px solid var(--blue);
}

.portal-header__top,
.portal-header__masthead,
.portal-nav {
  width: min(1320px, calc(100% - clamp(2rem, 6vw, 6rem)));
  margin-inline: auto;
}

.portal-header__top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 38px;
  color: #647480;
  border-bottom: 1px solid rgba(8, 73, 162, 0.13);
  font-size: 0.64rem;
  font-weight: 760;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.portal-header__top a {
  text-decoration: none;
}

.portal-header__descriptor:hover,
.portal-header__descriptor:focus-visible,
.portal-header__back:hover,
.portal-header__back:focus-visible {
  color: var(--blue);
}

.portal-header__back {
  display: inline-flex;
  gap: 0.45rem;
  align-items: center;
  color: var(--navy);
}

.portal-header__back span {
  font-size: 1rem;
  transition: transform 180ms ease;
}

.portal-header__back:hover span,
.portal-header__back:focus-visible span {
  transform: translateX(-0.2rem);
}

.portal-header__masthead {
  display: grid;
  min-height: 92px;
  place-items: center;
}

.portal-header__brand img {
  display: block;
  width: clamp(92px, 8.4vw, 118px);
  height: auto;
}

.portal-nav {
  display: flex;
  justify-content: center;
  min-height: 43px;
  background: #eaf4ff;
  border-top: 1px solid #d7e9fb;
  border-bottom: 1px solid #d7e9fb;
  box-shadow: 0 0 0 100vmax #eaf4ff;
  clip-path: inset(0 -100vmax);
}

.portal-nav::before,
.portal-nav::after {
  content: none;
}

.portal-nav a {
  display: inline-flex;
  align-items: center;
  padding: 0.4rem clamp(0.8rem, 2.1vw, 1.8rem);
  border-right: 1px solid rgba(8, 73, 162, 0.12);
  font-size: 0.66rem;
  font-weight: 850;
  text-decoration: none;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.portal-nav a:first-child {
  border-left: 1px solid rgba(8, 73, 162, 0.12);
}

.portal-nav a:hover,
.portal-nav a:focus-visible {
  color: #fff;
  background: var(--blue);
  outline: 0;
}

.game-page {
  padding: clamp(2rem, 4.2vw, 4rem) 0 clamp(3.5rem, 7vw, 6rem);
}

.game-heading {
  grid-template-columns: minmax(0, 1.1fr) minmax(250px, 0.55fr);
  gap: clamp(2rem, 7vw, 7rem);
  margin-bottom: clamp(1.5rem, 2.7vw, 2.5rem);
  padding-bottom: clamp(1.4rem, 2.4vw, 2rem);
  border-bottom: 1px solid var(--line);
}

.game-heading h1 {
  font-size: clamp(2.55rem, 4.6vw, 4.45rem);
  line-height: 0.92;
  letter-spacing: -0.035em;
}

.game-heading__lead {
  max-width: 51rem;
  margin: 1rem 0 0;
  font-size: clamp(0.92rem, 1.15vw, 1.06rem);
  line-height: 1.62;
}

.game-heading__facts {
  max-width: 22rem;
  margin: 0 0 0.25rem;
  color: var(--blue);
  font-size: 0.68rem;
  font-weight: 850;
  line-height: 1.65;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.game-heading__facts span {
  margin-inline: 0.35rem;
  color: #8a9aaa;
}

.game-shell {
  border-top: 4px solid var(--blue);
  box-shadow: 0 20px 44px rgba(8, 73, 162, 0.13);
}

.game-overlay {
  width: min(510px, calc(100% - 2rem));
  padding: clamp(1.15rem, 2.6vw, 2rem);
  background: rgba(255, 255, 255, 0.975);
  border-top: 4px solid var(--blue);
  box-shadow: 10px 12px 0 rgba(8, 73, 162, 0.12);
}

.game-overlay__flag {
  height: 6px;
  margin-bottom: 1rem;
}

.game-overlay h2 {
  font-size: clamp(1.65rem, 2.8vw, 2.65rem);
}

.game-overlay > p:not(.game-overlay__eyebrow):not(.game-overlay__hint) {
  margin: 0.75rem 0 1rem;
  font-size: 0.82rem;
  line-height: 1.48;
}

.game-setup {
  gap: 0.7rem;
  margin: 0.9rem 0 1rem;
}

.score-form {
  margin: 0.9rem 0;
  padding-top: 0.85rem;
  border-top: 1px solid var(--line);
}

.score-form[hidden] {
  display: none;
}

.score-form > label {
  display: block;
  margin-bottom: 0.45rem;
  color: var(--navy);
  font-size: 0.65rem;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.07em;
}

.score-form__row {
  display: grid;
  grid-template-columns: 1fr auto;
}

.score-form input {
  min-width: 0;
  min-height: 44px;
  padding: 0.6rem 0.75rem;
  color: var(--navy);
  background: #fff;
  border: 1px solid #b9d1ec;
  border-right: 0;
  border-radius: 0;
  outline: 0;
  font: 720 0.82rem var(--body);
}

.score-form input:focus {
  border-color: var(--blue);
  box-shadow: inset 0 0 0 1px var(--blue);
}

.score-form button {
  min-height: 44px;
  padding: 0.55rem 0.9rem;
  color: #fff;
  background: var(--blue);
  border: 1px solid var(--blue);
  cursor: pointer;
  font-size: 0.65rem;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.score-form button:hover,
.score-form button:focus-visible {
  color: var(--navy);
  background: var(--sky);
  outline: 2px solid var(--blue);
  outline-offset: 2px;
}

.score-form button:disabled {
  cursor: default;
  opacity: 0.65;
}

.score-form p {
  margin: 0.4rem 0 0;
  color: #738390;
  font-size: 0.62rem;
  font-weight: 620;
  line-height: 1.4;
}

.score-form .score-form__status {
  min-height: 0;
  color: var(--navy);
  font-weight: 780;
}

.score-form__status:empty {
  display: none;
}

.score-form__status.is-success {
  color: #087458;
}

.score-form__status.is-error {
  color: #b63c2b;
}

.leaderboard {
  margin-top: clamp(3.5rem, 7vw, 6.5rem);
  scroll-margin-top: 1.5rem;
}

.leaderboard__header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 2rem;
  align-items: end;
  margin-bottom: 1.35rem;
}

.leaderboard__header h2 {
  margin: 0;
  color: var(--navy);
  font-family: var(--display);
  font-size: clamp(2rem, 3.7vw, 3.7rem);
  font-weight: 400;
  line-height: 0.95;
  text-transform: uppercase;
  letter-spacing: -0.035em;
}

.leaderboard__header p {
  max-width: 48rem;
  margin: 0.65rem 0 0;
  color: var(--muted);
  font-size: 0.83rem;
  font-weight: 570;
  line-height: 1.55;
}

.leaderboard__mark {
  padding-bottom: 0.2rem;
  color: var(--blue);
  font: 400 clamp(1.65rem, 3vw, 2.8rem) var(--display);
  letter-spacing: -0.035em;
}

.leaderboard__table-wrap {
  overflow-x: auto;
  background: #fff;
  border-top: 4px solid var(--blue);
  border-bottom: 1px solid var(--line);
}

.leaderboard table {
  width: 100%;
  min-width: 780px;
  border-collapse: collapse;
}

.leaderboard th,
.leaderboard td {
  padding: 0.9rem clamp(0.7rem, 1.5vw, 1.2rem);
  border-bottom: 1px solid var(--line);
  text-align: left;
  white-space: nowrap;
}

.leaderboard th {
  color: #687987;
  background: #edf6ff;
  font-size: 0.58rem;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.07em;
}

.leaderboard td {
  color: #536674;
  font-size: 0.76rem;
  font-weight: 620;
}

.leaderboard tr:last-child td {
  border-bottom: 0;
}

.leaderboard tr.is-podium td {
  background: rgba(214, 233, 254, 0.28);
}

.leaderboard__place {
  width: 92px;
  color: var(--blue) !important;
  font: 400 1rem var(--display) !important;
}

.leaderboard__captain,
.leaderboard__score {
  color: var(--navy) !important;
  font-weight: 850 !important;
}

.leaderboard__score,
.leaderboard__time {
  text-align: right !important;
}

.leaderboard__empty,
.leaderboard__error {
  margin: 0;
  padding: clamp(2rem, 5vw, 4.5rem) 1rem;
  color: #687987;
  background: #f7fbff;
  font-size: 0.82rem;
  font-weight: 700;
  text-align: center;
}

.leaderboard__error {
  color: #9d3a2e;
}

.leaderboard.has-new-score {
  animation: leaderboard-pulse 900ms ease-out;
}

@keyframes leaderboard-pulse {
  0% { background: rgba(214, 233, 254, 0.7); }
  100% { background: transparent; }
}

.game-manual {
  grid-template-columns: minmax(220px, 0.48fr) minmax(0, 1.52fr);
  gap: clamp(2rem, 6vw, 6rem);
  margin-top: clamp(3.5rem, 7vw, 6rem);
  padding-top: clamp(2rem, 4vw, 3.5rem);
  border-top: 1px solid var(--line);
}

.game-manual h2 {
  font-size: clamp(1.8rem, 3vw, 3rem);
}

.game-footer {
  padding-block: 1.2rem;
  background: #071d3e;
}

@media (max-width: 760px) {
  .portal-header__top,
  .portal-header__masthead,
  .portal-nav,
  .game-page {
    width: min(100% - 1.25rem, 1320px);
  }

  .portal-header__top {
    min-height: 34px;
    font-size: 0.54rem;
  }

  .portal-header__descriptor {
    display: none;
  }

  .portal-header__top {
    justify-content: flex-end;
  }

  .portal-header__masthead {
    min-height: 72px;
  }

  .portal-header__brand img {
    width: 78px;
  }

  .portal-nav {
    display: none;
  }

  .game-page {
    padding-top: 1.8rem;
  }

  .game-heading {
    grid-template-columns: 1fr;
    gap: 0.85rem;
    margin-bottom: 1.25rem;
    padding-bottom: 1.2rem;
  }

  .game-heading h1 {
    font-size: clamp(2.25rem, 10vw, 3.6rem);
  }

  .game-heading__lead {
    margin-top: 0.75rem;
    font-size: 0.82rem;
    line-height: 1.5;
  }

  .game-heading__facts {
    font-size: 0.57rem;
    line-height: 1.5;
  }

  .game-overlay {
    border-top-width: 3px;
  }

  .game-stage.is-menu {
    min-height: 470px;
  }

  .game-stage.is-menu:has(.score-form:not([hidden])) {
    min-height: 585px;
  }

  .score-form {
    margin: 0.65rem 0;
    padding-top: 0.65rem;
  }

  .score-form input,
  .score-form button {
    min-height: 39px;
  }

  .score-form input {
    font-size: 0.7rem;
  }

  .score-form > label,
  .score-form button,
  .score-form p {
    font-size: 0.54rem;
  }

  .leaderboard {
    margin-top: 3.5rem;
  }

  .leaderboard__header {
    gap: 1rem;
    margin-bottom: 1rem;
  }

  .leaderboard__header h2 {
    font-size: clamp(1.75rem, 8vw, 2.65rem);
  }

  .leaderboard__header p {
    font-size: 0.72rem;
  }

  .leaderboard__mark {
    font-size: 1.25rem;
  }

  .leaderboard table {
    min-width: 0;
  }

  .leaderboard th:nth-child(5),
  .leaderboard td:nth-child(5) {
    display: none;
  }

  .leaderboard th,
  .leaderboard td {
    padding: 0.72rem 0.45rem;
    font-size: 0.63rem;
  }

  .leaderboard th {
    font-size: 0.48rem;
  }

  .leaderboard__place {
    width: 48px;
    font-size: 0.78rem !important;
  }

  .game-manual {
    grid-template-columns: 1fr;
    margin-top: 3.5rem;
  }
}

@media (max-width: 520px) {
  .leaderboard th:nth-child(4),
  .leaderboard td:nth-child(4) {
    display: none;
  }

  .leaderboard__mark {
    align-self: start;
    padding-top: 0.3rem;
  }

  .leaderboard__score {
    font-size: 0.59rem !important;
  }
}

@media (max-width: 430px) {
  .game-page {
    padding-top: 1.45rem;
  }

  .game-heading h1 {
    font-size: 2.2rem;
  }

  .game-heading__facts span {
    margin-inline: 0.18rem;
  }

  .game-stage.is-menu {
    min-height: 455px;
  }

  .game-stage.is-menu:has(.score-form:not([hidden])) {
    min-height: 575px;
  }

  .game-overlay {
    width: min(350px, calc(100% - 0.8rem));
    padding: 0.85rem;
  }

  .score-form__row {
    grid-template-columns: minmax(0, 1fr) 104px;
  }

  .leaderboard__header {
    grid-template-columns: 1fr auto;
  }

  .leaderboard th:first-child {
    font-size: 0;
  }

  .leaderboard th:first-child::after {
    content: "Lp.";
    font-size: 0.46rem;
  }
}

/* Final portal scale and component alignment v4 */
:root {
  --cg-type-h1: clamp(32px, calc(26.8054px + 1.2081vw), 50px);
  --cg-type-h2: clamp(24px, calc(21.6913px + 0.5369vw), 32px);
  --cg-type-body: clamp(16px, calc(15.7114px + 0.0671vw), 17px);
}

.portal-header {
  border-top-width: 3px;
}

.portal-header__masthead {
  width: min(calc(100% - 2rem), 1360px);
  min-height: 104px;
}

.portal-header__brand img {
  width: 96px;
}

.game-page {
  width: min(calc(100% - 2rem), 1360px);
  padding-top: clamp(2rem, 3.5vw, 3.25rem);
}

.game-heading {
  grid-template-columns: minmax(0, 1fr) minmax(240px, 0.42fr);
  gap: clamp(2rem, 6vw, 6rem);
  margin-bottom: clamp(1.5rem, 3vw, 2.5rem);
  padding-bottom: 0;
  border-bottom: 0;
}

.game-heading h1 {
  font-size: var(--cg-type-h1);
  line-height: 0.96;
  text-transform: none;
  letter-spacing: -0.02em;
}

.game-heading__lead {
  max-width: 760px;
  margin-top: 0.8rem;
  color: rgba(17, 17, 17, 0.72);
  font-size: var(--cg-type-body);
  font-weight: 400;
  line-height: 1.68;
}

.game-heading__facts {
  max-width: 320px;
  margin-bottom: 0.2rem;
  font-size: 0.72rem;
  line-height: 1.55;
  letter-spacing: 0;
}

.game-shell {
  border-top-width: 3px;
  box-shadow: none;
}

.game-overlay {
  width: min(520px, calc(100% - 2rem));
  padding: clamp(1.2rem, 2.5vw, 2rem);
  border: 0;
  background: rgba(255, 255, 255, 0.98);
  box-shadow: 0 12px 30px rgba(8, 73, 162, 0.16);
}

.game-overlay__flag {
  display: none;
}

.game-overlay__eyebrow {
  margin-bottom: 0.5rem;
  font-size: 0.75rem;
  font-weight: 750;
  text-transform: none;
  letter-spacing: 0;
}

.game-overlay h2,
.leaderboard__header h2,
.game-manual h2 {
  font-size: var(--cg-type-h2);
  line-height: 1.03;
  text-transform: none;
  letter-spacing: -0.015em;
}

.game-overlay > p:not(.game-overlay__eyebrow):not(.game-overlay__hint) {
  color: rgba(17, 17, 17, 0.72);
  font-size: 0.86rem;
  font-weight: 400;
  line-height: 1.55;
}

.difficulty-picker,
.ranking-filter__buttons--difficulty {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.difficulty-description {
  font-size: 0.68rem !important;
  font-weight: 500 !important;
  letter-spacing: 0 !important;
}

.primary-button,
.score-form button {
  min-height: 46px;
  border: 1px solid var(--blue);
  background-color: var(--blue);
  background-image: linear-gradient(90deg, #fff 0 50%, var(--blue) 50% 100%);
  background-size: 220% 100%;
  background-position: 100% 0;
  color: #fff;
  box-shadow: 0 10px 22px rgba(8, 73, 162, 0.22);
  font-size: 0.76rem;
  font-weight: 850;
  letter-spacing: 0;
}

.primary-button:hover,
.primary-button:focus-visible,
.score-form button:hover,
.score-form button:focus-visible {
  color: var(--blue);
  background-position: 0 0;
  box-shadow: 0 12px 28px rgba(8, 73, 162, 0.18);
  outline: 0;
  transform: translateY(1px);
}

.leaderboard__header {
  grid-template-columns: minmax(0, 820px) auto;
  gap: 1.5rem;
}

.leaderboard__header p {
  color: rgba(17, 17, 17, 0.72);
  font-size: var(--cg-type-body);
  font-weight: 400;
  line-height: 1.68;
}

.leaderboard__mark {
  padding-bottom: 0.25rem;
  font: 850 0.76rem var(--body);
  letter-spacing: 0;
}

.leaderboard__table-wrap {
  border-top-width: 3px;
}

.leaderboard table {
  min-width: 540px;
}

.leaderboard th {
  font-size: 0.67rem;
  letter-spacing: 0;
}

.leaderboard td {
  font-size: 0.82rem;
  font-weight: 500;
}

.game-manual__rules p {
  color: rgba(17, 17, 17, 0.72);
  font-size: var(--cg-type-body);
  font-weight: 400;
  line-height: 1.68;
}

@media (max-width: 760px) {
  :root {
    --cg-type-h1: 32px;
    --cg-type-h2: 24px;
    --cg-type-body: 16px;
  }

  .portal-header__masthead,
  .game-page {
    width: min(calc(100% - 1.25rem), 1360px);
  }

  .portal-header__masthead {
    min-height: 76px;
  }

  .portal-header__brand img {
    width: 76px;
  }

  .game-heading {
    grid-template-columns: 1fr;
    gap: 0.7rem;
  }

  .game-heading h1 {
    font-size: 32px;
  }

  .game-heading__lead {
    font-size: 0.9rem;
    line-height: 1.55;
  }

  .game-heading__facts {
    font-size: 0.64rem;
  }

  .game-overlay h2,
  .leaderboard__header h2,
  .game-manual h2 {
    font-size: 24px;
  }

  .leaderboard__header p,
  .game-manual__rules p {
    font-size: 0.9rem;
    line-height: 1.6;
  }

  .leaderboard table {
    min-width: 0;
  }
}

@media (max-width: 520px) {
  .leaderboard th:nth-child(4),
  .leaderboard td:nth-child(4) {
    display: table-cell;
  }
}

@media (max-width: 430px) {
  .sound-button {
    width: 44px;
    min-width: 0;
  }

  .game-stage.is-menu {
    min-height: 500px;
  }

  .game-stage.is-menu:has(.score-form:not([hidden])) {
    min-height: 600px;
  }
}

/* Portal light-blue refinement v5 */
.game-heading__facts {
  display: flex;
  flex-direction: column;
  gap: 0.16rem;
  align-items: flex-start;
  line-height: 1.18;
}

.game-heading__facts span {
  display: block;
  margin: 0;
  color: var(--blue);
  transform-origin: left center;
}

.game-heading__facts span:nth-child(1) {
  transform: rotate(-1.2deg);
}

.game-heading__facts span:nth-child(2) {
  transform: rotate(0.9deg);
}

.game-heading__facts span:nth-child(3) {
  transform: rotate(-0.55deg);
}

.game-shell,
.game-hud,
.touch-controls,
.game-footer,
.skip-link {
  background: var(--blue);
}

.game-message {
  background: rgba(8, 73, 162, 0.92);
}

.dock-progress {
  background: rgba(8, 73, 162, 0.86);
}

.hud-item--route:hover,
.hud-item--route:focus-visible,
.sound-button:hover,
.sound-button:focus-visible,
.touch-button.is-active,
.touch-button:active {
  color: var(--blue);
}

@media (max-width: 760px) {
  .game-heading__facts {
    gap: 0.12rem;
    margin-top: 0.15rem;
  }
}

/* Full-screen mobile game and unified blue v6 */
h1,
h2,
h3,
.game-heading h1,
.game-overlay h2,
.leaderboard__header h2,
.game-manual h2 {
  color: var(--blue);
}

.game-heading__facts {
  max-width: 360px;
  font-size: clamp(1.05rem, 1.35vw, 1.22rem);
  line-height: 1.2;
}

.mobile-orientation {
  display: none;
}

.touch-controls {
  display: none;
}

.touch-joystick {
  --joystick-size: clamp(76px, 22dvh, 104px);
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  align-items: center;
  color: #fff;
  pointer-events: auto;
  touch-action: none;
  user-select: none;
}

.touch-joystick__label {
  padding: 0.18rem 0.45rem;
  background: rgba(8, 73, 162, 0.82);
  font-size: 0.52rem;
  font-weight: 850;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.touch-joystick__base {
  position: relative;
  display: block;
  width: var(--joystick-size);
  height: var(--joystick-size);
  border: 2px solid rgba(255, 255, 255, 0.72);
  border-radius: 50%;
  background: rgba(8, 73, 162, 0.28);
  box-shadow: inset 0 0 0 1px rgba(8, 73, 162, 0.18);
}

.touch-joystick__axis {
  position: absolute;
  top: 50%;
  left: 50%;
  color: rgba(255, 255, 255, 0.58);
  font-style: normal;
  font-size: calc(var(--joystick-size) * 0.62);
  font-weight: 400;
  line-height: 1;
  transform: translate(-50%, -53%);
}

.touch-joystick__knob {
  position: absolute;
  top: 50%;
  left: 50%;
  display: block;
  width: calc(var(--joystick-size) * 0.42);
  height: calc(var(--joystick-size) * 0.42);
  border: 2px solid #fff;
  border-radius: 50%;
  background: rgba(8, 73, 162, 0.92);
  box-shadow: 0 4px 10px rgba(8, 73, 162, 0.22);
  transform: translate(-50%, -50%);
  transition: background-color 100ms ease, transform 70ms linear;
}

.touch-joystick.is-active .touch-joystick__knob {
  background: #d6e9fe;
  border-color: #0849a2;
}

@media (max-width: 900px) and (orientation: portrait),
       (hover: none) and (pointer: coarse) and (orientation: portrait) {
  html,
  body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    overscroll-behavior: none;
    background: var(--blue);
  }

  .skip-link,
  .portal-header,
  .game-heading,
  .leaderboard,
  .game-manual,
  .game-footer {
    display: none !important;
  }

  .game-page {
    position: fixed;
    inset: 0;
    display: flex !important;
    align-items: center;
    justify-content: center;
    width: 100dvw;
    height: 100dvh;
    margin: 0;
    padding: 0;
  }

  .game-shell {
    position: relative;
    display: grid;
    grid-template-rows: 42px auto;
    width: 100dvw;
    height: auto;
    border: 0;
    background: var(--blue);
    box-shadow: none;
    filter: grayscale(0.92) saturate(0.32) brightness(0.9);
    pointer-events: none;
  }

  .game-hud {
    grid-template-columns: repeat(3, minmax(0, 0.75fr)) minmax(92px, 1.25fr) 40px;
    min-height: 42px;
    border: 0;
  }

  .hud-item {
    min-height: 42px;
    padding: 0.35rem 0.42rem;
  }

  .hud-item__label {
    margin-bottom: 0.05rem;
    font-size: 0.4rem;
    letter-spacing: 0.03em;
  }

  .hud-item strong {
    overflow: hidden;
    font-size: clamp(0.55rem, 2.8vw, 0.74rem);
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .sound-button {
    width: 40px;
    min-width: 40px;
    min-height: 42px;
    font-size: 0.9rem;
  }

  .game-stage,
  .game-stage.is-menu,
  .game-stage:not(.is-menu) {
    display: block;
    width: 100%;
    height: auto;
    min-height: 0 !important;
    aspect-ratio: 16 / 9 !important;
  }

  .game-stage canvas {
    display: block;
    width: 100% !important;
    height: auto !important;
    aspect-ratio: 16 / 9;
  }

  .game-overlay,
  .touch-controls,
  .dock-progress,
  .game-message {
    display: none !important;
  }

  .mobile-orientation {
    position: fixed;
    z-index: 200;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    color: #fff;
    text-align: center;
    pointer-events: auto;
  }

  .mobile-orientation strong {
    max-width: 260px;
    padding: 0.75rem 1rem;
    border: 2px solid rgba(255,255,255,0.8);
    background: rgba(8,73,162,0.9);
    box-shadow: 0 8px 22px rgba(8,73,162,0.22);
    font-size: clamp(0.78rem, 3.5vw, 0.95rem);
    font-weight: 850;
  }
}

/* v9 mobile controls: one steering stick and one compact throttle rocker. */
.touch-throttle {
  display: grid;
  grid-template-columns: minmax(92px, 118px);
  gap: 3px;
  justify-items: stretch;
  color: #fff;
  pointer-events: auto;
  touch-action: none;
  user-select: none;
}

.touch-throttle__label {
  justify-self: center;
  padding: 0.18rem 0.45rem;
  background: rgba(8, 73, 162, 0.82);
  font-size: 0.52rem;
  font-weight: 850;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.touch-throttle__button {
  min-height: 48px;
  padding: 0.45rem 0.65rem;
  color: #fff;
  background: rgba(8, 73, 162, 0.88);
  border: 2px solid rgba(255, 255, 255, 0.76);
  border-radius: 0;
  box-shadow: 0 4px 12px rgba(8, 73, 162, 0.2);
  font-family: var(--body);
  text-align: center;
  touch-action: none;
}

.touch-throttle__button strong,
.touch-throttle__button small {
  display: block;
}

.touch-throttle__button strong {
  font-size: 0.68rem;
  font-weight: 900;
  text-transform: uppercase;
}

.touch-throttle__button small {
  margin-top: 0.08rem;
  color: rgba(255, 255, 255, 0.68);
  font-size: 0.48rem;
  font-weight: 750;
}

.touch-throttle__button--reverse {
  min-height: 40px;
  background: rgba(8, 49, 107, 0.86);
}

.touch-throttle__button.is-active {
  color: var(--blue);
  background: #d6e9fe;
  border-color: #fff;
}

.touch-throttle__button.is-active small {
  color: rgba(8, 73, 162, 0.72);
}

@media (max-width: 900px) and (orientation: portrait),
       (hover: none) and (pointer: coarse) and (orientation: portrait) {
  html,
  body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: var(--blue);
  }

  body > :not(.mobile-orientation) {
    display: none !important;
  }

  .mobile-orientation {
    position: fixed;
    z-index: 300;
    inset: 0;
    display: flex !important;
    flex-direction: column;
    gap: 0.75rem;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    color: #fff;
    background: var(--blue);
    text-align: center;
  }

  .mobile-orientation__phone {
    display: block;
    width: 58px;
    height: 34px;
    border: 3px solid #fff;
    box-shadow: inset 0 0 0 2px var(--blue);
  }

  .mobile-orientation strong {
    max-width: 280px;
    padding: 0;
    border: 0;
    background: transparent;
    box-shadow: none;
    font-size: 1rem;
    font-weight: 900;
  }

  .mobile-orientation small {
    max-width: 270px;
    color: rgba(255, 255, 255, 0.72);
    font-size: 0.72rem;
    line-height: 1.45;
  }
}

@media (max-width: 1024px) and (orientation: landscape),
       (hover: none) and (pointer: coarse) and (orientation: landscape) {
  .mobile-orientation {
    display: none !important;
  }

  .game-stage canvas {
    width: 100% !important;
    max-width: none;
    height: 100% !important;
    aspect-ratio: auto;
  }

  .touch-controls {
    gap: 1rem;
    padding-right: calc(clamp(12px, 2.4vw, 24px) + env(safe-area-inset-right));
    padding-bottom: calc(clamp(7px, 1.8dvh, 14px) + env(safe-area-inset-bottom));
    padding-left: calc(clamp(12px, 2.4vw, 24px) + env(safe-area-inset-left));
  }

  .touch-joystick {
    --joystick-size: clamp(78px, 23dvh, 98px);
  }

  .touch-throttle {
    grid-template-columns: clamp(92px, 14vw, 118px);
  }

  .game-overlay {
    width: min(560px, calc(100vw - 250px));
  }
}

/* Touch controls behave like controls, never like selectable page text. */
.touch-controls,
.touch-controls *,
.touch-joystick,
.touch-joystick *,
.touch-throttle,
.touch-throttle * {
  -webkit-user-select: none !important;
  user-select: none !important;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}

.touch-throttle__button {
  touch-action: none;
}

@media (max-width: 760px) and (orientation: landscape) and (max-height: 360px) {
  .touch-throttle__button {
    min-height: 42px;
    padding-block: 0.32rem;
  }

  .touch-throttle__button--reverse {
    min-height: 35px;
  }

  .game-overlay {
    width: min(520px, calc(100vw - 220px));
  }
}

@media (max-width: 1024px) and (orientation: landscape),
       (hover: none) and (pointer: coarse) and (orientation: landscape) {
  html,
  body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    overscroll-behavior: none;
    background: var(--water-deep);
  }

  .skip-link,
  .mobile-orientation,
  .portal-header,
  .game-heading,
  .leaderboard,
  .game-manual,
  .game-footer {
    display: none !important;
  }

  .game-page {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100dvh;
    margin: 0;
    padding: 0;
  }

  .game-shell {
    position: fixed;
    inset: 0;
    display: grid;
    grid-template-rows: 46px minmax(0, 1fr);
    width: 100dvw;
    height: 100dvh;
    border: 0;
    background: var(--blue);
  }

  .game-hud {
    position: relative;
    z-index: 12;
    grid-template-columns: repeat(3, minmax(68px, 0.7fr)) minmax(130px, 1.25fr) 44px;
    min-height: 46px;
    border: 0;
  }

  .hud-item {
    min-height: 46px;
    padding: 0.42rem 0.62rem;
  }

  .hud-item__label {
    margin-bottom: 0.08rem;
    font-size: 0.46rem;
    letter-spacing: 0.04em;
  }

  .hud-item strong {
    font-size: clamp(0.67rem, 1.9vw, 0.88rem);
  }

  .sound-button {
    width: 44px;
    min-height: 46px;
    font-size: 1rem;
  }

  .game-stage,
  .game-stage.is-menu,
  .game-stage:not(.is-menu) {
    position: relative;
    display: flex;
    overflow: hidden;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: auto;
    min-height: 0 !important;
    aspect-ratio: auto !important;
    background: var(--water-deep);
  }

  .game-stage canvas {
    display: block;
    width: auto !important;
    max-width: 100%;
    height: 100% !important;
    aspect-ratio: 16 / 9;
  }

  .game-overlay {
    width: min(560px, calc(100vw - 170px));
    max-height: calc(100dvh - 58px);
    padding: 0.72rem 0.9rem;
    overflow-y: auto;
    border: 0;
    box-shadow: 0 8px 20px rgba(8, 73, 162, 0.18);
  }

  .game-overlay__eyebrow {
    margin-bottom: 0.25rem;
    font-size: 0.56rem;
  }

  .game-overlay h2 {
    font-size: clamp(1.2rem, 3.8vw, 1.65rem);
  }

  .game-overlay > #overlayText,
  .difficulty-description,
  .game-overlay__hint {
    display: none;
  }

  .game-setup {
    display: grid;
    grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr);
    gap: 0.65rem;
    margin: 0.5rem 0 0.6rem;
  }

  .game-setup__group legend {
    margin-bottom: 0.24rem;
    font-size: 0.48rem;
  }

  .level-picker button {
    grid-template-columns: 1fr;
    gap: 0;
    min-height: 42px;
    padding: 0.25rem;
    text-align: center;
  }

  .level-picker b {
    font-size: 0.85rem;
  }

  .level-picker span,
  .difficulty-picker button {
    font-size: 0.46rem;
  }

  .difficulty-picker button {
    min-height: 42px;
    padding: 0.25rem;
  }

  .primary-button,
  .score-form button {
    min-height: 38px;
    padding: 0.48rem 0.8rem;
    font-size: 0.62rem;
  }

  .touch-controls {
    position: fixed;
    z-index: 10;
    inset: 46px 0 0;
    display: flex !important;
    align-items: flex-end;
    justify-content: space-between;
    padding: 0 clamp(12px, 3vw, 28px) clamp(8px, 2.2dvh, 16px);
    border: 0;
    background: transparent;
    opacity: 1;
    pointer-events: none;
    transition: opacity 140ms ease;
  }

  .game-shell:has(.game-stage.is-menu) .touch-controls {
    visibility: hidden;
    opacity: 0;
  }

  .dock-progress {
    top: 0.45rem;
    min-width: min(250px, calc(100% - 220px));
  }
}

@media (max-width: 760px) and (orientation: landscape) and (max-height: 360px) {
  .game-shell {
    grid-template-rows: 40px minmax(0, 1fr);
  }

  .game-hud,
  .hud-item,
  .sound-button {
    min-height: 40px;
  }

  .touch-controls {
    inset-block-start: 40px;
  }

  .touch-joystick {
    --joystick-size: 72px;
  }

  .game-overlay {
    width: min(540px, calc(100vw - 150px));
    padding-block: 0.55rem;
  }
}

/* Cała plansza w jednym widoku na niższych ekranach laptopów. */
@media (min-width: 1025px) and (max-height: 900px) {
  .game-shell {
    background: var(--blue);
  }

  .game-hud,
  .hud-item,
  .sound-button {
    height: 58px;
    min-height: 0;
  }

  .game-hud {
    grid-template-rows: 58px;
    overflow: hidden;
  }

  .hud-item {
    overflow: hidden;
    padding-block: 0.4rem;
  }

  .game-stage,
  .game-stage.is-menu,
  .game-stage:not(.is-menu) {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: auto;
    min-height: 0 !important;
    aspect-ratio: auto !important;
    background: var(--water-deep);
  }

  #gameCanvas {
    display: block;
    width: min(100%, calc((100dvh - 61px) * 1.7777778)) !important;
    height: auto !important;
    aspect-ratio: 16 / 9;
  }

  .game-overlay {
    max-height: calc(100dvh - 82px);
    overflow-y: auto;
  }
}

/* iPhone / telefon pionowo: pełna, grywalna plansza bez blokady obrotu. */
@media (max-width: 900px) and (orientation: portrait),
       (hover: none) and (pointer: coarse) and (orientation: portrait) {
  html,
  body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    overscroll-behavior: none;
    background: var(--water-deep);
  }

  .mobile-orientation {
    display: none !important;
  }

  .game-page {
    position: fixed;
    inset: 0;
    display: block !important;
    width: 100%;
    height: 100vh;
    height: 100dvh;
    margin: 0;
    padding: 0;
  }

  .game-shell {
    position: fixed;
    inset: 0;
    display: grid;
    grid-template-rows: calc(42px + env(safe-area-inset-top)) minmax(0, 1fr);
    width: 100%;
    height: 100vh;
    height: 100dvh;
    border: 0;
    background: var(--blue);
    box-shadow: none;
    filter: none;
    pointer-events: auto;
  }

  .game-hud {
    position: relative;
    z-index: 12;
    height: auto;
    padding-top: env(safe-area-inset-top);
  }

  .game-stage,
  .game-stage.is-menu,
  .game-stage:not(.is-menu) {
    position: relative;
    display: flex;
    overflow: hidden;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: auto;
    min-height: 0 !important;
    aspect-ratio: auto !important;
    background: var(--water-deep);
  }

  .game-stage canvas {
    display: block;
    width: 100% !important;
    max-width: 100%;
    height: auto !important;
    aspect-ratio: 16 / 9;
  }

  .game-overlay {
    left: 50%;
    display: block !important;
    width: calc(100vw - 1rem);
    max-height: calc(100dvh - 58px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
    padding: 0.75rem 0.8rem;
    overflow-y: auto;
    border: 0;
    box-shadow: 0 8px 20px rgba(8, 73, 162, 0.18);
    transform: translate(-50%, -50%);
  }

  .game-overlay.is-hidden {
    transform: translate(-50%, calc(-50% + 8px));
  }

  .game-overlay__flag,
  .game-overlay > #overlayText,
  .difficulty-description,
  .game-overlay__hint {
    display: none !important;
  }

  .game-overlay__eyebrow {
    margin-bottom: 0.2rem;
    font-size: 0.56rem;
  }

  .game-overlay h2 {
    font-size: clamp(1.3rem, 7vw, 1.75rem);
  }

  .game-setup {
    gap: 0.55rem;
    margin: 0.5rem 0 0.6rem;
  }

  .game-setup__group legend {
    margin-bottom: 0.24rem;
    font-size: 0.48rem;
  }

  .level-picker button {
    grid-template-columns: 1fr;
    gap: 0;
    min-height: 44px;
    padding: 0.28rem 0.2rem;
    text-align: center;
  }

  .level-picker b {
    font-size: 0.9rem;
  }

  .level-picker span,
  .difficulty-picker button {
    font-size: 0.48rem;
  }

  .difficulty-picker button {
    min-height: 38px;
    padding: 0.3rem;
  }

  .primary-button,
  .score-form button,
  .score-form input {
    min-height: 40px;
  }

  .touch-controls {
    position: fixed;
    z-index: 10;
    inset: calc(42px + env(safe-area-inset-top)) 0 0;
    display: flex !important;
    align-items: flex-end;
    justify-content: space-between;
    padding: 0 0.8rem calc(0.7rem + env(safe-area-inset-bottom));
    border: 0;
    background: transparent;
    opacity: 1;
    pointer-events: none;
  }

  .game-stage.is-menu + .touch-controls,
  .game-shell:has(.game-stage.is-menu) .touch-controls {
    visibility: hidden;
    opacity: 0;
  }

  .dock-progress {
    top: 0.45rem;
    display: flex !important;
    min-width: min(240px, calc(100% - 1.5rem));
  }

  .game-message {
    display: block !important;
    bottom: calc(0.65rem + env(safe-area-inset-bottom));
  }
}

/* Keep the final cascade aligned with the landscape-only mobile decision. */
@media (max-width: 900px) and (orientation: portrait),
       (hover: none) and (pointer: coarse) and (orientation: portrait) {
  html,
  body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: var(--blue);
  }

  body > :not(.mobile-orientation) {
    display: none !important;
  }

  .mobile-orientation {
    position: fixed;
    z-index: 300;
    inset: 0;
    display: flex !important;
    flex-direction: column;
    gap: 0.75rem;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    color: #fff;
    background: var(--blue);
    text-align: center;
  }

  .mobile-orientation__phone {
    display: block;
    width: 58px;
    height: 34px;
    border: 3px solid #fff;
    box-shadow: inset 0 0 0 2px var(--blue);
  }

  .mobile-orientation strong {
    max-width: 280px;
    padding: 0;
    border: 0;
    background: transparent;
    box-shadow: none;
    font-size: 1rem;
    font-weight: 900;
  }

  .mobile-orientation small {
    max-width: 270px;
    color: rgba(255, 255, 255, 0.72);
    font-size: 0.72rem;
    line-height: 1.45;
  }
}

@media (max-width: 1024px) and (orientation: landscape),
       (hover: none) and (pointer: coarse) and (orientation: landscape) {
  .mobile-orientation {
    display: none !important;
  }

  .game-stage canvas {
    width: 100% !important;
    max-width: none;
    height: 100% !important;
    aspect-ratio: auto;
  }

  .touch-controls {
    gap: 1rem;
    padding-right: calc(clamp(12px, 2.4vw, 24px) + env(safe-area-inset-right));
    padding-bottom: calc(clamp(7px, 1.8dvh, 14px) + env(safe-area-inset-bottom));
    padding-left: calc(clamp(12px, 2.4vw, 24px) + env(safe-area-inset-left));
  }

  .touch-joystick {
    --joystick-size: clamp(78px, 23dvh, 98px);
  }

  .touch-throttle {
    grid-template-columns: clamp(92px, 14vw, 118px);
  }

  .game-overlay {
    width: min(560px, calc(100vw - 250px));
  }
}

/* Final iOS selection guard. */
.touch-controls,
.touch-controls *,
.touch-joystick,
.touch-joystick *,
.touch-throttle,
.touch-throttle * {
  -webkit-user-select: none !important;
  user-select: none !important;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}

.touch-throttle__button {
  touch-action: none;
}
