@font-face { font-family: 'Fredoka'; src: url('fonts/fredoka.woff2') format('woff2'); font-weight: 300 700; font-display: swap; }
@font-face { font-family: 'Press Start 2P'; src: url('fonts/press-start-2p.woff2') format('woff2'); font-display: swap; }

:root {
  --ink: #2b2350;
  --cream: #fff4e0;
  --pink: #ff6fa3;
  --pink2: #ff8fb8;
  --mint: #7fe6cc;
  --sun: #ffd166;
  --sky: #8ecbff;
  --lav: #c9a3ff;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: #10163a; overflow: hidden; font-family: 'Fredoka', 'Arial Rounded MT Bold', system-ui, sans-serif; color: var(--ink); -webkit-user-select: none; user-select: none; }
#stage { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; cursor: grab; }
#stage:active { cursor: grabbing; }
.pixel { font-family: 'Press Start 2P', ui-monospace, monospace; letter-spacing: 0.02em; }
.off { display: none !important; }

/* ------------------------------------------------------------ HUD */
#hud { position: fixed; inset: 0; pointer-events: none; transition: opacity 0.6s; z-index: 5; }
#hud.off { display: block !important; opacity: 0; visibility: hidden; }
#hud.photo { opacity: 0; }
.corner { position: absolute; display: flex; gap: 10px; padding: 14px; }
.corner.tl { top: env(safe-area-inset-top); left: env(safe-area-inset-left); flex-direction: column; align-items: flex-start; }
.corner.tr { top: env(safe-area-inset-top); right: env(safe-area-inset-right); align-items: flex-start; flex-wrap: wrap; justify-content: flex-end; max-width: 100vw; }
.corner.bl { bottom: env(safe-area-inset-bottom); left: env(safe-area-inset-left); align-items: flex-end; }

.logo, .chip, .btn, .seg, .panel, .pop, .hint, #toast {
  background: var(--cream);
  border: 3px solid var(--ink);
  box-shadow: 0 4px 0 var(--ink);
}
.logo { display: flex; align-items: center; gap: 8px; padding: 6px 16px 6px 10px; border-radius: 999px; font-size: 20px; font-weight: 500; letter-spacing: 0.01em; }
.logo b { color: var(--pink); font-weight: 700; margin-right: -2px; }
.logo .cone { width: 22px; height: 26px; background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 64 64'%3E%3Cpath d='M20 30h24L32 60z' fill='%23e0a458' stroke='%232b2350' stroke-width='4' stroke-linejoin='round'/%3E%3Ccircle cx='32' cy='24' r='14' fill='%23ff8fb8' stroke='%232b2350' stroke-width='4'/%3E%3Ccircle cx='32' cy='11' r='9' fill='%237fe6cc' stroke='%232b2350' stroke-width='4'/%3E%3C/svg%3E") center / contain no-repeat; }

button { font-family: inherit; color: var(--ink); cursor: pointer; pointer-events: auto; }
svg { fill: none; stroke: var(--ink); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.chip { display: flex; align-items: center; gap: 8px; padding: 6px 16px 6px 10px; border-radius: 999px; font-weight: 600; font-size: 18px; transition: transform 0.12s, box-shadow 0.12s; }
.chip svg { width: 24px; height: 24px; }
.chip:hover, .btn:hover { transform: translateY(-2px); box-shadow: 0 6px 0 var(--ink); }
.chip:active, .btn:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }
.btn { width: 48px; height: 48px; border-radius: 16px; display: grid; place-items: center; padding: 0; transition: transform 0.12s, box-shadow 0.12s, background 0.15s; }
.btn svg { width: 26px; height: 26px; }
.btn.active { background: var(--mint); }

.seg { display: flex; border-radius: 16px; overflow: hidden; height: 48px; }
.seg button { border: 0; background: transparent; font-family: 'Press Start 2P', monospace; font-size: 9px; padding: 0 12px; height: 100%; letter-spacing: 0.02em; transition: background 0.15s; }
.seg button + button { border-left: 3px solid var(--ink); }
.seg button:hover { background: #ffe6b8; }
.seg button.on { background: var(--pink); color: #fff; text-shadow: 0 2px 0 rgba(0,0,0,0.25); }

.pop { padding: 12px 14px; border-radius: 18px; display: flex; flex-direction: column; gap: 10px; pointer-events: auto; min-width: 230px; }
.pop label { font-size: 8px; color: var(--pink); }
.pop input[type=range] { width: 100%; accent-color: var(--pink); height: 22px; }
.mini { border: 3px solid var(--ink); background: #fff; border-radius: 10px; font-family: 'Press Start 2P', monospace; font-size: 8px; padding: 8px 10px; }
.mini.on { background: var(--mint); }

.panel { padding: 10px 14px; border-radius: 18px; min-width: 230px; }
.panel .row { display: flex; align-items: center; gap: 10px; margin: 5px 0; min-height: 20px; }
.panel .k { font-size: 8px; color: var(--pink); width: 62px; flex: none; }
.panel .v { font-weight: 600; font-size: 16px; white-space: nowrap; }
.meter { width: 120px; height: 14px; border: 3px solid var(--ink); border-radius: 9px; background: #fff; overflow: hidden; display: block; }
.meter i { display: block; height: 100%; width: 20%; background: linear-gradient(90deg, var(--mint), var(--sun) 55%, var(--pink)); transition: width 0.25s; }

.hint { position: absolute; left: 50%; bottom: calc(16px + env(safe-area-inset-bottom)); transform: translateX(-50%); padding: 8px 18px; border-radius: 999px; font-size: 15px; white-space: nowrap; transition: opacity 0.8s; opacity: 1; }
.hint.hide { opacity: 0; }
.hint b { color: var(--pink); font-weight: 700; }
.hint i { display: inline-block; width: 6px; height: 6px; background: var(--ink); border-radius: 50%; margin: 0 10px 2px; opacity: 0.35; }

#toast { position: fixed; left: 50%; bottom: 74px; transform: translate(-50%, 20px); padding: 8px 20px; border-radius: 999px; font-weight: 600; font-size: 17px; opacity: 0; pointer-events: none; transition: opacity 0.25s, transform 0.25s; z-index: 9; }
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#flash { position: fixed; inset: 0; background: #fff; opacity: 0; pointer-events: none; z-index: 8; transition: opacity 0.45s; }
#flash.on { opacity: 0.85; transition: none; }

/* ------------------------------------------------------------ title card */
#intro {
  position: fixed; inset: 0; display: grid; place-items: center; z-index: 10; padding: 16px;
  background: radial-gradient(ellipse at 50% 55%, rgba(43, 35, 80, 0.18), rgba(16, 22, 58, 0.75));
  -webkit-backdrop-filter: blur(3px) saturate(1.15); backdrop-filter: blur(3px) saturate(1.15);
  transition: opacity 0.9s, visibility 0.9s;
}
#intro.gone { opacity: 0; visibility: hidden; pointer-events: none; }
.card {
  position: relative; text-align: center; padding: 30px 40px 22px; width: min(700px, 94vw);
  background: var(--cream); border: 5px solid var(--ink); border-radius: 38px;
  box-shadow: 0 10px 0 var(--ink), 0 40px 90px rgba(0, 0, 0, 0.45);
  animation: pop 0.8s cubic-bezier(0.2, 1.5, 0.4, 1) both;
}
.card::before { content: ''; position: absolute; inset: 10px; border-radius: 28px; border: 3px dashed rgba(43, 35, 80, 0.22); pointer-events: none; }
.kicker { font-size: 10px; color: var(--pink); margin-bottom: 10px; }
h1 { margin: 0.1em 0 0.12em; font-weight: 700; line-height: 0.88; font-size: clamp(50px, 11vw, 104px); display: flex; flex-direction: column; align-items: center; letter-spacing: -0.01em; }
h1 span { -webkit-text-stroke: 0.09em var(--ink); paint-order: stroke fill; text-shadow: 0 0.07em 0 var(--ink); display: block; }
h1 span:nth-child(1) { color: var(--pink2); transform: rotate(-2.5deg); animation: wob 3.6s ease-in-out infinite; }
h1 span:nth-child(2) { color: var(--mint); transform: rotate(1.5deg); animation: wob 3.6s ease-in-out -1.8s infinite; }
.tag { font-size: clamp(15px, 2.4vw, 19px); line-height: 1.35; margin: 12px auto 20px; max-width: 30em; font-weight: 500; opacity: 0.85; }
.tag b { color: var(--pink); }
.big { font: 700 30px 'Fredoka', sans-serif; color: #fff; background: var(--pink); border: 5px solid var(--ink); border-radius: 28px; padding: 12px 42px 14px; box-shadow: 0 8px 0 var(--ink); text-shadow: 0 3px 0 rgba(0, 0, 0, 0.28); letter-spacing: 0.02em; animation: bob 1.5s ease-in-out infinite; transition: background 0.2s, filter 0.3s; }
.big:hover { background: var(--pink2); }
.big:active { transform: translateY(6px) !important; box-shadow: 0 2px 0 var(--ink); animation: none; }
.big:disabled { filter: grayscale(0.9) brightness(1.05); cursor: progress; animation: none; }
.note { font-size: 8px; margin-top: 20px; color: var(--ink); opacity: 0.55; }
.fine { font-size: 8px; margin: 12px 0 0; color: var(--pink); }
.sprinkles i { position: absolute; width: 22px; height: 8px; border-radius: 5px; border: 2px solid var(--ink); background: var(--sun); }
.sprinkles i:nth-child(1) { left: 6%; top: 10%; transform: rotate(35deg); background: var(--mint); }
.sprinkles i:nth-child(2) { left: 12%; top: 70%; transform: rotate(-20deg); background: var(--sun); }
.sprinkles i:nth-child(3) { right: 8%; top: 12%; transform: rotate(-40deg); background: var(--pink2); }
.sprinkles i:nth-child(4) { right: 5%; top: 64%; transform: rotate(60deg); background: var(--sky); }
.sprinkles i:nth-child(5) { left: 3%; top: 40%; transform: rotate(-70deg); background: var(--lav); }
.sprinkles i:nth-child(6) { right: 11%; top: 38%; transform: rotate(15deg); background: var(--mint); }
.sprinkles i:nth-child(7) { left: 20%; top: 4%; transform: rotate(80deg); background: var(--pink2); }
.sprinkles i:nth-child(8) { right: 22%; top: 84%; transform: rotate(-30deg); background: var(--sun); }
.sprinkles i:nth-child(9) { left: 28%; bottom: 3%; transform: rotate(50deg); background: var(--sky); }
.sprinkles i:nth-child(10) { right: 26%; top: 3%; transform: rotate(-55deg); background: var(--lav); }

@keyframes pop { from { transform: scale(0.6) translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }
@keyframes wob { 0%, 100% { translate: 0 0; } 50% { translate: 0 -5px; } }

@media (max-width: 720px) {
  .corner { padding: 10px; gap: 8px; }
  .logo { display: none; }
  .corner.tr { max-width: calc(100vw - 150px); }
  .seg { height: 42px; }
  .seg button { font-size: 7px; padding: 0 8px; }
  .btn { width: 42px; height: 42px; }
  .hint { display: none; }
  .panel { min-width: 0; padding: 8px 10px; }
  .panel .v { font-size: 13px; }
  .meter { width: 80px; }
  .card { padding: 24px 22px 18px; }
}
@media (prefers-reduced-motion: reduce) { .big, h1 span, .card { animation: none !important; } }
