:root {
  --paper: #fdf7e7;
  --line: rgba(80, 120, 200, 0.10);
  --ink: #2f2747;
  --muted: #7a7194;
  --pink: #ff5fa2;
  --pink-d: #d43d7f;
  --blue: #4d7cff;
  --blue-d: #2f56c9;
  --yellow: #ffd23f;
  --green: #2bb673;
  --red: #ef4b5b;
  --card: #ffffff;
  --shadow: 0 6px 0 rgba(47, 39, 71, 0.12);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background-color: var(--paper);
  background-image: linear-gradient(var(--line) 1px, transparent 1px), linear-gradient(90deg, var(--line) 1px, transparent 1px);
  background-size: 28px 28px;
  color: var(--ink);
  font-family: "Gochi Hand", "Comic Sans MS", cursive;
  font-size: 20px;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}
button { font: inherit; color: inherit; cursor: pointer; border: none; background: none; }
#app { max-width: 980px; margin: 0 auto; padding: 14px 16px 24px; min-height: 100%; }
.screen { display: none; }
.screen.active { display: block; animation: rise .3s ease-out; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }

/* ---------- home ---------- */
#home { text-align: center; padding-top: 4vh; }
.logo { font-family: "Lilita One", system-ui; font-weight: 400; font-size: clamp(48px, 11vw, 84px); margin: 0; line-height: 1; letter-spacing: 1px;
  color: var(--blue); text-shadow: 3px 4px 0 var(--ink); transform: rotate(-3deg); }
.logo span { color: var(--pink); margin-left: .15em; display: inline-block; transform: rotate(4deg) translateY(4px); }
.logo.small { font-size: 40px; color: var(--ink); text-shadow: none; transform: none; }
.tag { color: var(--muted); margin: 10px 0 6px; font-size: 22px; }
.modes { display: grid; gap: 14px; max-width: 460px; margin: 18px auto; }
.mode { background: var(--card); border: 3px solid var(--ink); border-radius: 22px; padding: 14px 18px; text-align: left; box-shadow: 0 6px 0 var(--ink);
  transition: transform .12s, box-shadow .12s; display: grid; gap: 2px; }
