:root {
  --blue: #3f7fe6;
  --blue-deep: #1f4fa8;
  --sky: #cfe6ff;
  --ink: #23324d;
  --card: rgba(255, 255, 255, 0.82);
  --pink: #f3b7cf;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #a9d2ff; color: var(--ink);
  font-family: 'Baloo 2', ui-rounded, system-ui, -apple-system, sans-serif; touch-action: none; user-select: none; -webkit-user-select: none; }
#stage { position: fixed; inset: 0; }
#stage canvas { display: block; width: 100%; height: 100%; }
.hidden { display: none !important; }

.screen { position: fixed; inset: 0; display: grid; place-items: center; padding: 16px; z-index: 20; }
#intro { background: radial-gradient(120% 90% at 50% 10%, #e9f4ff 0%, #a9d2ff 55%, #5d97ea 100%); }
.card { width: min(440px, 100%); background: var(--card); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border-radius: 28px; padding: 28px 24px 22px; text-align: center; box-shadow: 0 20px 60px rgba(31, 79, 168, 0.25); }
.petals { color: var(--blue); letter-spacing: 10px; font-size: 18px; }
h1 { margin: 4px 0 6px; font-size: clamp(30px, 8vw, 40px); line-height: 1.05; color: var(--blue-deep); font-weight: 800; }
.sub { margin: 0 0 18px; font-size: 15px; line-height: 1.45; opacity: 0.85; }
.bar { height: 8px; border-radius: 99px; background: rgba(63, 127, 230, 0.15); overflow: hidden; }
#bar-fill { height: 100%; width: 0; background: linear-gradient(90deg, #7fb6ff, var(--blue)); border-radius: 99px; transition: width 0.25s; }
.load { margin: 8px 0 14px; font-size: 13px; opacity: 0.7; }
.btn { appearance: none; border: 0; border-radius: 99px; padding: 12px 34px; font: 700 18px/1 'Baloo 2', system-ui, sans-serif;
  color: #fff; background: linear-gradient(180deg, #5b98f2, var(--blue)); box-shadow: 0 6px 0 var(--blue-deep), 0 10px 20px rgba(31, 79, 168, 0.3);
  cursor: pointer; transition: transform 0.12s, opacity 0.2s; }
.btn:active { transform: translateY(3px); box-shadow: 0 3px 0 var(--blue-deep); }
.btn:disabled { opacity: 0.45; cursor: default; }
.btn.ghost { background: #fff; color: var(--blue-deep); box-shadow: 0 6px 0 #c9dcf8, 0 10px 20px rgba(31, 79, 168, 0.15); }
.keys { margin: 14px 0 0; font-size: 12.5px; opacity: 0.65; }
.touch #keys-desktop, body:not(.touch) #keys-touch { display: none; }

#hud { position: fixed; inset: 0; pointer-events: none; z-index: 10; }
.quest { position: absolute; left: max(14px, env(safe-area-inset-left)); top: max(14px, env(safe-area-inset-top)); max-width: min(330px, calc(100vw - 90px));
  background: var(--card); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); border-radius: 18px; padding: 10px 14px 11px;
  box-shadow: 0 8px 24px rgba(31, 79, 168, 0.18); transition: transform 0.35s cubic-bezier(.2, 1.4, .4, 1); }
.quest.pop { transform: scale(1.06); }
.q-title { font-weight: 800; font-size: 15px; color: var(--blue-deep); }
.q-text { font-size: 14px; line-height: 1.35; }
.q-cats { margin-top: 4px; font-size: 22px; letter-spacing: 4px; }
.q-cats span { filter: grayscale(1); opacity: 0.45; transition: all 0.3s; display: inline-block; }
.q-cats span.done { filter: none; opacity: 1; transform: scale(1.15); }
.round { pointer-events: auto; position: absolute; right: max(14px, env(safe-area-inset-right)); top: max(14px, env(safe-area-inset-top)); width: 44px; height: 44px; border-radius: 50%;
  border: 0; background: var(--card); font-size: 20px; box-shadow: 0 6px 18px rgba(31, 79, 168, 0.2); cursor: pointer; }
