:root {
  --pink: #ff5d8f;
  --purple: #9b7bff;
  --blue: #3fa9f5;
  --green: #5fd35f;
  --yellow: #ffd23d;
  --orange: #ff9f43;
  --ink: #3a2c5a;
  --panel: #fffdf7;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; font-family: "Baloo 2", "Comic Sans MS", "Segoe UI", system-ui, sans-serif; color: var(--ink); background: linear-gradient(160deg, #e8f0ff 0%, #f0e8ff 50%, #fff9e8 100%); overflow: hidden; user-select: none; -webkit-user-select: none; touch-action: manipulation; }
body { display: flex; flex-direction: column; }
button { font-family: inherit; cursor: pointer; border: none; }
.topbar { position: relative; z-index: 3; flex: 0 0 auto; display: flex; align-items: center; gap: 8px; padding: 6px 10px; background: rgba(255,255,255,0.72); backdrop-filter: blur(6px); box-shadow: 0 2px 10px rgba(120,80,160,0.15); flex-wrap: nowrap; overflow-x: auto; overflow-y: hidden; scrollbar-width: none; }
.topbar::-webkit-scrollbar { display: none; }
.topbar > * { flex: 0 0 auto; }
.topbar-spacer { flex: 1 1 auto; min-width: clamp(60px, 16vw, 200px); }
.site-logo { display: inline-flex; align-items: center; gap: 8px; color: var(--ink); font-size: 0.95rem; font-weight: 900; text-decoration: none; }
.site-logo-mark { display: grid; width: 34px; height: 34px; place-items: center; border: 2px solid var(--ink); border-radius: 9px; background: var(--green); color: #fff; box-shadow: 3px 3px 0 rgba(58,44,90,0.28); font-size: 0.72rem; letter-spacing: 0; }
.logo { font-size: 1.25rem; font-weight: 800; background: linear-gradient(90deg, var(--pink), var(--purple), var(--blue)); -webkit-background-clip: text; background-clip: text; color: transparent; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.logo .star { -webkit-text-fill-color: initial; }
.chip { display: inline-flex; align-items: center; gap: 5px; background: #fff; border-radius: 999px; padding: 4px 11px; font-weight: 700; font-size: 0.85rem; box-shadow: 0 2px 6px rgba(120,80,160,0.18); }
.icon-btn { width: 40px; height: 40px; border-radius: 50%; font-size: 1.15rem; background: #fff; box-shadow: 0 3px 8px rgba(120,80,160,0.22); display: grid; place-items: center; transition: transform 0.1s; }
.icon-btn:active { transform: scale(0.9); }
.btn { border-radius: 999px; padding: 8px 16px; font-weight: 800; font-size: 0.95rem; color: #fff; box-shadow: 0 4px 0 rgba(0,0,0,0.12); transition: transform 0.08s, box-shadow 0.08s; }
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 rgba(0,0,0,0.12); }
.btn.green { background: var(--green); }
.btn.blue { background: var(--blue); }
.btn.orange { background: var(--orange); }
.progress-wrap { position: relative; z-index: 3; flex: 0 0 auto; height: 10px; background: rgba(255,255,255,0.6); }
.progress-bar { height: 100%; width: 0%; border-radius: 0 999px 999px 0; background: linear-gradient(90deg, var(--green), var(--yellow)); transition: width 0.35s ease; }
.game-area { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; align-items: center; padding: 10px; gap: 8px; overflow: hidden; position: relative; }
.letter-nav { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; justify-content: center; }
.letter-btn { width: 38px; height: 38px; border-radius: 50%; font-weight: 800; font-size: 0.9rem; background: #fff; color: var(--ink); box-shadow: 0 3px 6px rgba(120,80,160,0.15); display: grid; place-items: center; }
.letter-btn.active { background: var(--purple); color: #fff; }
.letter-btn.done { background: var(--green); color: #fff; }
.letter-btn.done.active { background: var(--green); }
.nav-arrow { width: 36px; height: 36px; border-radius: 50%; font-weight: 900; font-size: 1rem; background: var(--blue); color: #fff; box-shadow: 0 3px 6px rgba(120,80,160,0.15); display: grid; place-items: center; }
.canvas-wrap { flex: 1 1 auto; min-height: 200px; width: min(90vw, 500px); display: flex; align-items: center; justify-content: center; position: relative; }
#traceCanvas { width: 100%; height: 100%; display: block; touch-action: none; cursor: pointer; border-radius: 16px; }
.letter-info { text-align: center; }
.letter-info h2 { font-size: clamp(1.5rem, 5vw, 2.2rem); margin: 0; color: var(--purple); }
.letter-info p { margin: 2px 0 0; font-weight: 600; opacity: 0.7; font-size: 0.9rem; }
.win-area { text-align: center; padding: 20px; display: none; }
.win-area.show { display: block; }
.win-area .trophy { font-size: clamp(4rem, 12vw, 6rem); animation: bounce 0.8s ease infinite alternate; }
@keyframes bounce { to { transform: translateY(-14px); } }
.win-area h2 { font-size: clamp(1.8rem, 5vw, 2.5rem); margin: 10px 0; color: var(--purple); }
#confetti { position: fixed; inset: 0; z-index: 95; pointer-events: none; }
