/* The online version's menus: the game's own fonts, and the Astro sidebar's orange and
   brushed-metal look. */

@font-face { font-family: 'NissanD'; src: url('../../assets/fonts/683_NissanD.ttf'); font-weight: 400; }
@font-face { font-family: 'NissanD'; src: url('../../assets/fonts/1641_NissanD.ttf'); font-weight: 700; }
@font-face { font-family: 'Martian'; src: url('../../assets/fonts/4870_Martian.ttf'); }

:root {
  --orange-hi: #ffc15a;
  --orange: #ff8a00;
  --orange-lo: #c65400;
  --metal-hi: #f2f2f2;
  --metal: #b9bcc0;
  --metal-lo: #6d7176;
  --ink: #fff;
  --ink-dim: #c9c9c9;
  --panel: rgba(12, 12, 14, 0.78);
  --edge: rgba(255, 255, 255, 0.14);
  --glow: 0 0 3px #000, 0 0 6px #000;
}

.ui {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: none;
  color: var(--ink);
  font: 400 15px/1.35 'NissanD', 'Arial Black', Arial, sans-serif;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  background: #000 url('../../assets/online/horizon.jpg') center 30% / cover no-repeat;
  overflow: hidden;
  user-select: none;
}
.ui.shown { display: block; }
.ui::before {
  /* Deepen the sky toward the edges, and keep text readable over the glow. */
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at 50% 38%, rgba(0, 0, 0, 0) 0%, rgba(0, 0, 0, 0.35) 55%, rgba(0, 0, 0, 0.85) 100%);
  pointer-events: none;
}

.screen {
  position: absolute;
  inset: 0;
  display: none;
  padding: max(16px, 3vh) 16px 16px;
  box-sizing: border-box;
  overflow-y: auto;
  /* (a finger's scroll kept to the screen, with the phone's own glide on older iPhones) */
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}
.screen.active { display: flex; flex-direction: column; align-items: center; }
/* (a screen's parts keep their height and the screen scrolls, rather than being squeezed into
   the window, where a panel -- which hides what overflows it -- would lose its bottom) */
.screen > * { flex-shrink: 0; }
/* The menus' scrollbars, always there to see (not only while scrolling), in the menus' colours. */
.screen, .panel.ingame, .chatlog { scrollbar-width: thin; scrollbar-color: var(--orange) rgba(0, 0, 0, 0.35); }

/* ---- the title --------------------------------------------------------------------------- */

.logo { text-align: center; margin: 2vh 0 3vh; position: relative; z-index: 1; }
.logo .script {
  /* The game's alien script, as decoration. */
  font: 400 clamp(14px, 2.2vw, 24px)/1 'Martian', sans-serif;
  letter-spacing: 0.12em;
  color: var(--orange-hi);
  opacity: 0.75;
  text-transform: none;
  text-shadow: 0 0 8px rgba(255, 138, 0, 0.8);
  margin-bottom: 0.5em;
}
.logo .l1 {
  font: 700 clamp(34px, 7.5vw, 84px)/0.95 'NissanD', sans-serif;
  letter-spacing: 0.06em;
  color: #fff;
  text-shadow: 0 0 18px rgba(255, 138, 0, 0.9), 0 3px 0 var(--orange-lo), 0 5px 10px #000;
}
.logo .l2 {
  font: 700 clamp(22px, 4.6vw, 48px)/1.1 'NissanD', sans-serif;
  letter-spacing: 0.18em;
  background: linear-gradient(180deg, var(--orange-hi), var(--orange) 55%, var(--orange-lo));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 2px 2px #000);
}
.logo .l3 {
  display: inline-block;
  margin-top: 0.6em;
  padding: 0.25em 1.1em 0.2em;
  font: 700 clamp(13px, 1.9vw, 19px)/1 'NissanD', sans-serif;
  letter-spacing: 0.35em;
  color: #fff;
  background: linear-gradient(180deg, var(--orange-hi), var(--orange) 45%, var(--orange-lo));
  border-radius: 999px;
  box-shadow: 0 2px 0 #6a2d00, 0 4px 12px rgba(0, 0, 0, 0.6);
  text-shadow: 0 1px 1px rgba(0, 0, 0, 0.6);
}

.chars { position: absolute; inset: auto 0 0 0; height: 0; pointer-events: none; }
.chars img { position: fixed; bottom: 2vh; height: min(38vh, 320px); filter: drop-shadow(0 6px 10px rgba(0, 0, 0, 0.7)); }
.chars .astro { left: max(2vw, 8px); }
.chars .alien { right: max(2vw, 8px); }
@media (max-width: 720px), (max-height: 520px) { .chars { display: none; } }

/* ---- buttons ----------------------------------------------------------------------------- */

