/* Game Creator (#/create-game). Reuses .panel, .big-card, .chip, .btn and the .game-wrap/.game-overlay look from the
   Arcade; this file only adds the layout. Mobile first, touch targets at least 44px. */

/* Promo card on Home and the Arcade */
.cg-promo { grid-column: 1 / -1; flex-direction: row; align-items: center; flex-wrap: wrap; gap: 14px; min-height: 0; }
.cg-promo .bc-ic { font-size: 46px; }
.cg-promo-text { display: flex; flex-direction: column; gap: 4px; flex: 1 1 240px; }
.cg-promo .bc-foot { margin-top: 0; align-self: center; }
.cg-promo-row { margin: 0 0 18px; display: grid; }

/* Header */
.cg-hero { display: flex; align-items: center; gap: 18px; flex-wrap: wrap-reverse; justify-content: space-between; }
.cg-hero > div:last-child { flex: 1 1 320px; }
.cg-hero .page-lead { margin-bottom: 14px; }

/* Form */
.cg-form { display: flex; flex-direction: column; gap: 18px; }
.cg-form fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }
.cg-form legend { font: 800 22px/1.2 var(--font-head); color: var(--gold); margin-bottom: 10px; padding: 0; }
.cg-radio { position: absolute; opacity: 0; width: 1px; height: 1px; pointer-events: none; }
.cg-opt { position: relative; cursor: pointer; }
.cg-opt:has(.cg-radio:focus-visible) { outline: 3px solid #fff; outline-offset: 3px; }

.cg-themes { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.cg-theme { min-height: 128px; padding: 14px; opacity: .82; }
.cg-theme .bc-ic { font-size: 38px; }
.cg-theme b { font-size: clamp(17px, 2vw, 22px); }
.cg-theme small { font-size: 14px; }
.cg-theme:has(.cg-radio:checked) { opacity: 1; transform: translateY(-3px); border-color: #fff; box-shadow: 0 0 0 4px var(--gold), 0 12px 28px rgba(0,0,0,.4); }
.cg-theme:has(.cg-radio:checked)::after { content: '✅'; position: absolute; top: 10px; right: 12px; font-size: 22px; }

.cg-label { display: block; font-weight: 800; margin: 10px 0 6px; }
.cg-form input[type="text"], .cg-form textarea, .cg-ask input, .cg-lab input {
  width: 100%; font: inherit; color: var(--ink); background: rgba(5, 11, 31, .7); border: 2px solid var(--line);
  border-radius: 14px; padding: 12px 14px; min-height: 48px;
}
.cg-form textarea { resize: vertical; min-height: 110px; line-height: 1.45; }
.cg-form input::placeholder, .cg-form textarea::placeholder, .cg-ask input::placeholder { color: #8ea3c9; }
.cg-form input:focus-visible, .cg-form textarea:focus-visible, .cg-ask input:focus-visible, .cg-lab input:focus-visible { outline: 3px solid var(--gold); outline-offset: 1px; border-color: var(--gold); }
.cg-under { display: flex; gap: 10px; justify-content: space-between; align-items: flex-start; margin-top: 6px; }
.cg-hint { margin: 0; font-size: 14px; }
.cg-count { color: var(--muted); white-space: nowrap; font-weight: 700; }

.cg-chips { display: flex; flex-wrap: wrap; gap: 10px; }
.cg-chip { min-height: 46px; padding: 10px 18px; font-size: 16px; }
.cg-chip:has(.cg-radio:checked) { background: var(--gold); color: #10142a; border-color: var(--gold-2); }

.cg-modes { display: grid; grid-template-columns: 1fr; gap: 12px; }
.cg-mode { display: grid; grid-template-columns: auto 1fr; column-gap: 12px; align-items: center; padding: 14px 16px; border-radius: 18px;
  border: 2px solid var(--line); background: var(--panel-2); }
.cg-mode-ic { grid-row: span 2; font-size: 34px; }
.cg-mode b { font: 800 19px var(--font-head); }
.cg-mode small { color: var(--muted); font-weight: 700; }
.cg-mode:has(.cg-radio:checked) { border-color: var(--gold); box-shadow: 0 0 0 2px var(--gold) inset, 0 0 18px rgba(255,199,44,.3); }

.cg-actions { display: flex; justify-content: center; }
.cg-submit { width: 100%; max-width: 420px; }
.cg-status:empty { display: none; }
.cg-status { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 10px; text-align: center; padding: 12px; border-radius: 14px; }
.cg-status p { margin: 0; font-weight: 700; }
.cg-status.is-error { background: rgba(239, 68, 68, .14); border: 1px solid rgba(248, 113, 113, .6); }
.cg-status.is-loading { background: rgba(47, 128, 255, .14); border: 1px solid var(--line); }
.cg-loading { display: flex; align-items: center; gap: 10px; font-weight: 800; }
.cg-spin { display: inline-block; font-size: 28px; animation: cg-wobble .9s ease-in-out infinite; }
@keyframes cg-wobble { 0%, 100% { transform: rotate(-14deg); } 50% { transform: rotate(14deg) scale(1.1); } }

/* Game + coach */
.cg-out:empty { display: none; }
.cg-play { display: grid; grid-template-columns: 1fr; gap: 16px; margin-top: 16px; }
.cg-game, .cg-coach { min-width: 0; scroll-margin-top: 12px; }
.cg-game-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; justify-content: space-between; }
.cg-title { margin: 0; font: 800 clamp(24px, 3vw, 32px)/1.1 var(--font-head); color: var(--gold); }
.cg-meta { display: flex; flex-wrap: wrap; gap: 6px; }
.cg-meta .chip { font-size: 13px; padding: 4px 10px; }
.cg-intro { margin: 8px 0 12px; }
.cg-wrap { min-height: 0; }
.cg-stage .g-canvas { border-radius: 0; max-height: none; }
.cg-go h3 { margin: 0; font: 800 26px var(--font-head); color: var(--gold); }
.cg-go .go-big { font-size: 54px; line-height: 1; }
.cg-how { margin: 8px 0 0; padding-left: 20px; display: grid; gap: 4px; }
.cg-how-sm { text-align: left; font-size: 14px; max-width: 360px; }
.cg-controls { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-top: 12px; }
.cg-buttons { display: flex; flex-wrap: wrap; gap: 8px; }
.cg-buttons .btn { min-height: 44px; }
.cg-howbox { margin-top: 12px; }
.cg-howbox summary, .cg-lesson summary { cursor: pointer; font-weight: 800; min-height: 44px; display: flex; align-items: center; gap: 6px; }

.cg-pad { display: grid; gap: 6px; touch-action: none; user-select: none; -webkit-user-select: none; }
.cg-pad[data-layout="cross"] { grid-template-columns: repeat(3, 56px); grid-template-areas: ". up ." "left down right"; }
.cg-pad[data-layout="row"] { grid-template-columns: repeat(2, 72px); grid-template-areas: "left right"; }
.cg-pad-btn { width: 100%; height: 56px; font-size: 26px; border-radius: 16px; border: 2px solid var(--line); background: var(--panel-2); color: var(--ink); cursor: pointer; touch-action: none; }
.cg-pad-btn:active { background: rgba(255,199,44,.35); border-color: var(--gold); }
.cg-pad-up { grid-area: up; } .cg-pad-down { grid-area: down; } .cg-pad-left { grid-area: left; } .cg-pad-right { grid-area: right; }
@media (hover: hover) and (pointer: fine) { .cg-pad { opacity: .75; } }

.cg-coach h2 { margin: 0 0 10px; }
.cg-bubble { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: 18px; background: rgba(47,128,255,.14); border: 1px solid var(--line); margin-bottom: 12px; }
.cg-bubble p { margin: 0; font-weight: 700; }
.cg-coach-face { font-size: 30px; line-height: 1; }
.cg-code { margin: 8px 0 0; padding: 10px 12px; border-radius: 12px; background: #030818; border: 1px solid #1f2f5c; color: #a7f3c0; font: 700 14px/1.5 ui-monospace, 'Cascadia Code', Menlo, monospace; white-space: pre-wrap; overflow-x: auto; }
.cg-prompts { margin-bottom: 10px; }
.cg-prompts .chip { cursor: pointer; color: var(--ink); min-height: 44px; font: inherit; font-weight: 800; font-size: 14px; }
.cg-ask { display: flex; gap: 8px; margin-bottom: 8px; }
.cg-ask input { min-height: 44px; padding: 8px 12px; }
.cg-ask .btn { min-height: 44px; }
.cg-sub { margin: 16px 0 8px; font: 800 19px var(--font-head); }
.cg-lessons { display: grid; gap: 8px; }
.cg-lesson { padding: 4px 12px 8px; border-radius: 14px; background: var(--panel-2); border: 1px solid var(--line); }
.cg-lesson p { margin: 4px 0 0; }
.cg-lab { display: grid; gap: 10px; }
.cg-lab-row { display: grid; grid-template-columns: minmax(130px, auto) 90px; gap: 2px 10px; align-items: center; }
.cg-lab-row label { font-weight: 800; }
.cg-lab-row code { color: #a7f3c0; }
.cg-lab-row small { grid-column: 1 / -1; font-size: 13px; }
.cg-lab input { min-height: 44px; padding: 6px 10px; text-align: center; font-weight: 800; }
.cg-vars { display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; margin: 0; padding: 10px 14px; border-radius: 14px; background: #030818; border: 1px solid #1f2f5c; font-weight: 800; }
.cg-vars dt code { color: #a7f3c0; }
.cg-vars dd { margin: 0; color: var(--gold); }

/* Voice: 🔊 read-aloud and 🎤 speak-to-type */
.cg-voice-row { display: flex; flex-wrap: wrap; gap: 8px; }
.cg-theme .cg-card-say { position: absolute; bottom: 10px; right: 10px; min-width: 40px; min-height: 40px; font-size: 18px; }
.cg-3d { position: absolute; top: 10px; left: 10px; font: 900 12px var(--font-head); letter-spacing: .05em; padding: 2px 8px; border-radius: 999px;
  background: linear-gradient(135deg, #fff, #ffe066); color: #10142a; box-shadow: 0 2px 0 rgba(0,0,0,.25); }
.cg-theme:has(.cg-radio:checked) .cg-3d { left: 10px; }
.cg-form legend .speak-btn { font-size: 16px; vertical-align: middle; }
.cg-with-mic { display: flex; gap: 8px; align-items: stretch; }
.cg-with-mic > input, .cg-with-mic > textarea { flex: 1 1 auto; min-width: 0; }
.cg-mic-tip { color: var(--gold); font-weight: 800; }
.mic-btn { flex: none; width: 56px; min-height: 48px; font-size: 26px; border-radius: 16px; border: 2px solid var(--line); background: var(--panel-2); color: var(--ink); cursor: pointer; }
.cg-idea-row .mic-btn { width: 64px; font-size: 30px; }
.mic-btn:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }
.mic-btn.mic-on { background: #ef4444; border-color: #fecaca; animation: cg-pulse 1s ease-in-out infinite; }
@keyframes cg-pulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(239,68,68,.6); } 50% { box-shadow: 0 0 0 10px rgba(239,68,68,0); } }
.cg-ask .mic-btn { width: 48px; min-height: 44px; font-size: 22px; }
.cg-bubble > div { flex: 1 1 auto; }
.cg-bubble-say { flex: none; align-self: flex-start; }
.cg-lesson p .speak-btn { font-size: 14px; padding: 2px 8px; }
.cg-status .speak-btn { flex: none; }

/* The hero says hello on the start screen */
.cg-hello { display: flex; align-items: center; gap: 10px; justify-content: center; }
.cg-char { font-size: 72px !important; filter: drop-shadow(0 8px 6px rgba(0,0,0,.4)); animation: cg-bounce 1.2s ease-in-out infinite; }
.cg-speech { position: relative; margin: 0; max-width: 240px; padding: 10px 14px; border-radius: 18px; background: #fff; color: #10142a; font-weight: 900; text-align: left; }
.cg-speech::before { content: ''; position: absolute; left: -9px; top: 50%; margin-top: -8px; border: 8px solid transparent; border-right-color: #fff; border-left: 0; }
@keyframes cg-bounce { 0%, 100% { transform: translateY(0) rotate(-4deg); } 50% { transform: translateY(-10px) rotate(4deg); } }

/* Teach Me While I Build: code blocks next to the game */
.cg-code-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.cg-code-head h2 { margin: 0; }
.cg-code-lead { margin: 6px 0 10px; }
.cg-blocks-box { margin-top: 14px; }
.cg-blocks-box summary { cursor: pointer; font-weight: 800; min-height: 44px; display: flex; align-items: center; }
.gb { display: grid; gap: 10px; }
.gb-cols { display: grid; grid-template-columns: 1fr; gap: 12px; }
.gb-palette { display: flex; flex-wrap: wrap; gap: 8px; align-content: flex-start; padding: 10px; border-radius: 16px; background: rgba(255,255,255,.06); border: 1px dashed var(--line); }
.gb-pal-title { width: 100%; margin: 0 0 2px; font: 800 17px var(--font-head); }
.gb-tip { width: 100%; margin: 4px 0 0; font-size: 13px; }
.gb-empty { margin: 4px 0; font-size: 14px; }
.gb-script { display: grid; gap: 10px; padding: 12px; border-radius: 16px; min-width: 0;
  background-color: #eef7e8; background-image: radial-gradient(rgba(16,20,42,.12) 1px, transparent 1px); background-size: 16px 16px; color: #fff; }
.gb-block { --c: #4c97ff; position: relative; border-radius: 12px; background: var(--c); box-shadow: 0 3px 0 rgba(0,0,0,.22); font-weight: 800; font-size: 15px; min-width: 0; }
.gb-block.gb-small { box-shadow: 0 2px 0 rgba(0,0,0,.2); font-size: 14px; }
.gb-head { display: flex; align-items: center; gap: 6px; padding: 8px 10px; min-height: 40px; flex-wrap: wrap; }
.gb-words { display: inline-flex; align-items: center; flex-wrap: wrap; gap: 4px; flex: 1 1 auto; text-shadow: 0 1px 0 rgba(0,0,0,.25); }
.gb-words code { background: rgba(0,0,0,.18); padding: 1px 6px; border-radius: 6px; font: 800 13px ui-monospace, Menlo, monospace; color: #fff; }
.gb-inner { display: grid; gap: 6px; margin: 0 0 0 18px; padding: 0 8px 10px 10px; border-left: 4px solid rgba(0,0,0,.15); }
.gb-event { --c: #ffab19; } .gb-event > .gb-head { border-radius: 18px 18px 0 0; }
.gb-loop { --c: #c34fd1; }
.gb-motion { --c: #4c97ff; }
.gb-if { --c: #0fa37c; }
.gb-var { --c: #ff7a1a; }
.gb-num { width: 3.4em; min-height: 30px; padding: 2px 4px; border: 0; border-radius: 999px; background: #fff; color: #10142a; text-align: center; font: 900 15px var(--font-head, inherit); }
.gb-num.gb-fixed { display: inline-flex; align-items: center; justify-content: center; width: auto; min-width: 2em; padding: 2px 8px; }
.gb-num:focus-visible { outline: 3px solid #10142a; }
.gb-say, .gb-x { flex: none; width: 32px; height: 32px; border-radius: 50%; border: 2px solid rgba(255,255,255,.7); background: rgba(0,0,0,.18); color: #fff; font-size: 14px; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; padding: 0; }
.gb-x:hover, .gb-x:focus-visible { background: #ef4444; outline: none; }
.gb-say:focus-visible { outline: 3px solid #fff; }
.gb-lock { font-size: 14px; opacity: .8; }
.gb-hits { font-size: 12px; background: rgba(255,255,255,.25); border-radius: 999px; padding: 0 6px; }
.gb-hits:empty { display: none; }
.gb-count { margin-left: 6px; padding: 1px 8px; border-radius: 999px; background: #fff; color: #7c2d8c; font: 900 13px ui-monospace, Menlo, monospace; }
.gb-add { --c: #4c97ff; font: inherit; font-weight: 800; font-size: 14px; color: #fff; background: var(--c); border: 0; border-radius: 12px; padding: 8px 12px; min-height: 44px; cursor: pointer; box-shadow: 0 3px 0 rgba(0,0,0,.25); text-align: left; }
.gb-add:hover { filter: brightness(1.1); } .gb-add:focus-visible { outline: 3px solid #fff; outline-offset: 2px; }
/* live: the loop's edge runs round while playing, and a block glows each time it runs */
.gb-script.is-running > .gb-loop { animation: gb-loop .8s linear infinite; }
@keyframes gb-loop { 0% { box-shadow: 0 3px 0 rgba(0,0,0,.22), 0 0 0 0 rgba(195,79,209,.7); } 70% { box-shadow: 0 3px 0 rgba(0,0,0,.22), 0 0 0 8px rgba(195,79,209,0); } 100% { box-shadow: 0 3px 0 rgba(0,0,0,.22); } }
.gb-script.is-running > .gb-loop > .gb-head::after { content: '🔁'; display: inline-block; animation: gb-spin 1s linear infinite; }
@keyframes gb-spin { to { transform: rotate(360deg); } }
.gb-block.is-live > .gb-head { background-image: repeating-linear-gradient(-45deg, rgba(255,255,255,.14) 0 10px, transparent 10px 20px); background-size: 28px 28px; animation: gb-stripes .6s linear infinite; border-radius: 12px; }
@keyframes gb-stripes { to { background-position: 28px 0; } }
.gb-block.is-run { animation: gb-flash .6s ease-out; z-index: 1; }
@keyframes gb-flash { 0% { transform: scale(1.04) translateX(4px); box-shadow: 0 0 0 4px #fff, 0 0 22px 6px #ffe066; } 100% { transform: none; box-shadow: 0 3px 0 rgba(0,0,0,.22); } }
.gb-textbox summary { cursor: pointer; font-weight: 800; min-height: 40px; display: flex; align-items: center; }

@media (min-width: 640px) {
  .cg-themes { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .gb-cols { grid-template-columns: minmax(150px, 210px) minmax(0, 1fr); }
  .cg-modes { grid-template-columns: 1fr 1fr; }
}
@media (min-width: 900px) {
  .cg-themes { grid-template-columns: repeat(5, minmax(0, 1fr)); }
}
@media (min-width: 1100px) {
  .cg-play { grid-template-columns: minmax(0, 1.65fr) minmax(300px, 1fr); align-items: start; }
  /* teach mode: game and code side by side, coach underneath */
  .cg-play.is-teach { grid-template-columns: minmax(0, 1.3fr) minmax(360px, 1fr); }
  .cg-play.is-teach .cg-coach { grid-column: 1 / -1; }
  .cg-play.is-teach .cg-codepanel { position: sticky; top: 10px; max-height: calc(100vh - 20px); overflow: auto; }
  .cg-play.is-teach .gb-cols { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) {
  .cg-spin, .cg-char, .mic-btn.mic-on, .gb-script.is-running > .gb-loop, .gb-block.is-live > .gb-head, .gb-script.is-running > .gb-loop > .gb-head::after { animation: none; }
  .gb-block.is-run { animation: none; box-shadow: 0 0 0 4px #fff; }
  .cg-theme:has(.cg-radio:checked) { transform: none; }
}
