@font-face {
  font-family: 'Baloo';
  src: url('./baloo.woff2') format('woff2');
  font-weight: 400 900;
  font-display: swap;
}
:root {
  --ink: #0b3a4a;
  --coral: #ff6b4a;
  --coral-d: #d9492a;
  --sun: #ffd23f;
  --sea: #16b9d4;
  --paper: #fffaf0;
  --teal: #3dd6c9;
  font-size: clamp(12px, 1.2vmin + 9px, 22px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; height: 100%; overflow: hidden; background: var(--sea);
  font-family: 'Baloo', 'Arial Rounded MT Bold', system-ui, sans-serif; color: var(--ink);
  user-select: none; -webkit-user-select: none; touch-action: none; overscroll-behavior: none;
}
#game { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
#ui { position: fixed; inset: 0; pointer-events: none; }
#ui > * { pointer-events: auto; }
.hidden { display: none !important; }
button {
  font: inherit; font-weight: 800; color: inherit; border: 0; cursor: pointer;
  border-radius: 0.9rem; padding: 0.55rem 1.1rem; background: #fff;
  box-shadow: 0 0.25rem 0 rgba(11, 58, 74, 0.25); transition: transform 0.06s;
}
button:active { transform: translateY(0.15rem); box-shadow: 0 0.1rem 0 rgba(11, 58, 74, 0.25); }
button:focus-visible { outline: 0.2rem solid var(--sun); outline-offset: 0.15rem; }
button.primary { background: var(--coral); color: #fff; box-shadow: 0 0.3rem 0 var(--coral-d); }

button.ad::before { content: '🎬'; margin-right: 0.4rem; font-family: 'Apple Color Emoji', 'Segoe UI Emoji', 'Noto Color Emoji', sans-serif; font-weight: 400; }
/* the decline/continue choice is never smaller than the reward choice */
.row.pair > button { min-inline-size: 9rem; }
button:disabled { opacity: 0.45; cursor: default; }

/* HUD */
#hud { position: fixed; inset: 0 0 auto 0; pointer-events: none; padding: 0.4rem 0.6rem; }
#xpbar { height: 0.7rem; border-radius: 1rem; background: rgba(11, 58, 74, 0.35); overflow: hidden; border: 0.15rem solid rgba(255, 255, 255, 0.85); }
#xpfill { height: 100%; width: 0; background: linear-gradient(90deg, #7dff7a, #3ee6ff); transition: width 0.15s; }
#hudrow { display: flex; align-items: center; gap: 0.5rem; margin-top: 0.35rem; }
.pill {
  background: rgba(255, 255, 255, 0.92); border-radius: 1rem; padding: 0.1rem 0.7rem; font-weight: 800;
  box-shadow: 0 0.15rem 0 rgba(11, 58, 74, 0.2); white-space: nowrap; display: flex; align-items: center; gap: 0.3rem;
}
.pill canvas { width: 1.2rem; height: 1.2rem; }
#spacer { flex: 1; }
#pausebtn { pointer-events: auto; width: 2.4rem; height: 2.4rem; padding: 0; border-radius: 50%; font-size: 1rem; display: flex; align-items: center; justify-content: center; }
#pausebtn i { display: inline-block; width: 0.3rem; height: 0.9rem; background: var(--ink); margin: 0 0.1rem; border-radius: 0.1rem; }
#bossbar { position: fixed; top: 3.6rem; left: 50%; transform: translateX(-50%); width: min(60vw, 26rem); text-align: center; color: #fff; font-weight: 800; text-shadow: 0 0.12rem 0 var(--ink); pointer-events: none; }
#bossbar .bar { height: 0.8rem; background: rgba(11, 58, 74, 0.5); border-radius: 1rem; overflow: hidden; border: 0.15rem solid #fff; }
#bossbar .bar div { height: 100%; background: #ff5a4e; width: 100%; }
#combo { position: fixed; top: 3.3rem; right: 0.8rem; font-weight: 900; color: #fff; font-size: 1.4rem; text-shadow: 0 0.15rem 0 var(--ink); pointer-events: none; transform-origin: right center; }
#toast {
  position: fixed; top: 22%; left: 50%; transform: translateX(-50%); text-align: center; pointer-events: none;
  color: #fff; font-weight: 900; font-size: 2rem; line-height: 1.1; text-shadow: 0 0.18rem 0 var(--ink), 0 0 1rem rgba(11, 58, 74, 0.4);
  transition: opacity 0.3s; white-space: nowrap;
}
#toast small { display: block; font-size: 1.05rem; font-weight: 800; }
#hint {
  position: fixed; bottom: 12%; left: 50%; transform: translateX(-50%); pointer-events: none; text-align: center;
  color: #fff; font-weight: 900; font-size: 1.5rem; text-shadow: 0 0.15rem 0 var(--ink); animation: bob 1.1s ease-in-out infinite;
}
#hint .keys { display: inline-grid; grid-template-columns: repeat(3, 1.7rem); gap: 0.2rem; margin-bottom: 0.4rem; }
#hint .keys span { background: #fff; color: var(--ink); border-radius: 0.35rem; height: 1.7rem; display: grid; place-items: center; font-size: 0.9rem; box-shadow: 0 0.15rem 0 rgba(11,58,74,.3); text-shadow: none; }
#hint .finger { font-size: 2.2rem; display: block; }
@keyframes bob { 50% { transform: translate(-50%, -0.4rem); } }

