:root {
  font-family: ui-rounded, "SF Pro Rounded", "Avenir Next", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #20163a;
  background: #f9f4ff;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  --ink: #20163a;
  --purple: #5a38a5;
  --paper: #fffdf8;
  --yellow: #ffd85c;
  --blue: #55b7ff;
  --pink: #ff77c8;
  --green: #72d5a3;
}

* { box-sizing: border-box; }
html, body, #app { min-height: 100%; margin: 0; }
body {
  min-height: 100svh;
  overscroll-behavior: none;
  background:
    radial-gradient(circle at 15% 15%, rgba(255, 216, 92, .45), transparent 23rem),
    radial-gradient(circle at 85% 18%, rgba(85, 183, 255, .30), transparent 22rem),
    radial-gradient(circle at 75% 85%, rgba(255, 119, 200, .24), transparent 24rem),
    #f9f4ff;
}
button { font: inherit; }
button:focus-visible { outline: 4px solid #ff9c2f; outline-offset: 3px; }

.app-shell { min-height: 100svh; padding: max(18px, env(safe-area-inset-top)) 18px max(24px, env(safe-area-inset-bottom)); }
.topbar { max-width: 1120px; margin: 0 auto 18px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.brand-button { border: 0; background: transparent; display: flex; align-items: center; gap: 10px; color: var(--ink); cursor: pointer; padding: 4px; }
.brand-mark { display: grid; place-items: center; width: 46px; height: 46px; background: var(--yellow); border: 3px solid var(--ink); border-radius: 14px 18px 12px 17px; transform: rotate(-3deg); box-shadow: 4px 4px 0 var(--ink); font-size: 24px; }
.brand-copy strong { display: block; font-size: 1.05rem; }
.brand-copy span { display: block; font-size: .78rem; opacity: .72; }
.player-pill { border: 2px solid var(--ink); background: white; border-radius: 999px; padding: 8px 12px; display: flex; align-items: center; gap: 7px; box-shadow: 3px 3px 0 var(--ink); cursor: pointer; }

.screen { max-width: 1120px; margin: 0 auto; }
.hero { position: relative; overflow: hidden; border: 4px solid var(--ink); background: var(--paper); border-radius: 30px 40px 26px 38px; padding: clamp(24px, 5vw, 58px); box-shadow: 10px 12px 0 var(--ink); }
.hero::after { content: "ZAP!"; position: absolute; right: -20px; top: 18px; background: var(--yellow); border: 3px solid var(--ink); padding: 13px 30px; transform: rotate(9deg); font-weight: 950; letter-spacing: .12em; }
.kicker { margin: 0 0 8px; font-size: .85rem; font-weight: 900; letter-spacing: .14em; text-transform: uppercase; color: var(--purple); }
h1 { margin: 0; font-size: clamp(3rem, 10vw, 7rem); line-height: .84; letter-spacing: -.07em; max-width: 790px; }
.hero-subtitle { max-width: 650px; font-size: clamp(1rem, 2vw, 1.32rem); line-height: 1.45; margin: 24px 0 0; }
.scribble { display: inline-block; text-decoration: underline wavy var(--pink) 5px; text-underline-offset: 8px; }

.section-title { margin: 30px 0 14px; font-size: clamp(1.55rem, 4vw, 2.25rem); }
.player-grid, .world-grid, .sticker-grid { display: grid; gap: 16px; }
.player-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); margin-top: 26px; }
.player-card { min-height: 180px; border: 4px solid var(--ink); border-radius: 28px 20px 30px 22px; background: white; box-shadow: 7px 8px 0 var(--ink); padding: 20px; cursor: pointer; text-align: left; transition: transform .16s ease, box-shadow .16s ease; }
.player-card:nth-child(2) { transform: rotate(1deg); }
.player-card:hover, .player-card:active { transform: translate(3px, 3px) rotate(0); box-shadow: 4px 5px 0 var(--ink); }
.player-icon { font-size: 3.6rem; }
.player-card strong { display: block; font-size: 1.8rem; margin-top: 8px; }
.player-card span { opacity: .72; }