.menu { display: flex; flex-direction: column; gap: 12px; width: min(340px, 100%); position: relative; z-index: 1; }

.btn {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 18px 11px 20px;
  font: 700 19px/1 'NissanD', sans-serif;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #1c1c1c;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.6);
  background: linear-gradient(180deg, var(--metal-hi) 0%, #d7d9dc 42%, var(--metal) 58%, #e3e4e6 100%);
  border: 0;
  border-radius: 6px 18px 6px 18px;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.35), inset 0 2px 0 rgba(255, 255, 255, 0.8), 0 3px 0 #3a3a3a, 0 6px 14px rgba(0, 0, 0, 0.55);
  cursor: pointer;
}
.btn::after {
  /* The game's orange chevron. */
  content: '';
  width: 14px;
  height: 22px;
  flex: none;
  background: linear-gradient(180deg, var(--orange-hi), var(--orange) 50%, var(--orange-lo));
  clip-path: polygon(0 0, 45% 0, 100% 50%, 45% 100%, 0 100%, 55% 50%);
}
.btn:hover:not(:disabled), .btn:focus-visible { filter: brightness(1.08); box-shadow: inset 0 0 0 2px var(--orange), inset 0 2px 0 rgba(255, 255, 255, 0.8), 0 3px 0 #3a3a3a, 0 6px 16px rgba(255, 120, 0, 0.35); outline: none; }
.btn:active:not(:disabled) { transform: translateY(2px); box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.35), 0 1px 0 #3a3a3a; }
.btn:disabled { cursor: default; color: #666; text-shadow: none; filter: grayscale(1) brightness(0.75); }
.btn small { font-size: 11px; letter-spacing: 0.12em; color: var(--orange-lo); margin-left: auto; }
.btn.small { padding: 8px 14px 7px 16px; font-size: 15px; }
.btn.primary { background: linear-gradient(180deg, var(--orange-hi) 0%, var(--orange) 50%, var(--orange-lo) 100%); color: #fff; text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6); }
.btn.primary::after { background: linear-gradient(180deg, #fff, #ffe2b8); }

.footnote { margin-top: auto; padding-top: 18px; font-size: 11px; color: var(--ink-dim); text-align: center; text-shadow: var(--glow); position: relative; z-index: 1; text-transform: none; letter-spacing: 0; }
/* A phone on its side (a short, wide window): the title beside the buttons, all of it in view
   with nothing to scroll. */
@media (orientation: landscape) and (max-height: 640px) {
  .screen.main.active { display: grid; grid-template-columns: minmax(0, 1fr) minmax(190px, 300px); grid-template-rows: minmax(0, 1fr) auto;
    align-items: center; column-gap: 5vw; padding: 10px max(16px, env(safe-area-inset-right)) 6px max(16px, env(safe-area-inset-left)); }
  .screen.main .logo { grid-column: 1; grid-row: 1; margin: 0; justify-self: center; max-width: 100%; }
  .screen.main .chars { display: none; }
  .screen.main .logo .script { font-size: min(2.2vw, 4.5vh); }
  .screen.main .logo .l1 { font-size: min(5.6vw, 15vh); }
  .screen.main .logo .l2 { font-size: min(3.5vw, 9.5vh); }
  .screen.main .logo .l3 { font-size: min(1.9vw, 4vh); }
  .screen.main .menu { grid-column: 2; grid-row: 1; width: 100%; gap: min(8px, 1.6vh); }
  .screen.main .menu .btn { padding: min(10px, 2.2vh) 14px min(9px, 2vh) 16px; font-size: min(17px, 4.4vh); }
  .screen.main .menu .btn::after { height: min(20px, 4.8vh); width: 12px; }
  .screen.main .footnote { grid-column: 1 / -1; grid-row: 2; padding-top: 4px; font-size: 10px; }
}

/* ---- panels ------------------------------------------------------------------------------ */

.panel {
  position: relative;
  z-index: 1;
  background: var(--panel);
  border: 1px solid var(--edge);
  border-radius: 10px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6);
  overflow: hidden;
}
.panel > h2 {
  margin: 0;
  padding: 9px 14px 7px;
  font: 700 16px/1 'NissanD', sans-serif;
  letter-spacing: 0.14em;
  color: #fff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6);
  background: linear-gradient(180deg, var(--orange-hi), var(--orange) 50%, var(--orange-lo));
}
.panel > .body { padding: 12px 14px 14px; }

.titlebar { display: flex; align-items: center; gap: 14px; width: min(1100px, 100%); margin-bottom: 14px; position: relative; z-index: 1; }
.titlebar h1 { margin: 0; font: 700 clamp(22px, 3.2vw, 34px)/1 'NissanD', sans-serif; letter-spacing: 0.14em; text-shadow: 0 0 12px rgba(255, 138, 0, 0.7), var(--glow); }
.titlebar .spacer { flex: 1; }

/* ---- the lobby --------------------------------------------------------------------------- */

.lobby-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; width: min(1100px, 100%); position: relative; z-index: 1; }
@media (max-width: 860px) { .lobby-grid { grid-template-columns: minmax(0, 1fr); } }

.slots { display: flex; flex-direction: column; gap: 8px; }
.slot {
  display: grid;
  grid-template-columns: 26px minmax(80px, 1.2fr) minmax(86px, 0.9fr) minmax(86px, 0.9fr) minmax(90px, 0.9fr);
  align-items: center;
  gap: 8px;
  padding: 7px 8px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.08);
}
.slot.closed { opacity: 0.45; }
.slot.over { opacity: 0.35; filter: grayscale(1); }
.slot .num { font: 700 15px/1 'NissanD', sans-serif; color: var(--ink-dim); text-align: center; }
.slot .who { display: flex; align-items: center; gap: 8px; min-width: 0; }
.slot .who .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-transform: none; }
@media (max-width: 560px) {
  .slot { grid-template-columns: 22px minmax(0, 1fr) minmax(0, 1fr); }
  .slot .num { grid-row: span 2; }
}

.swatch { display: inline-block; vertical-align: middle; width: 18px; height: 18px; flex: none; border-radius: 4px; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.5), 0 1px 2px #000; cursor: pointer; }
.swatches { display: flex; flex-wrap: wrap; gap: 6px; }
/* A slot's colour square, a button (OnlineUI.colourSquare), and the column of colours it opens. */
.swatch.pick { border: 0; padding: 0; width: 20px; height: 20px; }
.swatch.pick:disabled { cursor: default; }
.swatch.pick:not(:disabled):hover, .swatch.pick:not(:disabled):focus-visible { box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--orange); outline: none; }
.colourmenu { position: fixed; z-index: 30; display: flex; flex-direction: column; gap: 7px; padding: 7px; background: rgba(20, 12, 8, 0.96);
  border: 1px solid var(--edge); border-radius: 8px; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.7); }
