:root {
  color-scheme: dark;
  font-family: Inter, ui-rounded, "SF Pro Rounded", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  --navy-950: #061225;
  --navy-900: #08172b;
  --navy-800: #102640;
  --ice: #eaf8ff;
  --ice-muted: #abc7d8;
  --cyan: #45d4f2;
  --coral: #ff6f51;
  --coral-dark: #e54f37;
  --gold: #ffd34c;
  --panel: rgba(7, 19, 37, 0.92);
  --line: rgba(205, 238, 255, 0.22);
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--navy-950);
}

body {
  overscroll-behavior: none;
}

button {
  font: inherit;
}

button:focus-visible {
  outline: 3px solid var(--gold);
  outline-offset: 4px;
}

[hidden] {
  display: none !important;
}

.app {
  position: fixed;
  inset: 0;
  min-height: 100svh;
  overflow: hidden;
  isolation: isolate;
  background: var(--navy-900);
}

#game {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

.hud {
  position: absolute;
  z-index: 3;
  inset: max(18px, env(safe-area-inset-top)) max(18px, env(safe-area-inset-right)) auto max(18px, env(safe-area-inset-left));
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  pointer-events: none;
}

.score-block {
  display: grid;
  gap: 2px;
  min-width: 108px;
  padding: 10px 14px 11px;
  background: rgba(6, 18, 37, 0.86);
  border: 1px solid rgba(219, 247, 255, 0.22);
  box-shadow: 0 8px 24px rgba(3, 10, 24, 0.28);
  clip-path: polygon(0 0, calc(100% - 12px) 0, 100% 12px, 100% 100%, 0 100%);
}

