/* Make Day Lab: chunky, toy-like, high-contrast. Each lab sets its own accent via body[data-lab]. */

@font-face { font-family: "Fredoka"; src: url("/fonts/fredoka.woff2") format("woff2"); font-weight: 300 700; font-display: swap; }
@font-face { font-family: "Nunito"; src: url("/fonts/nunito.woff2") format("woff2"); font-weight: 200 1000; font-display: swap; }

:root {
  --paper: #fff6e5;
  --bg: var(--paper);
  --ink: #1d1638;
  --muted: #5f5880;
  --card: #ffffff;
  --line: #1d1638;
  --soft: #f3ead8;
  --primary: #ff4f8b;
  --primary-dark: #d02f68;
  --primary-tint: #ffe3ee;
  --accent: #7c4dff;
  --sun: #ffc93c;
  --sky: #38bdf8;
  --leaf: #2fbf71;
  --leaf-dark: #1f8f52;
  --grape: #7c4dff;
  --code-bg: #120e2a;
  --code-ink: #7cf29a;
  --radius: 22px;
  --shadow: 5px 5px 0 var(--ink);
  --shadow-sm: 3px 3px 0 var(--ink);
  --display: "Fredoka", ui-rounded, "SF Pro Rounded", system-ui, sans-serif;
  --body: "Nunito", ui-rounded, "SF Pro Rounded", system-ui, sans-serif;
  font-family: var(--body);
  color-scheme: light;
}
body[data-lab="game"] { --primary: #ff4f8b; --primary-dark: #d02f68; --primary-tint: #ffe3ee; --accent: #7c4dff; }
body[data-lab="audio"] { --primary: #ff8a00; --primary-dark: #c96a00; --primary-tint: #fff0d9; --accent: #00b3a4; }
body[data-lab="app"] { --primary: #2f7bff; --primary-dark: #1b55c4; --primary-tint: #e1ecff; --accent: #2fbf71; }
body[data-lab="website"] { --primary: #0e9f8e; --primary-dark: #08776a; --primary-tint: #d8f5f0; --accent: #ff6b4a; }
body[data-lab="story"] { --primary: #8b5cf6; --primary-dark: #6d3fd8; --primary-tint: #efe7ff; --accent: #f59e0b; }
body[data-lab="art"] { --primary: #e0478f; --primary-dark: #b52d6f; --primary-tint: #fde4f0; --accent: #14b8a6; }

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  background-color: var(--paper);
  background-image:
    radial-gradient(circle at 12% 8%, color-mix(in srgb, var(--primary) 18%, transparent) 0 120px, transparent 121px),
    radial-gradient(circle at 92% 30%, color-mix(in srgb, var(--accent) 16%, transparent) 0 90px, transparent 91px),
    radial-gradient(circle, rgba(29, 22, 56, 0.09) 1.2px, transparent 1.6px);
  background-size: auto, auto, 22px 22px;
  background-attachment: fixed;
  color: var(--ink);
  font-size: 18px;
  line-height: 1.4;
  -webkit-tap-highlight-color: transparent;
  transition: background-color 0.3s;
}
button, input, textarea, select { font: inherit; color: inherit; }
a { color: var(--accent); font-weight: 800; }
[hidden] { display: none !important; }
h1, h2, h3, .display { font-family: var(--display); font-weight: 600; letter-spacing: -0.3px; }
:focus-visible { outline: 4px solid var(--sky); outline-offset: 3px; }

.wrap { max-width: 920px; margin: 0 auto; padding: 18px 16px 48px; }

/* Brand */
.brand { display: flex; align-items: center; gap: 12px; margin: 2px 0 18px; flex-wrap: wrap; }
.brand .logo {
  display: grid; place-items: center; width: 56px; height: 56px; font-size: 32px; border-radius: 16px;
  background: var(--sun); border: 3px solid var(--ink); box-shadow: var(--shadow-sm); transform: rotate(-6deg);
}
.brand .name { display: flex; flex-direction: column; line-height: 1; font-family: var(--display); font-size: 30px; font-weight: 700; }
.brand .name small { font-family: var(--body); font-size: 12px; font-weight: 900; letter-spacing: 1.6px; text-transform: uppercase; color: var(--accent); margin-bottom: 4px; }
.brand .tag {
  margin-left: auto; font-size: 15px; font-weight: 900; background: var(--card); border: 3px solid var(--ink);
  border-radius: 999px; padding: 6px 14px; box-shadow: var(--shadow-sm); white-space: nowrap;
}
@media (max-width: 560px) {
  .brand .name { font-size: 25px; }
  .brand .tag { margin-left: 0; }
}

h1 { font-size: clamp(30px, 5.4vw, 48px); line-height: 1.05; margin: 6px 0 8px; }
.lead { color: var(--muted); margin: 0 0 20px; font-size: 19px; font-weight: 600; }

.card { background: var(--card); border: 3px solid var(--ink); border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow); }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px; min-height: 58px; padding: 10px 24px;
  border: 3px solid var(--ink); border-radius: 18px; background: var(--primary); color: #fff; cursor: pointer;
  font-family: var(--display); font-weight: 600; font-size: 22px; letter-spacing: .2px; text-decoration: none;
  box-shadow: var(--shadow-sm); touch-action: manipulation; transition: transform .08s, box-shadow .08s, filter .15s;
}
.btn:hover { filter: brightness(1.05); }
.btn:active { transform: translate(3px, 3px); box-shadow: 0 0 0 var(--ink); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.big { width: 100%; min-height: 74px; font-size: 28px; border-radius: 22px; box-shadow: var(--shadow); }
.btn.big:active { transform: translate(5px, 5px); }
.btn.alt { background: var(--card); color: var(--ink); }
.btn.green { background: var(--leaf); }
.btn.small { min-height: 46px; font-size: 17px; padding: 6px 14px; border-radius: 14px; }
.btn.sun { background: var(--sun); color: var(--ink); }

/* Fields */
input.field, textarea.field {
  width: 100%; border: 3px solid var(--ink); border-radius: 16px; padding: 14px 16px; background: #fff; font-size: 20px; outline: none;
  box-shadow: inset 0 3px 0 rgba(29, 22, 56, 0.06);
}
input.field:focus, textarea.field:focus { border-color: var(--primary); box-shadow: 0 0 0 4px var(--primary-tint); }
textarea.field { min-height: 104px; resize: vertical; }
input.code { text-align: center; font-family: var(--display); font-size: 36px; font-weight: 700; letter-spacing: 8px; text-transform: uppercase; }
label.hint { display: flex; align-items: baseline; flex-wrap: wrap; gap: 2px 8px; font-family: var(--display); font-weight: 600; margin: 4px 0 10px; font-size: 21px; }
.opt { color: var(--muted); font-family: var(--body); font-weight: 700; font-size: 15px; }
.hint-small { color: var(--muted); font-size: 15px; margin: 0; font-weight: 600; }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.spacer { flex: 1; }
.links { margin-top: 20px; display: flex; gap: 10px 20px; flex-wrap: wrap; justify-content: center; font-size: 17px; align-items: center; }

/* Welcome */
.welcome { text-align: center; padding: 28px 22px; }
.welcome .doors { display: flex; justify-content: center; gap: 14px; font-size: 44px; margin: 4px 0 6px; }
.welcome .doors span { display: inline-block; animation: bob 2.4s ease-in-out infinite; }
.welcome .doors span:nth-child(2) { animation-delay: .3s; }
.welcome .doors span:nth-child(3) { animation-delay: .6s; }
.welcome .doors span:nth-child(4) { animation-delay: .9s; }
.welcome .doors span:nth-child(5) { animation-delay: 1.2s; }
.welcome .doors span:nth-child(6) { animation-delay: 1.5s; }
.welcome .doors { flex-wrap: wrap; font-size: 38px; }
.ai-note { background: #fff7cc; border: 3px solid var(--ink); border-radius: 16px; padding: 10px 14px; font-weight: 700; font-size: 15px; text-align: left; margin: 0 0 16px; }
.ai-line { margin-top: 10px; text-align: center; }

/* Look picker */
.looks { display: flex; flex-wrap: wrap; gap: 8px; }
.look {
  border: 3px solid var(--ink); border-radius: 999px; background: var(--card); padding: 6px 14px 6px 10px; cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px; font-weight: 900; font-size: 16px; box-shadow: var(--shadow-sm); touch-action: manipulation;
}
.look .e { font-size: 22px; }
.look.on { background: var(--primary); color: #fff; transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--ink); }

/* Lab picker */
.labs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 20px; }
.lab {
  position: relative; border: 3px solid var(--ink); border-radius: 22px; padding: 14px 10px 12px; cursor: pointer; text-align: center;
  display: flex; flex-direction: column; align-items: center; gap: 2px; background: var(--card); box-shadow: var(--shadow-sm);
  touch-action: manipulation; transition: transform .12s, box-shadow .12s, background .2s;
}
.lab .e { font-size: 42px; line-height: 1.1; transition: transform .2s; }
.lab .n { font-family: var(--display); font-weight: 600; font-size: 21px; }
.lab .d { font-size: 13px; font-weight: 700; color: var(--muted); line-height: 1.2; }
.lab[data-lab="game"] { --c: #ff4f8b; --t: #ffe3ee; }
.lab[data-lab="audio"] { --c: #ff8a00; --t: #fff0d9; }
.lab[data-lab="app"] { --c: #2f7bff; --t: #e1ecff; }
.lab[data-lab="website"] { --c: #0e9f8e; --t: #d8f5f0; }
.lab[data-lab="story"] { --c: #8b5cf6; --t: #efe7ff; }
.lab[data-lab="art"] { --c: #e0478f; --t: #fde4f0; }
.lab[data-lab="bug"] { --c: #16a34a; --t: #dcfce7; }
/* A lab left alone on the last row of three takes the whole row. */
.labs:not([data-count="2"]):not([data-count="4"]) .lab:last-child:nth-child(3n+1) { grid-column: 1 / -1; }
.labs[data-count="2"], .labs[data-count="4"] { grid-template-columns: repeat(2, 1fr); }
.lab:hover .e { transform: scale(1.12) rotate(-6deg); }
.lab.on { background: var(--t); box-shadow: 6px 6px 0 var(--c); transform: translate(-2px, -2px); border-color: var(--ink); }
.lab.on::after {
  content: "✓"; position: absolute; top: -12px; right: -10px; width: 30px; height: 30px; border-radius: 50%;
  background: var(--c); color: #fff; border: 3px solid var(--ink); display: grid; place-items: center; font-weight: 900; font-size: 16px;
}
@media (max-width: 560px) {
  .lab { padding: 10px 4px; }
  .lab .e { font-size: 32px; }
  .lab .n { font-size: 16px; }
  .lab .d { display: none; }
}

/* Steps in the make card */
.step { display: flex; align-items: center; gap: 10px; margin: 0 0 10px; font-family: var(--display); font-weight: 600; font-size: 21px; }
.step .num {
  width: 34px; height: 34px; flex: none; border-radius: 50%; display: grid; place-items: center; font-size: 18px;
  background: var(--primary); color: #fff; border: 3px solid var(--ink);
}
.divider { height: 0; border-top: 3px dashed var(--soft); margin: 20px 0; }

/* Photos */
.photos { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.add-photo {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; text-align: center;
  min-height: 140px; border: 3px dashed var(--ink); border-radius: 18px; background: var(--primary-tint); cursor: pointer; padding: 10px;
  transition: transform .12s;
}
.add-photo:hover { transform: rotate(-1deg) scale(1.02); }
.add-photo .emoji { font-size: 40px; }
.add-photo strong { font-family: var(--display); font-weight: 600; font-size: 19px; }
.add-photo span { color: var(--muted); font-size: 13px; font-weight: 700; }
.add-photo input { display: none; }
.thumb { position: relative; min-height: 140px; border-radius: 18px; overflow: hidden; background: var(--soft); border: 3px solid var(--ink); box-shadow: var(--shadow-sm); }
.thumb:nth-child(odd) { transform: rotate(-1.5deg); }
.thumb:nth-child(even) { transform: rotate(1.5deg); }
.thumb img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.thumb .x {
  position: absolute; top: 6px; right: 6px; width: 38px; height: 38px; border: 2px solid #fff; border-radius: 50%;
  background: rgba(29, 22, 56, 0.85); color: #fff; font-size: 16px; cursor: pointer;
}
@media (max-width: 560px) {
  .add-photo, .thumb { min-height: 104px; }
  .add-photo .emoji { font-size: 30px; }
  .add-photo span:not(.emoji) { display: none; }
}

.idea-row { display: flex; gap: 10px; margin-top: 12px; align-items: center; flex-wrap: wrap; }
.btn.rolling { animation: shake .22s linear infinite; }
@keyframes shake { 0%, 100% { transform: rotate(0); } 25% { transform: rotate(-7deg); } 75% { transform: rotate(7deg); } }
.btn.pulse { animation: pulse .8s ease-in-out 3; }
@keyframes pulse { 50% { transform: scale(1.03); } }
.left-chip { margin-top: 14px; display: flex; justify-content: center; gap: 8px; flex-wrap: wrap; font-size: 14px; font-weight: 800; color: var(--muted); }
.left-chip .pill { background: var(--soft); border-radius: 999px; padding: 4px 12px; }

/* Building */
.building { text-align: center; }
.machine { position: relative; padding: 26px 22px; overflow: hidden; }
.flask { position: relative; display: inline-grid; place-items: center; width: 140px; height: 140px; margin: 4px auto 6px; }
.flask .big-emoji { font-size: 88px; animation: bob 1s ease-in-out infinite; z-index: 1; }
.flask .bubble { position: absolute; bottom: 10px; width: 14px; height: 14px; border-radius: 50%; background: var(--primary); border: 2px solid var(--ink); opacity: 0; animation: rise 2.2s ease-in infinite; }
.flask .bubble:nth-child(2) { left: 26px; animation-delay: .4s; background: var(--sun); }
.flask .bubble:nth-child(3) { left: 62px; animation-delay: 1.1s; background: var(--accent); }
.flask .bubble:nth-child(4) { right: 26px; animation-delay: 1.6s; background: var(--sky); }
@keyframes rise { 0% { transform: translateY(0) scale(.6); opacity: 0; } 20% { opacity: 1; } 100% { transform: translateY(-130px) scale(1.2); opacity: 0; } }
@keyframes bob { 0%, 100% { transform: translateY(0) rotate(-6deg); } 50% { transform: translateY(-12px) rotate(6deg); } }
.building .status { font-family: var(--display); font-size: 30px; font-weight: 600; margin: 4px 0; }
.building .sub { color: var(--muted); margin-bottom: 14px; min-height: 26px; font-weight: 700; }
.steps { display: flex; justify-content: center; gap: 8px; flex-wrap: wrap; margin: 0 0 16px; padding: 0; list-style: none; }
.steps li { border: 3px solid var(--ink); border-radius: 999px; padding: 4px 12px; font-weight: 800; font-size: 15px; background: var(--card); opacity: .45; transition: all .3s; }
.steps li.on { opacity: 1; background: var(--sun); transform: scale(1.06); }
.steps li.done { opacity: 1; background: var(--leaf); color: #fff; }
.codebox {
  background: var(--code-bg); color: var(--code-ink); border-radius: 16px; border: 3px solid var(--ink); padding: 14px 16px; text-align: left;
  font: 13px/1.45 ui-monospace, "SF Mono", Menlo, Consolas, monospace; height: 240px; overflow: hidden;
  white-space: pre-wrap; word-break: break-all; position: relative; box-shadow: inset 0 0 30px rgba(124, 242, 154, .08);
}
.codebox::after { content: "▌"; animation: blink .8s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }
.counter { margin-top: 12px; font-family: var(--display); font-weight: 600; font-size: 20px; color: var(--accent); }

/* Play */
body.playing { height: 100dvh; overflow: hidden; }
.play { display: grid; grid-template-columns: 1fr 360px; grid-template-rows: auto 1fr; height: 100dvh; gap: 12px; padding: 12px; }
.play .top { grid-column: 1 / -1; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.play .top h2 { margin: 0; font-size: 28px; }
.play .top .maker { color: var(--muted); font-weight: 800; }
.stage { position: relative; border-radius: var(--radius); overflow: hidden; background: #000; border: 4px solid var(--ink); box-shadow: var(--shadow); min-height: 0; }
.stage iframe { width: 100%; height: 100%; border: 0; display: block; background: #fff; }
.stage .overlay {
  position: absolute; inset: 0; background: rgba(18, 14, 42, 0.88); color: #fff; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 10px; padding: 18px; text-align: center; backdrop-filter: blur(3px);
}
.stage .overlay .big-emoji { font-size: 72px; animation: bob 1s ease-in-out infinite; }
.stage .overlay .status { font-family: var(--display); font-size: 26px; font-weight: 600; }
.stage .overlay .codebox { width: min(560px, 100%); height: 150px; }
.panel { display: flex; flex-direction: column; gap: 10px; min-height: 0; }
.tabs { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 6px; }
.tab {
  position: relative; border: 3px solid var(--ink); border-radius: 14px; background: var(--card); padding: 6px 2px; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; font-weight: 900; font-size: 13px; box-shadow: var(--shadow-sm); touch-action: manipulation;
}
.tab .e { font-size: 22px; line-height: 1.2; }
.tab.on { background: var(--primary); color: #fff; transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--ink); }
.tab .dot { position: absolute; top: -6px; right: -6px; width: 16px; height: 16px; border-radius: 50%; background: var(--sun); border: 2px solid var(--ink); }
.tab-body { flex: 1; overflow-y: auto; min-height: 0; display: flex; flex-direction: column; gap: 10px; padding: 2px 6px 8px 2px; }
.panel h3 { margin: 4px 0 0; font-size: 21px; }
.powerups { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.pu {
  border: 3px solid var(--ink); background: var(--card); border-radius: 16px; padding: 8px 4px; min-height: 76px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; cursor: pointer;
  box-shadow: var(--shadow-sm); font-weight: 900; font-size: 15px; touch-action: manipulation; transition: transform .08s, box-shadow .08s, background .15s;
}
.pu .e { font-size: 28px; }
.pu .l { text-align: center; line-height: 1.15; padding: 0 4px; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.quick { display: flex; flex-wrap: wrap; gap: 6px; }
.qk {
  border: 3px solid var(--ink); background: var(--card); border-radius: 999px; padding: 6px 12px 6px 8px; cursor: pointer;
  display: inline-flex; align-items: center; gap: 4px; font-weight: 900; font-size: 15px; box-shadow: var(--shadow-sm); touch-action: manipulation;
}
.qk .e { font-size: 20px; }
.qk:hover { background: var(--primary-tint); }
.qk:active { transform: translate(3px, 3px); box-shadow: none; }
.qk:disabled { opacity: .45; }
#pu-box { display: flex; flex-direction: column; gap: 10px; }
#pu-box[hidden] { display: none; }
.stage .testing {
  position: absolute; top: 10px; left: 0; right: 0; margin: 0 auto; width: max-content; max-width: calc(100% - 20px);
  background: var(--ink); color: #fff; border-radius: 999px; padding: 6px 14px; font-weight: 900; font-size: 15px;
  pointer-events: none; z-index: 3; animation: blink 1s ease-in-out infinite alternate;
}
@keyframes blink { from { opacity: 1; } to { opacity: .55; } }
.pu:hover { background: var(--primary-tint); }
.pu:active { transform: translate(3px, 3px); box-shadow: none; }
.pu:disabled { opacity: .45; }
.own { display: flex; gap: 8px; }
.own input { font-size: 17px; padding: 10px 12px; border-radius: 14px; }
.box { background: var(--card); border: 3px solid var(--ink); border-radius: 18px; padding: 12px; display: flex; flex-direction: column; gap: 8px; box-shadow: var(--shadow-sm); }
.box h3 { margin: 0; }
.free { background: var(--leaf); color: #fff; border: 2px solid var(--ink); border-radius: 999px; padding: 1px 9px; font-family: var(--body); font-size: 13px; font-weight: 900; vertical-align: middle; }
.tweak { display: grid; grid-template-columns: 1fr auto; gap: 2px 8px; align-items: center; font-weight: 900; font-size: 16px; padding: 6px 0; }
.tweak .tv { font: 700 13px ui-monospace, "SF Mono", Menlo, monospace; color: var(--accent); background: var(--soft); border-radius: 8px; padding: 2px 6px; }
.tweak input { grid-column: 1 / -1; width: 100%; accent-color: var(--primary); height: 34px; }
.lesson { border: 3px solid var(--ink); background: #fffbeb; border-radius: 14px; padding: 10px 12px; }
.lesson .lh { font-family: var(--display); font-weight: 600; font-size: 16px; color: #b45309; margin-bottom: 4px; }
.lesson .concept {
  border: 2px solid var(--ink); background: var(--accent); color: #fff; border-radius: 999px; padding: 2px 10px;
  font-weight: 900; font-size: 13px; cursor: pointer; text-transform: uppercase; letter-spacing: .6px;
}
.lesson .lt { margin: 6px 0 0; font-size: 16px; font-weight: 600; }
.lesson .def { margin: 6px 0 0; font-size: 14px; color: var(--muted); font-style: italic; }
.next { display: flex; flex-direction: column; gap: 8px; }
.idea {
  text-align: left; border: 3px solid var(--ink); background: #fff7cc; border-radius: 14px; padding: 10px 12px;
  font-weight: 800; font-size: 16px; cursor: pointer; touch-action: manipulation; box-shadow: var(--shadow-sm);
}
.idea:hover { background: #ffef99; }
.idea:active { transform: translate(3px, 3px); box-shadow: none; }
.idea:disabled { opacity: .5; }
.panel .left-chip { margin: 0; justify-content: flex-start; }

@media (max-width: 860px), (orientation: portrait) {
  body.playing { height: auto; overflow: auto; }
  .play { grid-template-columns: 1fr; grid-template-rows: auto 60dvh auto; height: auto; }
  .tab-body { overflow: visible; }
}

/* Code viewer */
.code-view { background: var(--code-bg); }
.code-view .code-legend { color: #cbd5e1; margin: 0 14px 6px; font-size: 14px; }
.code-view pre { flex: 1; margin: 0; overflow: auto; padding: 14px; color: #e2e8f0; font: 13px/1.5 ui-monospace, "SF Mono", Menlo, Consolas, monospace; white-space: pre-wrap; word-break: break-word; }
.code-modes { display: flex; gap: 6px; flex-wrap: wrap; }
.code-modes .btn.on { background: var(--primary); color: #fff; }
.code-modes .btn[hidden] { display: none; }
#code-text .ln { display: block; padding-left: 4.2em; text-indent: -4.2em; border-radius: 4px; cursor: pointer; }
#code-text .ln i { display: inline-block; width: 3.4em; margin-right: .8em; text-indent: 0; text-align: right; color: #64748b; font-style: normal; user-select: none; }
#code-text .ln:hover { background: rgba(255, 255, 255, .07); }
#code-text .ln.m-lesson { background: rgba(253, 230, 138, .18); }
#code-text .ln.m-tweak { background: rgba(134, 239, 172, .18); }
#code-text .ln.hl { background: rgba(250, 204, 21, .3); box-shadow: inset 4px 0 #facc15; }
#code-text .ln.hl2 { background: rgba(250, 204, 21, .1); box-shadow: inset 4px 0 rgba(250, 204, 21, .45); }
#code-text .ln.asked { background: rgba(56, 189, 248, .25); box-shadow: inset 4px 0 #38bdf8; }
#code-text .ln.add { background: rgba(34, 197, 94, .25); box-shadow: inset 4px 0 #22c55e; }
#code-text .ln.del { background: rgba(239, 68, 68, .2); box-shadow: inset 4px 0 #ef4444; color: #fca5a5; }
#code-text .ln.same-gap { color: #94a3b8; font-style: italic; cursor: default; }
.code-edit { flex: 1; display: flex; min-height: 0; background: var(--code-bg); }
.code-edit .gutter { flex: none; margin: 0; padding: 14px 8px 14px 6px; overflow: hidden; color: #64748b; text-align: right; user-select: none; font: 13px/1.5 ui-monospace, "SF Mono", Menlo, Consolas, monospace; white-space: pre; }
.code-edit textarea { flex: 1; min-width: 0; border: 0; outline: none; resize: none; padding: 14px; background: transparent; color: #e2e8f0; caret-color: #facc15; font: 13px/1.5 ui-monospace, "SF Mono", Menlo, Consolas, monospace; white-space: pre; overflow: auto; tab-size: 2; }
.code-card { flex: none; max-height: 42vh; overflow: auto; margin: 0 10px 10px; padding: 12px 14px; border-radius: 16px; border: 3px solid var(--ink); background: #fffbeb; color: var(--ink); display: flex; flex-direction: column; gap: 6px; }
.code-card h3 { margin: 0; font-size: 20px; }
.code-card p { margin: 0; font-size: 17px; font-weight: 600; }
.code-card .tour-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.code-card .tour-step { background: var(--accent); color: #fff; border: 2px solid var(--ink); border-radius: 999px; padding: 1px 10px; font-weight: 900; font-size: 13px; }
.code-card .tour-try { background: #fff; border: 2px dashed #b45309; border-radius: 12px; padding: 6px 10px; font-size: 16px; }
.code-card code { display: block; background: var(--code-bg); color: #e2e8f0; border-radius: 10px; padding: 6px 10px; font: 13px/1.4 ui-monospace, "SF Mono", Menlo, Consolas, monospace; white-space: pre-wrap; word-break: break-word; }
.code-card.edit-bar { flex-direction: row; align-items: center; flex-wrap: wrap; background: #f0fdf4; }
.learn-cta { width: 100%; }
mark.m-lesson { background: #fde68a; color: #1d1638; border-radius: 4px; }
mark.m-tweak { background: #86efac; color: #1d1638; border-radius: 4px; }

/* Toast */
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 160%); max-width: min(560px, calc(100% - 32px));
  background: var(--ink); color: #fff; padding: 14px 20px; border-radius: 18px; border: 3px solid var(--ink); font-weight: 800; font-size: 18px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .25); transition: transform .25s cubic-bezier(.2, 1.4, .4, 1); z-index: 50; text-align: center;
}
.toast.show { transform: translate(-50%, 0); }
.toast.warn { background: #b45309; }
.toast.ok { background: var(--leaf-dark); }

/* The caring message (#care in index.html) */
.care {
  max-width: min(520px, calc(100% - 32px)); background: var(--card); color: var(--ink); border: 3px solid var(--ink);
  border-radius: var(--radius); padding: 24px; text-align: center; box-shadow: var(--shadow);
}
.care::backdrop { background: rgba(29, 22, 56, .45); }
.care h2 { margin: 0 0 12px; }
.care p { font-size: 18px; font-weight: 700; margin: 0 0 18px; }

/* Arcade */
.arcade-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 18px; }
.game-card {
  border: 3px solid var(--ink); border-radius: var(--radius); padding: 16px; text-align: left; cursor: pointer; color: #fff; min-height: 180px;
  display: flex; flex-direction: column; justify-content: space-between; box-shadow: var(--shadow); touch-action: manipulation;
  transition: transform .12s, box-shadow .12s;
}
.game-card:hover { transform: translate(-2px, -2px) rotate(-1deg); box-shadow: 8px 8px 0 var(--ink); }
.game-card:active { transform: translate(3px, 3px); box-shadow: 1px 1px 0 var(--ink); }
.game-card .e { font-size: 54px; filter: drop-shadow(3px 3px 0 rgba(0, 0, 0, .25)); }
.game-card .t { font-family: var(--display); font-size: 23px; font-weight: 600; line-height: 1.1; text-shadow: 2px 2px 0 rgba(0, 0, 0, .25); }
.game-card .m { font-size: 14px; font-weight: 800; opacity: .95; }
.game-card .top { display: flex; justify-content: space-between; align-items: flex-start; }
.game-card .kind { background: #fff; color: var(--ink); border: 2px solid var(--ink); border-radius: 999px; padding: 3px 10px; font-size: 14px; font-weight: 900; }
.game-card.new { animation: pop .5s cubic-bezier(.2, 1.4, .4, 1); }
@keyframes pop { from { transform: scale(.6); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.chips { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 18px; }
.chip { border: 3px solid var(--ink); background: var(--card); border-radius: 999px; padding: 8px 16px; font-weight: 900; cursor: pointer; box-shadow: var(--shadow-sm); }
.chip.on { background: var(--primary); color: #fff; }
.fullscreen { position: fixed; inset: 0; background: var(--ink); display: flex; flex-direction: column; z-index: 40; }
.fullscreen .bar { display: flex; align-items: center; gap: 12px; padding: 10px 14px; color: #fff; flex-wrap: wrap; }
.fullscreen .bar h2 { margin: 0; font-size: 24px; }
.fullscreen iframe { flex: 1; border: 0; background: #fff; width: 100%; }
.empty { text-align: center; color: var(--muted); padding: 40px 10px; font-size: 22px; font-weight: 700; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* Bug catcher and tweak modes */
.bugbar {
  position: absolute; left: 10px; right: 10px; top: 10px; z-index: 5; display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  background: #fff7cc; color: var(--ink); border: 3px solid var(--ink); border-radius: 16px; padding: 8px 10px; box-shadow: var(--shadow-sm);
  font-weight: 800; font-size: 15px; animation: pop .35s cubic-bezier(.2, 1.4, .4, 1);
}
.bugbar span { flex: 1; min-width: 180px; }
.bugbar b { font: 600 13px ui-monospace, "SF Mono", Menlo, monospace; word-break: break-word; }
.tweak .tm { grid-column: 1 / -1; font-size: 12px; font-weight: 800; color: var(--muted); margin-top: -4px; }

/* Cutting a drawing out of a photo */
.photo-tip { margin-top: 10px; }
.cutouts { margin-top: 14px; }
.cut-list { display: flex; flex-wrap: wrap; gap: 10px; }
.cut-item { position: relative; display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 8px; border: 3px solid var(--ink); border-radius: 16px; box-shadow: var(--shadow-sm);
  background: repeating-conic-gradient(#f1ede4 0% 25%, #fff 0% 50%) 0 0 / 16px 16px; }
.cut-item img { width: 88px; height: 88px; object-fit: contain; }
.cut-item span { font-weight: 900; font-size: 14px; background: #fff; border-radius: 999px; padding: 0 8px; }
.cut-item .x { position: absolute; top: -10px; right: -10px; }
.thumb .cut { position: absolute; left: 6px; bottom: 6px; border: 2px solid var(--ink); border-radius: 999px; background: var(--sun); font-weight: 900; font-size: 14px; padding: 4px 10px; cursor: pointer; }
.cutter { background: #1d1638; }
.cutter .cut-hint { color: #fff; margin: 0 14px 8px; font-size: 18px; font-weight: 800; }
.cut-body { flex: 1; min-height: 0; display: flex; gap: 14px; padding: 0 14px 14px; }
#cut-stage { flex: 1; min-width: 0; max-height: 100%; object-fit: contain; border-radius: 12px; background: #fff; touch-action: none; cursor: crosshair; align-self: center; max-width: 100%; }
.cut-side { width: min(320px, 38vw); display: flex; flex-direction: column; gap: 12px; }
.cut-preview { min-height: 180px; border: 3px solid var(--ink); border-radius: 16px; display: grid; place-items: center; padding: 10px;
  background: repeating-conic-gradient(#e9e4f5 0% 25%, #fff 0% 50%) 0 0 / 20px 20px; }
.cut-preview .cut-result { max-width: 100%; max-height: 240px; }
.cutter .looks .look { color: var(--ink); }
@media (max-width: 760px), (orientation: portrait) {
  .cut-body { flex-direction: column; overflow: auto; }
  #cut-stage { max-height: 50vh; width: 100%; }
  .cut-side { width: 100%; }
  .cut-preview { min-height: 120px; }
  .cut-preview .cut-result { max-height: 140px; }
  #cut-use { position: sticky; bottom: 0; }
}

/* Show it off: link, QR code, save */
.share-view { background: #1d1638; overflow: auto; }
.share-body { flex: 1; display: grid; place-items: start center; padding: 6px 14px 20px; }
.share-card { width: min(560px, 100%); display: flex; flex-direction: column; gap: 10px; text-align: center; }
.share-card h3 { margin: 0; font-size: 24px; }
.share-qr { margin: 0 auto; width: min(300px, 70vw); aspect-ratio: 1; display: grid; place-items: center; background: #fff; border: 3px solid var(--ink); border-radius: 18px; padding: 10px; }
.share-qr svg { width: 100%; height: 100%; }
.share-card .own input { font-size: 15px; }
.share-for b { color: var(--primary-dark); }

/* Age */
.ages { display: grid; grid-template-columns: repeat(6, 1fr); gap: 10px; margin: 6px 0 16px; }
.ages .btn { min-height: 64px; font-size: 28px; padding: 0; }
@media (max-width: 560px) { .ages { grid-template-columns: repeat(4, 1fr); } }
.age-tag { cursor: pointer; margin-left: 6px; }

/* Playing with friends online */
.room-code { font-family: var(--display); font-size: clamp(48px, 12vw, 88px); font-weight: 700; letter-spacing: .18em; color: var(--primary-dark); line-height: 1; }
.stage .room-badge { position: absolute; top: 10px; right: 10px; z-index: 3; background: var(--ink); color: #fff; border-radius: 999px; padding: 5px 12px; font-weight: 900; font-size: 15px; pointer-events: none; }
#join-code { max-width: 220px; letter-spacing: .3em; text-align: center; }

/* Bug hunt (Bug Lab) */
.hunt { display: flex; flex-direction: column; gap: 8px; }
.bug-card { border: 3px solid var(--ink); border-radius: 14px; padding: 8px 10px; background: var(--card); box-shadow: var(--shadow-sm); display: flex; flex-direction: column; gap: 6px; }
.bug-card.changed { background: #fef9c3; }
.bug-card.fixed { background: #dcfce7; }
.bug-card .bh { display: flex; gap: 8px; align-items: baseline; font-weight: 900; font-size: 16px; }
.bug-card .bn { flex: none; }
.bug-card .bc, .bug-card .bf { margin: 0; font-size: 14px; font-weight: 700; line-height: 1.35; }
.bug-card .bf code { background: #1e293b; color: #f8fafc; padding: 1px 6px; border-radius: 6px; font-size: 13px; word-break: break-all; }
.bug-card .bb { display: flex; flex-wrap: wrap; gap: 6px; }
.bug-card .bb .learn-cta { width: auto; }
