:root {
  --gold: #ffb52e;
  --gold-bright: #ffe45a;
  --lime: #70ff31;
  --red: #ff4b39;
  --ink: #2a1307;
  --cream: #fff2c5;
  --shadow: rgba(0, 0, 0, 0.4);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  overflow: hidden;
  background:
    radial-gradient(circle at 50% 45%, rgba(255, 193, 80, 0.18), transparent 40%),
    linear-gradient(120deg, #1d120c, #080604);
  color: var(--cream);
  font-family: Impact, "Arial Black", ui-rounded, system-ui, sans-serif;
  user-select: none;
}

button {
  border: 4px solid #351604;
  border-radius: 9px;
  background: linear-gradient(#fff174, #ff9e1b 55%, #dc5b0a);
  color: #4a1700;
  cursor: pointer;
  font: inherit;
  font-weight: 900;
  letter-spacing: 0.02em;
  text-shadow: 0 2px 0 rgba(255, 255, 255, 0.55);
  box-shadow: 0 7px 0 #2b1002, 0 14px 25px rgba(0, 0, 0, 0.35);
  transition: transform 120ms ease, box-shadow 120ms ease;
}

button:hover {
  transform: translateY(-2px);
}

button:active {
  transform: translateY(4px);
  box-shadow: 0 3px 0 #2b1002, 0 8px 16px rgba(0, 0, 0, 0.35);
}

.shell {
  display: grid;
  place-items: center;
  width: 100vw;
  height: 100dvh;
  padding: 18px;
}

.game-panel {
  position: relative;
  width: min(1500px, 100%);
  height: min(900px, 100%);
  min-height: 620px;
  overflow: hidden;
  border: 8px solid #160b05;
  border-radius: 18px;
  background:
    linear-gradient(90deg, rgba(0, 0, 0, 0.28), transparent 12%, transparent 88%, rgba(0, 0, 0, 0.3)),
    repeating-linear-gradient(90deg, rgba(80, 38, 14, 0.32) 0 4px, transparent 4px 186px),
    linear-gradient(90deg, #3a1d0c, #7a3e18 18%, #5b2c10 36%, #8a4b1e 55%, #49230d 74%, #7b3d16);
  box-shadow: 0 28px 60px rgba(0, 0, 0, 0.55);
}

.game-panel::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(ellipse at 45% 42%, rgba(255, 232, 142, 0.18), transparent 28%),
    repeating-linear-gradient(90deg, transparent 0 178px, rgba(20, 8, 2, 0.42) 179px 183px),
    repeating-linear-gradient(0deg, rgba(255, 226, 132, 0.04) 0 2px, transparent 2px 62px);
  mix-blend-mode: screen;
}

.game-panel::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(110deg, transparent 0 16%, rgba(0, 0, 0, 0.2) 16.5% 17%, transparent 17.5% 100%),
    linear-gradient(75deg, transparent 0 71%, rgba(0, 0, 0, 0.22) 71.5% 72%, transparent 72.5% 100%),
    radial-gradient(circle at 14% 20%, rgba(0, 0, 0, 0.22), transparent 13%),
    radial-gradient(circle at 76% 70%, rgba(0, 0, 0, 0.2), transparent 12%);
}

#gameCanvas {
  position: absolute;
  inset: 0;
  z-index: 1;
  width: 100%;
  height: 100%;
}

.hud {
  position: absolute;
  z-index: 4;
  inset: 20px 26px auto;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: start;
  pointer-events: none;
}

.score-block {
  display: flex;
  align-items: center;
  gap: 16px;
  color: var(--gold);
  text-shadow: 4px 5px 0 #3b1300, 0 0 18px rgba(255, 201, 41, 0.28);
}

