@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

:root {
  --navy: #0b2f5f;
  --blue: #1769aa;
  --sky: #58b9ef;
  --ice: #eef8ff;
  --ink: #12304f;
  --line: #cfe3f2;
  --white: #ffffff;
  --shadow: 0 24px 70px rgba(11, 47, 95, .18);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 15% 5%, rgba(88,185,239,.22), transparent 30%),
    linear-gradient(145deg, #f7fcff 0%, #e9f5fd 100%);
}

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

.app {
  width: min(1120px, 100%);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 14px;
}

.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  width: 44px; height: 44px; border-radius: 13px;
  display: grid; place-items: center;
  color: white; background: linear-gradient(145deg, var(--navy), var(--blue));
  font-weight: 800; font-size: 22px;
  box-shadow: 0 8px 22px rgba(11,47,95,.22);
}
.brand strong { display: block; letter-spacing: .08em; font-size: 14px; }
.brand span { display: block; color: #66809a; font-size: 11px; margin-top: 3px; }

.scores { display: flex; gap: 22px; text-align: right; }
.scores small { display: block; color: #6f879d; font-size: 9px; letter-spacing: .12em; font-weight: 700; }
.scores b { font-variant-numeric: tabular-nums; color: var(--navy); font-size: 19px; letter-spacing: .05em; }

.game-shell {
  position: relative;
  overflow: hidden;
  border: 1px solid rgba(160,197,220,.65);
  border-radius: 24px;
  background: #dff2ff;
  box-shadow: var(--shadow);
  min-height: 510px;
}

canvas {
  display: block;
  width: 100%;
  height: 510px;
  touch-action: none;
}

.game-hud {
  position: absolute;
  z-index: 3;
  top: 16px; left: 16px; right: 16px;
  display: flex; justify-content: space-between; align-items: center;
  pointer-events: none;
}
.status-pill {
  background: rgba(255,255,255,.78);
  border: 1px solid rgba(255,255,255,.95);
  color: var(--navy);
  padding: 7px 11px; border-radius: 999px;
  font-size: 10px; font-weight: 800; letter-spacing: .08em;
  backdrop-filter: blur(8px);
}
.hint { color: rgba(18,48,79,.56); font-size: 9px; font-weight: 700; letter-spacing: .06em; }

.overlay {
  position: absolute; inset: 0; z-index: 5;
  display: grid; place-items: center;
  padding: 24px;
  background: rgba(238,248,255,.45);
  backdrop-filter: blur(7px);
  opacity: 0; pointer-events: none;
  transition: opacity .25s ease;
}
.overlay.visible { opacity: 1; pointer-events: auto; }

.panel {
  width: min(440px, 100%);
  text-align: center;
  background: rgba(255,255,255,.94);
  border: 1px solid rgba(207,227,242,.95);
  border-radius: 25px;
  padding: 34px;
  box-shadow: 0 22px 60px rgba(11,47,95,.17);
}
.panel h1, .panel h2 { margin: 5px 0 10px; color: var(--navy); letter-spacing: -.04em; }
.panel h1 { font-size: clamp(32px, 6vw, 48px); }
.panel h2 { font-size: 42px; }
.panel p { line-height: 1.65; color: #637c91; margin: 10px 0 22px; }
.eyebrow { color: var(--blue) !important; font-size: 10px !important; font-weight: 800; letter-spacing: .16em; margin-bottom: 3px !important; }
.codi-badge {
  width: 120px; height: 120px; margin: -10px auto 8px;
  display: grid; place-items: center;
  border-radius: 50%;
  background: linear-gradient(145deg, #eaf7ff, #cbeafd);
  font-size: 64px;
  line-height: 1;
}
.codi-badge img { width: 98px; height: 98px; object-fit: contain; }

button {
  appearance: none; border: 0; cursor: pointer;
  color: #fff; background: linear-gradient(135deg, var(--navy), var(--blue));
  font: inherit; font-weight: 800; letter-spacing: .02em;
  padding: 14px 28px; border-radius: 13px;
  box-shadow: 0 10px 24px rgba(23,105,170,.25);
  transition: transform .15s ease, box-shadow .15s ease;
}
button:hover { transform: translateY(-2px); box-shadow: 0 14px 28px rgba(23,105,170,.3); }
button:active { transform: translateY(0); }

.controls { margin-top: 17px; display: flex; justify-content: center; gap: 7px; }
.controls span {
  border: 1px solid var(--line); color: #6b8398; background: #f7fbfe;
  padding: 5px 8px; border-radius: 6px; font-size: 8px; font-weight: 800;
}
.record-message { min-height: 20px; color: var(--blue) !important; font-weight: 800; font-size: 13px; }

footer {
  display: flex; justify-content: space-between;
  color: #7a91a4; font-size: 10px; padding: 13px 3px;
}

@media (max-width: 680px) {
  body { padding: 8px; }
  .topbar { padding: 3px 4px; }
  .brand span { display: none; }
  .scores { gap: 12px; }
  .game-shell { border-radius: 18px; min-height: 440px; }
  canvas { height: 440px; }
  .hint { display: none; }
  .panel { padding: 27px 22px; }
  footer { padding: 10px 4px; }
}

/* Mobile-first interaction layer */
html { min-height: 100%; }
body {
  min-height: 100svh;
  overscroll-behavior: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}
button, canvas { -webkit-tap-highlight-color: transparent; }
canvas { touch-action: none; }
.game-shell { isolation: isolate; }
.mobile-jump {
  display: none;
  position: absolute;
  z-index: 4;
  right: 14px;
  bottom: 14px;
  min-width: 92px;
  min-height: 54px;
  padding: 10px 14px;
  border-radius: 18px;
  border: 1px solid rgba(255,255,255,.75);
  background: rgba(11,47,95,.88);
  box-shadow: 0 10px 28px rgba(11,47,95,.25);
  color: #fff;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: .08em;
  touch-action: manipulation;
}
.mobile-jump span { font-size: 20px; line-height: 0; vertical-align: -2px; }
.mobile-jump:active { transform: scale(.96); }
.mobile-tip { display: none; margin-top: 12px; color: #6d8497; font-size: 11px; }

@media (max-width: 680px) {
  body {
    padding: max(6px, env(safe-area-inset-top)) max(6px, env(safe-area-inset-right)) max(6px, env(safe-area-inset-bottom)) max(6px, env(safe-area-inset-left));
    display: block;
  }
  .app { width: 100%; max-width: none; }
  .topbar { margin-bottom: 8px; padding: 0 4px; }
  .brand-mark { width: 38px; height: 38px; border-radius: 11px; font-size: 19px; }
  .brand { gap: 9px; }
  .brand strong { font-size: 12px; }
  .scores { gap: 10px; }
  .scores b { font-size: 16px; }
  .game-shell {
    width: 100%;
    min-height: 360px;
    height: clamp(360px, calc(100svh - 118px), 620px);
    border-radius: 18px;
  }
  canvas { width: 100%; height: 100%; }
  .game-hud { top: 10px; left: 10px; right: 10px; }
  .status-pill { padding: 6px 9px; font-size: 9px; }
  .hint { display: none; }
  .mobile-jump { display: block; }
  .mobile-tip { display: block; }
  .controls { display: none; }
  .panel {
    width: min(430px, calc(100% - 24px));
    padding: 23px 18px;
    border-radius: 21px;
  }
  .codi-badge { width: 92px; height: 92px; margin: -4px auto 5px; font-size: 48px; }
  .codi-badge img { width: 78px; height: 78px; }
  .panel h1 { font-size: clamp(31px, 10vw, 42px); }
  .panel h2 { font-size: 34px; }
  .panel p { font-size: 13px; line-height: 1.5; margin-bottom: 17px; }
  .panel button { min-height: 50px; min-width: 150px; font-size: 14px; }
  footer { padding: 8px 4px; font-size: 9px; }
}

@media (max-height: 620px) and (max-width: 680px) {
  .game-shell { height: calc(100svh - 94px); min-height: 320px; }
  .codi-badge { display: none; }
  .panel { padding: 18px 16px; }
  .panel p { margin: 7px 0 12px; }
  .mobile-tip { margin-top: 8px; }
}

@media (orientation: landscape) and (max-width: 900px) {
  body { padding: 5px 8px; }
  .topbar { margin-bottom: 5px; }
  .game-shell { height: calc(100svh - 62px); min-height: 280px; }
  footer { display: none; }
  .panel { max-width: 390px; padding: 15px 20px; }
  .codi-badge { display: none; }
  .panel p { margin: 6px 0 10px; }
}
body.paused .mobile-jump { opacity: .65; }
