:root {
  color-scheme: dark;
  --bg: #191e20;
  --surface: #252b2d;
  --selected: #283b38;
  --cream: #f2ece0;
  --muted: #9ba49f;
  --secondary: #b9c0b9;
  --teal: #8ec7bc;
  --coral: #d99a86;
  --ink: #1c2524;
  font-family: -apple-system, BlinkMacSystemFont, "Helvetica Neue", sans-serif;
  font-synthesis: none;
}
* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}
[hidden] {
  display: none !important;
}
html,
body {
  margin: 0;
  background: var(--bg);
  color: var(--cream);
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
}
body {
  position: fixed;
  inset: 0;
  width: 100%;
  -webkit-user-select: none;
  user-select: none;
}
button {
  font: inherit;
  color: inherit;
  cursor: pointer;
  border: 0;
  touch-action: manipulation;
}
button:disabled {
  cursor: default;
}
button:focus-visible {
  outline: 3px solid var(--cream);
  outline-offset: 4px;
}
button:not(:disabled):active {
  opacity: 0.72;
}
button,
svg {
  flex-shrink: 0;
}
svg {
  width: 20px;
  height: 20px;
  vertical-align: middle;
}
.symbols {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}
#app {
  height: 100vh;
  height: 100dvh;
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
}
.menu {
  height: 100%;
  overflow: hidden;
  touch-action: none;
  container-type: size;
}
.menu-content {
  height: 100%;
  max-width: 480px;
  margin: auto;
  padding: clamp(8px, 2cqh, 20px) 20px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: clamp(6px, 2cqh, 18px);
}
.brand {
  text-align: center;
  margin: 0;
}
h1 {
  font-family:
    ui-rounded,
    "SF Pro Rounded",
    -apple-system,
    sans-serif;
  font-size: clamp(24px, 5cqh, 42px);
  font-weight: 900;
  letter-spacing: 4px;
  line-height: 1.18;
  margin: clamp(6px, 1.5cqh, 14px) 0;
}
.studio {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 2px;
  color: var(--muted);
  margin: 0;
}
.mark {
  position: relative;
  width: 76px;
  height: 76px;
  margin: auto;
}
.mark i,
.mark b,
.mark em {
  position: absolute;
  display: block;
}
.mark i:nth-child(1) {
  width: 16px;
  height: 16px;
  left: 24px;
  top: 10px;
  background: var(--teal);
  border-radius: 5px;
}
.mark i:nth-child(2) {
  width: 22px;
  height: 22px;
  left: 42px;
  top: 23px;
  background: #bcd2c8;
  border-radius: 6px;
}
.mark i:nth-child(3) {
  width: 16px;
  height: 16px;
  left: 54px;
  top: 51px;
  background: #e3d4bb;
  border-radius: 5px;
}
.mark b {
  width: 17px;
  height: 17px;
  left: 11px;
  top: 46px;
  border-radius: 50%;
  background: #fff;
}
.mark em {
  border-radius: 50%;
  background: var(--cream);
  width: 5px;
  height: 5px;
  left: 26px;
  top: 41px;
  opacity: 0.7;
}
.mark em:last-child {
  width: 4px;
  height: 4px;
  left: 35px;
  top: 32px;
  opacity: 0.4;
}
.difficulty-list {
  display: grid;
  gap: clamp(6px, 1.2cqh, 12px);
}
.difficulty {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  text-align: left;
  background: var(--surface);
  border-radius: 18px;
  padding: clamp(8px, 1.6cqh, 18px);
  min-height: clamp(68px, 11cqh, 102px);
  width: 100%;
}
.difficulty[aria-pressed="true"] {
  background: var(--selected);
}
.difficulty strong {
  display: block;
  font-family:
    ui-rounded,
    -apple-system,
    sans-serif;
  font-weight: 700;
  font-size: clamp(18px, 3cqh, 23px);
  margin: 0 0 4px;
}
.difficulty small {
  display: block;
  font-size: 12px;
  font-weight: 500;
  line-height: 1.35;
  color: var(--secondary);
}
.difficulty[aria-pressed="true"] strong {
  color: var(--teal);
}
.difficulty[data-mode="medium"][aria-pressed="true"] strong {
  color: #e3d4bb;
}
.difficulty[data-mode="hard"][aria-pressed="true"] strong {
  color: var(--coral);
}
.check {
  display: none;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 900;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  color: var(--ink);
  background: currentColor;
  vertical-align: middle;
  position: relative;
  margin-left: 5px;
}
.difficulty[aria-pressed="true"] .check {
  display: inline-flex;
  background: var(--teal);
}
.difficulty[data-mode="medium"] .check {
  background: #e3d4bb;
}
.difficulty[data-mode="hard"] .check {
  background: var(--coral);
}
.best {
  text-align: center;
  min-width: 62px;
}
.best small {
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 1px;
  color: var(--muted);
  white-space: nowrap;
}
.best b {
  display: block;
  font-size: 24px;
  font-weight: 300;
  margin-top: 5px;
  font-variant-numeric: tabular-nums;
}
.primary,
.secondary {
  min-height: 49px;
  border-radius: 14px;
  padding: 16px 18px;
  font-size: 15px;
  font-weight: 750;
  width: 100%;
}
.primary {
  background: var(--teal);
  color: var(--ink);
}
#play {
  letter-spacing: 2px;
  font-size: 14px;
  font-weight: 850;
}
.secondary {
  background: var(--surface);
  color: var(--cream);
}
.text-button {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
  background: transparent;
  color: var(--secondary);
  font-size: 13px;
  min-height: 44px;
  padding: 4px 10px;
}
.sound-toggle {
  font-size: 12px;
  letter-spacing: 1px;
  font-weight: 600;
}
.install {
  font-size: 11px;
  color: var(--muted);
  margin: 0;
}
.menu-actions {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 4px 8px;
}
.menu-actions > .primary,
.menu-actions > #update,
.menu-actions > .storage-note {
  grid-column: 1 / -1;
}
.menu-actions:has(#continue:not([hidden])) > .primary {
  grid-column: auto;
}
.menu-actions > .primary,
.menu-actions > .secondary {
  min-height: 44px;
  padding: 10px 8px;
}
.menu-actions .install {
  line-height: 1.25;
}
.menu-actions #continue {
  font-size: 12px;
}
.storage-note {
  font-size: 11px;
  text-align: center;
  color: var(--muted);
  margin: 0;
}
.game {
  height: 100%;
  max-width: 520px;
  margin: auto;
  display: grid;
  grid-template-rows: 90px minmax(0, 1fr);
  position: relative;
}
.game-header {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 26px;
}
.game-brand {
  display: grid;
  gap: 5px;
  z-index: 1;
}
.game-brand > b {
  font-family:
    ui-rounded,
    -apple-system,
    sans-serif;
  font-size: 13px;
  font-weight: 850;
  line-height: 1.2;
  letter-spacing: 2px;
}
#active-mode {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 1.5px;
  color: var(--teal);
}
.game-brand small {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 10px;
  font-weight: 600;
  color: var(--muted);
}
.game-brand svg {
  color: var(--teal);
  width: 13px;
  height: 13px;
}
.round {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  text-align: center;
  display: grid;
  gap: 1px;
}
.round strong {
  font-size: 42px;
  line-height: 1.08;
  font-weight: 300;
  font-variant-numeric: tabular-nums;
}
.round span {
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 2px;
  color: var(--muted);
}
.round-button {
  background: var(--surface);
  border-radius: 50%;
  width: 44px;
  height: 44px;
}
.play-surface {
  display: flex;
  flex-direction: column;
  min-height: 0;
  touch-action: none;
}
.board-host {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
  flex: 1;
}
#board {
  display: block;
  touch-action: none;
}
.game-footer {
  height: 74px;
  flex: 0 0 74px;
  text-align: center;
  padding: 5px 5px 0;
}
.counter {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 1.5px;
  font-variant-numeric: tabular-nums;
  height: 24px;
}
.counter i {
  background: white;
  border-radius: 50%;
  width: 12px;
  height: 12px;
}
#bonus {
  color: var(--coral);
}
.game-footer p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 12px;
}
.volley-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
}
.volley-controls button {
  display: flex;
  align-items: center;
  gap: 7px;
  min-height: 44px;
  padding: 0 3px;
  background: transparent;
  font-size: 15px;
  font-weight: 600;
  color: var(--secondary);
}
.volley-controls button:disabled {
  color: rgba(242, 236, 224, 0.35);
}
.volley-controls #speed.boosted {
  color: var(--teal);
}
.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  background: rgba(25, 30, 32, 0.96);
  padding: 24px;
  z-index: 5;
  overflow: auto;
}
.overlay h2 {
  font-family:
    ui-rounded,
    -apple-system,
    sans-serif;
  font-size: 36px;
  margin: 0;
  font-weight: 700;
}
.overlay > p {
  text-align: center;
  color: var(--secondary);
  font-size: 14px;
  line-height: 1.5;
  margin: 0;
  max-width: 280px;
}
.overlay > .primary,
.overlay > .secondary {
  max-width: 220px;
}
.overlay .text-button {
  margin-top: -8px;
}
.overlay > small {
  font-size: 10px;
  letter-spacing: 2px;
  font-weight: 700;
  color: var(--muted);
}
.end-scores {
  display: flex;
  gap: 45px;
  text-align: center;
}
.end-scores b {
  display: block;
  font-size: 32px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}
