:root {
  --ink: #1a1423; --paper: #fffdf5; --cream: #fff6e0; --yellow: #ffc93c;
  --red: #ff5d3a; --blue: #3d7dff; --green: #57c84d; --teal: #2ec4b6; --sky: #cfe8ff; --pink: #ffd6e6;
  --head: "Bungee", system-ui, sans-serif; --body: "Atkinson Hyperlegible", system-ui, sans-serif;
  --r: 18px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--cream); color: var(--ink); font: 18px/1.35 var(--body); }
body { overscroll-behavior: none; }
[hidden] { display: none !important; }
button { font: inherit; color: inherit; cursor: pointer; -webkit-user-select: none; user-select: none; touch-action: manipulation; }
textarea, input { font: inherit; color: var(--ink); background: var(--paper); border: 3px solid var(--ink); border-radius: var(--r); padding: 12px 14px; width: 100%; resize: none; }
textarea:focus, input:focus { outline: 4px solid var(--blue); outline-offset: 1px; }
h1, h2 { font-family: var(--head); font-weight: 400; margin: 0; }

.pill, .round { border: 3px solid var(--ink); background: var(--paper); border-radius: 999px; min-height: 52px; padding: 0 20px; box-shadow: 0 4px 0 var(--ink); }
.pill:active, .round:active, .card:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }
.round { width: 52px; padding: 0; font-size: 22px; }
.pill.go { background: var(--yellow); font-weight: 700; margin-left: auto; }
.pill.small { min-height: 44px; padding: 0 14px; font-size: 16px; }
.pill.send { background: var(--teal); }
button:disabled { opacity: .45; pointer-events: none; }
.ask-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-top: 10px; }
.mic.listening { background: var(--red); color: #fff; }

/* Start */
.start { max-width: 980px; margin: 0 auto; padding: max(20px, env(safe-area-inset-top)) 20px 40px; }
.brand { display: flex; align-items: center; gap: 10px; font-family: var(--head); font-size: 20px; }
.brand img { width: 40px; height: 40px; }
.start h1 { font-size: clamp(28px, 5vw, 46px); margin: 28px 0 16px; }
.ask { background: var(--paper); border: 3px solid var(--ink); border-radius: 24px; padding: 14px; box-shadow: 0 6px 0 var(--ink); }
.ask textarea { border: 0; font-size: 22px; padding: 6px; }
.ask textarea:focus { outline: none; }
.or { margin: 30px 0 12px; font-weight: 700; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 14px; }
.card { text-align: left; border: 3px solid var(--ink); border-radius: var(--r); background: var(--paper); padding: 14px; box-shadow: 0 4px 0 var(--ink); display: flex; flex-direction: column; gap: 4px; min-height: 130px; }
.card .emoji { font-size: 34px; }
.card.remix { background: var(--sky); }
.card small { font-size: 15px; }
.mine { margin-top: 30px; display: flex; flex-wrap: wrap; gap: 10px; }
.mine:not(:empty)::before { content: "Your games"; display: block; width: 100%; font-weight: 700; }
.art-chips img { height: 52px; width: 52px; object-fit: contain; border: 2px dashed var(--ink); border-radius: 12px; background: var(--paper); }

/* Studio: landscape is side by side, portrait is stacked */
.studio { height: 100dvh; display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(320px, 1fr); gap: 16px; padding: max(12px, env(safe-area-inset-top)) 16px max(12px, env(safe-area-inset-bottom)); }
@media (max-aspect-ratio: 1/1) { .studio { grid-template-columns: 1fr; grid-template-rows: auto minmax(0, 1fr); } }
.play { display: flex; flex-direction: column; gap: 12px; min-height: 0; }
.bar { display: flex; align-items: center; gap: 10px; }
.bar h2 { font-size: 22px; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.frame { position: relative; width: min(100%, calc(62dvh * 4 / 3)); aspect-ratio: 4 / 3; flex: none; margin: 0 auto; background: #000; border: 4px solid var(--ink); border-radius: 14px; overflow: hidden; }
@media (max-aspect-ratio: 1/1) { .frame { max-height: none; width: min(100%, calc(38dvh * 4 / 3)); } }
.frame iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.empty { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: #fff9; font-family: var(--head); }
.steps { position: absolute; left: 10px; right: 10px; bottom: 10px; display: flex; gap: 10px; align-items: center; background: var(--paper); border: 3px solid var(--ink); border-radius: 999px; padding: 8px 16px; font-weight: 700; }
.spinner { width: 20px; height: 20px; border-radius: 50%; border: 4px solid var(--yellow); border-top-color: var(--ink); animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.toast { position: absolute; top: 10px; right: 10px; background: var(--green); color: #fff; font-weight: 700; padding: 6px 14px; border-radius: 999px; border: 3px solid var(--ink); }

/* The pad, laid out like the handheld */
.pad { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 10px; touch-action: none; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; padding: 4px 6px; }
.pad button { border: 3px solid var(--ink); background: var(--paper); box-shadow: 0 4px 0 var(--ink); font-weight: 700; touch-action: none; }
.pad button.down-now { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); background: var(--yellow); }
.dpad { display: grid; grid-template-columns: repeat(3, 58px); grid-template-rows: repeat(3, 58px); justify-self: start; }
.dpad button { border-radius: 12px; font-size: 20px; }
.dpad .up { grid-area: 1 / 2; } .dpad .left { grid-area: 2 / 1; } .dpad .right { grid-area: 2 / 3; } .dpad .down { grid-area: 3 / 2; }
.mid { display: flex; flex-direction: column; align-items: center; gap: 14px; }
.shoulders { display: flex; gap: 10px; }
.shoulders button { width: 64px; height: 40px; border-radius: 10px; }
.start-btn { height: 36px; padding: 0 14px; border-radius: 999px; font-size: 14px; }
.face { display: grid; grid-template-columns: repeat(3, 58px); grid-template-rows: repeat(3, 58px); justify-self: end; }
.face button { border-radius: 50%; font-size: 20px; }
.face .x { grid-area: 1 / 2; background: var(--sky); } .face .y { grid-area: 2 / 1; background: var(--green); }
.face .a { grid-area: 2 / 3; background: var(--red); color: #fff; } .face .b { grid-area: 3 / 2; background: var(--yellow); }

/* The talk */
.talk { display: flex; flex-direction: column; min-height: 0; background: var(--paper); border: 3px solid var(--ink); border-radius: 24px; overflow: hidden; }
.log { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 10px; -webkit-overflow-scrolling: touch; }
.msg { max-width: 88%; padding: 10px 14px; border-radius: 16px; border: 2px solid var(--ink); white-space: pre-wrap; }
.msg.you { align-self: flex-end; background: var(--sky); }
.msg.say { align-self: flex-start; background: var(--cream); }
.msg.error { align-self: flex-start; background: var(--pink); }
.msg.note { align-self: center; border-style: dashed; font-size: 15px; }
.msg img { max-height: 90px; display: block; margin-top: 6px; }
.plan { align-self: stretch; background: var(--cream); border: 3px solid var(--ink); border-radius: 20px; padding: 14px; box-shadow: 0 4px 0 var(--ink); }
.plan h3 { font-family: var(--head); font-weight: 400; margin: 0 0 6px; }
.plan p { margin: 0; white-space: pre-wrap; }
.say { border-top: 3px solid var(--ink); padding: 12px; }

/* The drawing pad */
.sheet { position: fixed; inset: 0; background: rgba(26, 20, 35, .55); display: flex; align-items: center; justify-content: center; z-index: 10; padding: 16px; }
.sheet-box { background: var(--paper); border: 3px solid var(--ink); border-radius: 24px; padding: 16px; width: min(560px, 100%); max-height: 100%; overflow: auto; display: flex; flex-direction: column; gap: 10px; }
#canvas { width: 100%; aspect-ratio: 1; border: 3px solid var(--ink); border-radius: 14px; touch-action: none; background: #fff repeating-conic-gradient(#f3f0ea 0% 25%, #fff 0% 50%) 0 0 / 32px 32px; }
.tools { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.tools .round.on { background: var(--yellow); }
.swatch { width: 40px; height: 40px; border-radius: 50%; border: 3px solid var(--ink); margin-right: 4px; }
.swatch.on { outline: 4px solid var(--blue); }

/* The hosted demo's sign-in */
.signin { text-align: center; }
.signin .brand { justify-content: center; }
.signin .pill.go { display: inline-flex; align-items: center; text-decoration: none; margin: 24px auto 0; font-size: 22px; }
.signin .why { background: var(--pink); border: 3px solid var(--ink); border-radius: var(--r); padding: 12px 16px; max-width: 520px; margin: 0 auto; }
