/* Hopadoo app shell: full-window canvas plus the HTML start / loading / error overlays (LLD §6.4). */

:root {
  --p1: #ff7a1a;
  --p1-dark: #c2540a;
  --p2: #19b7c9;
  --p2-dark: #0e7f8c;
  --gold: #ffd23f;
  --ink: #1f2a44;
  --ink-soft: #4a5775;
  --card: #ffffff;
  --sky-top: #8fd3ff;
  --sky-bottom: #dff4ff;
  --grass: #6cc24a;
  --safe: #2e9b5f;
  --font-fun: 'Arial Rounded MT Bold', 'Trebuchet MS', 'Nunito', system-ui, sans-serif;
  --font-body: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #11151f;
  color: var(--ink);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
}

[hidden] {
  display: none !important;
}

#game {
  position: fixed;
  inset: 0;
  display: block;
  width: 100vw;
  height: 100vh;
  background: #11151f;
}

/* ---------- Overlay + backdrop ---------- */

#overlay {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  padding: 24px;
  overflow: auto;
  background: linear-gradient(180deg, var(--sky-top) 0%, var(--sky-bottom) 70%);
}

.sky {
  position: fixed;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}

.cloud {
  position: absolute;
  width: 170px;
  height: 52px;
  border-radius: 52px;
  background: #fff;
  opacity: 0.9;
  animation: drift 38s linear infinite;
}

.cloud::before,
.cloud::after {
  content: '';
  position: absolute;
  background: #fff;
  border-radius: 50%;
}

.cloud::before {
  width: 74px;
  height: 74px;
  left: 26px;
  top: -34px;
}

.cloud::after {
  width: 56px;
  height: 56px;
  left: 86px;
  top: -24px;
}

.c1 { top: 9%; left: 4%; }
.c2 { top: 5%; left: 70%; transform: scale(0.75); animation-duration: 46s; animation-delay: -12s; }
.c3 { top: 30%; left: 86%; transform: scale(0.6); animation-duration: 54s; animation-delay: -30s; opacity: 0.7; }

@keyframes drift {
  from { translate: -40px 0; }
  50% { translate: 40px 0; }
  to { translate: -40px 0; }
}

.hill {
  position: absolute;
  bottom: -46vh;
  width: 90vw;
  height: 70vh;
  border-radius: 50%;
}

.h1 { left: -20vw; background: #7acb57; }
.h2 { right: -25vw; background: var(--grass); bottom: -50vh; }

.screen {
  position: relative;
  z-index: 1;
  width: 100%;
  display: grid;
  place-items: center;
}

.card {
  background: var(--card);
  border-radius: 32px;
  box-shadow:
    0 26px 60px rgba(24, 48, 92, 0.25),
    0 6px 0 rgba(24, 48, 92, 0.08);
  animation: pop-in 0.35s cubic-bezier(0.2, 1.4, 0.4, 1) both;
}

@keyframes pop-in {
  from { opacity: 0; transform: translateY(14px) scale(0.97); }
  to { opacity: 1; transform: none; }
}

/* ---------- Start screen ---------- */

.start-card {
  width: min(1120px, 100%);
  padding: 34px 40px 32px;
  display: grid;
  grid-template-columns: 1.05fr 1fr;
  gap: 40px;
  align-items: center;
}

.hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.scene {
  display: block;
  width: 100%;
  max-width: 440px;
  height: auto;
  border-radius: 22px;
  box-shadow: 0 8px 20px rgba(24, 48, 92, 0.18);
}

.svg-pop {
  font: 700 15px var(--font-fun);
  fill: var(--gold);
  stroke: #7a5200;
  stroke-width: 3px;
  paint-order: stroke;
}

.runner {
  transform-box: fill-box;
}

.r1 {
  animation: hop 1.1s ease-in-out infinite;
}

.r2 {
  animation: jog 0.5s ease-in-out infinite alternate;
}

@keyframes hop {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-7px); }
}

@keyframes jog {
  from { transform: translateY(0) rotate(-1.5deg); }
  to { transform: translateY(-2px) rotate(1.5deg); }
}

.logo {
  margin: 18px 0 2px;
  font: 800 clamp(56px, 7.4vw, 86px) / 1 var(--font-fun);
  letter-spacing: -0.02em;
}

.logo-hop {
  color: var(--p1);
  text-shadow: 0 5px 0 var(--p1-dark);
}

.logo-adoo {
  color: var(--p2);
  text-shadow: 0 5px 0 var(--p2-dark);
}

