/* Shared styles for every game screen */
/* The site's own fonts (same files as the home page), so games look the same on every device */
@font-face { font-family: "Fredoka"; src: url("../fonts/fredoka.woff2") format("woff2"); font-weight: 300 700; font-style: normal; font-display: swap; }
@font-face { font-family: "Quicksand"; src: url("../fonts/quicksand.woff2") format("woff2"); font-weight: 300 700; font-style: normal; font-display: swap; }
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
  width: 100%; height: 100%; overflow: hidden;
  font-family: "Fredoka", "Quicksand", "Trebuchet MS", system-ui, sans-serif;
  background: #0b1d33; color: #fff;
  user-select: none; -webkit-user-select: none;
  touch-action: none; -webkit-tap-highlight-color: transparent;
}
canvas { display: block; width: 100vw; height: 100vh; }

/* Start screen */
.bk-start {
  position: fixed; inset: 0; z-index: 50;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px;
  background:
    radial-gradient(circle at 82% 12%, rgba(255,255,255,.22), transparent 32%),
    radial-gradient(circle at 12% 88%, rgba(255,255,255,.12), transparent 30%),
    linear-gradient(to bottom, var(--bk-from, #1f3b63), var(--bk-to, #0b1d33));
  color: #fff; text-align: center; padding: 24px;
}
.bk-start::before {
  content: ""; position: absolute; inset: 0; pointer-events: none; opacity: .18;
  background-image: radial-gradient(#fff 1.4px, transparent 1.6px); background-size: 34px 34px;
}
.bk-start > * { position: relative; }
.bk-start h1 { text-shadow: 0 3px 14px rgba(0,0,0,.18); }
.bk-start-emoji { font-size: 96px; animation: bob 2s ease-in-out infinite; }
/* Keyboard Smash: the same piano icon as its home-page card, scaled up */
.bk-start-pianobox { width: clamp(120px, 26vmin, 170px); aspect-ratio: 1; border-radius: 30%; display: flex;
  align-items: center; justify-content: center; background: rgba(255,255,255,.2);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.25), 0 14px 30px -10px rgba(0,0,0,.3); animation: bob 2s ease-in-out infinite; }
.bk-start-piano { position: relative; display: flex; width: 75%; height: 62.5%; background: #fff; border-radius: 9%; overflow: hidden;
  box-shadow: 0 6px 14px rgba(0,0,0,.18); }
.bk-start-piano i { flex: 1; border-right: 2px solid #e2e8f0; } .bk-start-piano i:last-of-type { border-right: 0; }
.bk-start-piano b { position: absolute; top: 0; width: 16.7%; height: 50%; background: #0f172a; border-radius: 0 0 4px 4px; }
.bk-start-art { width: clamp(140px, 30vmin, 220px); height: auto; animation: bob 2s ease-in-out infinite;
  filter: drop-shadow(0 10px 18px rgba(0,0,0,.25)); }
.bk-start h1 { font-size: clamp(32px, 6vw, 56px); }
.bk-start-btn {
  font: inherit; font-size: 28px; font-weight: 800;
  padding: 20px 48px; border: 0; border-radius: 999px; cursor: pointer;
  background: #fff; color: var(--bk-accent, #0b1d33); box-shadow: 0 8px 0 rgba(0,0,0,.18);
  transition: transform .15s;
}
.bk-start-btn:hover { transform: translateY(-2px) scale(1.03); }
.bk-start-btn:active { transform: translateY(4px); box-shadow: 0 4px 0 rgba(0,0,0,.18); }
.bk-hint { max-width: 420px; opacity: .7; font-size: 15px; line-height: 1.5; }

/* Home button + back link */
.bk-home {
  position: fixed; top: 14px; right: 14px; z-index: 55;
  width: 56px; height: 56px; border-radius: 18px;
  display: flex; align-items: center; justify-content: center; text-decoration: none;
  background: #fff; color: var(--bk-accent, #4f46e5);
  border: 3px solid rgba(255,255,255,.9);
  box-shadow: 0 5px 0 rgba(0,0,0,.14), 0 10px 22px -6px rgba(0,0,0,.28);
  transition: transform .2s cubic-bezier(.34,1.56,.64,1), box-shadow .2s;
}
.bk-home svg { width: 28px; height: 28px; fill: currentColor; }
.bk-fs {
  position: fixed; top: 14px; right: 82px; z-index: 55;
  width: 56px; height: 56px; border-radius: 18px; padding: 0; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  background: #fff; color: var(--bk-accent, #4f46e5);
  border: 3px solid rgba(255,255,255,.9);
  box-shadow: 0 5px 0 rgba(0,0,0,.14), 0 10px 22px -6px rgba(0,0,0,.28);
  transition: transform .2s cubic-bezier(.34,1.56,.64,1), box-shadow .2s;
}
.bk-fs svg { width: 26px; height: 26px; fill: currentColor; }
.bk-fs:hover { transform: translateY(-2px) scale(1.07); }
.bk-fs:active { transform: translateY(3px); box-shadow: 0 2px 0 rgba(0,0,0,.14); }
.bk-fs:focus-visible { outline: 4px solid #fbbf24; outline-offset: 3px; }
.bk-start ~ .bk-fs { display: none; }
@media (max-width: 640px) {
  .bk-home, .bk-fs { top: 10px; width: 46px; height: 46px; border-radius: 15px; }
  .bk-home { right: 10px; }
  .bk-fs { right: 64px; }
  .bk-home svg { width: 24px; height: 24px; }
  .bk-fs svg { width: 22px; height: 22px; }
}
.bk-home:hover { transform: translateY(-2px) scale(1.07); }
.bk-home:active { transform: translateY(3px); box-shadow: 0 2px 0 rgba(0,0,0,.14); }
.bk-home:focus-visible { outline: 4px solid #fbbf24; outline-offset: 3px; }
.bk-back {
  color: #fff; opacity: .8; font-weight: 800; font-size: 17px; text-decoration: none;
  padding: 8px 16px; border-radius: 999px; border: 2px solid rgba(255,255,255,.35);
}
.bk-back:hover { opacity: 1; background: rgba(255,255,255,.1); }

/* Hidden parent corner */
.bk-corner { position: fixed; top: 0; left: 0; width: 80px; height: 80px; z-index: 40; }
.bk-ring {
  position: absolute; top: 16px; left: 16px; width: 44px; height: 44px; border-radius: 50%;
  border: 4px solid rgba(255,255,255,.08);
}
.bk-corner.holding .bk-ring { border-color: #ffe066; animation: fill 2s linear forwards; }

/* Parent panel */
.bk-panel {
  position: fixed; inset: 0; z-index: 60; background: rgba(5, 12, 24, .8);
  display: flex; align-items: center; justify-content: center;
}
.bk-panel.hidden { display: none; }
.bk-panel-box {
  background: #fff; color: #0b1d33; border-radius: 24px; padding: 28px;
  display: flex; flex-direction: column; gap: 10px; min-width: 280px;
  /* never taller than the screen: scroll inside instead */
  max-width: calc(100% - 24px); max-height: calc(100% - 24px); overflow-y: auto;
  touch-action: pan-y; -webkit-overflow-scrolling: touch; overscroll-behavior: contain;
}
.bk-panel-box h2 { margin-bottom: 6px; }
.bk-panel-box button {
  font: inherit; font-size: 18px; font-weight: 700; text-align: left;
  padding: 12px 16px; border-radius: 12px; border: 2px solid #e4e8f0; background: #f6f8fc; cursor: pointer;
}
.bk-panel-box button:hover { background: #eaf1ff; }

@keyframes bob { 50% { transform: translateY(-12px); } }
@keyframes fill { from { transform: scale(.6); opacity: .4; } to { transform: scale(1.3); opacity: 1; } }

/* "Turn your device sideways" screen (phones and tablets held upright) */
.bk-rotate {
  position: fixed; inset: 0; z-index: 52; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 22px; padding: 24px; text-align: center;
  background: linear-gradient(160deg, var(--bk-from, #6d5bd0), var(--bk-to, #4f46e5)); color: #fff;
}
.bk-rotate.hidden { display: none; }
.bk-rotate-phone {
  width: 74px; height: 124px; border: 7px solid #fff; border-radius: 18px; position: relative;
  animation: bk-turn 2.4s ease-in-out infinite; box-shadow: 0 10px 30px rgba(0,0,0,.25);
}
.bk-rotate-phone span { position: absolute; left: 50%; bottom: 7px; width: 14px; height: 14px; margin-left: -7px;
  border-radius: 50%; background: #fff; opacity: .9; }
@keyframes bk-turn { 0%, 20% { transform: rotate(0); } 55%, 80% { transform: rotate(-90deg); } 100% { transform: rotate(0); } }
.bk-rotate-text { font-size: clamp(22px, 6vw, 34px); font-weight: 900; text-shadow: 0 2px 10px rgba(0,0,0,.2); }
.bk-rotate-skip {
  margin-top: 18px; font: inherit; font-size: 15px; font-weight: 800; color: #fff; cursor: pointer;
  background: rgba(255,255,255,.16); border: 2px solid rgba(255,255,255,.45); border-radius: 999px; padding: 8px 18px;
}
@media (prefers-reduced-motion: reduce) { .bk-rotate-phone { animation: none; transform: rotate(-90deg); } }

/* Keep corner buttons clear of the iPhone notch / rounded corners */
@supports (top: env(safe-area-inset-top)) {
  .bk-home { top: max(14px, env(safe-area-inset-top)); right: calc(14px + env(safe-area-inset-right)); }
  .bk-fs { top: max(14px, env(safe-area-inset-top)); right: calc(82px + env(safe-area-inset-right)); }
  @media (max-width: 640px) {
    .bk-home { top: max(10px, env(safe-area-inset-top)); right: calc(10px + env(safe-area-inset-right)); }
    .bk-fs { top: max(10px, env(safe-area-inset-top)); right: calc(64px + env(safe-area-inset-right)); }
  }
}

/* Phones held sideways (short screens) */
@media (orientation: landscape) and (max-height: 500px) {
  /* Start screen: everything smaller so it all fits */
  .bk-start { gap: 8px; padding: 10px 84px; }
  .bk-start-art { width: auto; height: min(26vh, 110px); animation: none; }
  .bk-start-emoji { font-size: min(18vh, 64px); line-height: 1.1; animation: none; }
  .bk-start-pianobox { width: min(26vh, 110px); animation: none; }
  .bk-start h1 { font-size: clamp(22px, 9vh, 36px); line-height: 1.15; }
  .bk-start-btn { font-size: 20px; padding: 11px 34px; box-shadow: 0 5px 0 rgba(0,0,0,.18); }
  .bk-hint { font-size: 12px; line-height: 1.3; max-width: 520px; }
  .bk-back { font-size: 14px; padding: 4px 12px; }
  /* Grown-up settings: two columns of buttons */
  .bk-panel-box { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; padding: 16px; border-radius: 18px; }
  .bk-panel-box h2 { grid-column: 1 / -1; margin: 0; font-size: 20px; }
  .bk-panel-box button { font-size: 15px; padding: 9px 12px; }
}
