:root {
  --ink: #392417;
  --cream: #fff5d9;
  --gold: #f6b933;
  --orange: #e66d26;
  --green: #438c5a;
  --red: #c44d3e;
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  background:
    radial-gradient(circle at 50% -10%, rgba(255, 245, 205, 0.98), transparent 42%),
    linear-gradient(150deg, #a9582e 0%, #6f371f 52%, #3b2318 100%);
  color: var(--ink);
  font-family: "Trebuchet MS", "Arial Rounded MT Bold", Arial, sans-serif;
  overflow-x: hidden;
}

button {
  font: inherit;
}

.game-page {
  min-height: 100svh;
  display: grid;
  place-items: center;
  padding: clamp(10px, 2vw, 24px);
}

.game-shell {
  width: min(1220px, 100%);
  padding: clamp(10px, 1.6vw, 20px);
  border: 3px solid rgba(255, 240, 196, 0.72);
  border-radius: 28px;
  background: rgba(255, 242, 204, 0.92);
  box-shadow: 0 26px 70px rgba(41, 20, 10, 0.43), inset 0 0 0 4px rgba(114, 60, 29, 0.12);
  backdrop-filter: blur(8px);
}

.topbar {
  min-height: 54px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 4px 12px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-mark {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: white;
  box-shadow: 0 3px 0 #d6a24c;
  font-size: 23px;
}

h1 {
  margin: 0;
  color: #713516;
  font-size: clamp(23px, 3vw, 38px);
  line-height: 1;
  letter-spacing: -0.03em;
  text-shadow: 0 2px 0 white;
}

.sound-button {
  padding: 9px 14px;
  border: 2px solid #d3a65e;
  border-radius: 999px;
  background: #fffaf0;
  color: #70401f;
  cursor: pointer;
  box-shadow: 0 3px 0 #c99343;
  font-weight: 800;
}

.sound-button:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 #c99343;
}

.game-stage {
  position: relative;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  border: clamp(5px, 0.8vw, 10px) solid #6f3c22;
  border-radius: 20px;
  background: #a96d3b;
  box-shadow: inset 0 0 0 3px #d7a65e, 0 8px 0 #4f2a19, 0 14px 25px rgba(62, 31, 16, 0.28);
  touch-action: manipulation;
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.scoreboard {
  position: absolute;
  top: clamp(8px, 1.4vw, 18px);
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: stretch;
  gap: clamp(5px, 0.8vw, 10px);
  width: min(600px, calc(100% - 24px));
  pointer-events: none;
}

.score {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(5px, 1vw, 12px);
  padding: clamp(6px, 1vw, 12px) clamp(5px, 1.2vw, 15px);
  border: 2px solid rgba(255, 255, 255, 0.84);
  border-radius: 14px;
  color: white;
  box-shadow: 0 5px 0 rgba(68, 35, 20, 0.42), 0 8px 16px rgba(52, 25, 12, 0.24);
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.24);
}

.score span {
  font-size: clamp(10px, 1.6vw, 17px);
  font-weight: 800;
}

.score strong {
  font-size: clamp(18px, 3vw, 34px);
  line-height: 1;
}

.score strong > span {
  font-size: inherit;
}

.score small {
  font-size: 0.48em;
  opacity: 0.85;
}

.level-score { background: #c66e28; }
.caught-score { background: #438c5a; }
.missed-score { background: #b94b3f; }

.game-overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(58, 29, 15, 0.28);
  backdrop-filter: blur(3px);
}

.game-overlay.is-hidden {
  display: none;
}

.overlay-card {
  width: min(510px, 94%);
  padding: clamp(18px, 4vw, 38px);
  border: 4px solid #f0c572;
  border-radius: 26px;
  background: rgba(255, 250, 232, 0.97);
  box-shadow: 0 12px 0 rgba(98, 51, 24, 0.72), 0 28px 50px rgba(43, 20, 9, 0.34);
  text-align: center;
}

.eyebrow {
  margin: 0 0 7px;
  color: #bd5d25;
  font-size: clamp(12px, 2vw, 16px);
  font-weight: 900;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.overlay-card h2 {
  margin: 0;
  color: #683217;
  font-size: clamp(25px, 4vw, 42px);
  line-height: 1.08;
}

.overlay-card p:not(.eyebrow) {
  max-width: 410px;
  margin: 14px auto 21px;
  color: #6e4a32;
  font-size: clamp(14px, 2vw, 19px);
  line-height: 1.45;
}

.primary-button {
  min-width: 205px;
  padding: 13px 24px;
  border: 3px solid #fff0bc;
  border-radius: 16px;
  background: linear-gradient(#f7973b, #dc5f20);
  color: white;
  cursor: pointer;
  box-shadow: 0 6px 0 #993c16, 0 10px 20px rgba(117, 49, 20, 0.26);
  font-size: clamp(18px, 2.5vw, 25px);
  font-weight: 900;
  text-shadow: 0 2px 0 rgba(101, 38, 12, 0.35);
}

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

.primary-button:active {
  transform: translateY(4px);
  box-shadow: 0 2px 0 #993c16;
}

.space-hint {
  display: block;
  margin-top: 13px;
  color: #9a8069;
  font-size: 13px;
  font-weight: 700;
}

.controls {
  display: grid;
  grid-template-columns: minmax(135px, 1fr) auto minmax(135px, 1fr);
  align-items: center;
  gap: clamp(9px, 2vw, 24px);
  padding-top: 16px;
}

.controls p {
  margin: 0;
  color: #76523a;
  font-weight: 800;
  text-align: center;
}

.controls p span,
.controls p i {
  color: #9b775f;
  font-size: 12px;
  font-style: normal;
}

.control-button {
  min-height: 62px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  border: 3px solid #ffe7a3;
  border-radius: 17px;
  color: white;
  cursor: pointer;
  box-shadow: 0 6px 0 #82421e;
  font-size: 20px;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}

.control-button span {
  font-size: 34px;
  line-height: 1;
}

.control-button b {
  font-weight: 900;
}

.left-button { background: linear-gradient(#df7835, #b75024); }
.right-button { background: linear-gradient(#599b68, #347a4d); }

.control-button:active {
  transform: translateY(4px);
  box-shadow: 0 2px 0 #82421e;
}

button:focus-visible {
  outline: 4px solid white;
  outline-offset: 3px;
}

@media (max-width: 680px) {
  .game-page { padding: 6px; }
  .game-shell { padding: 8px; border-radius: 18px; }
  .topbar { min-height: 44px; padding-bottom: 7px; }
  .brand-mark { display: none; }
  .sound-button { padding: 7px 10px; font-size: 12px; }
  .game-stage { border-width: 5px; border-radius: 13px; }
  .scoreboard { top: 6px; gap: 4px; width: calc(100% - 12px); }
  .score { min-height: 39px; padding: 4px; border-radius: 9px; gap: 4px; box-shadow: 0 3px 0 rgba(68,35,20,.38); }
  .score span { font-size: 9px; }
  .score strong { font-size: 18px; }
  .overlay-card { padding: 15px; border-width: 3px; border-radius: 17px; }
  .overlay-card p:not(.eyebrow) { margin: 7px auto 12px; line-height: 1.3; }
  .space-hint { display: none; }
  .primary-button { min-width: 160px; padding: 9px 16px; border-radius: 12px; }
  .controls { grid-template-columns: 1fr 1fr; padding-top: 10px; gap: 9px; }
  .controls p { display: none; }
  .control-button { min-height: 58px; font-size: 17px; border-radius: 13px; }
  .control-button span { font-size: 29px; }
}

@media (max-height: 620px) and (orientation: landscape) {
  .game-page { display: block; padding: 3px; }
  .game-shell { width: min(960px, 100%); margin: auto; padding: 5px 8px; }
  .topbar { min-height: 34px; padding-bottom: 4px; }
  h1 { font-size: 22px; }
  .brand-mark { display: none; }
  .sound-button { padding: 4px 9px; font-size: 11px; }
  .controls { position: absolute; inset: 0; padding: 0; pointer-events: none; grid-template-columns: 1fr 1fr; }
  .controls p { display: none; }
  .control-button { position: fixed; bottom: 8px; width: 118px; min-height: 51px; opacity: 0.88; pointer-events: auto; }
  .left-button { left: 9px; }
  .right-button { right: 9px; }
}

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