* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body {
  width: 100%; height: 100%; overflow: hidden; background: #5ec8ff;
  font-family: "Trebuchet MS", "Arial Rounded MT Bold", system-ui, sans-serif;
  touch-action: none; user-select: none; -webkit-user-select: none; overscroll-behavior: none;
}
canvas#game { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
.hidden { display: none !important; }

#hud {
  position: fixed; top: calc(env(safe-area-inset-top, 0px) + 12px); left: 12px; right: 64px;
  display: flex; justify-content: space-between; pointer-events: none; z-index: 5;
}
.pill {
  background: rgba(255,255,255,0.88); color: #2b2d6e; font-weight: 900; font-size: 24px;
  padding: 6px 16px; border-radius: 999px; box-shadow: 0 4px 0 rgba(0,0,0,0.15);
  display: flex; align-items: center; gap: 8px; min-width: 64px; justify-content: center;
}
.coin-icon {
  width: 26px; height: 18px; border-radius: 3px; display: inline-block; position: relative;
  background:
    linear-gradient(to bottom right, transparent calc(50% - 1.5px), #7a5a2e calc(50% - 1px), #7a5a2e calc(50% + 0.5px), transparent calc(50% + 1px)) left top / 50% 70% no-repeat,
    linear-gradient(to bottom left, transparent calc(50% - 1.5px), #7a5a2e calc(50% - 1px), #7a5a2e calc(50% + 0.5px), transparent calc(50% + 1px)) right top / 50% 70% no-repeat,
    #fffaf0;
  border: 2px solid #7a5a2e;
}
.icon-btn {
  position: fixed; top: calc(env(safe-area-inset-top, 0px) + 12px); right: 12px; z-index: 6;
  width: 44px; height: 44px; border-radius: 50%; border: none; font-size: 20px;
  background: rgba(255,255,255,0.88); box-shadow: 0 4px 0 rgba(0,0,0,0.15); cursor: pointer;
}

.overlay {
  position: fixed; inset: 0; display: flex; align-items: center; justify-content: center;
  z-index: 10; padding: 20px; background: rgba(40, 60, 140, 0.25);
}
.panel {
  background: #ffffff; border-radius: 28px; padding: 26px 24px 22px; width: min(360px, 100%);
  text-align: center; box-shadow: 0 10px 0 rgba(0,0,0,0.18), 0 20px 40px rgba(0,0,0,0.2);
  animation: pop 0.35s cubic-bezier(.2,1.6,.4,1);
}
@keyframes pop { from { transform: scale(0.7); opacity: 0; } to { transform: scale(1); opacity: 1; } }

.logo { display: flex; flex-direction: column; align-items: center; line-height: 0.95; font-size: 64px; font-weight: 900; letter-spacing: 1px; }
.logo span:first-child { font-size: clamp(30px, 9.6vw, 42px); white-space: nowrap; letter-spacing: 0; margin-bottom: 6px; }
.logo span:first-child { color: #ff5a8a; text-shadow: 0 5px 0 #c2305f; }
.logo span:last-child  { color: #ffb400; text-shadow: 0 5px 0 #c97f00; transform: rotate(-3deg); }
.tag { color: #2b2d6e; margin: 8px 0 2px; font-size: 24px; font-weight: 900; }
.sub { color: #4a4f8c; margin: 0 0 14px; font-size: 15px; font-weight: 700; }
.cast { display: block; width: 100%; height: clamp(92px, 16vh, 128px); margin-top: 8px; }

.big-btn {
  display: block; width: 100%; border: none; cursor: pointer;
  font: inherit; font-size: 30px; font-weight: 900; color: #fff;
  padding: 14px 0; border-radius: 20px; background: #31c95a;
  box-shadow: 0 7px 0 #1f8f3c; transition: transform 0.08s, box-shadow 0.08s;
}
.big-btn:active { transform: translateY(5px); box-shadow: 0 2px 0 #1f8f3c; }

.howto { margin-top: 18px; color: #3b3f73; font-size: 15px; display: grid; gap: 4px; }
.howto b { color: #ff5a8a; }
.howto .desk { color: #8a8db8; font-size: 13px; margin-top: 4px; }
.best { margin-top: 12px; color: #8a6d00; font-weight: 800; min-height: 1em; }

.oops { font-size: clamp(32px, 10vw, 44px); white-space: nowrap; font-weight: 900; color: #ff5a8a; text-shadow: 0 4px 0 #c2305f; }
.final-score { font-size: 64px; font-weight: 900; color: #2b2d6e; margin: 6px 0; }
.stats { color: #4a4f8c; font-weight: 700; display: grid; gap: 2px; margin-bottom: 4px; }
.stats span { color: #2b2d6e; font-weight: 900; }
#over .big-btn { margin-top: 14px; }


#ending { position: fixed; inset: 0; z-index: 30; background: #000; display: flex; align-items: center; justify-content: center; }
#endVid { width: 100%; height: 100%; object-fit: contain; display: block; pointer-events: none; }
#endHint {
  position: absolute; bottom: calc(env(safe-area-inset-bottom, 0px) + 14px); left: 0; right: 0; text-align: center;
  color: rgba(255,255,255,0.75); font-weight: 800; font-size: 15px; text-shadow: 0 1px 3px #000; pointer-events: none;
}
#endSound {
  position: absolute; top: calc(env(safe-area-inset-top, 0px) + 14px); left: 50%; transform: translateX(-50%);
  border: none; border-radius: 999px; padding: 10px 18px; font: inherit; font-weight: 900; font-size: 17px;
  background: rgba(255,255,255,0.92); color: #18140f; cursor: pointer;
}
