:root {
  --page-bg: #18233b;
  --panel-bg: #243457;
  --frame-bg: #101827;
  --cyan: #50e3e6;
  --mint: #7df6a6;
  --yellow: #ffe66d;
  --pink: #ff5fa2;
  --orange: #ff9f43;
  --text: #f8fbff;
  --muted: #b8c7e8;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background:
    linear-gradient(0deg, rgba(255, 255, 255, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.03) 1px, transparent 1px),
    radial-gradient(circle at 50% 0%, #2f466f 0%, var(--page-bg) 48%, #101827 100%);
  background-size: 24px 24px, 24px 24px, auto;
  color: var(--text);
  font-family: "Trebuchet MS", Verdana, sans-serif;
}

body {
  display: grid;
  place-items: center;
  padding: 18px;
}

.page-shell {
  width: min(100%, 940px);
}

.game-wrap {
  position: relative;
  border: 4px solid var(--cyan);
  border-radius: 8px;
  background: var(--panel-bg);
  box-shadow:
    0 0 0 4px #101827,
    0 0 28px rgba(80, 227, 230, 0.32);
  overflow: hidden;
}

.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border-bottom: 3px solid #101827;
  background: linear-gradient(90deg, #263d68, #2b3057);
}

.brand {
  color: var(--yellow);
  font-size: clamp(1.1rem, 3vw, 1.55rem);
  font-weight: 900;
  letter-spacing: 0;
  text-shadow: 2px 2px 0 #101827;
}

.mute-button,
.mobile-controls button {
  min-height: 42px;
  border: 3px solid #101827;
  border-radius: 8px;
  background: var(--yellow);
  color: #101827;
  cursor: pointer;
  font: inherit;
  font-weight: 900;
  box-shadow: 0 4px 0 #101827;
}

.mute-button:active,
.mobile-controls button:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 #101827;
}

.canvas-frame {
  position: relative;
  padding: 12px;
  background: #101827;
}

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

  aspect-ratio: 800 / 520;
  background: var(--frame-bg);
  image-rendering: pixelated;
  touch-action: none;
}

.mobile-controls {
  display: none;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  padding: 12px;
  border-top: 3px solid #101827;
  background: #223454;
}

@media (max-width: 700px) {
  body {
    padding: 10px;
  }

  .canvas-frame {
    padding: 8px;
  }

  .mobile-controls {
    display: grid;
  }

  .mute-button,
  .mobile-controls button {
    min-height: 46px;
    font-size: 0.95rem;
  }
}

.mobile-controls { display:grid; }
.mobile-controls button {touch-action:none; user-select:none;}
#startButton {margin:10px 14px;padding:10px 20px;font:inherit;font-weight:bold;background:var(--mint);border-radius:8px;cursor:pointer;}
#result {margin:8px 14px;}
@media(max-width:420px){body{padding:4px}.mobile-controls{gap:4px;padding:6px}.mobile-controls button{font-size:12px;min-height:48px}.canvas-frame{padding:2px}}

.hud {display:flex;flex-wrap:wrap;gap:8px 20px;padding:10px 14px;font-weight:900;font-size:16px;background:#101827;color:var(--mint)}
#hudScore{color:var(--yellow)}#hudAmmo{color:var(--cyan)}
@media(max-width:500px){.hud{display:grid;grid-template-columns:1fr 1fr;font-size:14px;gap:7px;padding:10px}.hud span:last-child{grid-column:1/-1}}

.health-hearts {position:absolute;top:18px;left:18px;z-index:1;display:flex;gap:0;pointer-events:none;padding:0 4px;background:rgba(16,24,39,.65);border-radius:8px;min-height:49px;}
.health-hearts img {display:block;width:54px;height:49px;object-fit:contain;image-rendering:pixelated;}
.health-hearts img[hidden] {display:none;}
@media(max-width:500px){.health-hearts{top:8px;left:8px;min-height:40px}.health-hearts img{width:44px;height:40px}}

canvas.timer-display {position:absolute;left:198px;top:18px;z-index:1;width:78px;height:49px;aspect-ratio:96/60;background:rgba(16,24,39,.65);border-radius:8px;pointer-events:none;}
@media(max-width:500px){canvas.timer-display{left:156px;top:8px;width:64px;height:40px}}

canvas.ammo-display{position:absolute;top:18px;right:18px;z-index:1;width:170px;height:49px;aspect-ratio:208/60;background:rgba(16,24,39,.65);border-radius:8px;pointer-events:none;}
@media(max-width:500px){canvas.ammo-display{top:8px;right:8px;width:136px;height:40px}}
@media(max-width:360px){.health-hearts img{width:36px;height:34px}.health-hearts{min-height:34px}canvas.timer-display{left:128px;width:54px;height:34px}canvas.ammo-display{width:104px;height:34px}}

canvas.ammo-display {width:128px;height:37px;}
.hud {position:relative;min-height:60px;align-items:center;}
canvas.score-display {position:absolute;left:50%;top:50%;transform:translate(-50%,-50%);width:auto;height:44px;max-width:48%;aspect-ratio:auto;background:transparent;pointer-events:none;}
@media(max-width:500px){canvas.ammo-display{width:102px;height:30px}.hud{display:block;min-height:66px}canvas.score-display{top:3px;transform:translateX(-50%);height:36px}.hud #hudWasher{position:absolute;bottom:6px;left:10px;font-size:12px}}
@media(max-width:360px){canvas.ammo-display{width:88px;height:26px}}

.washer-indicator {position:absolute;right:18px;top:64px;z-index:1;width:54px;height:54px;padding:2px;border:2px solid transparent;border-radius:10px;background:rgba(16,24,39,.7);cursor:pointer;}
.washer-indicator canvas {width:100%;height:100%;aspect-ratio:1;background:transparent;}
.washer-indicator[data-ready="false"] canvas {filter:grayscale(1);opacity:.38;}
.washer-indicator[data-ready="true"] {border-color:#36a5ff;animation:washer-ready 1.6s ease-in-out infinite;}
#touchMega[data-ready="true"] {border-color:#36a5ff;box-shadow:0 0 12px #36a5ff;}
#touchMega:disabled {opacity:.55;cursor:default;}
@keyframes washer-ready {50%{box-shadow:0 0 14px #36a5ff;}}
@media(max-width:500px){.washer-indicator{right:8px;top:46px;width:44px;height:44px}.hud{min-height:48px}canvas.score-display{top:50%;transform:translate(-50%,-50%)}}
@media(max-width:360px){.washer-indicator{top:42px;width:40px;height:40px}}
@media(pointer:coarse){.washer-indicator{pointer-events:none;}}
@media(prefers-reduced-motion:reduce){.washer-indicator[data-ready="true"]{animation:none;box-shadow:0 0 8px #36a5ff;}}
