/* Cuby Code: game screens. Generic pieces (buttons, HUD, modal, toast) are in base.css, from Cuby Learn. */
:root { --move: #4aa8ff; --arm: #f0a035; --flow: #b37bff; --cond: #1fb3b0; --gold: #ffd76a; }
#sky[data-bg="starmap"]::after { background: linear-gradient(180deg, #0b0a1fcc 0%, #0b0a1f88 40%, #0b0a1fcc 100%); }
#app { padding-bottom: calc(var(--safe-b) + 30px); }   /* the brand badge has its own strip */

/* ---------- title ---------- */
.title-screen { gap: 10px; }
.cuby-title { height: clamp(90px, 22vmin, 190px); filter: drop-shadow(0 10px 18px #000a); }
.subtitle { font-weight: 800; color: var(--gold); letter-spacing: 1px; }
.tagline { margin: 0; max-width: 34em; color: var(--muted); }
.langs { display: flex; gap: 6px; justify-content: center; }
.lang { padding: 6px 14px; border-radius: 999px; border: 2px solid #ffffff33; font-weight: 800; }
.lang.on { background: var(--gold); color: #1c1940; border-color: var(--gold); }
.story { font-size: 1.1em; margin: 0; }

/* ---------- station ---------- */
.station { display: flex; flex-direction: column; gap: var(--gap); }
.station-hero { display: flex; align-items: center; justify-content: center; gap: var(--gap); flex-wrap: wrap; }
.station-hero .col { display: flex; flex-direction: column; gap: 12px; }
.station-hero small { font-weight: 600; font-size: .7em; }
.cuby-station { height: clamp(110px, 26vmin, 220px); filter: drop-shadow(0 10px 18px #000a); }
.modules { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 8px; margin-top: 8px; }
.module { display: flex; flex-direction: column; align-items: center; text-align: center; padding: 8px 4px; border-radius: 14px; background: #ffffff0d; line-height: 1.15; opacity: .45; filter: grayscale(1); }
.module.on { opacity: 1; filter: none; background: #ffd76a1f; border: 1px solid #ffd76a55; }
.module .mi { font-size: 1.8em; }
.card { background: #14113ae6; border: 1px solid #ffffff2a; border-radius: var(--r); padding: 12px 14px; }

/* ---------- star map, site ---------- */
.sites { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 330px), 1fr)); gap: 10px; align-content: start; }
.site { display: flex; align-items: center; gap: 12px; padding: 10px; border-radius: 20px; background: #14113ae6; border: 1px solid #ffffff2a; text-align: start; }
.site.locked { opacity: .55; }
.site .planet { position: relative; isolation: isolate; flex: none; width: 64px; height: 64px; border-radius: 50%; overflow: hidden; display: grid; place-items: center; font-weight: 800; font-size: 1.4em; color: #fff;
  text-shadow: 0 2px 4px #000; box-shadow: inset -10px -10px 20px #0009, 0 0 18px #6ee7ff44; }
.site .planet::before { content: ''; position: absolute; inset: 0; z-index: -1; background: var(--ground) center/cover; filter: var(--gf, none); }
.sinfo { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.soon { color: var(--gold); }
.idea { flex: none; }
.missions { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 10px; align-content: start; }
.mcard { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 10px 6px; border-radius: 18px; background: #14113ae6; border: 2px solid #ffffff2a; }
.mcard .num { font-size: 1.6em; } .mcard .mstars { color: var(--gold); letter-spacing: 2px; }
.mcard.done { border-color: #46d36a88; } .mcard.locked { opacity: .45; }

/* ---------- mission ---------- */
.mission { gap: 6px; }
.brief { display: flex; align-items: center; gap: 8px; flex: none; }
.cuby-mini { height: clamp(48px, 10vmin, 84px); flex: none; filter: drop-shadow(0 6px 10px #0008); }
.msg { flex: 1; background: var(--card); color: var(--card-ink); border-radius: var(--r); padding: .45em .8em; font-size: .9em; line-height: 1.3; min-height: 48px; display: flex; align-items: center; max-height: 30vh; overflow: auto; }
.msg pre.code { background: #1c1940; color: #e8e6ff; margin: 6px 0 0; }
.mbody { flex: 1; min-height: 0; display: grid; gap: 8px; grid-template-columns: minmax(0, 1fr) minmax(300px, 1fr); }
.feed-col { min-height: 0; display: flex; flex-direction: column; gap: 6px; }
.tabs { display: flex; gap: 6px; flex: none; }
.tab { padding: 4px 12px; border-radius: 999px; background: #ffffff14; font-weight: 800; font-size: .85em; }
.tab.on { background: var(--gold); color: #1c1940; }
.feed { flex: 1; min-height: 0; display: grid; place-items: center; }
.console { min-height: 0; display: flex; flex-direction: column; gap: 6px; background: #14113ae6; border: 1px solid #ffffff2a; border-radius: var(--r); padding: 8px; }
.runbar { display: flex; gap: 8px; align-items: center; flex: none; }
.runbar .send { flex: 1; min-height: 50px; }

@media (orientation: portrait), (max-width: 700px) {
  .mbody { grid-template-columns: 1fr; grid-template-rows: minmax(150px, 40%) minmax(0, 1fr); }
}

/* board (camera feed) */
.board { --c: 56px; display: grid; grid-template-columns: repeat(var(--cols), var(--c)); grid-auto-rows: var(--c); gap: 3px; padding: 6px; border-radius: 16px;
  background: #0b0a1fcc; box-shadow: 0 10px 30px #0009, inset 0 0 0 2px #6ee7ff33; overflow: hidden; position: relative; }
.board::after { content: 'LIVE · R-7'; position: absolute; left: 8px; top: 4px; font-size: 10px; font-weight: 800; color: #ff6b6b; letter-spacing: 1px; text-shadow: 0 1px 2px #000; z-index: 3; pointer-events: none; }
.cell { position: relative; border-radius: 6px; }
.cell::before { content: ''; position: absolute; inset: 0; border-radius: 6px; background: var(--ground) center/cover; filter: var(--gf, none); }
.board.moon, .planet.moon { --gf: grayscale(1) brightness(1.05) contrast(1.05); }
.board.europa, .planet.europa { --gf: hue-rotate(170deg) saturate(.55) brightness(1.25); }
.board.storm, .planet.storm { --gf: sepia(.6) saturate(.8) brightness(1.05); }
.board.io, .planet.io { --gf: hue-rotate(-25deg) saturate(1.6) brightness(.8); }
.board.factory, .planet.factory, .board.dark, .planet.dark { --gf: grayscale(.6) brightness(.6); }
.cell .tile-img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; border-radius: 6px; }
.cell .tile-img.rock, .cell .tile-img.beacon, .cell .tile-img.lander { inset: 8%; width: 84%; height: 84%; object-fit: contain; }
.cell .item { position: absolute; inset: 16%; width: 68%; height: 68%; object-fit: contain; animation: glow 1.6s ease-in-out infinite; }
@keyframes glow { 50% { filter: drop-shadow(0 0 8px #ffd166); } }
.rover { position: absolute; inset: 1%; transition: transform .2s; z-index: 2; }
.rover > img { position: relative; width: 100%; height: 100%; object-fit: contain; filter: drop-shadow(0 3px 4px #0009); }
.rover > .beam { position: absolute; left: 14%; right: 14%; bottom: 88%; height: 100%; pointer-events: none; clip-path: polygon(30% 100%, 70% 100%, 100% 0, 0 0);
  background: linear-gradient(to top, #fff3a0f2, #ffe06aa0 50%, #ffe06a30); animation: beam 1.6s ease-in-out infinite; }
@keyframes beam { 50% { opacity: .75; } }
/* (the old yellow arrow is gone: R-7's own art shows its front) */
.rover > .nose-unused { position: absolute; left: 50%; top: -14%; width: 34%; aspect-ratio: 1.3; transform: translateX(-50%); background: #ffd23f; clip-path: polygon(50% 0, 100% 100%, 0 100%); filter: drop-shadow(0 0 4px #000); }
.rover .carry { position: absolute; right: -8%; bottom: -8%; width: 46%; height: 46%; object-fit: contain; filter: drop-shadow(0 0 6px #ffd166); }
.rover.fail { animation: shake .3s 2; } .rover.fail.fell { animation: fall .7s forwards; }
@keyframes shake { 25% { translate: -3px 0; } 75% { translate: 3px 0; } }
@keyframes fall { to { scale: .2; opacity: .2; } }

/* editor */
.etools { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; flex: none; }
.mem { font-weight: 800; padding: 2px 10px; border-radius: 999px; background: #ffffff14; }
.mem.full { background: #ff6b6b44; color: #ffd0d0; }
.tb { padding: 4px 10px; border-radius: 999px; background: #ffffff14; font-weight: 700; font-size: .8em; min-height: 34px; }
.tb.on { background: var(--gold); color: #1c1940; }
.prog-wrap { flex: 1; min-height: 60px; overflow: auto; background: #0b0a1f99; border-radius: 12px; padding: 6px; }
.prog .empty { margin: 4px 6px; }
.blist { display: flex; flex-wrap: wrap; align-items: center; row-gap: 4px; }
.blist > .blk.box { flex-basis: 100%; }
.slot { width: 10px; height: 38px; border-radius: 6px; padding: 0; flex: none; }
.blist > .slot:last-child { flex: 1; min-width: 24px; }
.slot.on { width: 14px; background: repeating-linear-gradient(180deg, #ffd76a 0 8px, transparent 8px 13px); animation: blink 1s ease-in-out infinite; }
.blist > .slot.on:last-child { flex: 0 0 14px; }
@keyframes blink { 50% { opacity: .45; } }
.blk { position: relative; border-radius: 10px; font-weight: 800; font-size: .88em; }
.blk.cmd { display: flex; align-items: center; justify-content: center; gap: 4px; width: 42px; height: 38px; color: #10102a; }
.blk.cmd b { font-size: 1.25em; }
.blk.cmd .del { position: absolute; top: -12px; right: -10px; width: 26px; height: 26px; z-index: 2; font-size: 13px; }
.blk.move { background: linear-gradient(#9fd0ff, var(--move)); } .blk.arm { background: linear-gradient(#ffd08f, var(--arm)); }
.blk.box { border: 2px solid var(--flow); background: #b37bff22; padding: 0 0 4px 0; margin: 2px 0; }
.blk.box.if, .blk.box.while { border-color: var(--cond); background: #1fb3b022; }
.blk.box > .blist { margin-inline-start: 18px; margin-inline-end: 6px; }
.blk .head { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; padding: 4px 8px; min-height: 36px; }
.blk.box.rep > .head { background: var(--flow); color: #fff; border-radius: 8px 8px 0 0; }
.blk.box.if > .head, .blk.box.while > .head { background: var(--cond); color: #fff; border-radius: 8px 8px 0 0; }
.blk .head.else { border-radius: 0 !important; margin-top: 4px; min-height: 26px; padding: 2px 8px; }
.num { width: 30px; height: 30px; border-radius: 50%; background: #ffffff33; font-weight: 800; color: #fff; }
.blk .n { min-width: 1.4em; text-align: center; font-size: 1.15em; }
.cond { display: inline-flex; gap: 4px; }
.cond button { padding: 2px 8px; border-radius: 999px; background: #ffffff33; color: #fff; font-weight: 800; min-height: 30px; }
.cond .not { opacity: .5; text-decoration: line-through; } .cond .not.on { opacity: 1; text-decoration: none; background: #ff6b6b; }
.blk.sel { outline: 3px solid #fff; outline-offset: 1px; }
.blk.now { outline: 3px solid var(--gold); box-shadow: 0 0 14px var(--gold); }
.blk.bad { outline: 3px solid #ff6b6b; box-shadow: 0 0 14px #ff6b6b; }
.del { margin-inline-start: auto; width: 32px; height: 32px; border-radius: 50%; background: #ff6b6b; color: #fff; }
pre.code { margin: 0; font: 600 .82em/1.45 ui-monospace, Menlo, Consolas, monospace; color: #e8e6ff; white-space: pre; text-align: left; }
.palette { display: grid; grid-template-columns: repeat(auto-fit, minmax(62px, 1fr)); gap: 6px; flex: none; }
.pb { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0; min-height: 52px; border-radius: 12px; color: #10102a; font-weight: 800; line-height: 1.05; padding: 3px; box-shadow: 0 3px 0 #0006; }
.pb small { font-size: .62em; }
.pb.move { background: linear-gradient(#cde7ff, var(--move)); } .pb.arm { background: linear-gradient(#ffe2b8, var(--arm)); }
.pb.flow { background: linear-gradient(#e2cfff, var(--flow)); color: #fff; }
.pb[data-k="if"], .pb[data-k="while"] { background: linear-gradient(#bff3f1, var(--cond)); }
.pb:active { transform: translateY(2px); box-shadow: 0 1px 0 #0006; }
.pb:disabled { opacity: .4; }
.gold-text { color: var(--gold); font-weight: 800; }

/* short landscape phones */
@media (max-height: 430px) and (orientation: landscape) {
  .console { display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-rows: auto minmax(0, 1fr) auto; }
  .etools, .runbar { grid-column: 1 / -1; }
  .prog-wrap { grid-column: 1; grid-row: 2; }
  .palette { grid-column: 2; grid-row: 2; grid-template-columns: repeat(3, 40px); grid-auto-rows: 40px; align-content: start; overflow: auto; }
  .palette .pb { min-height: 0; }
  .tb { min-height: 30px; padding: 2px 8px; } .mem { padding: 1px 8px; }
  .brief .cuby-mini { height: 40px; } .msg { min-height: 36px; font-size: .8em; padding: .3em .6em; }
  .hud { min-height: 40px; } .icon-btn { width: 40px; height: 40px; font-size: 18px; }
  .pb { min-height: 40px; } .pb small { display: none; } .runbar .send { min-height: 40px; }
  .blk.cmd { height: 32px; width: 36px; } .slot { height: 32px; } .blk .head { min-height: 30px; padding-block: 2px; }
  .brief .cuby-mini { display: none; }
}

/* SVG control icons (src/icons.js) */
.ic { display: block; width: 30px; height: 30px; flex: none; }
.ic.sm { width: 20px; height: 20px; } .ic.md { width: 26px; height: 26px; }
.pb .ic { width: 32px; height: 32px; }
.blk.cmd .ic { width: 30px; height: 30px; }
.blk .head .ic { color: #fff; }
.tb { display: inline-flex; align-items: center; gap: 4px; }
.icon-btn .ic { margin: auto; color: var(--ink); }
.send .ic { color: #10102a; }
@media (max-height: 430px) and (orientation: landscape) { .pb .ic { width: 28px; height: 28px; } .blk.cmd .ic { width: 24px; height: 24px; } }

/* quick game types */
.drill-screen .brief { position: relative; }
.next-round { flex: none; min-height: 44px; }
.progress { display: flex; gap: 6px; justify-content: center; flex: none; }
.progress i { width: 26px; height: 8px; border-radius: 4px; background: #ffffff26; } .progress i.ok { background: var(--good); } .progress i.now { background: var(--gold); }
.dfield { flex: 1; min-height: 0; display: flex; }
.drill { flex: 1; min-height: 0; display: grid; gap: 8px; }
.drill.two { grid-template-columns: minmax(0, 1fr) minmax(260px, 1fr); }
.drill .feed, .drill .feed-col { min-height: 0; }
.drill .console pre.code { flex: none; max-height: 30%; overflow: auto; background: #0b0a1f99; border-radius: 10px; padding: 6px 8px; }
.cell.pick::after { position: absolute; inset: 0; border-radius: 6px; box-shadow: inset 0 0 0 4px var(--gold), 0 0 14px var(--gold); z-index: 3; }
.cell.answer::after { content: ''; position: absolute; inset: 0; border-radius: 6px; box-shadow: inset 0 0 0 4px var(--good), 0 0 14px var(--good); z-index: 3; }
.board.pickable .cell { cursor: pointer; transition: transform .12s, filter .12s; }
.board.pickable .cell:hover { transform: scale(1.06); filter: brightness(1.15); z-index: 2; box-shadow: 0 0 0 3px #ffd76acc; }
.board.pickable .cell:active { transform: scale(.96); }
.cell.pick::before { filter: brightness(1.2) sepia(.4) hue-rotate(5deg); }
.cell.pick::after { content: '📍'; display: grid; place-items: start end; padding: 2px 4px; font-size: calc(var(--c) * .32); }
.blk.tappable { cursor: pointer; } .blk.tappable:hover { filter: brightness(1.1); }
.blk.cmd.tappable, .blk.tappable > .head { box-shadow: 0 0 0 2px #ffffff55; }
.chipc { padding: 2px 8px; border-radius: 999px; background: #ffffff33; font-weight: 800; } .chipc.not { background: #ff6b6b; }
.fixes { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.fix { display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: 14px; background: #fff; color: #1c1940; font-weight: 800; min-height: 48px; }
.drill.loop { grid-template-rows: auto minmax(0, 1fr); }
.flatbox { flex: none; } .flatbox .prog-wrap { max-height: 120px; }
.options { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 8px; overflow: auto; align-content: start; }
.option { display: flex; flex-direction: column; gap: 6px; padding: 8px; border-radius: 16px; background: #14113ae6; border: 2px solid #ffffff33; text-align: start; }
.option pre.code { font-size: .72em; opacity: .8; }
.option.good { border-color: var(--good); box-shadow: 0 0 16px #46d36a88; } .option.bad { border-color: var(--bad); opacity: .55; }
.drill.sortd { place-items: center; align-content: center; text-align: center; }
.cargo { --u: min(64px, calc((100vw - 48px) / (var(--n) * 1.75))); display: flex; align-items: flex-end; justify-content: center; gap: 3px; flex-wrap: nowrap; padding: 12px; border-radius: 16px; background: linear-gradient(transparent 70%, #ffffff14 70%); }
.crate { width: calc(var(--u) * var(--s)); height: calc(var(--u) * var(--s)); min-width: 26px; min-height: 26px; flex: none; border-radius: 8px; display: grid; place-items: center;
  background: linear-gradient(135deg, #e7b46a, #b77a2c); border: 3px solid #6b4416; box-shadow: inset 0 0 0 3px #f6d39a55, 0 4px 0 #0006; font-weight: 800; font-size: 1.2em; color: #3a2408; transition: transform .2s; }
.crate.done { background: linear-gradient(135deg, #9df0b3, #3cc06a); border-color: #1b7d3a; }
.swap { width: max(26px, calc(var(--u) * .55)); height: max(26px, calc(var(--u) * .55)); flex: none; padding: 0; font-size: .8em; border-radius: 50%; background: #ffffff1f; border: 2px solid #ffffff44; font-weight: 800; align-self: center; }
@media (orientation: portrait), (max-width: 700px) {
  .drill.two { grid-template-columns: 1fr; grid-template-rows: minmax(140px, 45%) minmax(0, 1fr); }
}
@media (max-height: 430px) and (orientation: landscape) { .progress i { height: 5px; } .drill .console pre.code { display: none; } }
.option .blk.cmd { width: 32px; height: 30px; } .option .blk.cmd .ic { width: 24px; height: 24px; }
.option .blk .head { min-height: 26px; padding: 2px 6px; font-size: .9em; } .option .blk.box > .blist { margin-inline-start: 10px; }
@media (max-height: 430px) and (orientation: landscape) { .option pre.code { display: none; } .flatbox .prog-wrap { max-height: 60px; } }

/* R-7 hero art */
.title-art { display: flex; align-items: flex-end; justify-content: center; gap: 4px; }
.r7-hero { height: clamp(80px, 20vmin, 170px); filter: drop-shadow(0 10px 18px #000a); animation: idle 3s ease-in-out infinite; }
.r7-station { height: clamp(90px, 22vmin, 190px); filter: drop-shadow(0 10px 18px #000a); animation: idle 3s ease-in-out infinite; }
@keyframes idle { 50% { transform: translateY(-4px) rotate(-1deg); } }
@media (max-height: 430px) { .station-hero .r7-station { display: none; } }
.title-screen { overflow-y: auto; justify-content: safe center; }
@media (max-height: 430px) and (orientation: landscape) {
  .title-screen { gap: 4px; } .cuby-title, .r7-hero { height: 60px; } .title-screen h1 { font-size: 30px; } .tagline { display: none; }
  .title-screen .btn.big { min-height: 48px; font-size: 1.05em; } .title-screen .btn.ghost { min-height: 40px; }
}

/* world landscapes (Gemini, assets/prompts/worlds.json) */
#sky[data-bg="moon"] { background-image: url(https://cdn.digitalarabians.xyz/games/cuby-code/v1/game/bg/moon.webp); background-position: center bottom; }
#sky[data-bg="mars"] { background-image: url(https://cdn.digitalarabians.xyz/games/cuby-code/v1/game/bg/mars.webp); background-position: center bottom; }
#sky[data-bg="europa"] { background-image: url(https://cdn.digitalarabians.xyz/games/cuby-code/v1/game/bg/europa.webp); background-position: center bottom; }
#sky[data-bg="storm"] { background-image: url(https://cdn.digitalarabians.xyz/games/cuby-code/v1/game/bg/storm.webp); background-position: center bottom; }
#sky[data-bg="moon"]::after, #sky[data-bg="mars"]::after, #sky[data-bg="europa"]::after, #sky[data-bg="storm"]::after { background: linear-gradient(180deg, #0b0a1fd9 0%, #0b0a1f99 45%, #0b0a1f80 100%); }
.site .planet.land::before { filter: none; background-size: 260%; background-position: 50% 80%; }
.board.moon .tile-img.crater { filter: grayscale(1) brightness(1.1); }
.board.europa .tile-img.crater { filter: hue-rotate(170deg) saturate(.6) brightness(1.15); }

.blist.ro { gap: 6px; padding: 2px; }