.toast { position: absolute; left: 50%; top: 22%; transform: translate(-50%, -10px); opacity: 0; background: rgba(255, 255, 255, 0.9); padding: 8px 18px;
  border-radius: 99px; font-weight: 700; color: var(--blue-deep); transition: all 0.4s; white-space: nowrap; box-shadow: 0 8px 24px rgba(31, 79, 168, 0.2); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.pet { pointer-events: auto; position: absolute; right: max(22px, env(safe-area-inset-right)); bottom: max(28px, calc(env(safe-area-inset-bottom) + 18px));
  border: 0; border-radius: 99px; padding: 14px 22px; font: 800 18px/1 'Baloo 2', system-ui, sans-serif; color: #fff;
  background: linear-gradient(180deg, #f6a6c6, #e9799f); box-shadow: 0 6px 0 #c05a80, 0 10px 24px rgba(192, 90, 128, 0.35); animation: bob 1.4s ease-in-out infinite; }
@keyframes bob { 50% { transform: translateY(-4px); } }
.joy { position: absolute; width: 120px; height: 120px; margin: -60px 0 0 -60px; border-radius: 50%; background: rgba(255, 255, 255, 0.25);
  border: 2px solid rgba(255, 255, 255, 0.6); }
#joy-knob { position: absolute; left: 50%; top: 50%; width: 52px; height: 52px; margin: -26px 0 0 -26px; border-radius: 50%; background: rgba(255, 255, 255, 0.85);
  box-shadow: 0 4px 12px rgba(31, 79, 168, 0.25); }

#labels { position: fixed; inset: 0; pointer-events: none; z-index: 11; }
.bubble { position: absolute; transform: translate(-50%, -100%); background: #fff; color: #e9799f; font-weight: 800; font-size: 18px; padding: 6px 14px;
  border-radius: 16px; box-shadow: 0 6px 16px rgba(0, 0, 0, 0.12); animation: pop 0.35s cubic-bezier(.2, 1.6, .4, 1); white-space: nowrap; }
.bubble::after { content: ''; position: absolute; left: 50%; bottom: -7px; margin-left: -7px; border: 7px solid transparent; border-bottom: 0; border-top-color: #fff; }
.bubble.out { transition: opacity 0.4s, transform 0.4s; opacity: 0; transform: translate(-50%, -130%); }
.tag { position: absolute; transform: translate(-50%, -100%); font-size: 13px; font-weight: 700; color: #fff; background: rgba(35, 50, 77, 0.55);
  padding: 2px 10px; border-radius: 99px; white-space: nowrap; }
@keyframes pop { from { transform: translate(-50%, -60%) scale(0.4); opacity: 0; } }

#finale { background: linear-gradient(180deg, transparent 45%, rgba(63, 127, 230, 0.18)); pointer-events: none; place-items: end center; padding-bottom: max(18px, env(safe-area-inset-bottom)); }
#finale .final-card { pointer-events: auto; }
.final-card { width: min(460px, 100%); text-align: center; background: rgba(255, 255, 255, 0.84); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border-radius: 30px; padding: 16px 20px 18px; box-shadow: 0 24px 70px rgba(31, 79, 168, 0.35); animation: rise 1.1s cubic-bezier(.2, 1.2, .3, 1); }
@keyframes rise { from { transform: translateY(40px) scale(0.85); opacity: 0; } }
.f-flower { font-size: 34px; animation: sway 3s ease-in-out infinite; }
@keyframes sway { 50% { transform: rotate(8deg) scale(1.05); } }
.f-title { font-family: 'Dancing Script', cursive; font-size: clamp(38px, 10.5vw, 56px); line-height: 1; margin: 2px 0 8px; color: var(--blue-deep);
  background: linear-gradient(90deg, #2f6fdc, #7fb0ff, #e9799f, #2f6fdc); background-size: 300% 100%; -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent; animation: shine 6s linear infinite; }
@keyframes shine { to { background-position: 300% 0; } }
.f-text { font-size: clamp(18px, 5vw, 22px); font-weight: 700; margin: 0 0 14px; color: var(--ink); }
.f-row { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }
.f-row .btn { padding: 11px 24px; font-size: 16px; }

.name-tag { position: absolute; transform: translate(-50%, -100%); font-weight: 800; font-size: 15px; color: #fff; letter-spacing: 0.2px;
  background: linear-gradient(180deg, rgba(243, 140, 182, 0.92), rgba(222, 104, 152, 0.92)); padding: 3px 12px 4px; border-radius: 99px;
  box-shadow: 0 4px 12px rgba(150, 40, 90, 0.25); white-space: nowrap; pointer-events: none; }

.round.flip { top: calc(max(14px, env(safe-area-inset-top)) + 54px); font-size: 19px; }
.round.flip.on { background: #fde3ec; }
.name-tag.cat { font-size: 13px; padding: 2px 10px 3px; background: linear-gradient(180deg, rgba(255, 196, 92, 0.94), rgba(240, 160, 60, 0.94)); box-shadow: 0 4px 12px rgba(160, 90, 20, 0.25); }
.inapp { margin: 12px 0 0; font-size: 13px; line-height: 1.4; background: #fff4d6; color: #7a5420; border-radius: 12px; padding: 8px 10px; }
html, body { overscroll-behavior: none; }
