:root {
  --sky: #20a8f5;
  --yellow: #ffde59;
  --cream: #fff7e8;
  --green: #17b964;
  --ink: #111111;
  --shadow: 4px 4px 0 var(--ink);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html,
body {
  min-height: 100%;
  margin: 0;
}

body {
  background: linear-gradient(180deg, var(--sky) 0%, #45c8ff 48%, #5fcb5a 49%, #168b45 100%);
  color: var(--ink);
  font-family: Chewy, system-ui, sans-serif;
  overflow: hidden;
}

button,
input { font: inherit; }

button { cursor: pointer; }

.app-shell {
  min-height: 100dvh;
  height: 100dvh;
  padding: 6px clamp(10px, 2.5vw, 28px) 12px;
  position: relative;
  overflow: hidden;
}

.game-topbar {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) auto minmax(180px, 1fr);
  gap: 10px;
  align-items: center;
  position: relative;
  z-index: 10;
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.brand-lockup img {
  width: min(128px, 32vw);
  height: auto;
  object-fit: contain;
  filter: drop-shadow(2px 3px 0 var(--ink));
}

.brand-lockup span,
.score-strip,
.controls button,
.mode-card h1 { letter-spacing: 0.03em; }

.brand-lockup span {
  background: var(--cream);
  border: 3px solid var(--ink);
  border-radius: 10px;
  box-shadow: var(--shadow);
  padding: 5px 10px 3px;
  transform: rotate(-2deg);
  white-space: nowrap;
}

.score-strip {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
  background: var(--cream);
  border: 3px solid var(--ink);
  border-radius: 10px;
  box-shadow: var(--shadow);
  padding: 6px 10px;
  text-align: center;
  min-width: 240px;
}

.score-strip span {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
}

.score-strip span:not(:last-child)::after {
  content: "";
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-left: 8px;
  border-radius: 999px;
  background: var(--yellow);
  border: 2px solid var(--ink);
}

.controls {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.controls button,
.mode-card button,
.score-submit button {
  border: 3px solid var(--ink);
  border-radius: 10px;
  background: var(--yellow);
  color: var(--ink);
  box-shadow: var(--shadow);
  padding: 7px 10px 5px;
  min-width: 72px;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}

.controls button:hover,
.mode-card button:hover,
.score-submit button:hover {
  transform: translateY(-2px) rotate(-1deg);
  box-shadow: 6px 6px 0 var(--ink);
}

.game-stage {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100dvh;
  overflow: hidden;
  background: var(--sky);
  touch-action: none;
  cursor: none;
  z-index: 1;
}

#game-canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}

.start-hint {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  gap: 12px;
  text-align: center;
  pointer-events: none;
  color: #fffaf0;
  text-shadow:
    0 4px 0 var(--ink),
    4px 4px 0 var(--ink),
    -3px 3px 0 var(--ink),
    0 0 12px rgba(17, 17, 17, 0.38);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.start-hint strong {
  font-family: Luckiest Guy, Chewy, sans-serif;
  font-size: clamp(48px, 8.4vw, 108px);
  letter-spacing: 0;
  -webkit-text-stroke: 2px var(--ink);
}

.start-hint span {
  justify-self: center;
  width: min(92vw, 780px);
  color: var(--cream);
  font-size: clamp(25px, 3.2vw, 42px);
  line-height: 1;
  -webkit-text-stroke: 1.2px var(--ink);
  text-shadow:
    0 3px 0 var(--ink),
    3px 3px 0 var(--ink),
    -2px 2px 0 var(--ink),
    0 0 10px rgba(17, 17, 17, 0.45);
}
.start-hint.hide { opacity: 0; transform: scale(0.96); }

.mascot-wrap {
  pointer-events: none;
  position: fixed;
  right: clamp(8px, 2vw, 22px);
  bottom: clamp(6px, 2vw, 18px);
  width: clamp(112px, 15vw, 190px);
  z-index: 4;
}

.mascot-face { position: relative; }

.mascot-face img {
  display: block;
  width: 100%;
  height: auto;
  filter: drop-shadow(4px 4px 0 var(--ink));
  transform-origin: bottom center;
  animation: dog-bob 1.8s ease-in-out infinite;
}

.dog-bubble {
  position: absolute;
  right: 78%;
  bottom: 64%;
  max-width: 175px;
  padding: 8px 12px 6px;
  border: 3px solid var(--ink);
  border-radius: 14px;
  background: var(--cream);
  box-shadow: var(--shadow);
  font-family: Luckiest Guy, Chewy, sans-serif;
  font-size: clamp(16px, 2vw, 24px);
  line-height: 1.05;
  text-align: center;
  opacity: 0;
  transform: translateY(8px) rotate(-3deg) scale(0.92);
  transition: opacity 0.18s ease, transform 0.18s ease;
}

.dog-bubble::after {
  content: "";
  position: absolute;
  right: 22px;
  bottom: -15px;
  width: 22px;
  height: 22px;
  background: var(--cream);
  border-right: 3px solid var(--ink);
  border-bottom: 3px solid var(--ink);
  transform: rotate(45deg);
}

.dog-bubble.show {
  opacity: 1;
  transform: translateY(0) rotate(-2deg) scale(1);
}

@keyframes dog-bob {
  0%, 100% { transform: translateY(0) rotate(-2deg); }
  50% { transform: translateY(-7px) rotate(1deg); }
}

.choice-modal {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(17, 17, 17, 0.42);
  z-index: 50;
}

.mode-card {
  width: min(460px, 94vw);
  max-height: min(86vh, 720px);
  overflow: auto;
  border: 4px solid var(--ink);
  border-radius: 8px;
  background: var(--cream);
  box-shadow: 9px 9px 0 var(--ink);
  padding: 22px;
  text-align: center;
}

.mode-card h1 {
  margin: 0 0 12px;
  font-family: Luckiest Guy, Chewy, sans-serif;
  font-size: clamp(34px, 8vw, 58px);
  line-height: 0.95;
}

.modal-copy,
.score-submit p,
.leaderboard-status {
  margin: 8px 0 14px;
  font-size: 24px;
}

.modal-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
}

.mode-card .secondary,
.quiet-button { background: white; }

.how-to-list {
  margin: 0 0 16px;
  padding-left: 22px;
  text-align: left;
  font-size: clamp(18px, 4.4vw, 24px);
  line-height: 1.14;
}

.how-to-list li + li { margin-top: 8px; }

.score-form label {
  display: block;
  margin-bottom: 6px;
  font-size: 20px;
}

.score-row {
  display: flex;
  gap: 8px;
}

.score-row input {
  min-width: 0;
  flex: 1;
  border: 3px solid var(--ink);
  border-radius: 8px;
  padding: 7px 9px;
  background: white;
  color: var(--ink);
}

.score-message { min-height: 24px; }

.leaderboard-list {
  display: grid;
  gap: 7px;
  margin: 10px 0 18px;
  padding: 0;
  text-align: left;
  font-size: clamp(19px, 4vw, 25px);
}

.leaderboard-list li {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  border: 3px solid var(--ink);
  border-radius: 8px;
  background: white;
  box-shadow: 3px 3px 0 var(--ink);
  padding: 7px 9px 5px;
}

.leaderboard-list b,
.leaderboard-list span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.leaderboard-list em {
  justify-self: end;
  font-style: normal;
}

.music-toggle {
  position: fixed;
  left: 14px;
  bottom: 14px;
  z-index: 30;
  width: 46px;
  height: 46px;
  border: 3px solid var(--ink);
  border-radius: 999px;
  background: var(--cream);
  box-shadow: var(--shadow);
}

.music-toggle::before {
  content: "";
  position: absolute;
  left: 17px;
  top: 12px;
  width: 0;
  height: 0;
  border-top: 9px solid transparent;
  border-bottom: 9px solid transparent;
  border-left: 14px solid var(--ink);
}

.music-toggle[aria-pressed="true"]::before,
.music-toggle[aria-pressed="true"]::after {
  content: "";
  position: absolute;
  top: 12px;
  width: 6px;
  height: 19px;
  background: var(--ink);
  border: 0;
}

.music-toggle[aria-pressed="true"]::before { left: 15px; }
.music-toggle[aria-pressed="true"]::after { right: 15px; }

@media (max-width: 760px), (orientation: portrait) {
  .app-shell {
    padding: 5px 8px 10px;
    gap: 6px;
  }

  .game-topbar {
    grid-template-columns: 1fr;
    justify-items: stretch;
    gap: 7px;
  }

  .brand-lockup { justify-content: center; }
  .brand-lockup img { width: 82px; }
  .brand-lockup span { font-size: 18px; }

  .score-strip {
    min-width: 0;
    padding: 4px 7px 3px;
    font-size: 17px;
  }

  .controls {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    width: calc(100vw - 16px);
    max-width: calc(100vw - 16px);
    justify-self: center;
    gap: 6px;
  }

  .controls button {
    min-width: 0;
    padding: 6px 4px 4px;
    box-shadow: 2px 2px 0 var(--ink);
  }

  .game-stage {
    width: 100vw;
    height: 100dvh;
  }

  .mascot-wrap {
    width: clamp(82px, 24vw, 120px);
    right: 2px;
    bottom: 3px;
  }

  .dog-bubble { display: none; }
}

@media (max-height: 620px) and (orientation: landscape) {
  .brand-lockup img { width: 82px; }
  .game-topbar { grid-template-columns: auto 1fr auto; }
  .score-strip {
    min-width: 0;
    padding: 4px 8px;
  }
  .controls button { padding: 5px 8px 3px; }
}