.world-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.world-card { position: relative; overflow: hidden; min-height: 255px; border: 4px solid var(--ink); border-radius: 25px; padding: 22px; background: white; box-shadow: 6px 7px 0 var(--ink); display: flex; flex-direction: column; align-items: flex-start; text-align: left; cursor: pointer; }
.world-card:nth-child(1) { background: linear-gradient(145deg, #fff9c9, #f7dfff 55%, #d8f5ff); transform: rotate(-.8deg); }
.world-card:nth-child(2) { background: linear-gradient(145deg, #d9f9e8, #fff8db 55%, #e8e0ff); transform: rotate(.7deg); }
.world-card:nth-child(3) { background: repeating-linear-gradient(-10deg, #fff, #fff 18px, #f6efff 18px, #f6efff 36px); transform: rotate(-.3deg); }
.world-card[disabled] { cursor: default; opacity: .68; }
.world-card:not([disabled]):hover { transform: translate(3px, 3px) rotate(0); box-shadow: 3px 4px 0 var(--ink); }
.world-icon { font-size: 3rem; }
.world-eyebrow { font-size: .72rem; font-weight: 950; letter-spacing: .13em; margin-top: 14px; }
.world-card h3 { margin: 7px 0 8px; font-size: 1.6rem; line-height: 1.05; }
.world-card p { margin: 0; line-height: 1.35; }
.status-badge { margin-top: auto; background: var(--ink); color: white; padding: 7px 10px; border-radius: 10px; font-size: .78rem; font-weight: 900; }
.status-badge.complete { background: #187850; }

.comic-panel { border: 4px solid var(--ink); background: rgba(255,255,255,.93); border-radius: 24px; box-shadow: 7px 8px 0 var(--ink); padding: 20px; }
.profile-row { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.profile-bubble { display: grid; place-items: center; width: 76px; height: 76px; border-radius: 50%; border: 4px solid var(--ink); font-size: 2.4rem; background: var(--yellow); }
.profile-copy h2 { margin: 0; font-size: 2rem; }
.profile-copy p { margin: 4px 0 0; }
.progress-bar { height: 20px; border: 3px solid var(--ink); border-radius: 99px; background: white; overflow: hidden; margin-top: 16px; }
.progress-fill { height: 100%; background: repeating-linear-gradient(90deg, var(--blue), var(--blue) 20px, var(--pink) 20px, var(--pink) 40px, var(--yellow) 40px, var(--yellow) 60px); }
.small-button { border: 2px solid var(--ink); border-radius: 12px; background: white; padding: 8px 12px; box-shadow: 3px 3px 0 var(--ink); cursor: pointer; font-weight: 800; }

.sticker-grid { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.sticker { border: 3px dashed var(--ink); border-radius: 18px; padding: 14px; background: white; text-align: center; min-height: 170px; display: grid; place-content: center; }
.sticker.locked { filter: grayscale(1); opacity: .35; }
.sticker-emoji { font-size: 3.2rem; }
.sticker strong { display: block; margin-top: 7px; }
.sticker small { display: block; margin-top: 4px; line-height: 1.25; }

.game-layout { display: grid; grid-template-columns: minmax(0, 1fr) 270px; gap: 18px; align-items: start; }
.game-frame { position: relative; border: 4px solid var(--ink); border-radius: 24px; overflow: hidden; background: #171128; box-shadow: 8px 9px 0 var(--ink); min-height: 420px; }
#game-root canvas { display: block; width: 100% !important; height: auto !important; max-height: calc(100svh - 150px); touch-action: none; }
.game-sidebar h2 { margin: 0 0 8px; }
.game-sidebar p { line-height: 1.4; }
.button-row { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 14px; }
.primary-button { border: 3px solid var(--ink); background: var(--yellow); color: var(--ink); border-radius: 14px; padding: 11px 15px; box-shadow: 4px 4px 0 var(--ink); cursor: pointer; font-weight: 950; }
.primary-button:active, .small-button:active { transform: translate(2px,2px); box-shadow: 1px 1px 0 var(--ink); }

.modal-backdrop { position: fixed; inset: 0; z-index: 20; background: rgba(22, 12, 43, .7); display: grid; place-items: center; padding: 22px; }
.modal { width: min(520px, 100%); border: 5px solid var(--ink); border-radius: 28px; background: white; box-shadow: 10px 11px 0 var(--ink); padding: 26px; text-align: center; }
.modal-emoji { font-size: 5rem; }
.modal h2 { font-size: 2.2rem; margin: 8px 0; }
.modal p { line-height: 1.45; }

.install-note { margin-top: 24px; background: #35265f; color: white; padding: 16px 18px; border-radius: 18px; line-height: 1.45; }
.muted { opacity: .65; }

@media (max-width: 850px) {
  .world-grid { grid-template-columns: 1fr; }
  .world-card { min-height: 210px; }
  .game-layout { grid-template-columns: 1fr; }
  .game-sidebar { order: -1; }
}

@media (max-width: 600px) {
  .app-shell { padding-inline: 12px; }
  .player-grid { grid-template-columns: 1fr; }
  .hero { padding: 24px 20px 30px; box-shadow: 6px 7px 0 var(--ink); }
  .hero::after { font-size: .7rem; padding: 9px 24px; }
  .brand-copy span { display: none; }
  .game-frame { min-height: 340px; }
}
