* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; }
body {
  background: linear-gradient(#4aa8ea 0%, #9ed6f7 55%, #e4f5ff 100%);
  font-family: "Trebuchet MS", "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  color: #2b1a10;
  user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
  overscroll-behavior: none;
}
#game { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }

/* HUD */
.hud {
  position: fixed; left: 0; right: 0; top: 0; z-index: 5;
  display: flex; align-items: flex-start; justify-content: space-between; gap: 8px;
  padding: calc(env(safe-area-inset-top) + 10px) calc(env(safe-area-inset-right) + 10px) 0 calc(env(safe-area-inset-left) + 10px);
  pointer-events: none;
}
.hud.hidden { display: none; }
.hud-left { display: flex; flex-wrap: wrap; gap: 6px; max-width: 60%; }
.hud-right { display: flex; gap: 6px; pointer-events: auto; }
.pill {
  background: rgba(255, 248, 232, .88); border: 2px solid #a8322a; border-radius: 999px;
  padding: 4px 11px; font-size: 15px; font-weight: 700; white-space: nowrap;
  box-shadow: 0 2px 0 rgba(0,0,0,.15);
}
.pill b { font-variant-numeric: tabular-nums; margin-left: 2px; }
.lives { color: #b8322a; letter-spacing: 1px; }
.timer.low { background: #ffe0d6; animation: pulse .6s infinite alternate; }
.t-label { font-weight: 400; font-size: 13px; }
@keyframes pulse { to { transform: scale(1.08); } }
.ic-baursak {
  display: inline-block; width: 14px; height: 11px; border-radius: 45%;
  background: radial-gradient(circle at 35% 35%, #ffd88a, #e39a2c 60%, #a8621a);
  vertical-align: -1px; margin-right: 3px;
}
.icon-btn {
  width: 42px; height: 42px; border-radius: 50%; border: 2px solid #a8322a;
  background: rgba(255, 248, 232, .9); color: #a8322a; display: grid; place-items: center;
  cursor: pointer; padding: 0; touch-action: manipulation;
}
.icon-btn .cross { display: none; }
.icon-btn.muted .cross { display: inline; }
.icon-btn.muted .wave { display: none; }

/* Banner */
.banner {
  position: fixed; left: 50%; top: 22%; transform: translate(-50%, -10px); z-index: 6;
  background: rgba(47, 93, 158, .92); color: #fff8e8; border: 3px solid #f2c14e;
  padding: 10px 22px; border-radius: 14px; font-size: 22px; font-weight: 800; text-align: center;
  opacity: 0; transition: opacity .3s, transform .3s; pointer-events: none; max-width: 90vw;
}
.banner.show { opacity: 1; transform: translate(-50%, 0); }

/* Overlay screens */
.overlay {
  position: fixed; inset: 0; z-index: 10; display: none; align-items: center; justify-content: center;
  background: rgba(30, 18, 40, .35); padding: 16px;
}
.overlay.show { display: flex; }
.card {
  width: min(520px, 100%); max-height: 100%; overflow: auto;
  background: #fff8e8; border-radius: 22px; padding: 22px 24px 20px; text-align: center;
  border: 4px solid #a8322a; outline: 3px dashed #f2c14e; outline-offset: -12px;
  box-shadow: 0 10px 30px rgba(0,0,0,.3);
}
.logo {
  font-size: 46px; font-weight: 900; letter-spacing: 1px; color: #a8322a; line-height: 1.05;
  text-shadow: 0 3px 0 #f2c14e, 0 5px 0 rgba(0,0,0,.15);
}
.logo span { color: #2f5d9e; }
.logo.small { font-size: 40px; }
.card h2 { margin: 4px 0 6px; font-size: 28px; color: #a8322a; }
.card p { margin: 8px 0; font-size: 16px; line-height: 1.4; }
.sub { color: #4a3424; }
.controls { display: grid; gap: 4px; margin: 12px auto; padding: 10px 12px; background: #f6ead0; border-radius: 12px; font-size: 15px; max-width: 360px; }
.controls b { background: #fff; border: 1px solid #c9a25e; border-radius: 6px; padding: 0 5px; }
.touch-only { display: none; }
body.touch .touch-only { display: block; font-weight: 700; }
.best { font-size: 17px; }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 12px 0; }
.stats div { background: #f6ead0; border-radius: 12px; padding: 8px; font-size: 14px; }
.stats b { display: block; font-size: 24px; color: #2f5d9e; }
.new-best { color: #b8322a; font-weight: 800; font-size: 20px !important; }
.next { color: #2f5d9e; font-weight: 700; }
.btn-row { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: 14px; }
.btn {
  font: inherit; font-size: 20px; font-weight: 800; padding: 12px 28px; border-radius: 14px; cursor: pointer;
  border: 3px solid #a8322a; background: #fff; color: #a8322a; box-shadow: 0 4px 0 #a8322a;
  touch-action: manipulation;
}
.btn.primary { background: #f2c14e; color: #5a2a10; border-color: #a8322a; }
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 #a8322a; }

/* Touch controls */
.touch-controls { display: none; }
body.touch.playing .touch-controls {
  display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 4; justify-content: space-between; align-items: flex-end;
  padding: 0 calc(env(safe-area-inset-right) + 14px) calc(env(safe-area-inset-bottom) + 16px) calc(env(safe-area-inset-left) + 14px);
  pointer-events: none;
}
.tc-left, .tc-right { display: flex; gap: 14px; pointer-events: auto; }
.tbtn {
  width: 80px; height: 80px; border-radius: 50%; display: grid; place-items: center; align-content: center;
  background: rgba(255, 248, 232, .55); border: 3px solid rgba(168, 50, 42, .85); color: #a8322a;
  touch-action: none; backdrop-filter: blur(2px); -webkit-backdrop-filter: blur(2px);
}
.tbtn svg { width: 40px; height: 40px; pointer-events: none; }
.tbtn.jump { width: 96px; height: 96px; background: rgba(242, 193, 78, .7); }
.tbtn.jump small { font-size: 12px; font-weight: 800; margin-top: -6px; pointer-events: none; }
.tbtn.on { background: rgba(242, 193, 78, .95); transform: scale(.94); }

@media (max-width: 600px) {
  .pill { font-size: 13px; padding: 3px 8px; }
  .t-label { display: none; }
  .logo { font-size: 38px; }
  .card { padding: 18px 16px 16px; }
  .card p { font-size: 15px; }
  .banner { font-size: 18px; }
}
@media (max-height: 500px) {
  .tbtn { width: 66px; height: 66px; }
  .tbtn.jump { width: 80px; height: 80px; }
  .card { padding: 12px 16px; }
  .logo { font-size: 32px; }
  .card p { margin: 4px 0; font-size: 14px; }
  .controls { margin: 6px auto; font-size: 13px; }
  .btn { padding: 8px 22px; font-size: 18px; }
  .banner { top: 18%; }
}