/* overlays */
.overlay { position: fixed; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0.8rem; padding: 1rem; background: rgba(11, 58, 74, 0.45); }
.overlay h1 { margin: 0; color: #fff; font-size: 2.3rem; line-height: 1; text-shadow: 0 0.2rem 0 var(--ink); text-align: center; }
.overlay p.sub { margin: 0; color: #fff; font-weight: 700; text-shadow: 0 0.12rem 0 var(--ink); text-align: center; }
.row { display: flex; gap: 0.7rem; flex-wrap: wrap; justify-content: center; }
.cards { display: flex; gap: 0.8rem; justify-content: center; width: 100%; max-width: 52rem; }
.card {
  flex: 1 1 0; max-width: 16rem; min-height: 13rem; background: var(--paper); border-radius: 1.2rem; padding: 0.9rem 0.8rem;
  display: flex; flex-direction: column; align-items: center; gap: 0.35rem; text-align: center; position: relative;
  box-shadow: 0 0.4rem 0 rgba(11, 58, 74, 0.35); border: 0.2rem solid #fff; animation: cardin 0.25s ease-out backwards;
}
.card:nth-child(2) { animation-delay: 0.05s; } .card:nth-child(3) { animation-delay: 0.1s; }
@keyframes cardin { from { transform: translateY(1.5rem) scale(0.9); opacity: 0; } }
.card canvas { width: 4.2rem; height: 4.2rem; }
.card .name { font-size: 1.15rem; font-weight: 900; line-height: 1.05; }
.card .desc { font-size: 0.9rem; font-weight: 600; line-height: 1.15; opacity: 0.85; }
.card .pips { display: flex; gap: 0.2rem; margin-top: auto; }
.card .pips i { width: 0.7rem; height: 0.7rem; border-radius: 50%; background: #d9e6ea; }
.card .pips i.on { background: var(--coral); }
.card .tag { position: absolute; top: -0.6rem; right: -0.4rem; background: var(--sun); border-radius: 0.6rem; padding: 0 0.5rem; font-size: 0.8rem; font-weight: 900; transform: rotate(8deg); }
.card .key { position: absolute; top: 0.35rem; left: 0.55rem; font-size: 0.75rem; opacity: 0.45; }
.card.weapon { border-color: #ffd9c9; }
.panel { background: var(--paper); border-radius: 1.2rem; padding: 1rem 1.2rem; box-shadow: 0 0.4rem 0 rgba(11, 58, 74, 0.35); text-align: center; max-width: 30rem; width: 100%; }
.stats { display: grid; grid-template-columns: 1fr auto; gap: 0.1rem 1rem; text-align: left; font-weight: 700; margin: 0.4rem 0 0.8rem; }
.stats b { text-align: right; }
.unlock { background: var(--sun); border-radius: 0.8rem; padding: 0.3rem 0.8rem; font-weight: 900; margin: 0.3rem 0; animation: cardin 0.3s ease-out backwards 0.2s; }
#countdown { font-size: 3rem; color: #fff; font-weight: 900; text-shadow: 0 0.2rem 0 var(--ink); line-height: 1; }
.breakbox { background: none; }

/* hub */
#hub { position: fixed; inset: 0; background: linear-gradient(180deg, #7fe3e0 0%, #16b9d4 70%); overflow-y: auto; touch-action: pan-y; padding: 0.8rem 1rem 6rem; }
#hub header { display: flex; align-items: center; gap: 0.6rem; max-width: 60rem; margin: 0 auto 0.6rem; }
#hub header h2 { margin: 0; font-size: 1.8rem; color: #fff; text-shadow: 0 0.15rem 0 var(--ink); flex: 1; line-height: 1; }
.hubgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.9rem; max-width: 60rem; margin: 0 auto; }
@media (max-aspect-ratio: 1/1) { .hubgrid { grid-template-columns: 1fr; } .cards { flex-direction: column; align-items: center; } .card { flex: none; min-height: 0; max-width: 24rem; width: 100%; flex-direction: row; text-align: left; padding: 0.6rem 0.8rem; } .card .pips { margin: 0 0 0 auto; flex-direction: column; } .card canvas { width: 3.2rem; height: 3.2rem; flex: none; } .card .txt { flex: 1; } }
.box { background: rgba(255, 250, 240, 0.95); border-radius: 1.1rem; padding: 0.7rem 0.8rem; box-shadow: 0 0.3rem 0 rgba(11, 58, 74, 0.25); }
.box h3 { margin: 0 0 0.4rem; font-size: 1.05rem; }
.picks { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0.4rem; }
.pick { display: flex; flex-direction: column; align-items: center; padding: 0.35rem 0.2rem; border-radius: 0.8rem; background: #fff; border: 0.18rem solid transparent; font-size: 0.85rem; line-height: 1.05; text-align: center; box-shadow: 0 0.2rem 0 rgba(11, 58, 74, 0.2); }
.pick canvas { width: 3rem; height: 3rem; }
.pick.sel { border-color: var(--coral); background: #fff1e8; }
.pick.locked { opacity: 0.6; filter: grayscale(0.8); }
.pick small { font-weight: 700; opacity: 0.8; font-size: 0.7rem; }
.picks.isl { grid-template-columns: repeat(3, 1fr); }
.info { font-size: 0.85rem; font-weight: 700; min-height: 1.2rem; margin-top: 0.4rem; opacity: 0.85; }
.upg { display: grid; grid-template-columns: 2.2rem 1fr auto; gap: 0.1rem 0.5rem; align-items: center; padding: 0.3rem 0; border-bottom: 0.1rem dashed #e2d6c2; }
.upg:last-child { border: 0; }
.upg canvas { width: 2.2rem; height: 2.2rem; grid-row: span 2; }
.upg .n { font-weight: 900; line-height: 1; }
.upg .d { font-size: 0.8rem; font-weight: 600; opacity: 0.8; line-height: 1; }
.upg button { grid-row: span 2; padding: 0.3rem 0.6rem; font-size: 0.9rem; min-width: 5rem; }
.upg .pp { display: inline-flex; gap: 0.15rem; margin-left: 0.3rem; vertical-align: middle; }
.upg .pp i { width: 0.45rem; height: 0.45rem; border-radius: 50%; background: #d9e6ea; display: inline-block; }
.upg .pp i.on { background: var(--coral); }
#playbtn { position: fixed; left: 50%; bottom: 1rem; transform: translateX(-50%); font-size: 1.7rem; padding: 0.5rem 3rem; border-radius: 1.3rem; z-index: 2; }
#playbtn:active { transform: translate(-50%, 0.15rem); }
.shellcount { display: inline-flex; align-items: center; gap: 0.3rem; }
.shellcount canvas { width: 1.4rem; height: 1.4rem; }
.toggles button { padding: 0.35rem 0.7rem; font-size: 0.85rem; }
.toggles button.off { opacity: 0.55; text-decoration: line-through; }
.upg button { display: inline-flex; align-items: center; justify-content: center; gap: 0.2rem; }
.upg button canvas { width: 1.1rem; height: 1.1rem; grid-row: auto; }
@media (prefers-reduced-motion: reduce) { #hint { animation: none; } .card, .unlock { animation: none; } }
.overlay .note { font-size: 0.85rem; font-weight: 700; opacity: 0.85; margin-top: 0.6rem; }