.fruit-medal {
  display: grid;
  place-items: center;
  width: 72px;
  height: 72px;
  border-radius: 999px;
  background: radial-gradient(circle, #2a0e04, #080301);
  font-size: 54px;
  box-shadow: inset 0 0 20px rgba(255, 255, 255, 0.12), 0 8px 22px var(--shadow);
}

.score-block strong {
  display: block;
  font-size: clamp(64px, 8vw, 110px);
  line-height: 0.78;
}

.score-block span {
  display: block;
  margin-top: 12px;
  color: #ff9d24;
  font-size: clamp(24px, 2.8vw, 42px);
  line-height: 0.9;
}

.frenzy-banner {
  min-width: 410px;
  padding: 10px 36px 14px;
  text-align: center;
  color: #e61f00;
  font-size: clamp(28px, 3.2vw, 46px);
  line-height: 0.9;
  text-shadow: 0 4px 0 #ffec5e, 3px 6px 0 #892000;
  background: linear-gradient(#ffe85c, #ff9b13 58%, #c94500);
  border: 5px solid #5a1600;
  border-top: 0;
  clip-path: polygon(0 0, 100% 0, 88% 100%, 12% 100%);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.36);
}

.timer-block {
  justify-self: end;
  color: var(--lime);
  font-size: clamp(56px, 7vw, 98px);
  line-height: 0.85;
  text-shadow: 5px 6px 0 #163900, 0 0 24px rgba(112, 255, 49, 0.28);
}

.target-card {
  position: absolute;
  z-index: 5;
  left: 50%;
  top: 120px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
  min-width: 230px;
  height: 98px;
  padding: 0 30px;
  border: 5px solid #f0c33a;
  border-radius: 12px;
  background: linear-gradient(#fffdf1, #ffd77d);
  box-shadow: 0 8px 0 #5a2506, 0 0 34px rgba(255, 218, 95, 0.36);
  transform: translateX(-50%);
}

.target-card strong {
  display: block;
  color: #351304;
  font-size: 58px;
  line-height: 0.88;
  text-shadow: 0 3px 0 #fff;
}

.target-copy {
  display: grid;
  gap: 4px;
  justify-items: start;
}

.target-copy small {
  display: block;
  color: #6d2a06;
  font-family: ui-rounded, system-ui, sans-serif;
  font-size: 15px;
  font-weight: 1000;
  letter-spacing: 0.06em;
  line-height: 1;
}

.target-pulse {
  width: 43px;
  height: 43px;
  border-radius: 999px;
  background: var(--red);
  box-shadow: 0 0 24px rgba(255, 75, 57, 0.9);
}

.lives {
  position: absolute;
  z-index: 5;
  top: 106px;
  right: 30px;
  color: #ff6a5e;
  font-size: 38px;
  letter-spacing: 9px;
  text-shadow: 0 4px 0 #571800;
}

.top-actions {
  position: absolute;
  z-index: 6;
  right: 26px;
  top: 118px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.device-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 180px;
  color: #4d2005;
  font-family: ui-rounded, system-ui, sans-serif;
  font-size: 16px;
  font-weight: 900;
}

.device-dot {
  width: 13px;
  height: 13px;
  flex: none;
  border-radius: 999px;
  background: var(--gold-bright);
  box-shadow: 0 0 12px var(--gold-bright);
}

.device-dot.connected {
  background: var(--lime);
  box-shadow: 0 0 12px var(--lime);
}

.device-dot.error {
  background: var(--red);
  box-shadow: 0 0 12px var(--red);
}

.top-actions button {
  width: 58px;
  height: 58px;
  padding: 0;
  border-width: 3px;
  font-size: 25px;
  box-shadow: 0 4px 0 #2b1002;
}

.hidden-keyboard {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
}

.debug-panels {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
}

.start-overlay,
.end-overlay {
  position: absolute;
  z-index: 10;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at center, rgba(255, 177, 54, 0.18), transparent 38%),
    rgba(0, 0, 0, 0.62);
}

.hidden {
  display: none;
}

.start-box {
  width: min(610px, 92%);
  padding: 34px;
  text-align: center;
  border: 6px solid #351604;
  border-radius: 16px;
  background: linear-gradient(#fff1ac, #ffb62b 45%, #9e3d09);
  color: #381402;
  box-shadow: 0 12px 0 #2b1002, 0 28px 55px rgba(0, 0, 0, 0.52);
}

.eyebrow {
  margin: 0 0 8px;
  color: #a51a00;
  font-size: 18px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  text-shadow: 0 2px 0 #ffe66d;
}

h1,
h2 {
  margin: 0;
  color: #e51e00;
  font-size: clamp(56px, 8vw, 92px);
  line-height: 0.9;
  text-shadow: 0 5px 0 #ffe66d, 4px 8px 0 #5b1600;
}

.start-box p:not(.eyebrow) {
  color: #4d2005;
  font-family: ui-rounded, system-ui, sans-serif;
  font-weight: 900;
  line-height: 1.45;
}

.start-actions {
  display: flex;
  justify-content: center;
  gap: 16px;
  margin-top: 24px;
}

.connect-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin: 22px auto 4px;
  padding: 14px 16px;
  width: min(510px, 100%);
  border: 4px solid #5a2506;
  border-radius: 12px;
  background: rgba(255, 246, 177, 0.78);
  box-shadow: inset 0 0 22px rgba(255, 255, 255, 0.35);
}

.connect-card button {
  flex: none;
  min-height: 48px;
  padding: 8px 15px;
  border-width: 3px;
  font-size: 16px;
}

.start-actions button,
#restartButton {
  min-width: 150px;
  padding: 14px 20px;
}

.shortcut-line {
  margin-top: 20px;
  color: #6d2a06;
  font-family: ui-rounded, system-ui, sans-serif;
  font-size: 14px;
  font-weight: 900;
}

.game-panel.combo {
  animation: panelPulse 360ms ease;
}

@keyframes hitFlash {
  45% {
    background: rgba(112, 255, 49, 0.42);
    box-shadow: 0 0 20px rgba(112, 255, 49, 0.9);
  }
}

@keyframes missFlash {
  45% {
    background: rgba(255, 75, 57, 0.42);
    box-shadow: 0 0 20px rgba(255, 75, 57, 0.9);
  }
}

@keyframes panelPulse {
  45% {
    filter: brightness(1.18) saturate(1.28);
  }
}

@media (max-width: 980px) {
  .shell {
    padding: 0;
  }

  .game-panel {
    width: 100vw;
    height: 100dvh;
    min-height: 0;
    border-radius: 0;
    border-width: 0;
  }

  .frenzy-banner {
    display: none;
  }

  .hud {
    grid-template-columns: 1fr 1fr;
  }
}
