:root {
  --ink: #29336f;
  --muted: #66709b;
  --violet: #6c63dc;
  --violet-dark: #4d48b8;
  --violet-soft: #eeecff;
  --yellow: #ffd55f;
  --pink: #f59abe;
  --cream: #fff9ef;
  --white: #fff;
  --line: rgba(80, 78, 158, 0.13);
  --shadow: 0 24px 70px rgba(62, 63, 131, 0.16);
}

* { box-sizing: border-box; }

html, body { min-height: 100%; }

body {
  margin: 0;
  overflow-x: hidden;
  color: var(--ink);
  background: linear-gradient(150deg, #faf7ff 0%, #f6fbff 48%, #fff7ec 100%);
  font-family: "Nunito", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button, a { -webkit-tap-highlight-color: transparent; }
button { font: inherit; }

.sky { position: fixed; inset: 0; z-index: -1; overflow: hidden; pointer-events: none; }
.soft-cloud { position: absolute; width: 220px; height: 74px; border-radius: 99px; background: rgba(255,255,255,.72); filter: blur(.2px); }
.soft-cloud::before, .soft-cloud::after { content: ""; position: absolute; border-radius: 50%; background: inherit; }
.soft-cloud::before { width: 92px; height: 92px; left: 38px; top: -40px; }
.soft-cloud::after { width: 120px; height: 120px; right: 24px; top: -56px; }
.cloud-a { left: -85px; top: 18%; opacity: .72; transform: scale(.8); }
.cloud-b { right: -80px; top: 7%; opacity: .62; transform: scale(.58); }
.cloud-c { right: 8%; bottom: 2%; opacity: .55; transform: scale(.45); }
.star { position: absolute; color: rgba(255, 190, 61, .48); font-size: 28px; }
.star-a { left: 7%; top: 10%; }.star-b { right: 9%; top: 49%; }.star-c { left: 42%; bottom: 8%; }

.app-shell { width: min(1280px, calc(100% - 40px)); min-height: 100vh; margin: 0 auto; display: flex; flex-direction: column; }
.brand-bar { min-height: 92px; display: flex; align-items: center; justify-content: space-between; }
.brand { color: var(--ink); text-decoration: none; display: inline-flex; align-items: center; gap: 13px; }
.brand > span:last-child { display: grid; line-height: 1; }
.brand strong { font-family: "Baloo 2", sans-serif; font-size: 25px; letter-spacing: .01em; }
.brand small { margin-top: 4px; color: var(--muted); font-size: 10px; font-weight: 800; letter-spacing: .16em; text-transform: uppercase; }
.brand-mark { position: relative; display: block; width: 48px; height: 39px; border-radius: 18px; background: var(--violet); box-shadow: 0 6px 15px rgba(108, 99, 220, .28); }
.brand-mark i { position: absolute; border-radius: 50%; background: var(--violet); }
.brand-mark i:nth-child(1) { width: 24px; height: 24px; left: 6px; top: -8px; }
.brand-mark i:nth-child(2) { width: 30px; height: 30px; right: 2px; top: -5px; }
.brand-mark i:nth-child(3) { width: 7px; height: 7px; background: #fff; right: 12px; top: 12px; box-shadow: -16px 0 0 #fff; }

.icon-button { border: 1px solid var(--line); border-radius: 999px; min-height: 44px; padding: 0 17px; display: inline-flex; align-items: center; gap: 8px; color: var(--ink); background: rgba(255,255,255,.74); cursor: pointer; font-weight: 800; box-shadow: 0 8px 24px rgba(59, 57, 123, .06); }
.icon-button:hover { border-color: rgba(108, 99, 220, .32); transform: translateY(-1px); }
.sound-on { width: 24px; height: 24px; display: inline-grid; place-items: center; border-radius: 50%; color: var(--violet); background: var(--violet-soft); }

.screen { display: none; flex: 1; animation: appear .5s ease both; }
.screen.is-active { display: flex; }
@keyframes appear { from { opacity: 0; transform: translateY(10px); } }

.start-screen { align-items: center; gap: clamp(30px, 5vw, 80px); padding: 20px 2% 70px; }
.hero-copy { flex: 1 1 520px; max-width: 620px; }
.eyebrow { margin: 0 0 14px; color: var(--violet); font-size: 12px; font-weight: 900; letter-spacing: .17em; }
h1, h2 { margin: 0; font-family: "Baloo 2", sans-serif; line-height: .98; }
h1 { max-width: 680px; font-size: clamp(48px, 6.1vw, 82px); letter-spacing: -.04em; }
h1 em { color: var(--violet); font-style: normal; position: relative; white-space: nowrap; }
h1 em::after { content: ""; position: absolute; left: 2%; right: 2%; bottom: 5px; height: 8px; border-radius: 50%; background: rgba(255, 213, 95, .6); z-index: -1; transform: rotate(-1.5deg); }
.intro { max-width: 555px; margin: 24px 0 29px; color: var(--muted); font-size: clamp(17px, 1.7vw, 20px); line-height: 1.68; font-weight: 600; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 12px; }
.button { min-height: 56px; padding: 0 24px; border-radius: 16px; border: 0; display: inline-flex; align-items: center; justify-content: center; gap: 13px; cursor: pointer; font-weight: 900; transition: transform .18s, box-shadow .18s, background .18s; }
.button:hover { transform: translateY(-2px); }
.button-primary { color: #fff; background: linear-gradient(135deg, var(--violet), #7b72e9); box-shadow: 0 13px 26px rgba(93, 84, 205, .28); }
.button-primary:hover { box-shadow: 0 16px 32px rgba(93, 84, 205, .35); }
.button-primary b { font-size: 22px; }
.button-secondary { color: var(--ink); background: rgba(255,255,255,.86); border: 1px solid var(--line); box-shadow: 0 10px 24px rgba(62, 63, 131, .07); }
.button-secondary > span:first-child { width: 23px; height: 23px; display: grid; place-items: center; border: 2px solid var(--violet); color: var(--violet); border-radius: 50%; font-size: 14px; }
.gentle-note { display: flex; gap: 8px; align-items: center; margin: 20px 0 0; color: #858bab; font-size: 13px; font-weight: 700; }
.gentle-note span { color: #f28cad; font-size: 19px; }

.hero-art { flex: 1 1 470px; max-width: 570px; aspect-ratio: 1.07; position: relative; display: grid; place-items: center; isolation: isolate; }
.hero-art::before { content: ""; position: absolute; inset: 3% 0; border-radius: 50%; background: radial-gradient(circle at 50% 42%, rgba(255,255,255,.98) 0 28%, rgba(227,229,255,.7) 55%, rgba(255,255,255,0) 72%); z-index: -3; }
.rainbow { position: absolute; width: 74%; aspect-ratio: 1; border-radius: 50%; border: 22px solid rgba(245, 154, 190, .77); border-bottom-color: transparent; border-left-color: rgba(255, 207, 94, .78); border-right-color: rgba(121, 195, 227, .7); transform: rotate(-8deg); filter: drop-shadow(0 15px 18px rgba(94, 88, 176, .08)); z-index: -2; }
.rainbow::before, .rainbow::after { content: ""; position: absolute; border-radius: 50%; inset: 17px; border: 19px solid rgba(255,213,95,.7); border-bottom-color: transparent; transform: rotate(4deg); }
.rainbow::after { inset: 52px; border-width: 17px; border-color: rgba(144, 221, 191, .66); border-bottom-color: transparent; }
.hero-cloud { position: relative; width: 58%; height: 36%; margin-top: 2%; border-radius: 48% 52% 44% 48%; background: linear-gradient(160deg, #fff 20%, #edf0ff 73%, #dfe3fb); box-shadow: 0 34px 45px rgba(61, 66, 142, .17), inset -14px -12px 30px rgba(132, 139, 210, .1); animation: float 3.8s ease-in-out infinite; }
@keyframes float { 50% { transform: translateY(-12px) rotate(1deg); } }
.hero-cloud .puff { position: absolute; border-radius: 50%; background: linear-gradient(145deg, #fff, #edf0ff); box-shadow: inset -7px -5px 15px rgba(126, 134, 204, .08); }
.hero-cloud .p1 { width: 40%; aspect-ratio: 1; left: 5%; top: -25%; }.hero-cloud .p2 { width: 48%; aspect-ratio: 1; left: 26%; top: -48%; }.hero-cloud .p3 { width: 38%; aspect-ratio: 1; right: 1%; top: -18%; }.hero-cloud .p4 { width: 24%; aspect-ratio: 1; right: 5%; bottom: -4%; }
.face .eye { position: absolute; width: 10px; height: 15px; top: 46%; border-radius: 50%; background: #36396e; z-index: 3; }
.face .eye::after { content: ""; position: absolute; width: 3px; height: 4px; left: 2px; top: 2px; border-radius: 50%; background: #fff; }
.face .eye.left { left: 38%; }.face .eye.right { right: 34%; }
.face .smile { position: absolute; left: 47%; top: 57%; width: 23px; height: 13px; border-bottom: 3px solid #4b4e87; border-radius: 50%; z-index: 3; }
.cheek { position: absolute; top: 58%; width: 22px; height: 9px; border-radius: 50%; background: rgba(242, 139, 177, .45); z-index: 3; }.cheek.left { left: 24%; }.cheek.right { right: 20%; }
.sparkle { position: absolute; color: #f6bd37; font-size: 34px; text-shadow: 0 6px 10px rgba(226, 160, 17, .2); animation: twinkle 2.1s ease-in-out infinite; }
.sparkle.s1 { left: 9%; top: 24%; }.sparkle.s2 { right: 10%; top: 25%; animation-delay: -.7s; }.sparkle.s3 { right: 16%; bottom: 30%; font-size: 21px; animation-delay: -1.2s; }
@keyframes twinkle { 50% { transform: scale(.65) rotate(15deg); opacity: .55; } }
.welcome-card { position: absolute; bottom: 8%; left: 50%; transform: translateX(-50%); width: max-content; max-width: 85%; display: flex; align-items: center; gap: 10px; border: 1px solid rgba(255,255,255,.85); border-radius: 15px; padding: 11px 17px; background: rgba(255,255,255,.8); backdrop-filter: blur(10px); color: var(--ink); font-size: 13px; box-shadow: 0 12px 32px rgba(65, 69, 138, .12); }
.welcome-card span { color: #f2b72e; font-size: 22px; }

.game-screen { flex-direction: column; padding: 12px 0 45px; }
.game-heading { display: flex; justify-content: space-between; align-items: flex-end; gap: 20px; margin-bottom: 18px; }
.game-heading .eyebrow { margin-bottom: 7px; }
.game-heading h2 { font-size: clamp(28px, 3vw, 42px); }
.hud { display: flex; gap: 9px; }
.hud-card { min-width: 92px; display: grid; gap: 2px; border: 1px solid var(--line); border-radius: 13px; padding: 8px 12px; background: rgba(255,255,255,.76); box-shadow: 0 7px 18px rgba(61, 62, 129, .06); }
.hud-card span { color: var(--muted); font-size: 10px; font-weight: 900; letter-spacing: .09em; text-transform: uppercase; }
.hud-card strong { font-family: "Baloo 2", sans-serif; font-size: 17px; line-height: 1.2; }
#livesDisplay { color: #f06f9a; letter-spacing: 2px; }

.game-layout { display: grid; grid-template-columns: minmax(0, 1fr) 250px; gap: 18px; align-items: stretch; }
.canvas-frame { position: relative; min-width: 0; overflow: hidden; border: 9px solid rgba(255,255,255,.92); border-radius: 24px; background: #dfe7ff; box-shadow: var(--shadow); touch-action: none; }
#gameCanvas { display: block; width: 100%; height: auto; aspect-ratio: 17/11; cursor: crosshair; touch-action: none; }
.canvas-frame::after { content: ""; position: absolute; inset: 0; border: 1px solid rgba(70, 71, 143, .1); border-radius: 16px; pointer-events: none; }
.canvas-badge { position: absolute; top: 11px; min-height: 25px; display: grid; place-items: center; padding: 0 9px; border-radius: 9px; color: #fff; font-size: 9px; font-weight: 900; letter-spacing: .08em; pointer-events: none; box-shadow: 0 5px 12px rgba(45, 49, 105, .15); }
.start-badge { left: 11px; background: #8c87df; }.exit-badge { right: 11px; color: #5a4a15; background: var(--yellow); }
.toast { position: absolute; left: 50%; top: 14px; transform: translate(-50%, -15px); z-index: 4; opacity: 0; pointer-events: none; border-radius: 12px; padding: 8px 14px; color: var(--ink); background: rgba(255,255,255,.94); box-shadow: 0 7px 20px rgba(45, 49, 105, .17); font-size: 12px; font-weight: 900; transition: .25s; }
.toast.show { transform: translate(-50%, 0); opacity: 1; }

.mission-panel { border: 1px solid var(--line); border-radius: 23px; padding: 19px; background: rgba(255,255,255,.83); box-shadow: var(--shadow); display: flex; flex-direction: column; }
.mission-card { display: flex; gap: 11px; align-items: center; padding-bottom: 15px; border-bottom: 1px solid var(--line); }
.mission-icon { width: 44px; height: 44px; display: grid; place-items: center; flex: 0 0 auto; border-radius: 14px; color: #fff; background: linear-gradient(135deg, var(--violet), #8e87ea); font-size: 25px; }
.mission-card div { display: grid; gap: 2px; }.mission-card small { color: var(--violet); font-size: 9px; font-weight: 900; letter-spacing: .12em; }.mission-card strong { font-size: 14px; line-height: 1.2; }
.mission-panel > p { margin: 15px 0; color: var(--muted); font-size: 13px; line-height: 1.55; }
.legend { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; margin-bottom: 15px; }
.legend span { display: flex; align-items: center; gap: 6px; color: #666d91; font-size: 11px; font-weight: 800; }
.legend-dot { width: 22px; height: 22px; border-radius: 8px; display: grid; place-items: center; font-style: normal; font-weight: 900; }
.legend-dot.missile { color: #da6e78; background: #fff0f1; }.legend-dot.bomb { color: #5a6289; background: #edf0fa; }.legend-dot.warning { color: #a8750e; background: #fff5c9; }
.dpad { width: 130px; margin: auto auto 14px; display: grid; grid-template-columns: repeat(3, 1fr); gap: 5px; }
.dpad button { aspect-ratio: 1; border: 1px solid var(--line); border-radius: 11px; color: var(--violet); background: var(--violet-soft); cursor: pointer; font-weight: 900; user-select: none; touch-action: none; }
.dpad button:active, .dpad button.is-pressed { color: #fff; background: var(--violet); transform: scale(.94); }
.dpad button[data-direction="up"] { grid-column: 2; }.dpad button[data-direction="left"] { grid-column: 1; grid-row: 2; }.dpad button[data-direction="down"] { grid-column: 2; grid-row: 2; }.dpad button[data-direction="right"] { grid-column: 3; grid-row: 2; }
.game-actions { display: flex; gap: 7px; padding-top: 14px; border-top: 1px solid var(--line); }
.small-button { flex: 1; min-height: 38px; border: 1px solid var(--line); border-radius: 10px; color: var(--ink); background: #fff; cursor: pointer; font-size: 11px; font-weight: 900; }
.small-button:hover { color: var(--violet); border-color: rgba(108, 99, 220, .35); }

.modal { width: min(570px, calc(100% - 28px)); max-height: calc(100vh - 28px); overflow: auto; border: 1px solid rgba(255,255,255,.82); border-radius: 27px; padding: 34px; color: var(--ink); background: rgba(255,255,255,.96); box-shadow: 0 30px 100px rgba(38, 39, 97, .28); text-align: center; }
.modal::backdrop { background: rgba(38, 40, 91, .46); backdrop-filter: blur(8px); }
.modal-close { position: absolute; right: 16px; top: 13px; width: 38px; height: 38px; border: 0; border-radius: 50%; color: var(--muted); background: var(--violet-soft); cursor: pointer; font-size: 25px; line-height: 1; }
.modal-symbol { width: 62px; height: 62px; margin: 0 auto 13px; display: grid; place-items: center; border-radius: 20px; color: #fff; background: var(--violet); font-size: 36px; transform: rotate(-4deg); box-shadow: 0 12px 27px rgba(92,84,203,.25); }
.modal .eyebrow { margin: 0 0 8px; }
.modal h2 { font-size: clamp(30px, 5vw, 42px); }
.instruction-grid { display: grid; gap: 9px; margin: 25px 0 15px; text-align: left; }
.instruction-grid > div { display: flex; align-items: center; gap: 13px; border-radius: 15px; padding: 12px; background: #f7f6ff; }
.instruction-grid b { width: 34px; height: 34px; display: grid; place-items: center; flex: 0 0 auto; border-radius: 11px; color: #fff; background: var(--violet); }
.instruction-grid span { display: grid; color: var(--muted); font-size: 12px; }.instruction-grid strong { color: var(--ink); font-size: 14px; }
.keyboard-tip { color: var(--muted); font-size: 12px; }
.modal-action { width: 100%; margin-top: 12px; }
.result-art { width: 84px; height: 84px; margin: 0 auto 17px; display: grid; place-items: center; border-radius: 50%; color: #946c08; background: radial-gradient(circle at 40% 30%, #fff9bb, var(--yellow)); font-size: 39px; box-shadow: 0 16px 38px rgba(224, 168, 33, .25); }
.result-modal > p:not(.eyebrow) { color: var(--muted); line-height: 1.55; }
.result-stats { display: flex; justify-content: center; gap: 10px; margin: 20px 0 7px; }
.result-stats span { min-width: 110px; display: grid; border-radius: 14px; padding: 11px; background: #f5f4ff; }.result-stats small { color: var(--muted); font-size: 10px; font-weight: 900; text-transform: uppercase; }.result-stats strong { font-family: "Baloo 2"; font-size: 22px; }
.text-button { margin-top: 15px; border: 0; color: var(--violet); background: none; cursor: pointer; font-weight: 900; }

button:focus-visible, a:focus-visible, canvas:focus-visible { outline: 3px solid var(--yellow); outline-offset: 3px; }
noscript { display: block; padding: 20px; text-align: center; color: #812b46; background: #ffeaf1; }

@media (max-width: 940px) {
  .start-screen { flex-direction: column; text-align: center; padding-top: 30px; }
  .hero-copy { flex-basis: auto; max-width: 700px; }
  .intro { margin-left: auto; margin-right: auto; }
  .hero-actions, .gentle-note { justify-content: center; }
  .hero-art { flex-basis: auto; width: min(560px, 100%); }
  .game-layout { grid-template-columns: 1fr; }
  .mission-panel { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 20px; }
  .mission-panel > p { margin: 0; }.legend { margin: 0; }.dpad { margin: 0 auto; grid-row: span 2; }.game-actions { align-items: end; }
}

@media (max-width: 640px) {
  .app-shell { width: min(100% - 20px, 1280px); }
  .brand-bar { min-height: 72px; }.brand strong { font-size: 20px; }.brand small { font-size: 8px; }.brand-mark { transform: scale(.85); transform-origin: left center; margin-right: -4px; }.sound-label { display: none; }.icon-button { padding: 0 10px; }
  .start-screen { padding: 14px 3px 45px; gap: 6px; }.hero-copy { display: flex; flex-direction: column; align-items: center; }.eyebrow { font-size: 9px; } h1 { font-size: clamp(40px, 12vw, 60px); }.intro { margin: 17px 0 21px; font-size: 16px; line-height: 1.5; }.hero-actions { width: 100%; }.hero-actions .button { width: 100%; }.gentle-note { font-size: 11px; }.hero-art { width: 100%; }
  .game-screen { padding-top: 4px; }.game-heading { align-items: flex-start; flex-direction: column; }.game-heading h2 { font-size: 27px; }.hud { width: 100%; }.hud-card { flex: 1; min-width: 0; padding: 6px 8px; }.hud-card strong { font-size: 14px; }
  .game-layout { gap: 10px; }.canvas-frame { border-width: 5px; border-radius: 17px; }.canvas-badge { transform: scale(.8); transform-origin: top; }.start-badge { left: 5px; top: 5px; }.exit-badge { right: 5px; top: 5px; }
  .mission-panel { grid-template-columns: 1fr; padding: 14px; }.mission-panel > p { display: none; }.legend { grid-template-columns: repeat(3, 1fr); }.dpad { grid-row: auto; width: 155px; }.game-actions { padding-top: 10px; }
  .modal { padding: 29px 18px 22px; }.modal-symbol { width: 54px; height: 54px; }.instruction-grid { margin-top: 19px; }.result-stats span { min-width: 95px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