.colourmenu .swatch { width: 26px; height: 26px; border: 0; padding: 0; }
.colourmenu .swatch.on, .colourmenu .swatch:hover, .colourmenu .swatch:focus-visible { box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--orange); outline: none; }
.swatches .swatch { width: 24px; height: 24px; }
.swatches .swatch.on { box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--orange); }

select, input[type=text], input[type=search] {
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
  padding: 6px 8px 5px;
  font: 400 14px/1.2 'NissanD', Arial, sans-serif;
  color: #1c1c1c;
  background: linear-gradient(180deg, #fafafa, #d8dadd);
  border: 1px solid #555;
  border-radius: 5px;
  text-transform: none;
}
select:disabled { color: #777; background: #bbb; }
select:focus, input:focus { outline: 2px solid var(--orange); outline-offset: 1px; }

.form { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); gap: 8px 12px; align-items: center; }
.form label { font-size: 13px; color: var(--ink-dim); }
.form .soon { font-size: 10px; color: var(--orange); margin-left: 4px; }
.form .wide { grid-column: 1 / -1; }
/* a settings list's parts (Display, Controls, ...), each under a thin line */
.form .section { margin-top: 8px; padding-top: 10px; border-top: 1px solid rgba(255, 255, 255, 0.14); font-size: 12px; font-weight: 700;
  letter-spacing: 0.14em; color: var(--orange-hi); }
.form > .section:first-child { margin-top: 0; padding-top: 0; border-top: 0; }

.mapcard { display: flex; gap: 12px; align-items: center; margin-bottom: 12px; }
.mapcard canvas { width: 160px; height: auto; flex: none; border-radius: 6px; background: #3a1a08; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.2); image-rendering: pixelated; }
.mapcard .info { min-width: 0; flex: 1; }
.mapcard .players { font-size: 12px; color: var(--ink-dim); margin-top: 4px; }

.notice { margin-top: 10px; padding: 8px 10px; font-size: 12px; border-radius: 6px; background: rgba(255, 138, 0, 0.15); border: 1px solid rgba(255, 138, 0, 0.5); text-transform: none; letter-spacing: 0; }
.notice:empty { display: none; }

.actions { display: flex; gap: 12px; justify-content: flex-end; margin-top: 14px; width: min(1100px, 100%); position: relative; z-index: 1; }

/* ---- settings ---------------------------------------------------------------------------- */

.settings-panel { width: min(560px, 100%); }
input[type=range] { width: 100%; accent-color: var(--orange); }

/* ---- over the original menus ------------------------------------------------------------- */

.ui-back {
  position: fixed;
  top: 10px;
  left: 10px;
  z-index: 11;
  display: none;
}
.ui-back.shown { display: flex; }

/* The options in a match (OnlineUI.buildIngame): beside the game's pause menu, at the window's
   right, between its bars, small enough to leave the game in view. */
.panel.ingame {
  position: fixed; top: 50%; right: 10px; transform: translateY(-50%); z-index: 11; display: none; width: min(300px, 34vw); max-height: calc(100% - 200px);
  overflow-y: auto; font: 400 13px/1.3 'NissanD', 'Arial Black', Arial, sans-serif; text-transform: uppercase; color: var(--ink);
  background: rgba(20, 12, 8, 0.9);
}
.panel.ingame.shown { display: block; }
.panel.ingame > h2 { position: sticky; top: 0; z-index: 1; font-size: 14px; }
.panel.ingame .form { grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: 6px 8px; }
.panel.ingame .form label { font-size: 11px; }
.panel.ingame select { font-size: 12px; padding: 4px 6px 3px; }
/* On a narrow screen (a phone held upright): folded to its title, a tab at the right, till that is
   tapped; open, wider, with each label over its control. */
@media (max-width: 700px) {
  .panel.ingame { width: min(320px, 84vw); }
  .panel.ingame:not(.open) { width: auto; }
  .panel.ingame:not(.open) > .body { display: none; }
  .panel.ingame > h2 { cursor: pointer; }
  .panel.ingame > h2::after { content: ' ◂'; font-family: system-ui, sans-serif; }
  .panel.ingame.open > h2::after { content: ' ▾'; }
  .panel.ingame .form { grid-template-columns: minmax(0, 1fr); gap: 3px 0; }
  .panel.ingame .form select { margin-bottom: 6px; }
}

/* The error notice (errors.js): small, in a corner, over the game and the menus. */
.errnote {
  position: fixed; left: 10px; bottom: 10px; z-index: 1000; display: flex; align-items: center; gap: 8px;
  padding: 6px 8px 6px 12px; background: var(--panel); border: 1px solid var(--orange-lo); border-radius: 6px;
  font: 12px/1.2 system-ui, sans-serif; color: var(--ink); text-shadow: var(--glow); box-shadow: 0 4px 14px rgba(0, 0, 0, 0.5);
}
.errnote button {
  font: inherit; color: var(--ink); background: rgba(255, 138, 0, 0.18); border: 1px solid var(--orange-lo);
  border-radius: 4px; padding: 3px 8px; cursor: pointer;
}
.errnote button:hover { background: rgba(255, 138, 0, 0.35); }
.errnote .close { padding: 1px 7px; font-size: 14px; }

/* ---- online: the list of games, a room --------------------------------------------------- */

.online-grid { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(0, 1fr); gap: 14px; width: min(1100px, 100%); position: relative; z-index: 1; align-items: start; }
.online-grid .side { display: flex; flex-direction: column; gap: 14px; }
@media (max-width: 860px) { .online-grid { grid-template-columns: minmax(0, 1fr); } }
.rooms { display: flex; flex-direction: column; gap: 6px; }
.roomrow {
  display: grid; grid-template-columns: 20px minmax(0, 1fr) auto 52px 70px auto; align-items: center; gap: 8px;
  padding: 6px 8px; border-radius: 8px; background: rgba(255, 255, 255, 0.06); border: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 13px; text-transform: none; letter-spacing: 0;
}
.roomrow .label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.roomrow .ping, .roomrow .phase, .roomrow .count { color: var(--ink-dim); font-size: 12px; text-align: right; }
.roomrow.playing .phase { color: var(--orange-hi); }
@media (max-width: 560px) { .roomrow { grid-template-columns: 16px minmax(0, 1fr) auto auto; } .roomrow .ping, .roomrow .phase { display: none; } }
.join { display: flex; gap: 8px; }
.code-input { text-transform: uppercase !important; letter-spacing: 0.2em; font-family: monospace !important; }
.right { display: flex; justify-content: flex-end; }

.room-grid { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); grid-template-rows: auto 1fr; gap: 14px; width: min(1100px, 100%); position: relative; z-index: 1; }
.room-grid > .panel:first-child { grid-row: span 2; }
.room-grid > .panel.wide { grid-column: 1 / -1; }
/* The skirmish's and a room's screens widen with the window, rather than grow long: the Match
   panel's parts side by side, as many across as there is room for. */
.screen.lobby .titlebar, .screen.lobby .room-grid, .screen.room .titlebar, .screen.room .room-grid { width: min(1680px, 100%); }
.screen.lobby .actions, .screen.room .actions { width: 100%; }
.match-groups { columns: 290px; column-gap: 26px; }
.match-groups .group { break-inside: avoid; padding: 10px 0 12px; border-top: 1px solid rgba(255, 255, 255, 0.14); }
.match-groups .section { margin-bottom: 8px; font-size: 12px; font-weight: 700; letter-spacing: 0.14em; color: var(--orange-hi); }
/* the unit and building limits, folded under their title below the match's settings */
.caps { border-top: 1px solid rgba(255, 255, 255, 0.14); padding: 10px 0 4px; }
.caps summary { cursor: pointer; font-size: 12px; font-weight: 700; letter-spacing: 0.14em; color: var(--orange-hi); text-transform: uppercase; }
.capgroups { columns: 420px; column-gap: 26px; margin-top: 8px; }
.capgroup { break-inside: avoid; margin-bottom: 10px; }
.capgroup .section { margin: 6px 0; font-size: 12px; font-weight: 700; letter-spacing: 0.14em; color: var(--orange-hi); }
.caprow { display: grid; grid-template-columns: 104px minmax(0, 1fr) minmax(90px, 140px) 26px; gap: 8px; align-items: center; padding: 2px 0; }
.caprow.off { opacity: 0.35; }
.caprow.changed .capnum { color: var(--orange-hi); }
.capicons { display: flex; gap: 2px; }
.capicon { display: inline-block; width: 50px; height: 30px; background-size: 50px 30px; background-repeat: no-repeat; border-radius: 3px; }
.caplabel { font-size: 12px; color: var(--ink-dim); }
.capnum { font-size: 13px; text-align: right; font-variant-numeric: tabular-nums; }
.caps .capswarn { color: #ff4a3d; font-weight: 700; font-size: 13px; margin: 6px 0; }
.caps .capswarn:empty { display: none; }
@media (max-width: 860px) { .room-grid { grid-template-columns: minmax(0, 1fr); } .room-grid > .panel:first-child { grid-row: auto; } }
.slot.mine { box-shadow: inset 0 0 0 1px var(--orange); }
.btn.kick { padding: 2px 8px; font-size: 13px; }
.watchers { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 10px; font-size: 12px; color: var(--ink-dim); text-transform: none; }
.watchers:empty { display: none; }
.coderow { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; flex-wrap: wrap; }
.coderow .code { font: 700 18px/1 monospace; letter-spacing: 0.25em; color: #fff; min-width: 7ch; }
.form.access { margin-top: 4px; }
/* (the chat fills its panel, however tall the column makes it: the log grows, the bar stays at the foot) */
.chatpanel { display: flex; flex-direction: column; }
.chat { display: flex; flex-direction: column; gap: 8px; flex: 1; min-height: 0; }
.chatlog { flex: 1; min-height: 150px; height: 0; overflow-y: auto; font-size: 13px; text-transform: none; letter-spacing: 0; line-height: 1.35; }
.chatlog b { color: var(--orange-hi); font-weight: 600; }
.chatlog .system { color: #b9b3a6; font-style: italic; }    /* someone coming or going */
.toast {
  position: fixed; top: 12px; left: 50%; transform: translateX(-50%); z-index: 1000; max-width: min(560px, calc(100vw - 24px));
  padding: 10px 14px; background: var(--panel); border: 1px solid var(--orange); border-radius: 8px; color: var(--ink);
  font: 13px/1.3 system-ui, sans-serif; box-shadow: 0 6px 20px rgba(0, 0, 0, 0.6);
}
.btn.kick::after { display: none; }

/* ---- touch (touch.js): buttons for the keys a touch screen lacks ------------------------- */
.touchbar { position: fixed; right: 10px; bottom: calc(10px + env(safe-area-inset-bottom)); z-index: 12; display: none; gap: 10px; }
.touchbar.shown { display: flex; }
.touchbar button {
  width: 48px; height: 48px; border-radius: 50%; border: 2px solid rgba(255, 255, 255, 0.7); background: rgba(20, 20, 24, 0.55);
  color: #fff; font: 22px/1 system-ui, sans-serif; box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5); touch-action: manipulation;
}
.touchbar button:active { background: rgba(255, 138, 0, 0.7); }
.note a { color: var(--orange-hi); } .form .note { font-size: 13px; color: var(--ink-dim); text-transform: none; letter-spacing: 0; }
.form .note.warn { color: #ff4a3d; font-weight: 700; margin-top: -4px; }

/* ---- Custom Maps: the Browser and the Level editor -------------------------------------------- */
/* Compact controls of their own (the big chevron buttons are the menus'): chips for actions --
   orange for the one that matters, red for the one that removes --, and segmented groups of
   tools, the one in use orange. */
.tabs { display: flex; gap: 6px; }
.tab { font: 700 14px/1 'NissanD', sans-serif; letter-spacing: 0.1em; text-transform: uppercase; padding: 9px 14px 7px; border-radius: 8px 8px 0 0;
  border: 1px solid var(--edge); background: rgba(0, 0, 0, 0.45); color: var(--ink-dim); cursor: pointer; }
.tab.on { background: linear-gradient(180deg, var(--orange-hi), var(--orange) 50%, var(--orange-lo)); color: #fff; }
.custom-browse, .custom-edit { width: min(1400px, 100%); display: flex; flex-direction: column; gap: 14px; position: relative; z-index: 1; margin-bottom: 14px; }
.screen.custom input[type=number], .screen.custom textarea { box-sizing: border-box; padding: 6px 8px 5px; font: 400 14px/1.3 system-ui, sans-serif; color: #1c1c1c;
  background: linear-gradient(180deg, #fafafa, #e4e6e9); border: 1px solid #555; border-radius: 5px; text-transform: none; }
.screen.custom textarea { resize: vertical; min-height: 54px; }

.chip { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 8px 14px 7px; border-radius: 8px; cursor: pointer;
  font: 700 13px/1 'NissanD', sans-serif; letter-spacing: 0.08em; text-transform: uppercase; color: #fff; white-space: nowrap;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.16), rgba(255, 255, 255, 0.05)); border: 1px solid rgba(255, 255, 255, 0.22);
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.5); }
.chip:hover { border-color: var(--orange-hi); }
.chip:active { transform: translateY(1px); box-shadow: none; }
.chip.primary { background: linear-gradient(180deg, var(--orange-hi), var(--orange) 50%, var(--orange-lo)); border-color: var(--orange-hi); text-shadow: 0 1px 1px rgba(0, 0, 0, 0.5); }
.chip.danger { background: rgba(120, 20, 16, 0.55); border-color: rgba(255, 90, 70, 0.5); color: #ffd6d0; }
.chip.danger:hover { background: rgba(170, 30, 22, 0.75); border-color: #ff6a55; }
.chip.like.on { background: linear-gradient(180deg, #ff7a96, #e0204c); border-color: #ff8aa2; }
.row { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.hint { font: 400 13px/1.35 system-ui, sans-serif; color: var(--ink-dim); text-transform: none; letter-spacing: 0; }

.seg { display: inline-flex; flex-wrap: wrap; border-radius: 8px; overflow: hidden; border: 1px solid rgba(255, 255, 255, 0.18); background: rgba(0, 0, 0, 0.5); }
.seg > .tool { border: 0; border-radius: 0; border-left: 1px solid rgba(255, 255, 255, 0.12); }
.seg > .tool:first-child { border-left: 0; }
.tool { display: inline-flex; align-items: center; gap: 6px; padding: 8px 11px 7px; color: #fff; background: transparent; cursor: pointer;
  font: 700 12px/1 'NissanD', sans-serif; letter-spacing: 0.06em; text-transform: uppercase; border: 1px solid var(--edge); border-radius: 6px; white-space: nowrap; }
.tool:hover { background: rgba(255, 255, 255, 0.08); }
.tool.on { background: linear-gradient(180deg, var(--orange-hi), var(--orange) 50%, var(--orange-lo)); color: #fff; text-shadow: 0 1px 1px rgba(0, 0, 0, 0.5); }
.tool .swatch { width: 12px; height: 12px; border-radius: 3px; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(255, 255, 255, 0.25); }

/* the Browser */
.categories { display: flex; gap: 8px; flex-wrap: wrap; }
.category { flex: 1 1 200px; padding: 12px 16px 10px; font: 700 16px/1 'NissanD', sans-serif; letter-spacing: 0.1em; text-transform: uppercase; color: var(--ink-dim);
  background: rgba(0, 0, 0, 0.45); border: 1px solid var(--edge); border-radius: 10px; cursor: pointer; display: flex; justify-content: center; align-items: center; gap: 10px; }
.category.on { color: #fff; background: linear-gradient(180deg, var(--orange-hi), var(--orange) 50%, var(--orange-lo)); border-color: var(--orange-hi); }
.browse-bar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 12px; }
.browse-bar select { width: auto; flex: none; }
.browse-bar input[type=search] { flex: 1; min-width: 160px; width: auto; }
.maplist { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 12px; }
.mapcard { display: flex; flex-direction: column; gap: 8px; padding: 10px; border: 1px solid var(--edge); border-radius: 10px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.06), rgba(0, 0, 0, 0.35)); }
.mapcard .mapthumb { width: 100%; height: auto; image-rendering: pixelated; border-radius: 6px; background: #000; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.15); }
.mapcard .meta { display: flex; flex-direction: column; gap: 3px; flex: 1; }
.mapcard .name { font: 700 16px/1.15 'NissanD', sans-serif; letter-spacing: 0.04em; color: #fff; }
.mapcard .meta .note { font: 400 12px/1.35 system-ui, sans-serif; color: var(--ink-dim); text-transform: none; letter-spacing: 0; }
.mapcard .note.warn { color: #ff6a55; font-weight: 700; }
.mapcard > .row { margin-top: 2px; }
.scorelist { margin: 0; padding: 8px 10px 8px 30px; font: 400 13px/1.5 system-ui, sans-serif; text-transform: none; background: rgba(0, 0, 0, 0.35); border-radius: 6px; }
.scorelist li span + span { float: right; color: var(--ink-dim); font-variant-numeric: tabular-nums; }

/* your maps */
.newmap { display: flex; flex-wrap: wrap; gap: 12px 16px; align-items: flex-end; }
.newmap .field { display: flex; flex-direction: column; gap: 5px; flex: 1 1 200px; }
.newmap .field label { font-size: 12px; color: var(--ink-dim); letter-spacing: 0.08em; }

/* the editor */
.editor { display: grid; grid-template-columns: minmax(0, 1fr) 330px; gap: 14px; align-items: start; }
@media (max-width: 900px) { .editor { grid-template-columns: 1fr; } }
.edit-main { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.edit-bar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 8px; border-radius: 10px; background: rgba(0, 0, 0, 0.5); border: 1px solid var(--edge); }
.edit-bar .spacer { flex: 1; }
.tools { display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: flex-end; }
.toolgroup { display: flex; flex-direction: column; gap: 4px; }
.grouplabel { font-size: 10px; letter-spacing: 0.14em; color: var(--ink-dim); padding-left: 2px; }
.tool-options { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; min-height: 32px; }
.tool-options label { font-size: 11px; letter-spacing: 0.12em; color: var(--ink-dim); }
.tool-options select { width: auto; }
.tilepick { display: flex; flex-wrap: wrap; gap: 3px; max-width: 100%; }
.tilebtn { width: 30px; height: 22px; font: 600 10px system-ui, sans-serif; border-radius: 3px; border: 1px solid rgba(0, 0, 0, 0.6); cursor: pointer; color: #fff; background: #a0522d; }
.tilebtn.k1 { background: #5a3420; } .tilebtn.k2 { background: #6aa828; } .tilebtn.k3 { background: #3c9a3c; }
.tilebtn.on { outline: 2px solid #fff; }
.edit-canvas { width: 100%; border: 1px solid var(--edge); border-radius: 10px; overflow: hidden; background: #0c0c0c; touch-action: none; }
.editmap { display: block; touch-action: none; cursor: crosshair; }
.edit-side { display: flex; flex-direction: column; gap: 12px; }
.edit-side .form { grid-template-columns: 96px minmax(0, 1fr); }
.edit-side .panel input[type=text], .edit-side .panel input[type=number], .edit-side .panel textarea { width: 100%; }
.edit-side .sizes { display: flex; align-items: center; gap: 6px; } .edit-side .sizes input { width: 64px; flex: none; }
.edit-side .seg { width: 100%; } .edit-side .seg > .tool { flex: 1; justify-content: center; }
.edit-side .row { justify-content: flex-end; }
.checks { display: flex; flex-direction: column; gap: 4px; font: 400 13px/1.35 system-ui, sans-serif; text-transform: none; }
.checks .bad { color: #ff6a55; font-weight: 700; } .checks .good { color: #7be36b; font-weight: 700; }
/* (the lobby's map card centres its parts: not these) */
.maplist .mapcard { align-items: stretch; text-align: left; }
.screen.custom .panel > .body > .note { font: 400 14px/1.4 system-ui, sans-serif; color: var(--ink-dim); text-transform: none; letter-spacing: 0; }
.edit-side .sizes input[type=number] { width: 62px; flex: none; }
.edit-side .seg > .tool { padding: 8px 4px 7px; font-size: 11px; }
.tilebtn.art { width: 52px; height: 28px; padding: 1px; background: #000; } .tilebtn.art canvas { display: block; width: 48px; height: 24px; }
.edit-side .sizes select { flex: 1; min-width: 0; }
.edit-side .seg { flex-wrap: nowrap; } .edit-side .seg > .tool { padding: 8px 2px 7px; letter-spacing: 0.02em; }

/* ---- the editor on a phone (custom.js isCompact): the whole screen, the map as big as it can be,
   a slim bar, the tools in a strip (down the side when the phone is on its side), the chosen tool's
   choices by the map, and the map's settings in a sheet that slides over it ------------------------ */
.editor:not(.compact) .compact-only { display: none !important; }
.editor.compact .desk-only { display: none !important; }
.screen.custom.editing-compact { padding: 0; overflow: hidden; }
.screen.custom.editing-compact > .titlebar, .screen.custom.editing-compact > .actions { display: none; }
.editor.compact { position: fixed; inset: 0; z-index: 30; display: block; background: #0c0c0c; }
.editor.compact .edit-main { position: absolute; inset: 0; display: grid; gap: 0;
  grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr) auto auto; grid-template-areas: "bar" "map" "opts" "tools";
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); box-sizing: border-box; }
.editor.compact .edit-bar { grid-area: bar; flex-wrap: nowrap; overflow-x: auto; gap: 6px; padding: 6px; border-radius: 0; border: 0;
  border-bottom: 1px solid var(--edge); background: #141414; scrollbar-width: none; }
.editor.compact .edit-bar::-webkit-scrollbar, .editor.compact .tools::-webkit-scrollbar, .editor.compact .tool-options::-webkit-scrollbar { display: none; }
.editor.compact .edit-bar .chip { padding: 9px 12px 8px; flex: none; }
.editor.compact .edit-bar .seg { flex: none; }
.editor.compact .chip.status { color: #7be36b; }
.editor.compact .chip.status.bad { color: #ffb0a5; border-color: rgba(255, 90, 70, 0.6); }
.editor.compact .edit-canvas { grid-area: map; position: relative; min-height: 0; border: 0; border-radius: 0; }
.editor.compact .edit-canvas canvas { position: absolute; left: 0; top: 0; }
.editor.compact .opts { grid-area: opts; min-width: 0; background: rgba(20, 20, 20, 0.96); border-top: 1px solid var(--edge); }
.editor.compact .opts:empty { display: none; }
.editor.compact .tool-options { flex-wrap: nowrap; overflow-x: auto; padding: 5px 8px; min-height: 0; scrollbar-width: none; }
.editor.compact .tool-options > * { flex: none; }
.editor.compact .tool-options .hint { white-space: nowrap; font-size: 12px; }
.editor.compact .tilepick { flex-wrap: nowrap; }
.editor.compact .selname { font-weight: 700; white-space: nowrap; }
.editor.compact .tools { grid-area: tools; flex-wrap: nowrap; overflow-x: auto; gap: 8px; padding: 6px 8px; align-items: center;
  background: #141414; border-top: 1px solid var(--edge); scrollbar-width: none; }
.editor.compact .toolgroup { flex: none; }
.editor.compact .grouplabel { display: none; }
.editor.compact .seg { flex-wrap: nowrap; }
.editor.compact .tool { padding: 10px 12px 9px; }
/* (on its side: the tools down the left, the choices under the map) */
@media (orientation: landscape) {
  .editor.compact .edit-main { grid-template-columns: auto minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr) auto;
    grid-template-areas: "bar bar" "tools map" "tools opts"; }
  .editor.compact .tools { flex-direction: column; overflow-x: hidden; overflow-y: auto; border-top: 0; border-right: 1px solid var(--edge);
    padding: 6px; align-items: stretch; }
  .editor.compact .tools .seg { flex-direction: column; }
  .editor.compact .tools .seg > .tool { border-left: 0; border-top: 1px solid rgba(255, 255, 255, 0.12); }
  .editor.compact .tools .seg > .tool:first-child { border-top: 0; }
  .editor.compact .tools .tool { justify-content: flex-start; padding: 9px 10px 8px; }
}
/* the sheet: the map's settings, what is selected, the checks; up from the bottom (from the right,
   on its side) */
.editor.compact .edit-side { position: fixed; z-index: 40; left: 0; right: 0; bottom: 0; max-height: 72%; overflow-y: auto; overscroll-behavior: contain;
  gap: 10px; padding: 0 10px calc(12px + env(safe-area-inset-bottom)); background: #171717; border-top: 2px solid var(--orange);
  border-radius: 14px 14px 0 0; box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.7); transform: translateY(105%); transition: transform 0.2s ease; }
.editor.compact .edit-side.open { transform: none; }
.editor.compact .sheet-head { position: sticky; top: 0; z-index: 1; display: flex; align-items: center; gap: 6px; padding: 10px 0 8px;
  background: #171717; border-bottom: 1px solid var(--edge); }
.editor.compact .sheet-head strong { font-size: 15px; letter-spacing: 0.1em; }
.editor.compact .sheet-head .spacer { flex: 1; }
.editor.compact .edit-side .panel { margin: 0; }
@media (orientation: landscape) {
  .editor.compact .edit-side { left: auto; top: 0; width: min(380px, 62%); max-height: none; border-top: 0; border-left: 2px solid var(--orange);
    border-radius: 14px 0 0 14px; transform: translateX(105%); }
}
/* (a narrow phone, upright: the bar's buttons tighter, Test only its arrow) */
@media (max-width: 480px) {
  .editor.compact .edit-bar { gap: 4px; padding: 5px; }
  .editor.compact .edit-bar .chip { padding: 9px 10px 8px; }
  .editor.compact .edit-bar .tool { padding: 9px 9px 8px; }
  .editor.compact .edit-bar .tlabel { display: none; }
}
/* (the sheet scrolls; its panels keep their whole height) */
.editor.compact .edit-side > * { flex-shrink: 0; }