.score-label {
  color: var(--ice-muted);
  font-size: 0.65rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.score-block strong {
  color: white;
  font-size: clamp(2rem, 4.7vw, 3.7rem);
  line-height: 0.95;
  letter-spacing: -0.07em;
  text-shadow: 0 4px 0 rgba(0, 0, 0, 0.26);
}

.pickup-count {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-top: 4px;
  color: var(--gold);
  font-size: 0.8rem;
  font-weight: 900;
}

.hud-actions {
  display: flex;
  gap: 10px;
  pointer-events: auto;
}

.icon-button {
  width: 52px;
  height: 52px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(219, 247, 255, 0.24);
  color: white;
  background: rgba(6, 18, 37, 0.84);
  box-shadow: 0 8px 24px rgba(3, 10, 24, 0.25);
  cursor: pointer;
  clip-path: polygon(0 0, calc(100% - 9px) 0, 100% 9px, 100% 100%, 0 100%);
}

.icon-button:hover {
  background: rgba(18, 43, 70, 0.94);
}

.icon-button svg {
  width: 27px;
  height: 27px;
  fill: currentColor;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.icon-button[data-muted="false"] .sound-off,
.icon-button[data-muted="true"] .sound-on {
  display: none;
}

.touch-hint {
  position: absolute;
  z-index: 3;
  left: 50%;
  bottom: calc(24px + env(safe-area-inset-bottom));
  margin: 0;
  padding: 8px 13px;
  transform: translateX(-50%);
  color: var(--ice);
  background: rgba(6, 18, 37, 0.68);
  border: 1px solid rgba(219, 247, 255, 0.16);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  pointer-events: none;
  animation: hint-pulse 1.8s ease-in-out infinite;
}

.screen {
  position: absolute;
  z-index: 5;
  inset: 0;
  display: grid;
  place-items: center;
  padding: max(82px, env(safe-area-inset-top)) 18px max(30px, env(safe-area-inset-bottom));
  background:
    linear-gradient(rgba(3, 11, 24, 0.28), rgba(3, 11, 24, 0.66)),
    radial-gradient(circle at 50% 45%, rgba(69, 212, 242, 0.08), transparent 48%);
  backdrop-filter: blur(4px);
}

.panel {
  width: min(420px, 100%);
  max-height: calc(100svh - 112px);
  overflow-y: auto;
  padding: clamp(24px, 5vw, 40px);
  color: var(--ice);
  text-align: center;
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: 0 24px 70px rgba(2, 8, 20, 0.52);
  clip-path: polygon(0 0, calc(100% - 24px) 0, 100% 24px, 100% 100%, 24px 100%, 0 calc(100% - 24px));
}

.panel-wide {
  width: min(560px, 100%);
}

.panel-title {
  padding-top: 28px;
}

.mascot-mark {
  width: 82px;
  height: 82px;
  margin: 0 auto 16px;
  border: 3px solid rgba(255, 255, 255, 0.82);
  background: url("./assets/icons/icon-192.png") center / cover;
  box-shadow: 8px 8px 0 rgba(69, 212, 242, 0.24);
}

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

h1,
h2 {
  margin-bottom: 12px;
  color: white;
  line-height: 0.98;
  letter-spacing: -0.055em;
}

h1 {
  font-size: clamp(2.75rem, 8vw, 4.6rem);
}

h2 {
  font-size: clamp(2rem, 6vw, 3rem);
}

.panel p {
  color: var(--ice-muted);
  line-height: 1.5;
}

.panel-kicker {
  margin-bottom: 8px;
  color: var(--cyan) !important;
  font-size: 0.72rem;
  font-weight: 900;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.best-line {
  margin: 20px 0;
  font-weight: 800;
}

.best-line strong {
  color: var(--gold);
}

.primary-button,
.text-button,
.setting-row {
  min-height: 48px;
  border: 0;
  cursor: pointer;
}

.primary-button {
  width: 100%;
  margin-top: 8px;
  padding: 14px 22px;
  color: #071629;
  background: var(--coral);
  box-shadow: 0 6px 0 var(--coral-dark);
  font-size: 1rem;
  font-weight: 950;
  letter-spacing: 0.035em;
  text-transform: uppercase;
  clip-path: polygon(0 0, calc(100% - 10px) 0, 100% 10px, 100% 100%, 10px 100%, 0 calc(100% - 10px));
}

.primary-button:hover {
  filter: brightness(1.08);
}

.primary-button:active {
  transform: translateY(4px);
  box-shadow: 0 2px 0 var(--coral-dark);
}

.secondary-actions {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-top: 20px;
}

.text-button {
  padding: 10px 12px;
  color: var(--ice);
  background: transparent;
  font-size: 0.86rem;
  font-weight: 800;
  text-decoration: underline;
  text-decoration-color: rgba(69, 212, 242, 0.45);
  text-underline-offset: 4px;
}

.key-prompt {
  margin: 18px 0 0 !important;
  font-size: 0.74rem;
  font-weight: 800;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.result-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 22px 0;
}

.result-grid div {
  padding: 16px 10px;
  background: rgba(255, 255, 255, 0.055);
  border: 1px solid var(--line);
}

.result-grid span {
  display: block;
  margin-bottom: 4px;
  color: var(--ice-muted);
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.result-grid strong {
  color: white;
  font-size: 2rem;
}

.new-best {
  display: inline-block;
  margin: 6px 0 0 !important;
  padding: 6px 9px;
  color: #241800 !important;
  background: var(--gold);
  font-size: 0.72rem;
  font-weight: 900;
  text-transform: uppercase;
}

.help-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin: 22px 0;
  text-align: left;
}

.help-grid div {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--line);
}

kbd {
  min-width: 34px;
  padding: 6px;
  color: white;
  text-align: center;
  background: var(--navy-800);
  border: 1px solid rgba(255, 255, 255, 0.2);
  box-shadow: 0 3px 0 #041020;
}

.help-grid span {
  color: var(--ice-muted);
  font-size: 0.82rem;
}

.rules {
  margin: 18px 0 22px;
  padding-left: 22px;
  color: var(--ice-muted);
  text-align: left;
  line-height: 1.5;
}

.rules li + li {
  margin-top: 7px;
}

.touch-guide {
  margin: 20px 0;
}

.swipe-glyph {
  color: var(--cyan);
  font-size: 3rem;
  font-weight: 900;
}

.setting-row {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 8px;
  padding: 0 14px;
  color: var(--ice);
  background: rgba(255, 255, 255, 0.055);
  border: 1px solid var(--line);
  font-size: 0.9rem;
  font-weight: 800;
}

.setting-row span:last-child {
  color: var(--cyan);
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.setting-row[aria-pressed="true"] {
  background: rgba(69, 212, 242, 0.13);
  border-color: rgba(69, 212, 242, 0.5);
}

.setting-row.danger span:last-child {
  color: #ff9c88;
}

.touch-controls {
  display: none;
}

@keyframes hint-pulse {
  50% {
    transform: translateX(-50%) translateY(-3px);
    opacity: 0.78;
  }
}

.app[data-reduced-motion="true"] .touch-hint {
  animation: none;
}

@media (pointer: coarse) {
  .desktop-controls {
    display: none !important;
  }

  .touch-controls {
    display: block;
  }

  .icon-button {
    width: 50px;
    height: 50px;
  }
}

@media (max-width: 560px) {
  .hud {
    inset: max(12px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) auto max(12px, env(safe-area-inset-left));
  }

  .score-block {
    min-width: 88px;
    padding: 8px 11px 9px;
  }

  .score-block strong {
    font-size: 2.25rem;
  }

  .score-label {
    font-size: 0.56rem;
  }

  .screen {
    padding: max(72px, env(safe-area-inset-top)) 12px max(18px, env(safe-area-inset-bottom));
  }

  .panel {
    max-height: calc(100svh - 96px);
    padding: 24px 20px 28px;
  }

  .mascot-mark {
    width: 66px;
    height: 66px;
  }

  .secondary-actions {
    flex-direction: column;
    gap: 0;
  }
}

@media (max-height: 500px) and (orientation: landscape) {
  .screen {
    padding:
      max(10px, env(safe-area-inset-top))
      max(72px, env(safe-area-inset-right))
      max(10px, env(safe-area-inset-bottom))
      max(72px, env(safe-area-inset-left));
  }

  .panel {
    max-height: calc(100svh - 20px);
    padding: 14px 24px 16px;
  }

  .panel-title {
    padding-top: 14px;
  }

  .mascot-mark {
    width: 48px;
    height: 48px;
    margin-bottom: 6px;
    border-width: 2px;
    box-shadow: 4px 4px 0 rgba(69, 212, 242, 0.24);
  }

  h1 {
    margin-bottom: 5px;
    font-size: 2.25rem;
  }

  h2 {
    margin-bottom: 7px;
    font-size: 1.8rem;
  }

  .panel p {
    margin-bottom: 6px;
    line-height: 1.25;
  }

  .best-line {
    margin: 7px 0;
  }

  .primary-button {
    min-height: 40px;
    margin-top: 3px;
    padding: 9px 18px;
  }

  .secondary-actions {
    flex-direction: row;
    gap: 10px;
    margin-top: 7px;
  }

  .text-button {
    min-height: 34px;
    padding: 5px 8px;
  }

  .key-prompt {
    margin-top: 5px !important;
  }

  .result-grid,
  .help-grid,
  .touch-guide,
  .rules {
    margin-top: 8px;
    margin-bottom: 8px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}