.tagline {
  margin: 12px 0 22px;
  font: 700 21px / 1.3 var(--font-fun);
  color: var(--ink-soft);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  min-height: 64px;
  padding: 0 34px;
  border: 0;
  border-radius: 999px;
  font: 800 24px / 1 var(--font-fun);
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease, filter 0.12s ease;
  -webkit-tap-highlight-color: transparent;
}

.btn:focus-visible,
.btn-link:focus-visible {
  outline: 4px solid #1a73e8;
  outline-offset: 4px;
}

.btn-primary {
  color: #fff;
  background: linear-gradient(180deg, #ffa24a 0%, var(--p1) 60%);
  box-shadow: 0 7px 0 var(--p1-dark), 0 14px 24px rgba(194, 84, 10, 0.35);
  text-shadow: 0 2px 0 rgba(122, 52, 0, 0.35);
}

.btn-primary:hover {
  filter: brightness(1.05);
  transform: translateY(-2px);
  box-shadow: 0 9px 0 var(--p1-dark), 0 18px 28px rgba(194, 84, 10, 0.35);
}

.btn-primary:active {
  transform: translateY(5px);
  box-shadow: 0 2px 0 var(--p1-dark), 0 6px 12px rgba(194, 84, 10, 0.3);
}

.btn-secondary {
  color: var(--p2-dark);
  background: #e8f8fa;
  box-shadow: inset 0 0 0 3px var(--p2), 0 5px 0 rgba(14, 127, 140, 0.25);
}

.btn-secondary:hover {
  background: #d8f3f6;
  transform: translateY(-2px);
}

.btn-secondary:active {
  transform: translateY(3px);
  box-shadow: inset 0 0 0 3px var(--p2), 0 1px 0 rgba(14, 127, 140, 0.25);
}

.btn-start {
  min-width: 300px;
  min-height: 84px;
  font-size: 38px;
  animation: breathe 2.2s ease-in-out infinite;
}

.btn-start:hover,
.btn-start:active {
  animation: none;
}

.btn-icon {
  font-size: 0.8em;
}

@keyframes breathe {
  0%, 100% { scale: 1; }
  50% { scale: 1.04; }
}

/* Game mode toggle (FR-70) */

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

.mode-toggle {
  display: inline-flex;
  gap: 4px;
  margin: 0 0 8px;
  padding: 5px;
  border: 0;
  border-radius: 999px;
  background: #eef1f7;
  box-shadow: inset 0 0 0 2px rgba(31, 42, 68, 0.1);
}

.mode-option {
  position: relative;
  cursor: pointer;
}

.mode-option input {
  position: absolute;
  inset: 0;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}

.mode-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 46px;
  padding: 0 20px;
  border-radius: 999px;
  font: 800 18px / 1 var(--font-fun);
  color: var(--ink-soft);
  transition: background 0.12s ease, color 0.12s ease, box-shadow 0.12s ease;
}

.mode-option:hover .mode-pill {
  color: var(--ink);
}

.mode-option input:checked + .mode-pill {
  background: #fff;
  color: var(--ink);
  box-shadow: 0 3px 0 rgba(31, 42, 68, 0.15), 0 0 0 2px var(--p2);
}

.mode-option input:focus-visible + .mode-pill {
  outline: 4px solid #1a73e8;
  outline-offset: 2px;
}

.mode-note {
  margin: 0 0 20px;
  font: 600 15px / 1.3 var(--font-body);
  color: var(--ink-soft);
}

.mode-hands .only-jump,
body:not(.mode-hands) .only-hands {
  display: none;
}

.btn-link {
  margin-top: 18px;
  padding: 6px 10px;
  border: 0;
  background: none;
  font: 700 16px var(--font-body);
  color: var(--ink-soft);
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: 4px;
  cursor: pointer;
  border-radius: 8px;
}

.btn-link:hover {
  color: var(--ink);
}

/* Setup column */

