* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; background: #123; overflow: hidden;
  font-family: "Trebuchet MS", "Segoe UI", sans-serif; }
#stage { position: relative; width: min(100vw, calc(100vh * 854 / 480));
  height: min(100vh, calc(100vw * 480 / 854)); margin: auto;
  top: 50%; transform: translateY(-50%); overflow: hidden;
  background: #2fb3b8; box-shadow: 0 0 40px rgba(0,0,0,.5); }
.screen { position: absolute; inset: 0; display: none; }
.screen.active { display: block; }

/* ---------- menu ---------- */
#menu-screen { text-align: center; color: #123; }
.menu-bg { position: absolute; inset: 0;
  background: linear-gradient(#2ec4c9 0%, #7fd8cf 42%, #cdeeda 55%, #2ec4c9 56%, #2ec4c9 100%); }
.logo { position: relative; margin-top: 7%; font-size: min(11vw, 84px); font-weight: 900;
  letter-spacing: 2px; color: #f5a623;
  text-shadow: 3px 3px 0 #000, -2px -2px 0 #000, 2px -2px 0 #000, -2px 2px 0 #000,
    0 6px 0 rgba(0,0,0,.25); }
.tagline { position: relative; margin-top: 6px; font-size: 15px; color: #0b3d40; }
.menu-btns { position: relative; margin-top: 22px; display: flex; flex-direction: column;
  align-items: center; gap: 12px; }
.big-btn { font: inherit; font-size: 20px; font-weight: 700; padding: 12px 34px;
  border: 3px solid #123; border-radius: 14px; background: #ffd23f; color: #123;
  cursor: pointer; box-shadow: 0 4px 0 #123; min-width: 240px; }
.big-btn:hover { filter: brightness(1.08); }
.big-btn:active { transform: translateY(3px); box-shadow: 0 1px 0 #123; }
.big-btn.ghost { background: #fff; }
.small-btn { font: inherit; font-size: 14px; padding: 8px 14px; border-radius: 10px;
  border: 2px solid #123; background: #fff; cursor: pointer; }
.menu-toggles { position: relative; margin-top: 16px; display: flex; gap: 10px; justify-content: center; }
#howto { position: relative; display: none; max-width: 560px; margin: 18px auto 0;
  background: rgba(255,255,255,.92); border: 2px solid #123; border-radius: 12px;
  padding: 12px 16px; font-size: 14px; line-height: 1.6; text-align: left; }
#howto.show { display: block; }
.credit { position: absolute; bottom: 10px; width: 100%; font-size: 11px; color: rgba(0,0,0,.55); }

/* ---------- level select ---------- */
#level-screen { background: linear-gradient(#2ec4c9, #cdeeda); text-align: center; padding: 18px; overflow-y: auto; }
#level-screen h2 { font-size: 30px; letter-spacing: 2px; margin-bottom: 4px; }
#level-grid { display: grid; grid-template-columns: repeat(8, 1fr); gap: 8px;
  max-width: 640px; margin: 14px auto; }
.lev-btn { font: inherit; font-size: 17px; font-weight: 700; padding: 12px 0;
  border-radius: 10px; border: 2px solid #123; background: #fff; cursor: pointer; }
.lev-btn.done { background: #ffe9a8; }
.lev-btn.locked { opacity: .45; cursor: not-allowed; }
/* current level (levelka) swings -25..+25 deg on a 0.5 s loop (EVENTS.md §3.6) */
.lev-btn.current { background: #ffd23f; animation: swing .5s ease-in-out infinite alternate; }
@keyframes swing { from { transform: rotate(-12deg); } to { transform: rotate(12deg); } }
.level-pages { display: flex; gap: 10px; justify-content: center; margin: 6px 0; }
.level-pages .small-btn:disabled { opacity: .4; cursor: not-allowed; }
#level-screen .big-btn { margin-top: 6px; min-width: 160px; }

/* ---------- game ---------- */
#game-canvas { width: 100%; height: 100%; display: block; background: #7fd4d8; }
#hud { position: absolute; top: 0; left: 0; right: 0; display: flex; gap: 14px;
  align-items: center; padding: 8px 12px; font-size: 15px; font-weight: 700;
  color: #fff; text-shadow: 1px 1px 0 #000; pointer-events: none; }
#hud button { pointer-events: auto; font: inherit; font-size: 15px; font-weight: 700;
  width: 34px; height: 30px; border-radius: 8px; border: 2px solid #123;
  background: rgba(255,255,255,.9); cursor: pointer; }
.hud-spacer { flex: 1; }
#toast { position: absolute; top: 38%; left: 0; right: 0; text-align: center;
  font-size: 44px; font-weight: 900; color: #ff5a5a;
  text-shadow: 2px 2px 0 #000; opacity: 0; pointer-events: none; transition: opacity .15s; }
#toast.show { opacity: 1; }
.overlay { position: absolute; inset: 0; display: none; flex-direction: column;
  align-items: center; justify-content: center; gap: 12px;
  background: rgba(10, 40, 45, .72); color: #fff; z-index: 5; }
.overlay.show { display: flex; }
.overlay h2 { font-size: 46px; letter-spacing: 2px; }
#touch-controls { position: absolute; inset: auto 0 0 0; display: none;
  justify-content: space-between; padding: 0 14px 14px; z-index: 4; }
#touch-controls.show { display: flex; }
#touch-controls .tc-left { display: flex; gap: 12px; }
#touch-controls button { font: inherit; font-size: 18px; font-weight: 800;
  width: 64px; height: 64px; border-radius: 50%; border: 3px solid rgba(0,0,0,.4);
  background: rgba(255,255,255,.55); color: #123; touch-action: none; }
#tc-jump { width: 84px !important; height: 84px !important; background: rgba(255,210,63,.75) !important; }
#tc-climb { width: 64px !important; height: 64px !important; background: rgba(63,214,143,.75) !important; font-size: 13px !important; }
#touch-controls .tc-right { display: flex; gap: 12px; }
@media (pointer: coarse) { #touch-controls.show { display: flex; } }
