:root {
  --paper: #edf0e9;
  --navy: #102a35;
  --cyan: #45bfc1;
  --teal: #356f73;
  --gold: #a78d45;
  --red: #b54d43;
  --muted: #718086;
  --line: rgba(16, 42, 53, 0.2);
  --mono: "IBM Plex Mono", monospace;
  --sans: "Inter", sans-serif;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

body {
  min-width: 320px;
  margin: 0;
  overflow-x: hidden;
  background-color: var(--paper);
  background-image: radial-gradient(circle, rgba(16, 42, 53, 0.12) 1px, transparent 1.25px);
  background-size: 28px 28px;
  color: var(--navy);
  font-family: var(--sans);
}

body::before {
  position: fixed;
  z-index: 30;
  top: 0;
  bottom: 0;
  left: clamp(28px, 3vw, 52px);
  width: 2px;
  background: rgba(181, 77, 67, 0.62);
  content: "";
  pointer-events: none;
}

a { color: inherit; }
button { color: inherit; font: inherit; }

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.mochi-skip-link {
  position: fixed;
  z-index: 100;
  top: 0.75rem;
  left: 0.75rem;
  padding: 0.65rem;
  background: var(--navy);
  color: var(--paper);
  font: 500 0.7rem/1 var(--mono);
  transform: translateY(-180%);
}

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

.mochi-page-header {
  display: grid;
  width: min(1440px, calc(100% - 48px));
  min-height: 118px;
  margin-inline: auto;
  padding: 0 2rem;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  border-bottom: 1px solid var(--line);
}

.mochi-page-header__brand {
  font: 700 1.5rem/1 var(--sans);
  letter-spacing: 0.08em;
  text-decoration: none;
}

.mochi-page-header > p,
.mochi-page-header__back,
.mochi-experience__header p,
.mochi-game__status,
.mochi-game__prompt,
.mochi-game__pause,
.mochi-game__result,
.mochi-game__footer,
.mochi-prototype-note {
  font-family: var(--mono);
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.mochi-page-header > p {
  margin: 0;
  color: var(--muted);
  font-size: 0.7rem;
}

.mochi-page-header__back {
  justify-self: end;
  font-size: 0.66rem;
  text-decoration: none;
}

.mochi-experience {
  width: min(1440px, calc(100% - 48px));
  margin-inline: auto;
  padding: clamp(1.75rem, 3vw, 3rem) 2rem 5rem;
}

.mochi-experience__header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(20rem, 0.65fr);
  gap: 2rem;
  align-items: end;
  margin-bottom: 1.25rem;
}

.mochi-experience__header p {
  margin: 0 0 0.5rem;
  color: var(--teal);
  font-size: 0.68rem;
  line-height: 1.5;
}

.mochi-experience__header > p {
  max-width: 38rem;
  justify-self: end;
  color: var(--muted);
  text-align: right;
}

.mochi-experience__header h1 {
  margin: 0;
  font-size: clamp(2.2rem, 4vw, 4.25rem);
  line-height: 0.92;
  letter-spacing: -0.055em;
}

.mochi-game {
  border: 1px solid var(--navy);
  background: rgba(237, 240, 233, 0.92);
}

.mochi-game__status {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  border-bottom: 1px solid var(--navy);
}

.mochi-game__status p {
  display: flex;
  min-width: 0;
  min-height: 3.75rem;
  margin: 0;
  padding: 0.8rem 1rem;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  font-size: 0.64rem;
}

.mochi-game__status p + p { border-left: 1px solid var(--line); }
.mochi-game__status span { color: var(--muted); }
.mochi-game__status strong { font-weight: 500; }
.mochi-game__status [data-delivered-count] { color: var(--cyan); font-size: 0.82rem; }
.mochi-game__status [data-pressure-state] {
  color: var(--cyan);
  font-size: 0.8rem;
  letter-spacing: 0.28em;
  transition: color 180ms ease, text-shadow 180ms ease;
}

.mochi-game__field {
  position: relative;
  overflow: hidden;
  background: #fff4e5;
}

.mochi-game canvas {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 16 / 9;
  background: #fff4e5;
  image-rendering: pixelated;
  outline: 0;
}

.mochi-game canvas:focus-visible {
  box-shadow: inset 0 0 0 2px var(--cyan);
}

.mochi-game__prompt,
.mochi-game__pause,
.mochi-game__result {
  position: absolute;
  z-index: 5;
  top: 50%;
  left: 50%;
  display: grid;
  width: min(31rem, calc(100% - 2rem));
  padding: clamp(1.25rem, 3vw, 2.25rem);
  border: 1px solid var(--navy);
  background: rgba(237, 240, 233, 0.96);
  box-shadow: 0 1.5rem 4rem rgba(16, 42, 53, 0.16);
  transform: translate(-50%, -50%);
}

.mochi-game__prompt p,
.mochi-game__pause p,
.mochi-game__result p {
  margin: 0 0 0.9rem;
  color: var(--teal);
  font-size: 0.62rem;
}

.mochi-game__prompt strong,
.mochi-game__pause strong,
.mochi-game__result strong {
  margin-bottom: 1.1rem;
  font-size: clamp(1rem, 2vw, 1.4rem);
  line-height: 1.35;
}

.mochi-game__prompt > span,
.mochi-game__pause > span {
  margin-bottom: 1.1rem;
  color: var(--muted);
  font-size: 0.62rem;
}

.mochi-game__prompt button,
.mochi-game__pause button,
.mochi-game__result button,
.mochi-game__result a {
  min-height: 2.75rem;
  padding: 0.75rem 1rem;
  border: 1px solid var(--navy);
  background: var(--navy);
  color: var(--paper);
  font: 500 0.68rem/1 var(--mono);
  letter-spacing: 0.06em;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
}

.mochi-game__mode-choice {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.55rem;
}

.mochi-game__mode-choice button {
  display: grid;
  min-height: 4.4rem;
  align-content: center;
  gap: 0.45rem;
}

.mochi-game__mode-choice button:last-child {
  border-color: #53636b;
  background: #252c35;
}

.mochi-game__mode-choice b { font: inherit; }
.mochi-game__mode-choice small {
  color: rgba(237, 240, 233, 0.72);
  font-size: 0.52rem;
}

.mochi-game__result a {
  margin-top: 0.55rem;
  background: transparent;
  color: var(--navy);
}

.mochi-game__footer {
  display: flex;
  min-height: 3.5rem;
  padding: 0.75rem 1rem;
  border-top: 1px solid var(--navy);
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  font-size: 0.62rem;
}

.mochi-game__footer p { margin: 0; color: var(--muted); }
.mochi-game__footer button { padding: 0.45rem 0; border: 0; border-bottom: 1px solid var(--red); background: transparent; cursor: pointer; }
.mochi-game__footer button:disabled { opacity: 0.38; cursor: default; }
.mochi-game__footer-actions { display: flex; align-items: center; gap: 1rem; }
.mochi-game__footer-actions [data-game-pause-button] { border-bottom-color: var(--cyan); }
.mochi-game__footer-actions [data-sound-toggle] { border-bottom-color: var(--gold); }

.mochi-touch-controls {
  display: none;
  grid-template-columns: repeat(3, 3rem);
  grid-template-rows: repeat(2, 3rem);
  gap: 0.35rem;
  justify-content: center;
  padding: 1rem;
  border-top: 1px solid var(--line);
}

.mochi-touch-controls button {
  border: 1px solid var(--navy);
  background: transparent;
  font-family: var(--mono);
  touch-action: none;
}

.mochi-touch-controls [data-direction="up"] { grid-column: 2; }
.mochi-touch-controls [data-direction="left"] { grid-column: 1; }
.mochi-touch-controls [data-direction="down"] { grid-column: 2; }
.mochi-touch-controls [data-direction="right"] { grid-column: 3; }
.mochi-touch-controls__action {
  display: none;
  grid-column: 1 / 4;
  width: 100%;
  color: var(--cyan);
}

.mochi-game[data-player-mode="GHOST"] .mochi-touch-controls__action { display: block; }
.mochi-prototype-note {
  display: grid;
  grid-template-columns: 15rem minmax(0, 1fr);
  gap: 1.5rem;
  margin-top: 1rem;
  color: var(--muted);
  font-size: 0.62rem;
  line-height: 1.55;
}

.mochi-prototype-note p,
.mochi-prototype-note span { margin: 0; }

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

@media (max-width: 48rem) {
  body::before { left: 0.5rem; }

  .mochi-page-header {
    width: calc(100% - 2rem);
    min-height: 82px;
    padding-inline: 0;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 0.75rem;
  }

  .mochi-page-header > p { display: none; }
  .mochi-page-header__brand { font-size: 1.15rem; }
  .mochi-page-header__back {
    font-size: 0.55rem;
    white-space: nowrap;
  }

  .mochi-experience {
    width: calc(100% - 2rem);
    padding: 1.5rem 0 3rem;
  }

  .mochi-experience__header {
    grid-template-columns: minmax(0, 1fr);
    gap: 1rem;
    margin-bottom: 1rem;
  }

  .mochi-experience__header > p { justify-self: start; text-align: left; }
  .mochi-experience__header h1 {
    max-width: 100%;
    font-size: clamp(2rem, 11vw, 3.35rem);
    overflow-wrap: anywhere;
  }

  .mochi-experience__header p {
    max-width: 34rem;
    font-size: 0.58rem;
    line-height: 1.55;
  }

  .mochi-game__status {
    grid-template-columns: 1.05fr 0.9fr 1.05fr;
  }

  .mochi-game__status p {
    display: grid;
    min-height: 4.3rem;
    padding: 0.65rem 0.7rem;
    align-content: center;
    justify-content: stretch;
    gap: 0.38rem;
    font-size: 0.52rem;
  }

  .mochi-game__status strong,
  .mochi-game__status [data-delivered-count],
  .mochi-game__status [data-pressure-state] {
    font-size: 0.7rem;
    letter-spacing: 0.08em;
    white-space: nowrap;
  }

  .mochi-game canvas {
    min-height: 0;
    aspect-ratio: 16 / 9;
    object-fit: fill;
  }

  .mochi-game__prompt,
  .mochi-game__pause,
  .mochi-game__result {
    width: calc(100% - 1rem);
    padding: 0.85rem;
  }

  .mochi-game__prompt p,
  .mochi-game__pause p,
  .mochi-game__result p { margin-bottom: 0.45rem; }

  .mochi-game__prompt strong,
  .mochi-game__pause strong,
  .mochi-game__result strong {
    margin-bottom: 0.55rem;
    font-size: 0.82rem;
  }

  .mochi-game__prompt > span,
  .mochi-game__pause > span {
    margin-bottom: 0.55rem;
    font-size: 0.5rem;
  }

  .mochi-game__mode-choice { gap: 0.4rem; }
  .mochi-game__mode-choice button {
    min-height: 3.25rem;
    padding: 0.55rem 0.4rem;
    font-size: 0.6rem;
  }

  .mochi-game__mode-choice small { font-size: 0.43rem; }

  .mochi-game__footer {
    display: grid;
    padding: 0.75rem;
    gap: 0.75rem;
  }

  .mochi-game__footer p {
    min-width: 0;
    line-height: 1.5;
  }

  .mochi-game__footer-actions {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.75rem;
  }

  .mochi-game__footer-actions button {
    min-width: 0;
    font-size: 0.56rem;
    white-space: nowrap;
  }

  .mochi-touch-controls {
    grid-template-columns: repeat(3, 3.25rem);
    grid-template-rows: repeat(2, 3.25rem);
    padding: 1rem 0.75rem;
  }

  .mochi-prototype-note {
    grid-template-columns: minmax(0, 1fr);
    gap: 0.75rem;
    overflow-wrap: anywhere;
  }
}

@media (max-width: 25rem) {
  .mochi-page-header__back { font-size: 0.48rem; }
  .mochi-experience__header h1 { font-size: 1.9rem; }
  .mochi-game__status p { padding-inline: 0.5rem; }
  .mochi-game__status span { font-size: 0.46rem; }
  .mochi-game__footer-actions { gap: 0.45rem; }
  .mochi-game__footer-actions button { font-size: 0.49rem; }
}

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