.setup {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.section-label {
  margin: 4px 0 0;
  font: 800 13px var(--font-body);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #7a86a3;
}

.howto {
  list-style: none;
  margin: 0 0 8px;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}

.howto li {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 12px 6px 10px;
  border-radius: 18px;
  background: #fff7e0;
  font: 700 14px / 1.2 var(--font-fun);
  text-align: center;
  color: var(--ink);
}

.howto li:nth-child(2) { background: #ffeede; }
.howto li:nth-child(3) { background: #e2f6f8; }
.howto li:nth-child(4) { background: #fff4c6; }

.howto-icon {
  display: grid;
  place-items: center;
  height: 36px;
  font-size: 34px;
  line-height: 1;
}

/* Drawn rather than the coin emoji, which renders silver on some systems. */
.mini-coin {
  display: block;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fff6c2 0 14%, var(--gold) 15% 62%, #e6ae00 63%);
  box-shadow: inset 0 0 0 3px #f2bf1d, 0 3px 6px rgba(170, 120, 0, 0.3);
}

.tips {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 8px;
}

.tips li {
  display: flex;
  align-items: center;
  gap: 14px;
  font: 500 17px / 1.3 var(--font-body);
  color: var(--ink);
}

.tips b {
  font-weight: 800;
}

.tip-icon {
  flex: none;
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border-radius: 14px;
  background: #eef4ff;
  font-size: 22px;
  letter-spacing: -0.3em;
  text-indent: -0.3em;
}

.chip {
  display: inline-block;
  padding: 1px 9px 2px;
  border-radius: 999px;
  color: #fff;
  font-weight: 800;
  white-space: nowrap;
}

.chip.p1 { background: var(--p1); }
.chip.p2 { background: var(--p2); }

.privacy {
  margin: 6px 0 0;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 16px;
  border-radius: 16px;
  background: #e7f7ee;
  box-shadow: inset 0 0 0 2px #bfe8cf;
  font: 500 16px / 1.35 var(--font-body);
  color: #1d5e3a;
}

.privacy b {
  color: #154a2d;
}

.privacy-icon {
  font-size: 26px;
}

/* Keyboard legend (error screen, and the start screen in ?keyboard mode) */

.kb-legend {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 10px 16px;
  margin: 0;
  font: 700 15px var(--font-body);
  color: var(--ink-soft);
}

.kb-player {
  display: inline-flex;
  gap: 5px;
  padding: 6px 8px;
  border-radius: 14px;
}

.kb-space {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.kb-player.p1 { background: #ffe8d6; }
.kb-player.p2 { background: #d9f4f7; }

kbd {
  display: inline-grid;
  place-items: center;
  min-width: 34px;
  height: 34px;
  padding: 0 8px;
  border-radius: 9px;
  background: #fff;
  box-shadow: inset 0 -3px 0 rgba(31, 42, 68, 0.18), 0 0 0 1.5px rgba(31, 42, 68, 0.2);
  font: 800 16px var(--font-fun);
  color: var(--ink);
}

.p1 kbd { color: var(--p1-dark); }
.p2 kbd { color: var(--p2-dark); }

.only-keyboard { display: none; }
.keyboard-mode .only-keyboard { display: flex; margin-top: 18px; }
.keyboard-mode .not-keyboard { display: none; }

/* ---------- Loading + error ---------- */

.small-card {
  width: min(660px, 100%);
  padding: 40px 44px 38px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 14px;
}

.coin-spinner {
  width: 96px;
  height: 96px;
  perspective: 400px;
  margin-bottom: 6px;
}

.coin-spinner span {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fff6c2 0 14%, var(--gold) 15% 62%, #e6ae00 63%);
  box-shadow: inset 0 0 0 7px #f2bf1d, 0 10px 18px rgba(170, 120, 0, 0.3);
  animation: spin 1.1s linear infinite;
}

@keyframes spin {
  from { transform: rotateY(0); }
  to { transform: rotateY(360deg); }
}

.status {
  margin: 0;
  font: 800 28px / 1.2 var(--font-fun);
  color: var(--ink);
}

.subtle {
  margin: 0;
  font: 500 17px / 1.4 var(--font-body);
  color: var(--ink-soft);
}

.error-face {
  font-size: 72px;
  line-height: 1;
}

.error-title {
  margin: 0;
  font: 800 44px / 1 var(--font-fun);
  color: var(--p1);
  text-shadow: 0 4px 0 var(--p1-dark);
}

.error-message {
  margin: 4px 0 6px;
  font: 700 21px / 1.4 var(--font-fun);
  color: var(--ink);
}

.small-card .kb-legend {
  margin-bottom: 10px;
}

.btn-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 16px;
  margin-top: 6px;
}

/* ---------- Responsive ---------- */

@media (max-width: 900px) {
  #overlay { place-items: start center; }
  .start-card { grid-template-columns: 1fr; gap: 26px; padding: 28px 24px; }
  .howto { grid-template-columns: repeat(2, 1fr); }
}

@media (max-height: 700px) and (min-width: 901px) {
  .start-card { padding: 24px 32px; }
  .scene { max-width: 360px; }
  .logo { margin-top: 12px; font-size: 64px; }
  .tagline { margin: 8px 0 16px; }
  .btn-start { min-height: 72px; font-size: 32px; }
  .mode-pill { min-height: 40px; font-size: 16px; }
  .mode-note { margin-bottom: 14px; }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}
