/* RescueLine Simulator window - AiBotCup-style: dark navy scoreboard, light control panel, amber accents */
:root {
  --navy: #0b2552; --navy-2: #06122a; --hud: #0c2d52; --hud-2: #133f70; --cyan: #6fd6ff;
  --amber: #ffb000; --blue: #2f6bff; --blue-2: #1d4fcf; --red: #e23c3c; --green: #1ea046;
  --bg: #e9edf2; --panel: #f6f7f9; --line: #d5dae1; --text: #1d2430; --muted: #6b7686;
  --ui: 'Barlow', 'Segoe UI', system-ui, sans-serif; --num: 'Barlow Condensed', 'Arial Narrow', 'Segoe UI', sans-serif;
  --mono: ui-monospace, 'Cascadia Mono', Consolas, Menlo, monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--bg); color: var(--text); font: 14px/1.35 var(--ui); }
button { font: 600 13px var(--ui); cursor: pointer; border: 0; border-radius: 4px; }
select, input { font: 13px var(--ui); }
code { font: 11px var(--mono); color: #4a6fa5; }
[hidden] { display: none !important; }
#app { display: grid; grid-template-rows: 64px 1fr; grid-template-columns: 330px 1fr; height: 100vh; }
#app.collapsed { grid-template-columns: 42px 1fr; }

/* ------------------------------------------------ top bar */
#top { grid-column: 1 / -1; background: linear-gradient(#123063, var(--navy)); color: #fff; display: grid; grid-template-columns: 330px 1fr 330px; align-items: stretch; box-shadow: 0 2px 10px rgba(0,0,0,.35); z-index: 3; }
.brand { display: flex; align-items: center; gap: 10px; padding: 0 14px; }
.brand .logo { width: 40px; height: 40px; border-radius: 50%; background: radial-gradient(circle at 35% 35%, #ffd35a, var(--amber)); color: var(--navy); display: grid; place-items: center; font: 700 16px var(--num); box-shadow: 0 0 0 3px rgba(255,176,0,.25); }
.brand .name { font: 700 19px var(--num); letter-spacing: .3px; }
.brand .sub { color: #a9c3e8; font-size: 12px; }
.board { display: grid; grid-template-columns: 1fr 230px 1fr; }
.team { background: linear-gradient(var(--blue), var(--blue-2)); display: flex; flex-direction: column; align-items: center; justify-content: center; }
.team .score { font: 700 38px/1 var(--num); }
.team .tname { font-size: 12px; opacity: .9; }
.team.right { background: linear-gradient(#174a85, #0f3566); display: grid; grid-template-columns: 1fr 1fr; padding: 4px 10px; gap: 0 10px; align-content: center; }
.team .mini { display: flex; justify-content: space-between; font-size: 12px; color: #cfe2ff; }
.team .mini b { font: 700 16px var(--num); color: #fff; }
.clockbox { background: var(--navy-2); text-align: center; display: flex; flex-direction: column; justify-content: center; }
.clockbox .title { color: var(--amber); font: 700 12px var(--ui); }
.clockbox .clock { font: 700 34px/1 var(--num); letter-spacing: 1px; }
.clockbox .status { color: #9fb6d6; font-size: 12px; }
#feed { font-size: 12px; padding: 6px 12px; overflow: hidden; display: flex; flex-direction: column; justify-content: center; gap: 1px; background: #0a1f45; }
#feed div { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: flex; gap: 6px; align-items: center; }
#feed div::before { content: ""; width: 8px; height: 8px; border-radius: 2px; background: var(--blue); flex: none; }
#feed div.score::before { background: #3ccf7a; } #feed div.lop::before { background: var(--red); } #feed div.warn::before { background: var(--amber); } #feed div.end::before { background: #fff; }

/* ------------------------------------------------ left panel */
#panel { background: var(--panel); border-right: 1px solid var(--line); overflow-y: auto; overflow-x: hidden; }
.ptitle { display: flex; align-items: center; gap: 8px; padding: 8px 12px; font-weight: 700; border-bottom: 1px solid var(--line); background: #fff; position: sticky; top: 0; z-index: 2; }
.ptitle .dot { width: 14px; height: 14px; border-radius: 50%; background: radial-gradient(circle at 35% 35%, #7fb0ff, var(--blue)); flex: none; }
.ptitle span:nth-child(2) { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ptitle button { background: none; font-size: 18px; color: var(--muted); }
#app.collapsed .pbody, #app.collapsed .ptitle span { display: none; }
.pbody { padding: 0 12px 20px; }
.robotcard { margin: 10px 0 4px; }
.robottab { display: flex; align-items: center; gap: 10px; background: linear-gradient(100deg, var(--blue) 70%, var(--blue-2)); color: #fff; padding: 6px 12px; border-radius: 6px 6px 0 0; font-weight: 700; clip-path: polygon(0 0, 100% 0, 94% 100%, 0 100%); }
.robottab svg { width: 44px; height: 22px; fill: none; stroke: #fff; stroke-width: 2.5; }
.ctrl { display: grid; grid-template-columns: 1fr 112px 1fr; gap: 6px; align-items: center; margin-top: 8px; }
.btncol { display: flex; flex-direction: column; border-radius: 6px; overflow: hidden; }
.btncol button { background: linear-gradient(var(--blue), var(--blue-2)); color: #fff; padding: 8px 6px; border-radius: 0; text-align: right; border-bottom: 1px solid rgba(255,255,255,.2); }
.btncol:last-child button { background: linear-gradient(#3a7bd5, #2563c0); text-align: left; }
.btncol button:hover { filter: brightness(1.12); }
.btncol button.on { background: var(--amber); color: var(--navy); }
#joy { width: 112px; height: 112px; border-radius: 50%; background: radial-gradient(circle, #58606b 0, #2c3138 62%, #1b1f24 63%, #3a4049 70%, #23272d 100%); position: relative; cursor: grab; box-shadow: inset 0 0 12px rgba(0,0,0,.6); touch-action: none; }
#joy::before, #joy::after { content: ""; position: absolute; background: rgba(255,255,255,.12); }
#joy::before { left: 50%; top: 8px; bottom: 8px; width: 1px; } #joy::after { top: 50%; left: 8px; right: 8px; height: 1px; }
#knob { position: absolute; width: 34px; height: 34px; left: 39px; top: 39px; border-radius: 50%; background: radial-gradient(circle at 35% 35%, #a8c8ff, var(--blue) 55%, #123b9c); box-shadow: 0 2px 8px rgba(0,0,0,.6); pointer-events: none; }
.progname { font-size: 12px; color: var(--muted); margin: 6px 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.play { display: flex; gap: 6px; align-items: center; }
.round { width: 34px; height: 34px; border-radius: 50%; background: #fff; border: 1px solid var(--line); color: var(--text); font-size: 12px; box-shadow: 0 1px 2px rgba(0,0,0,.1); }
.round:hover { border-color: var(--blue); }
.round.code { background: #1b1f24; color: #fff; font: 700 12px var(--mono); }
.round.active { background: var(--amber); border-color: var(--amber); }
.pill { background: #fff; border: 1px solid var(--line); padding: 6px 10px; border-radius: 16px; }
.pill.on { background: var(--amber); border-color: var(--amber); }
.play select { margin-left: auto; padding: 5px; border: 1px solid var(--line); border-radius: 4px; background: #fff; }
.hint { color: var(--muted); font-size: 12px; margin: 4px 2px; }
.hint.center { text-align: center; }
.sect { font-weight: 700; margin: 14px 0 6px; display: flex; align-items: center; gap: 8px; }
.chip { background: var(--blue); color: #fff; font-size: 10px; padding: 1px 6px; border-radius: 3px; }
.sub2 { font-weight: 600; font-size: 12.5px; margin: 10px 0 4px; }
#minimap { width: 100%; aspect-ratio: 4 / 3; background: #dfe5ec; border: 2px solid #c8d0da; border-radius: 4px; display: block; cursor: crosshair; }
.cams { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.cams figure { margin: 0; background: #000; border-radius: 4px; overflow: hidden; }
.cams img { width: 100%; aspect-ratio: 4 / 3; display: block; background: #222; image-rendering: pixelated; }
.cams figcaption { font-size: 10.5px; color: #cfd6df; padding: 2px 5px; background: #1b1f24; line-height: 1.3; }
.cams figcaption code { color: #8fb4ff; font-size: 10px; }
.live { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: #555; margin-left: 2px; }
.live.on { background: #3ccf7a; box-shadow: 0 0 6px #3ccf7a; }
.srow { display: grid; grid-template-columns: 62px 1fr 46px 118px; gap: 6px; align-items: center; font-size: 12px; margin: 3px 0; }
.srow span { text-align: right; color: #39424f; }
.srow b { font: 700 14px var(--num); text-align: right; }
.srow code { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sbar { height: 8px; background: #fff; border: 1px solid #c9d0d9; border-radius: 1px; position: relative; overflow: hidden; }
.sbar i { position: absolute; top: 0; bottom: 0; left: 0; background: #1b1f24; }
.sbar.mid::after { content: ""; position: absolute; left: 50%; top: 0; bottom: 0; width: 1px; background: #9aa4b1; }
.kv { display: grid; grid-template-columns: auto 1fr auto 1fr; gap: 2px 8px; font-size: 12px; }
.kv span { color: var(--muted); } .kv b { font: 700 14px var(--num); }

/* ------------------------------------------------ arena */
#stage { position: relative; background: #cfd9e3; overflow: hidden; }
#arena, #top2d { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; display: block; user-select: none; cursor: grab; }
#top2d { cursor: default; background: #cfd9e3; }
.views { position: absolute; left: 12px; bottom: 12px; display: flex; gap: 0; border-radius: 4px; overflow: hidden; box-shadow: 0 2px 8px rgba(0,0,0,.25); }
.views button { background: #4a5059; color: #fff; padding: 6px 12px; border-radius: 0; }
.views button.active { background: var(--amber); color: var(--navy); }
.corner { position: absolute; right: 12px; bottom: 12px; display: flex; gap: 8px; }
.corner button { width: 38px; height: 38px; border-radius: 50%; font-size: 18px; box-shadow: 0 2px 8px rgba(0,0,0,.3); }
.orange { background: var(--amber); color: var(--navy); } .dark { background: #2b3038; color: #fff; }
#mission { position: absolute; left: 12px; top: 12px; width: 330px; background: rgba(255,255,255,.95); border-radius: 8px; box-shadow: 0 6px 24px rgba(0,0,0,.25); padding: 10px 12px; font-size: 13px; }
#mission .mt { font: 700 15px var(--num); color: var(--navy); }
#mission .goal { color: #3d4757; margin: 4px 0 6px; }
#mission ul { list-style: none; margin: 0; padding: 0; }
#mission li { display: flex; gap: 8px; align-items: center; padding: 2px 0; }
#mission li i { width: 16px; height: 16px; border-radius: 50%; border: 2px solid #b8c1cc; flex: none; display: grid; place-items: center; font-style: normal; font-size: 10px; color: #fff; }
#mission li.done i { background: var(--green); border-color: var(--green); }
#mission li.done { color: var(--green); font-weight: 600; }
#mission .stars { color: var(--amber); font-size: 20px; letter-spacing: 2px; margin-top: 4px; }
#waitKey { position: absolute; left: 50%; top: 12px; transform: translateX(-50%); background: var(--amber); color: var(--navy); font-weight: 700; padding: 6px 14px; border-radius: 4px; }
#toast { position: absolute; left: 50%; top: 40%; transform: translate(-50%, -50%); background: rgba(11,37,82,.95); color: #fff; padding: 18px 28px; border-radius: 10px; text-align: center; box-shadow: 0 10px 40px rgba(0,0,0,.4); }
#toast .big { font: 700 26px var(--num); color: var(--amber); }
#debugWin, #settings, #picker { position: absolute; background: #fff; border-radius: 8px; box-shadow: 0 10px 40px rgba(0,0,0,.35); overflow: hidden; }
#debugWin { right: 12px; top: 12px; width: 420px; max-height: calc(100% - 80px); display: flex; flex-direction: column; }
.wtitle { background: var(--navy); color: #fff; padding: 6px 10px; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.wtitle .hint { color: #a9c3e8; margin: 0; }
.wtitle button { margin-left: auto; background: none; color: #fff; font-size: 18px; }
#windowsBox { overflow-y: auto; padding: 6px; display: grid; gap: 6px; }
#windowsBox .win { border: 1px solid var(--line); border-radius: 4px; overflow: hidden; }
#windowsBox .wt { background: #eef1f5; font-size: 12px; padding: 2px 6px; font-weight: 600; }
#windowsBox img { width: 100%; display: block; image-rendering: pixelated; background: #000; }
#windowsBox .tb { display: grid; grid-template-columns: 80px 1fr 34px; gap: 4px; align-items: center; font-size: 11px; padding: 1px 6px; }
#settings { right: 12px; bottom: 60px; width: 320px; padding-bottom: 8px; }
#settings label { display: flex; flex-direction: column; font-size: 12px; color: var(--muted); padding: 6px 12px 0; gap: 2px; }
#settings label.check { flex-direction: row; align-items: center; gap: 6px; color: var(--text); }
#settings select { padding: 4px; }
#picker { left: 50%; top: 50%; transform: translate(-50%, -50%); width: 420px; max-height: 70vh; display: flex; flex-direction: column; z-index: 10; }
#picker ul { list-style: none; margin: 0; padding: 6px; overflow-y: auto; }
#picker li { padding: 7px 10px; border-radius: 4px; cursor: pointer; font-family: var(--mono); font-size: 13px; }
#picker li:hover { background: #eaf1ff; }
#picker li.cur { background: var(--amber); }
#picker .hint { padding: 0 10px 10px; }
@media (max-width: 1100px) { #app { grid-template-columns: 290px 1fr; } #top { grid-template-columns: 290px 1fr; } #feed { display: none; } }
@media (max-width: 760px) { #app { grid-template-columns: 1fr; grid-template-rows: 64px 50vh 1fr; } #panel { grid-row: 3; } #stage { grid-row: 2; } #top { grid-template-columns: 1fr; } .brand { display: none; } }

/* ------------------------------------------------ web version: floating code window + loading */
#codeWin { position: fixed; left: 360px; top: 80px; width: min(1100px, calc(100vw - 380px)); height: calc(100vh - 110px); background: #1e1e1e; border-radius: 8px; box-shadow: 0 16px 60px rgba(0,0,0,.55); z-index: 50; display: flex; flex-direction: column; overflow: hidden; resize: both; min-width: 480px; min-height: 260px; }
#codeWin.min { height: 34px !important; min-height: 34px; resize: none; }
#codeWin.max { left: 0 !important; top: 0 !important; width: 100vw !important; height: 100vh !important; border-radius: 0; }
#codeWin .cwbar { height: 34px; background: #0b2552; color: #fff; display: flex; align-items: center; gap: 8px; padding: 0 8px 0 12px; cursor: move; user-select: none; flex: none; }
#codeWin .cwbar b { font: 700 15px var(--num); }
#codeWin .cwbar span { color: #a9c3e8; font-size: 12px; }
#codeWin .cwbar .sp { flex: 1; }
#codeWin .cwbar button { background: rgba(255,255,255,.12); color: #fff; width: 28px; height: 24px; padding: 0; border-radius: 4px; }
#codeWin .cwbar button:hover { background: rgba(255,255,255,.25); }
#codeWin .cwbar button.amber { background: var(--amber); color: var(--navy); width: auto; padding: 0 10px; }
#codeWin iframe { flex: 1; width: 100%; border: 0; background: #1e1e1e; }
#arena3d { position: absolute; inset: 0; width: 100%; height: 100%; display: block; cursor: grab; }
#loading { position: fixed; inset: 0; background: linear-gradient(135deg, #0b2552, #133f70); color: #fff; z-index: 100; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; }
#loading .logo2 { width: 76px; height: 76px; border-radius: 50%; background: radial-gradient(circle at 35% 35%, #ffd35a, var(--amber)); color: var(--navy); display: grid; place-items: center; font: 700 30px var(--num); animation: pulse 1.6s infinite; }
#loading .t { font: 700 26px var(--num); }
#loading .msg { color: #a9c3e8; }
#loading .bar2 { width: 280px; height: 6px; background: rgba(255,255,255,.15); border-radius: 3px; overflow: hidden; }
#loading .bar2 i { display: block; height: 100%; width: 40%; background: var(--amber); animation: slide 1.2s infinite ease-in-out; }
@keyframes slide { 0% { transform: translateX(-100%); } 100% { transform: translateX(260%); } }
@keyframes pulse { 50% { transform: scale(1.06); } }

/* ------------------------------------------------ map generator (left panel) */
.mapgenbtn { display: flex; align-items: center; gap: 10px; width: 100%; margin-top: 6px; background: linear-gradient(100deg, var(--amber) 70%, #ffc94a); color: var(--navy); padding: 7px 12px; border-radius: 6px; font-weight: 700; text-align: left; }
.mapgenbtn svg { width: 22px; height: 22px; fill: none; stroke: var(--navy); stroke-width: 2; flex: none; }
.mapgenbtn b { margin-left: auto; font-weight: 600; font-size: 12px; opacity: .75; max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mapgenbtn i { font-style: normal; transition: transform .15s; }
.mapgenbtn[aria-expanded="true"] i { transform: rotate(180deg); }
.mapgenbtn:hover { filter: brightness(1.05); }
#mapGen { background: #fff; border: 1px solid #d6dde8; border-top: 0; border-radius: 0 0 6px 6px; padding: 10px 12px; display: flex; flex-direction: column; gap: 8px; font-size: 13px; }
#mapGen label { display: flex; flex-direction: column; gap: 3px; font-weight: 600; color: #33445e; }
#mapGen select { padding: 5px 6px; border: 1px solid #c9d3e2; border-radius: 5px; font: 13px inherit; }
#mapGen .mgrow { display: flex; gap: 10px; align-items: flex-end; }
#mapGen .mgrow > label:first-child { flex: 1; }
#mapGen label.chk { flex-direction: row; align-items: center; gap: 5px; font-weight: 500; padding-bottom: 6px; }
#mapGen .mggo { background: linear-gradient(var(--blue), var(--blue-2)); color: #fff; padding: 8px; border-radius: 6px; font-weight: 700; }
#mapGen .mggo:disabled { opacity: .6; }
#mapGen .mginfo { font-size: 12px; color: #5b6b82; min-height: 0; }
#mapGen .mgtwo { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
#mapGen .mggo.alt { background: linear-gradient(#2e9d4f, #23803f); }

/* ------------------------------------------------ field designer (left panel + over the arena) */
#designHost { position: absolute; inset: 0; z-index: 4; background: #cfd9e3; }
#designCv { width: 100%; height: 100%; display: block; cursor: crosshair; }
#dPanel { display: flex; flex-direction: column; gap: 8px; }
#dPanel .dhead { display: flex; align-items: center; font-weight: 700; color: var(--navy); }
#dPanel .dhead button { margin-left: auto; width: 26px; height: 26px; border-radius: 50%; background: #e9eef5; color: var(--navy); font-size: 16px; padding: 0; }
#dPanel input { padding: 5px 6px; border: 1px solid #c9d3e2; border-radius: 5px; font: 13px inherit; width: 100%; box-sizing: border-box; }
#dPanel .mgrow label { flex: 1; }
#dPanel .dsmall { background: #e9eef5; color: var(--navy); padding: 6px 10px; border-radius: 5px; font-weight: 600; }
.dtools { display: grid; grid-template-columns: repeat(4, 1fr); gap: 3px; }
.dtools button { background: #e9eef5; color: var(--navy); padding: 5px 2px; border-radius: 4px; font-size: 11px; font-weight: 600; }
.dtools button.active { background: var(--blue); color: #fff; }
.dpalette { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; max-height: 300px; overflow-y: auto; padding-right: 2px; }
.dpalette .dtile { position: relative; aspect-ratio: 1; padding: 0; border: 2px solid transparent; border-radius: 3px; overflow: hidden; background: #fff; }
.dpalette .dtile img { width: 100%; height: 100%; display: block; }
.dpalette .dtile.active { border-color: var(--blue); }
.dpalette .dtile span { position: absolute; left: 0; right: 0; bottom: 0; font-size: 8px; line-height: 1.15; background: rgba(0,0,0,.6); color: #fff; padding: 1px 2px; }
.mginfo .bad { color: #c62828; }
.mginfo .good { color: #2e7d32; }
