/* Kai Creator — editor + play page */
.page-hero--tight { padding-bottom: 40px; }

.creator { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr); gap: clamp(24px, 4vw, 48px); align-items: start; }
@media (max-width: 1080px) { .creator { grid-template-columns: minmax(0, 1fr); } .creator__preview { order: -1; } }

.creator__form { display: grid; gap: 22px; }
.cstep { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); padding: 20px 22px 22px; margin: 0; min-width: 0; }
.cstep legend { display: flex; align-items: center; gap: 10px; padding: 0 8px; font-weight: 700; font-size: 17px; }
.cstep legend span { font-family: var(--font-display); font-size: 14px; letter-spacing: .14em; color: var(--accent); }

.choice { display: grid; gap: 12px; }
.choice--tpl { grid-template-columns: 1fr 1fr; }
.choice--hero { grid-template-columns: repeat(4, 1fr); }
.choice--bg { grid-template-columns: repeat(5, 1fr); }
@media (max-width: 560px) { .choice--hero { grid-template-columns: repeat(2, 1fr); } .choice--bg { grid-template-columns: repeat(3, 1fr); } .choice--tpl { grid-template-columns: 1fr; } }
.choice__card { position: relative; display: grid; gap: 6px; padding: 10px; border: 1px solid var(--line-2); border-radius: var(--radius); background: var(--bg); cursor: pointer; transition: border-color .2s, transform .2s var(--ease); text-align: center; }
.choice__card:hover { transform: translateY(-2px); border-color: rgba(var(--accent-rgb), .5); }
.choice__card input { position: absolute; opacity: 0; pointer-events: none; }
.choice__card:has(input:checked) { border-color: var(--hc, var(--accent)); box-shadow: 0 0 0 2px var(--hc, var(--accent)) inset; background: rgba(var(--accent-rgb), .06); }
.choice__card:has(input:focus-visible) { outline: 2px solid var(--accent-2); outline-offset: 2px; }
.choice__card strong { font-size: 14px; }
.choice__card small { color: var(--muted); font-size: 13px; line-height: 19px; }
.choice__thumb { width: 100%; height: auto; aspect-ratio: 1; }
.choice--bg img { width: 100%; aspect-ratio: 16 / 10; object-fit: cover; border-radius: 2px; }
.choice--tpl .choice__card { text-align: left; padding: 14px; }
.choice__tpl { display: block; height: 70px; border-radius: 2px; background: linear-gradient(180deg, #1c2433, #0d1119); position: relative; overflow: hidden; }
.choice__tpl--runner::before { content: ""; position: absolute; left: 0; right: 0; bottom: 14px; height: 2px; background: rgba(255,255,255,.3); }
.choice__tpl--runner::after { content: "🏃  ▲   ▲    ▲"; position: absolute; left: 14px; bottom: 16px; color: #ff9a4a; letter-spacing: 6px; font-size: 18px; }
.choice__tpl--slicer::after { content: "🍉  🍊  💣  🍎"; position: absolute; inset: 0; display: grid; place-items: center; font-size: 22px; letter-spacing: 4px; transform: rotate(-6deg); }
.choice__tpl--slicer::before { content: ""; position: absolute; left: 10%; right: 10%; top: 50%; height: 3px; background: linear-gradient(90deg, transparent, #9fd8ff, #fff, transparent); transform: rotate(-14deg); }

.rules, .fields { display: grid; gap: 16px; }
.field { display: grid; gap: 8px; min-width: 0; }
.field input:not([type=radio]):not([type=checkbox]) { min-width: 0; width: 100%; }
.creator__form, .creator__preview, .cprev { min-width: 0; }
.field > span { font-weight: 600; font-size: 14px; }
.field input:not([type]), .field input[type="text"] { height: 46px; padding: 0 14px; background: var(--bg); color: var(--text); border: 1px solid var(--line-2); border-radius: var(--radius); font: inherit; }
.field input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(var(--accent-rgb), .2); }
.field--range { grid-template-columns: 1fr auto; align-items: center; }
.field--range > span { grid-column: 1 / -1; }
.field--range input { width: 100%; accent-color: var(--accent); }
.field--range output { min-width: 44px; text-align: right; font-family: var(--font-display); font-weight: 700; font-size: 18px; color: var(--accent-2); }
.toggle { display: flex; gap: 10px; align-items: center; font-weight: 600; font-size: 14px; cursor: pointer; }
.toggle input { width: 18px; height: 18px; accent-color: var(--accent); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip-toggle { position: relative; }
.chip-toggle input { position: absolute; opacity: 0; width: 1px; height: 1px; margin: 0; pointer-events: none; }
.chip-toggle span { display: inline-block; padding: 7px 14px; border: 1px solid var(--line-2); border-radius: 999px; font-size: 14px; cursor: pointer; color: var(--muted); transition: all .2s; }
.chip-toggle input:checked + span { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 700; }
.chip-toggle input:focus-visible + span { outline: 2px solid var(--accent-2); outline-offset: 2px; }

.creator__preview { position: sticky; top: 96px; }
@media (max-width: 1080px) { .creator__preview { position: static; } }
.cprev { display: grid; gap: 12px; padding: 18px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.cprev__head { display: flex; justify-content: space-between; align-items: center; }
.cbadge { font-family: var(--font-display); font-weight: 700; font-size: 12px; letter-spacing: .14em; padding: 3px 10px; border-radius: 999px; background: rgba(var(--accent-rgb), .15); color: var(--accent-2); text-transform: uppercase; }
.cprev__stage { position: relative; aspect-ratio: 16 / 9; background: #000; border-radius: 2px; overflow: hidden; }
.cprev__stage canvas { display: block; width: 100%; height: 100%; touch-action: none; cursor: pointer; }
.cprev__stage:fullscreen { aspect-ratio: auto; display: grid; place-items: center; background: #000; }
.cprev__stage:fullscreen canvas { width: min(100vw, 177.78vh); height: auto; aspect-ratio: 16 / 9; }
.cprev__tools, .cprev__actions { display: flex; flex-wrap: wrap; gap: 8px; }
.cprev__actions { justify-content: flex-end; }
.cprev__actions .btn { --h: 46px; padding: 0 18px; font-size: 14px; }
.tool { border: 1px solid var(--line-2); background: transparent; color: var(--text); border-radius: var(--radius); padding: 7px 12px; font: inherit; font-size: 13px; cursor: pointer; }
.tool:hover { border-color: var(--accent); }
.tool--danger:hover { border-color: #ff6d5a; color: #ffb3a8; }
.ctoast { margin: 0; min-height: 20px; font-size: 14px; color: #9ff0c0; text-align: right; }

.mygames { margin-top: 56px; }
.mygames h2 { margin-bottom: 18px; }
.mygames__list { display: grid; gap: 10px; }
.mygame { display: grid; grid-template-columns: 96px 1fr auto; gap: 16px; align-items: center; padding: 10px; border: 1px solid var(--line); border-left: 3px solid var(--hc); border-radius: var(--radius); background: var(--surface); }
.mygame img { width: 96px; aspect-ratio: 16 / 10; object-fit: cover; border-radius: 2px; }
.mygame strong { display: block; }
.mygame__actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
@media (max-width: 640px) { .mygame { grid-template-columns: 72px 1fr; } .mygame img { width: 72px; } .mygame__actions { grid-column: 1 / -1; justify-content: flex-start; } }

.cdialog { max-width: 560px; width: calc(100% - 32px); border: 1px solid var(--line-2); border-radius: var(--radius); background: var(--surface); color: var(--text); padding: 26px; }
.cdialog::backdrop { background: rgba(4, 6, 10, .72); backdrop-filter: blur(4px); }
.cdialog p { color: #cfd5de; }
.sharebox { display: flex; gap: 8px; margin: 14px 0; }
.sharebox input { flex: 1; min-width: 0; height: 46px; padding: 0 12px; background: var(--bg); color: var(--text); border: 1px solid var(--line-2); border-radius: var(--radius); font-size: 13px; }
.sharebox .btn { --h: 46px; padding: 0 16px; font-size: 14px; }
.cdialog__actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }
.cdialog__actions .btn { --h: 42px; padding: 0 16px; font-size: 14px; }

/* Play page */
.play-section { padding: 112px 0 clamp(56px, 8vw, 96px); }
.play { display: grid; gap: 14px; }
.play__stage { border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 0 0 1px rgba(255,255,255,.02), 0 30px 80px rgba(0,0,0,.45); }
.play__bar { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; padding: 14px 18px; border: 1px solid var(--line); border-left: 3px solid var(--hc, var(--accent)); border-radius: var(--radius); background: var(--surface); }
.play__title { display: block; font-family: var(--font-display); font-size: 26px; letter-spacing: .02em; text-transform: uppercase; }
.play__actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.play__actions .btn { --h: 44px; padding: 0 16px; font-size: 14px; }
.play-error { padding: 140px 0 40px; display: grid; gap: 20px; justify-items: start; }
@media (orientation: landscape) and (max-height: 520px) { .play-section { padding-top: 76px; } .play__stage { max-height: calc(100dvh - 90px); aspect-ratio: auto; } .play__stage canvas { height: 100%; width: auto; aspect-ratio: 16 / 9; margin: 0 auto; } }