.end-scores small {
  display: block;
  font-size: 10px;
  letter-spacing: 2px;
  color: var(--muted);
  margin-top: 5px;
}
.rescue-clock {
  position: relative;
  width: 82px;
  height: 82px;
}
.rescue-clock svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}
.rescue-clock circle {
  fill: none;
  stroke: rgba(142, 199, 188, 0.15);
  stroke-width: 4;
}
.rescue-clock circle:last-child {
  stroke: var(--teal);
  stroke-linecap: round;
  stroke-dasharray: 245;
}
.rescue-clock b {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 36px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}
dialog {
  background: var(--surface);
  color: var(--cream);
  border: 0;
  border-radius: 22px;
  padding: 32px 26px;
  max-width: 380px;
  width: calc(100% - 36px);
  box-shadow: 0 24px 90px #0005;
}
dialog::backdrop {
  background: rgba(10, 15, 16, 0.75);
}
dialog h2 {
  font-size: 26px;
  line-height: 1.1;
  margin: 8px 18px 18px 0;
}
dialog p,
dialog li {
  color: var(--secondary);
  font-size: 14px;
  line-height: 1.5;
}
dialog ol {
  padding-left: 20px;
  margin: 24px 0;
}
dialog li {
  padding-left: 5px;
  margin-bottom: 12px;
}
dialog strong {
  color: var(--cream);
}
dialog .fine {
  font-size: 11px;
  color: var(--muted);
}
.close {
  position: absolute;
  right: 14px;
  top: 12px;
  width: 36px;
  height: 36px;
  font-size: 27px;
  background: transparent;
  color: var(--muted);
}
.no-script {
  text-align: center;
  padding: 30px;
}
@media (max-height: 700px) {
  .brand {
    display: grid;
    grid-template-columns: 64px minmax(0, 1fr);
    column-gap: 8px;
    align-items: center;
    max-width: 300px;
    margin: 0 auto;
  }
  .brand .mark {
    grid-column: 1;
    grid-row: 1 / 3;
    transform: scale(0.75);
    margin: -6px;
  }
  .brand h1 {
    text-align: left;
    letter-spacing: 2px;
  }
  .brand .studio {
    grid-column: 2;
    text-align: left;
  }
  .game {
    grid-template-rows: 82px minmax(0, 1fr);
  }
  .overlay {
    gap: 14px;
  }
}
@media (orientation: landscape) and (max-height: 600px) {
  .menu-content {
    max-width: 760px;
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.5fr);
    align-content: center;
    column-gap: 28px;
  }
  .brand {
    grid-column: 1;
    grid-row: 1;
    align-self: end;
  }
  .menu-actions {
    grid-column: 1;
    grid-row: 2;
  }
  .difficulty-list {
    grid-column: 2;
    grid-row: 1 / 3;
  }
}
@media (orientation: portrait) and (max-height: 520px) {
  .menu-content {
    padding: 6px 16px;
    gap: 4px;
  }
  .difficulty {
    padding: 6px 8px;
    min-height: 64px;
  }
  .difficulty small {
    font-size: 11px;
  }
  .brand h1 {
    margin: 4px 0;
  }
}
@media (prefers-reduced-motion: reduce) {
  * {
    scroll-behavior: auto;
  }
}

/* Keep the installation dialog usable with Safari bars or a short viewport. */
dialog {
  max-height: calc(100dvh - 32px);
  overflow: auto;
}
@media (max-width: 360px) {
  .game-brand > b {
    font-size: 12px;
    letter-spacing: 1.4px;
  }
  .round strong {
    font-size: 36px;
  }
}