.mode b { font-family: "Lilita One", system-ui; font-weight: 400; font-size: 26px; }
.mode small { color: var(--muted); font-size: 19px; }
.mode:hover { transform: translateY(-2px) rotate(-.5deg); }
.mode:active { transform: translateY(4px); box-shadow: 0 2px 0 var(--ink); }
.mode[data-mode="draw"] b { color: var(--pink-d); }
.mode[data-mode="guess"] b { color: var(--blue-d); }
.seg { display: inline-flex; background: #fff; border: 3px solid var(--ink); border-radius: 999px; padding: 4px; gap: 4px; }
.seg button { padding: 6px 18px; border-radius: 999px; font-size: 20px; }
.seg button.on { background: var(--yellow); }
.status { min-height: 1.4em; color: var(--muted); font-size: 18px; }
.status.err { color: var(--red); }

/* ---------- Marc (cartoon glam-rocker headshot; moods are transforms) ---------- */
.marc { width: 96px; height: 96px; flex: none; position: relative; }
.marcpanel .marc { width: 136px; height: 136px; }
.marc.big { width: 170px; height: 170px; margin: 10px auto 0; animation: bob 2.6s ease-in-out infinite; }
@keyframes bob { 50% { transform: translateY(-8px) rotate(2deg); } }
.marc img { width: 100%; height: 100%; object-fit: contain; display: block; transition: transform .35s cubic-bezier(.3, 1.6, .5, 1), filter .35s;
  filter: drop-shadow(0 4px 0 rgba(47, 39, 71, .14)); user-select: none; }
.marc .spark { position: absolute; top: 2%; right: 4%; font-size: 22px; color: #ffb21a; opacity: 0; transform: scale(.4); transition: opacity .3s, transform .3s; pointer-events: none; }
.marc[data-mood="thinking"] img { transform: rotate(-8deg) translateY(-2px); }
.marc[data-mood="thinking"] .spark { opacity: 1; transform: scale(1); animation: twinkle .6s infinite alternate; }
@keyframes twinkle { to { transform: scale(1.25) rotate(25deg); color: #ff5fa2; } }
.marc[data-mood="happy"] img { transform: scale(1.06) rotate(3deg); }
.marc[data-mood="happy"] .spark { opacity: 1; transform: scale(1.1); }
.marc[data-mood="sad"] img { transform: rotate(6deg) translateY(4px) scale(.96); filter: saturate(.55) drop-shadow(0 4px 0 rgba(47, 39, 71, .1)); }
.marc.jump { animation: jump .5s; }
@keyframes jump { 30% { transform: translateY(-14px) rotate(-6deg); } 60% { transform: translateY(0) rotate(4deg); } }

/* ---------- play ---------- */
.bar { display: flex; align-items: center; gap: 12px; }
.icon { width: 40px; height: 40px; border-radius: 50%; background: #fff; border: 3px solid var(--ink); font-size: 18px; font-family: system-ui; }
.round { font-family: "Lilita One", system-ui; font-size: 22px; }
.score { margin-left: auto; font-family: "Lilita One", system-ui; font-size: 22px; background: var(--yellow); border: 3px solid var(--ink); border-radius: 14px; padding: 2px 12px; }
.timer { width: 52px; height: 52px; }
.timer circle { fill: none; stroke-width: 5; }
.timer .track { stroke: rgba(47, 39, 71, .15); fill: #fff; }
.timer .fill { stroke: var(--green); stroke-linecap: round; transform: rotate(-90deg); transform-origin: 22px 22px; stroke-dasharray: 119.4; transition: stroke .3s; }
.timer.low .fill { stroke: var(--red); }
.timer.low { animation: tick 1s infinite; }
@keyframes tick { 10% { transform: scale(1.12); } 20% { transform: scale(1); } }
.timer text { font-family: "Lilita One", system-ui; font-size: 15px; text-anchor: middle; fill: var(--ink); }

.prompt { margin: 12px 0; text-align: center; font-size: 22px; }
.prompt .word { display: inline-block; font-family: "Lilita One", system-ui; font-size: 34px; background: #fff; border: 3px solid var(--ink); border-radius: 16px;
  padding: 2px 16px; margin-left: 6px; box-shadow: var(--shadow); transform: rotate(-1.5deg); }
.prompt .blanks { font-family: "Lilita One", system-ui; font-size: 32px; letter-spacing: 8px; }

.stage { display: grid; grid-template-columns: minmax(0, 1fr) 240px; gap: 16px; align-items: start; }
.paper { width: min(100%, calc(100vh - 270px)); min-width: 280px; justify-self: center; position: relative; background: #fff; border: 3px solid var(--ink); border-radius: 18px; box-shadow: 0 8px 0 var(--ink); aspect-ratio: 1; overflow: hidden; }
#board { width: 100%; height: 100%; display: block; touch-action: none; cursor: crosshair; }
#board.readonly { cursor: default; }
.toast { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%) scale(.8); font-family: "Lilita One", system-ui; font-size: 30px;
  background: var(--ink); color: #fff; padding: 8px 18px; border-radius: 14px; opacity: 0; transition: .25s; pointer-events: none; white-space: nowrap; }
.toast.show { opacity: .92; transform: translate(-50%, -50%) scale(1); }

.marcpanel { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.bubble { position: relative; background: #fff; border: 3px solid var(--ink); border-radius: 18px; padding: 10px 14px; font-size: 22px; line-height: 1.15;
  min-height: 56px; width: 100%; text-align: center; box-shadow: var(--shadow); }
.bubble::before { content: ""; position: absolute; top: -12px; left: 50%; margin-left: -10px; border: 10px solid transparent; border-bottom-color: var(--ink); border-top: 0; }
.bubble.pop { animation: pop .3s; }
@keyframes pop { 40% { transform: scale(1.06) rotate(-1deg); } }
.dots span { display: inline-block; animation: dot 1s infinite; }
.dots span:nth-child(2) { animation-delay: .15s; } .dots span:nth-child(3) { animation-delay: .3s; }
@keyframes dot { 30% { transform: translateY(-6px); } }
.chips { list-style: none; padding: 0; margin: 0; width: 100%; display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; }
.chips li:first-child { animation: pop .3s; }
.chips li:not(:first-child) { text-decoration: line-through; color: var(--muted); border-style: dashed; }
.chips li { position: relative; background: #fff; border: 2px solid var(--ink); border-radius: 12px; padding: 3px 10px; font-size: 19px; overflow: hidden; display: flex; justify-content: space-between; }
.chips li i { position: absolute; inset: 0 auto 0 0; background: rgba(77, 124, 255, .16); z-index: 0; transition: width .4s; }
.chips li span { position: relative; z-index: 1; }
.chips li.hit { background: #d9f7e6; border-color: var(--green); }

.tools { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin: 18px auto 0; max-width: calc(100vh - 270px + 256px); }
.colors, .sizes { display: flex; gap: 6px; background: #fff; border: 3px solid var(--ink); border-radius: 999px; padding: 5px 8px; }
.swatch { width: 30px; height: 30px; border-radius: 50%; border: 3px solid #fff; box-shadow: 0 0 0 2px var(--ink); }
.swatch.on { transform: scale(1.18); box-shadow: 0 0 0 3px var(--ink); }
.size { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; }
.size i { background: var(--ink); border-radius: 50%; display: block; }
.size.on { background: var(--yellow); }
.tool { width: 46px; height: 46px; border-radius: 14px; background: #fff; border: 3px solid var(--ink); font-size: 22px; box-shadow: 0 4px 0 var(--ink); font-family: system-ui; }
.tool.on { background: var(--yellow); }
.tool:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }
.tool.wide { width: auto; padding: 0 16px; margin-left: auto; font-family: "Gochi Hand", cursive; font-size: 22px; }

.guessbox { display: flex; gap: 8px; margin-top: 18px; }
.guessbox input { flex: 1; min-width: 0; font: inherit; font-size: 24px; padding: 8px 14px; border: 3px solid var(--ink); border-radius: 14px; background: #fff; outline: none; }
.guessbox input:focus { border-color: var(--blue); }
.guessbox input.shake { animation: shake .35s; border-color: var(--red); }
@keyframes shake { 25% { transform: translateX(-8px); } 50% { transform: translateX(7px); } 75% { transform: translateX(-4px); } }
.guessbox button { font-family: "Lilita One", system-ui; font-size: 20px; background: var(--blue); color: #fff; border: 3px solid var(--ink); border-radius: 14px; padding: 0 16px; box-shadow: 0 4px 0 var(--ink); }
.guessbox .ghost { background: #fff; color: var(--ink); }
.wrong { list-style: none; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0 0; }
.wrong li { text-decoration: line-through; color: var(--muted); background: #fff; border: 2px dashed rgba(47, 39, 71, .3); border-radius: 10px; padding: 0 8px; }
.wrong li.close { color: #c27a00; text-decoration: none; border-color: #ffb020; }

.mode-draw .guessbox, .mode-draw .wrong { display: none; }
.mode-guess .tools { display: none; }

/* ---------- overlays ---------- */
.overlay { position: fixed; inset: 0; background: rgba(47, 39, 71, .45); display: grid; place-items: center; opacity: 0; pointer-events: none; transition: .25s; padding: 16px; z-index: 5; }
.overlay.show { opacity: 1; pointer-events: auto; }
.card { background: #fff; border: 3px solid var(--ink); border-radius: 26px; padding: 22px 28px; text-align: center; box-shadow: 0 10px 0 var(--ink); max-width: 380px; width: 100%;
  transform: scale(.9) rotate(-1deg); transition: transform .35s cubic-bezier(.3, 1.6, .5, 1); }
.overlay.show .card { transform: scale(1) rotate(0); }
.card .marc { margin: -70px auto 0; width: 110px; height: 110px; }
.card h3 { font-family: "Lilita One", system-ui; font-weight: 400; font-size: 30px; margin: 6px 0 4px; }
.card p { margin: 0 0 6px; color: var(--muted); }
.pts { font-family: "Lilita One", system-ui; font-size: 40px; color: var(--green); margin-bottom: 12px; }
.big-btn { font-family: "Lilita One", system-ui; font-size: 24px; background: var(--pink); color: #fff; border: 3px solid var(--ink); border-radius: 18px; padding: 10px 28px; box-shadow: 0 5px 0 var(--ink); }
.big-btn.alt { background: #fff; color: var(--ink); }
.big-btn:active { transform: translateY(4px); box-shadow: 0 1px 0 var(--ink); }

#end { text-align: center; padding-top: 3vh; }
.final { font-family: "Lilita One", system-ui; font-size: 84px; color: var(--pink); text-shadow: 3px 4px 0 var(--ink); line-height: 1; }
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; margin: 20px 0; }
.thumb { background: #fff; border: 3px solid var(--ink); border-radius: 14px; padding: 6px; box-shadow: var(--shadow); }
.thumb:nth-child(odd) { transform: rotate(-1.5deg); } .thumb:nth-child(even) { transform: rotate(1.5deg); }
.thumb img { width: 100%; display: block; border-radius: 8px; border: 1px solid #eee; }
.thumb div { display: flex; justify-content: space-between; padding: 4px 4px 0; font-size: 19px; }
.thumb .ok { color: var(--green); } .thumb .no { color: var(--red); }
.row { display: flex; gap: 12px; justify-content: center; }
#confetti { position: fixed; inset: 0; pointer-events: none; z-index: 6; width: 100%; height: 100%; }

@media (max-width: 720px) {
  #app { padding: 10px 12px 20px; }
  .stage { grid-template-columns: 1fr; }
  .marcpanel { flex-direction: row; flex-wrap: wrap; order: -1; }
  .marcpanel .marc { width: 64px; height: 64px; }
  .bubble { flex: 1; width: auto; font-size: 19px; min-height: 0; }
  .bubble::before { top: 50%; left: -12px; margin: -10px 0 0; border: 10px solid transparent; border-right-color: var(--ink); border-left: 0; }
  .chips { display: flex; flex-wrap: wrap; }
  .chips li { font-size: 16px; gap: 6px; }
  .prompt .word { font-size: 28px; }
  .tool { width: 42px; height: 42px; }
  .swatch, .size { width: 24px; height: 24px; }
  .paper { width: 100%; }
  .tools { gap: 6px; max-width: none; }
  .colors, .sizes { gap: 4px; padding: 4px 6px; }
  .tool { width: 38px; height: 38px; font-size: 18px; }
  .tool.wide { padding: 0 10px; }
}

/* make room for the shared Classic/Tolan switch (top right) */
@media (max-width: 1240px) { .bar { padding-right: 112px; } }
@media (max-width: 560px) { .bar { padding-right: 76px; } }

/* ================= Tolan theme ================= */
:root[data-theme="tolan"] {
  --paper: #f4f2e7; --ink: #2c2c2c; --muted: #7a7869; --pink: #8f6cf0; --pink-d: #7253d8; --blue: #2c2c2c; --blue-d: #474744;
  --yellow: #edece2; --green: #2fae78; --red: #e8473f; --card: #fff; --line: transparent; --shadow: 0 1px 2px rgba(44, 44, 44, .06);
}
[data-theme="tolan"] body { background: #f4f2e7; color: #2c2c2c; font-size: 17px; letter-spacing: -.01em; }
[data-theme="tolan"] body, [data-theme="tolan"] button, [data-theme="tolan"] input,
[data-theme="tolan"] .logo, [data-theme="tolan"] .mode b, [data-theme="tolan"] .round, [data-theme="tolan"] .score, [data-theme="tolan"] .prompt .word,
[data-theme="tolan"] .prompt .blanks, [data-theme="tolan"] .toast, [data-theme="tolan"] .card h3, [data-theme="tolan"] .pts, [data-theme="tolan"] .big-btn,
[data-theme="tolan"] .guessbox button, [data-theme="tolan"] .final, [data-theme="tolan"] .tool.wide { font-family: "Inter Tight", system-ui, sans-serif; }
[data-theme="tolan"] .timer text { font-family: "Inter Tight", system-ui, sans-serif; font-weight: 600; font-size: 14px; }

[data-theme="tolan"] .logo { color: #2c2c2c; text-shadow: none; transform: none; font-weight: 600; letter-spacing: -.04em; font-size: clamp(44px, 9vw, 72px); }
[data-theme="tolan"] .logo span { color: #8f6cf0; transform: none; margin-left: .2em; }
[data-theme="tolan"] .logo.small { font-size: 32px; }
[data-theme="tolan"] .tag { font-size: 19px; }

/* hairline borders and soft shadows instead of thick ink outlines */
[data-theme="tolan"] :is(.mode, .seg, .icon, .score, .prompt .word, .paper, .bubble, .chips li, .colors, .sizes, .tool, .guessbox input, .guessbox button, .card, .big-btn, .thumb) {
  border: 1px solid #e2e0c3; box-shadow: 0 1px 2px rgba(44, 44, 44, .06);
}
[data-theme="tolan"] .mode { border-radius: 24px; padding: 18px 22px; transition: transform .2s, box-shadow .2s; }
[data-theme="tolan"] .mode:hover { transform: translateY(-2px); box-shadow: 0 8px 24px rgba(44, 44, 44, .08); }
[data-theme="tolan"] .mode:active { transform: translateY(0); box-shadow: var(--shadow); }
[data-theme="tolan"] .mode b { font-weight: 600; font-size: 22px; letter-spacing: -.02em; color: #2c2c2c !important; }
[data-theme="tolan"] .mode small { font-size: 16px; }
[data-theme="tolan"] .seg { background: #edece2; border: none; }
[data-theme="tolan"] .seg button { font-size: 16px; font-weight: 500; color: #474744; }
[data-theme="tolan"] .seg button.on { background: #fff; box-shadow: 0 1px 2px rgba(44, 44, 44, .12); }

[data-theme="tolan"] .icon { background: #fff; }
[data-theme="tolan"] .round { font-weight: 600; font-size: 18px; }
[data-theme="tolan"] .score { background: #edece2; border: none; border-radius: 999px; font-weight: 600; font-size: 16px; padding: 6px 14px; }
[data-theme="tolan"] .timer .track { stroke: #e2e0c3; }
[data-theme="tolan"] .timer .fill { stroke: #8f6cf0; }
[data-theme="tolan"] .prompt { font-size: 17px; color: #7a7869; }
[data-theme="tolan"] .prompt .word { font-weight: 600; font-size: 26px; transform: none; border-radius: 14px; color: #2c2c2c; letter-spacing: -.02em; }
[data-theme="tolan"] .prompt .blanks { font-weight: 600; font-size: 26px; color: #2c2c2c; }
[data-theme="tolan"] .paper { border-radius: 28px; box-shadow: 0 2px 12px rgba(44, 44, 44, .06); }
[data-theme="tolan"] .bubble { border-radius: 20px; font-size: 17px; font-weight: 500; }
[data-theme="tolan"] .bubble::before { border-bottom-color: #e2e0c3; }
@media (max-width: 720px) { [data-theme="tolan"] .bubble::before { border-bottom-color: transparent; border-right-color: #e2e0c3; } }
[data-theme="tolan"] .chips li { border-radius: 999px; font-size: 15px; padding: 3px 12px; }
[data-theme="tolan"] .colors, [data-theme="tolan"] .sizes { background: #fff; }
[data-theme="tolan"] .swatch { box-shadow: 0 0 0 1px #e2e0c3; }
[data-theme="tolan"] .swatch.on { box-shadow: 0 0 0 2px #2c2c2c; }
[data-theme="tolan"] .size.on, [data-theme="tolan"] .tool.on { background: #edece2; }
[data-theme="tolan"] .tool { background: #faf8f3; border-radius: 12px; font-size: 19px; }
[data-theme="tolan"] .tool.wide { font-size: 16px; font-weight: 500; }
[data-theme="tolan"] .tool:active { transform: translateY(1px); box-shadow: none; }
[data-theme="tolan"] .guessbox input { border-radius: 14px; font-size: 18px; }
[data-theme="tolan"] .guessbox input:focus { border-color: #8f6cf0; }
[data-theme="tolan"] .guessbox button { background: #2c2c2c; border-color: #2c2c2c; border-radius: 14px; font-weight: 500; font-size: 16px; }
[data-theme="tolan"] .guessbox .ghost { background: #faf8f3; border-color: #e2e0c3; color: #474744; }
[data-theme="tolan"] .wrong li { border-radius: 999px; font-size: 15px; }
[data-theme="tolan"] .toast { background: #2c2c2c; font-weight: 600; font-size: 24px; border-radius: 16px; }

[data-theme="tolan"] .overlay { background: rgba(44, 44, 44, .3); }
[data-theme="tolan"] .card { border: none; border-radius: 28px; box-shadow: 0 20px 60px rgba(44, 44, 44, .15); transform: scale(.96); }
[data-theme="tolan"] .card h3 { font-weight: 600; letter-spacing: -.02em; font-size: 26px; }
[data-theme="tolan"] .pts { font-weight: 600; font-size: 34px; }
[data-theme="tolan"] .big-btn { background: #2c2c2c; border-color: #2c2c2c; color: #fff; border-radius: 14px; font-weight: 500; font-size: 18px; box-shadow: none; padding: 12px 28px; }
[data-theme="tolan"] .big-btn.alt { background: #faf8f3; border-color: #e2e0c3; color: #474744; }
[data-theme="tolan"] .big-btn:active { transform: translateY(1px); box-shadow: none; }
[data-theme="tolan"] .final { color: #2c2c2c; text-shadow: none; font-weight: 600; letter-spacing: -.04em; }
[data-theme="tolan"] .thumb { border-radius: 18px; transform: none !important; }

