:root {
  --bg: #fff;
  --panel: #fff;
  --panel2: #f2f2f2;
  --line: #bbb;
  --text: #000;
  --muted: #555;
  --accent: #000;
  --danger: #c00;
  --input: #fff;
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg); color: var(--text);
  font: 14px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  display: flex; flex-direction: column; height: 100dvh; overflow: hidden;
}
a { color: var(--text); }
.spacer { flex: 1; }
p { margin: 0 0 12px; }
p:last-child { margin-bottom: 0; }
h1, h2, h3 { font-weight: bold; }

/* Controles */
button, .btn {
  background: var(--panel2); color: var(--text); border: 1px solid #767676;
  border-radius: 0; min-height: 32px; padding: 4px 12px; font: inherit; line-height: 1.4; cursor: pointer;
}
button:hover:not(:disabled), .btn:hover { background: #e2e2e2; }
button.primary { background: #000; color: #fff; border-color: #000; }
button.primary:hover:not(:disabled) { background: #333; }
button.link { background: none; border: 0; padding: 4px 6px; text-decoration: underline; text-underline-offset: 3px; }
button.link:hover:not(:disabled) { background: none; text-decoration-thickness: 2px; }
button:disabled { opacity: .45; cursor: not-allowed; }
input, select, textarea {
  background: var(--input); color: var(--text); border: 1px solid #767676;
  border-radius: 0; font: inherit;
}
input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="color"]), select { min-height: 30px; padding: 3px 6px; max-width: 100%; }
input:focus, select:focus, textarea:focus { outline: 2px solid #000; outline-offset: -1px; }
button:focus-visible, .btn:focus-within, a:focus-visible, summary:focus-visible { outline: 2px solid #000; outline-offset: 2px; }
input[type="checkbox"], input[type="radio"], input[type="range"] { accent-color: #000; vertical-align: middle; }

/* Cabeçalho, arquivo e abas */
.app-header {
  display: flex; gap: 16px; align-items: center; justify-content: space-between; flex-wrap: wrap;
  padding: 12px 20px; border-bottom: 1px solid #000; flex-shrink: 0;
}
.brand h1 { font-size: 20px; margin: 0; }
.brand h1 .brand-editor { font-weight: normal; }
.brand p { color: var(--muted); margin: 2px 0 0; font-size: 12px; }
.rom-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.file-bar {
  display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px 20px;
  padding: 6px 20px; border-bottom: 1px solid var(--line); color: var(--muted); font-size: 12px; flex-shrink: 0;
}
#romName { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#space { font-variant-numeric: tabular-nums; }
#space.bad { color: var(--danger); font-weight: bold; }
#tabs { display: flex; gap: 0; padding: 0 12px; border-bottom: 1px solid #000; flex-shrink: 0; overflow-x: auto; }
#tabs button {
  min-height: 40px; border: 0; background: transparent; color: var(--text);
  padding: 8px 12px; white-space: nowrap; text-decoration: underline; text-underline-offset: 3px;
}
#tabs button:hover:not(:disabled) { background: var(--panel2); }
#tabs button.on { font-weight: bold; text-decoration: none; background: #000; color: #fff; }

/* Layout */
main { flex: 1; display: flex; min-height: 0; overflow: hidden; }
aside {
  width: 250px; flex-shrink: 0; border-right: 1px solid var(--line);
  display: flex; flex-direction: column; min-height: 0;
}
aside .search { padding: 10px 12px; border-bottom: 1px solid var(--line); }
aside .search input { width: 100%; }
.no-rom aside, body.gen aside { display: none; }
#teamList { overflow: auto; flex: 1; padding-bottom: 20px; }
.league { padding: 14px 12px 4px; font-size: 12px; font-weight: bold; text-transform: uppercase; }
details.leagueGroup > summary.league { margin: 0; cursor: pointer; }
.teamItem {
  padding: 3px 12px; cursor: pointer; display: flex; align-items: center; gap: 8px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.teamItem:hover { background: var(--panel2); }
.teamItem.sel { background: #000; color: #fff; }
.teamItem .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex-shrink: 0; visibility: hidden; }
.teamItem.dirty .dot { visibility: visible; }
#content { flex: 1; overflow: auto; padding: 20px 24px 48px; min-width: 0; }
body.gen #content > .card, body.gen #content > .teamTitle, body.gen #content > .kitLayout, body.gen #content > .textsTop { max-width: 1440px; margin-left: auto; margin-right: auto; }

/* Tela inicial */
.empty { max-width: 560px; margin: 48px auto; text-align: center; }
.empty .eyebrow { color: var(--muted); font-size: 12px; }
.empty h2 { font-size: 26px; margin: 8px 0 12px; }
.empty .drop {
  border: 1px dashed #000; padding: 32px 20px; margin-top: 24px;
  display: flex; flex-direction: column; gap: 6px;
}
.empty .drop.over { background: var(--panel2); }
.drop strong { font-size: 15px; }
.drop small { font-size: 12px; color: var(--muted); margin-top: 6px; }

/* Blocos */
.card { border: 1px solid var(--line); padding: 16px 20px; margin-bottom: 20px; }
.card h2 { font-size: 17px; margin: 0 0 14px; }
.card h3 { font-size: 15px; margin: 18px 0 10px; }
.row { display: flex; gap: 10px 16px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.row:last-child { margin-bottom: 0; }
.field { display: flex; flex-direction: column; gap: 4px; }
.field label, .lbl { font-size: 13px; }
.teamTitle { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.teamTitle input { font-size: 20px; font-weight: bold; width: 260px; }
.teamTitle .meta { color: var(--muted); font-size: 12px; }
.note, .warn { font-size: 13px; line-height: 1.6; }
.note { color: var(--muted); }
.warn { font-weight: bold; }
.tools { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.scroll-x { overflow-x: auto; }
summary { padding: 8px 0; cursor: pointer; }
details[open] > summary { margin-bottom: 10px; }
.grid2, .kitLayout, .assets, .hdrGrid { gap: 20px; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 330px), 1fr)); }
.hdrGrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr)); }
.hdrGrid input { width: 100%; }
.toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
  background: #fff; border: 1px solid #000; padding: 8px 14px;
  display: none; z-index: 10; max-width: 90vw;
}
.toast.err { border: 2px solid var(--danger); color: var(--danger); }

/* Times */
.rating { display: grid; grid-template-columns: 110px 1fr 34px; gap: 8px; align-items: center; margin-bottom: 4px; }
.rating input[type=range] { width: 100%; }
.rating .v { text-align: right; font-variant-numeric: tabular-nums; }
.stripeSel { display: flex; gap: 6px; align-items: center; }
.stripeSel .c { width: 16px; height: 16px; border: 1px solid #000; }
table.players, table.langs { border-collapse: collapse; width: 100%; font-size: 13px; }
table.players th, table.langs th {
  position: sticky; top: 0; background: #fff; z-index: 1;
  font-size: 12px; font-weight: bold; padding: 6px 4px; border-bottom: 1px solid #000;
}
table.players th { text-align: center; }
table.players td { padding: 3px 4px; text-align: center; border-bottom: 1px solid var(--line); }
table.players td.nm { text-align: left; }
table.players input.nm { width: 140px; }
table.players input.num { width: 44px; text-align: center; }
table.players input.at { width: 36px; text-align: center; padding: 3px 0 !important; font-variant-numeric: tabular-nums; border-color: transparent; }
table.players select { padding: 3px 2px; }
table.players input[type=number] { appearance: textfield; -moz-appearance: textfield; }
table.players input[type=number]::-webkit-inner-spin-button,
table.players input[type=number]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
table.players tr.gk td { background: var(--panel2); }
.gv { display: block; font-size: 10px; color: var(--muted); line-height: 1; }
.teamLinks { display: flex; flex-wrap: wrap; gap: 6px; }
.teamLinks button { min-height: 26px; padding: 2px 8px; font-size: 12px; }

/* Faixas do menu, nas proporções de 40 × 16 pixels do console */
.flagMini, .flagBig { display: inline-flex; flex-shrink: 0; }
.flagMini { width: 40px; height: 16px; }
.flagBig { width: 120px; height: 48px; }
.flagMini svg, .flagBig svg { display: block; width: 100%; height: 100%; image-rendering: pixelated; overflow: visible; }
.flagOutline { stroke: var(--text); stroke-width: 1; stroke-linejoin: round; shape-rendering: geometricPrecision; }

/* Uniformes */
.kitBox { border: 1px solid var(--line); padding: 12px; }
.kitHead { display: flex; gap: 10px; align-items: center; margin-bottom: 8px; flex-wrap: wrap; }
.kitBody { display: flex; gap: 12px; align-items: flex-start; }
.swatches { display: grid; grid-template-columns: repeat(4, 1fr); gap: 5px; flex: 1; }
.sw { display: flex; flex-direction: column; align-items: stretch; gap: 2px; cursor: pointer; font-size: 11px; position: relative; }
button.sw { padding: 4px; background: transparent; border-color: transparent; text-align: left; }
button.sw:hover:not(:disabled) { background: transparent; border-color: #000; }
.sw .c { height: 22px; border: 1px solid #000; }
.sw input[type=color] { position: absolute; opacity: 0; width: 0; height: 0; pointer-events: none; }
.sw span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.shared { font-size: 12px; color: var(--muted); margin-top: 6px; }
.kitStrip { display: flex; width: 120px; height: 16px; border: 1px solid #000; overflow: hidden; margin-bottom: 6px; }
.kitStrip i { flex: 1; }
.kitGrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 8px; }
.kitCard { border: 1px solid var(--line); padding: 10px 8px; cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 12px; }
.kitCard:hover { border-color: #000; }
.kitCard.sel { border: 2px solid #000; }
.kitCard svg { width: 48px; height: 80px; }
.kitCard .u { color: var(--muted); font-size: 11px; }
.kitLayout { display: grid; grid-template-columns: minmax(300px, 420px) 1fr; align-items: start; }
.kitLayout .kitBody { flex-direction: column; }
.kitLayout .big svg { width: 140px; height: 232px; }
.kitPreviews { display: grid; grid-template-columns: repeat(auto-fit, minmax(148px, 1fr)); gap: 16px; width: 100%; }
.kitPreviews h3 { text-align: center; margin: 0 0 10px; }
.kitPreviews .spriteRotator { gap: 4px; justify-content: center; }
.kitPreviews .big { min-width: 0; }
.kitPreviews .big svg { width: 84px; height: 140px; }
.kitPreviews .spriteArrow { width: 28px; height: 32px; }
.spriteRotator { display: flex; align-items: center; gap: 10px; }
.spriteArrow {
  flex-shrink: 0; width: 32px; height: 32px; min-height: 0; font-size: 14px; line-height: 1; padding: 0;
  display: flex; align-items: center; justify-content: center;
}
.spriteRotator .big { display: flex; align-items: center; justify-content: center; min-width: 140px; }

/* Textos */
table.langs td { border-bottom: 1px solid var(--line); padding: 4px 6px; text-align: left; vertical-align: middle; }
table.langs th { text-align: left; }
table.langs td.id { color: var(--muted); font-variant-numeric: tabular-nums; width: 40px; }
table.langs td.ref { color: var(--muted); width: 38%; }
table.langs input { width: 100%; }
table.langs input.bad { border-color: var(--danger); }
table.langs td.n { width: 60px; color: var(--muted); font-size: 11px; text-align: right; }
.textsTop { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 20px; align-items: start; }
@media (max-width: 1000px) { .textsTop { grid-template-columns: minmax(0, 1fr); gap: 0; } }
.textsTop .hdrGrid { grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr)); }
textarea#credits { display: block; width: 100%; height: 280px; resize: none; font: 13px/1.5 ui-monospace, monospace; padding: 8px; }

/* Gráficos */
.assets { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 360px), 1fr)); }
.asset { border: 1px solid var(--line); padding: 12px; display: flex; flex-direction: column; gap: 8px; }
.asset h3 { margin: 0; font-size: 14px; }
.asset .view {
  align-self: flex-start; max-width: 100%; image-rendering: pixelated; border: 1px solid var(--line);
  background: repeating-conic-gradient(#ddd 0% 25%, #fff 0% 50%) 50% / 16px 16px;
}
.asset .row { gap: 8px; align-items: center; }
.asset .pal { display: grid; grid-template-columns: repeat(16, 1fr); gap: 2px; }
.asset .pal label { position: relative; cursor: pointer; }
.asset .pal button { min-height: 28px; min-width: 0; padding: 2px; position: relative; background: transparent; border-color: transparent; }
.asset .pal button:hover:not(:disabled) { background: transparent; border-color: #000; }
.asset .pal .c { width: 100%; height: 18px; border: 1px solid #000; }
.asset .pal input { position: absolute; opacity: 0; width: 0; height: 0; pointer-events: none; }
#gfxSearch { width: min(100%, 480px); margin: 6px 0 12px; }
.gfxMore { margin-top: 16px; }
.gfxGroup[hidden] { display: none; }

/* Sobre */
.about-dialog { width: min(640px, calc(100vw - 32px)); max-height: calc(100dvh - 32px); overflow: auto; background: #fff; color: var(--text); border: 1px solid #000; padding: 20px 24px; }
.about-dialog::backdrop { background: #0006; }
.about-dialog h3 { font-size: 15px; margin: 18px 0 6px; }
.about-dialog ul { margin: 0 0 12px; padding-left: 20px; }

/* Seletor da paleta do console */
.md-color-dialog { width: min(760px, calc(100vw - 32px)); max-height: calc(100dvh - 32px); overflow: auto; background: #fff; color: var(--text); border: 1px solid #000; padding: 20px; }
.md-color-dialog::backdrop { background: #0006; }
.md-color-heading { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-bottom: 12px; }
.md-color-heading h2 { margin: 0; font-size: 18px; }
.md-color-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.md-color-group { display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 2px; }
.md-color-group button { padding: 0; min-height: 0; min-width: 0; aspect-ratio: 1; border: 1px solid #8886; }
.md-color-group button[aria-pressed="true"] { outline: 2px solid #000; outline-offset: 1px; box-shadow: inset 0 0 0 2px #fff; }
.md-color-group button:focus-visible { outline: 3px solid #000; outline-offset: 2px; position: relative; z-index: 1; }

@media (max-width: 900px) { .kitLayout { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 760px) {
  .app-header { padding: 12px 16px; }
  .brand p { display: none; }
  .file-bar { padding: 6px 16px; }
  #tabs { padding: 0 4px; }
  main { flex-direction: column; }
  aside { width: 100%; max-height: 26vh; border-right: 0; border-bottom: 1px solid var(--line); }
  #content { padding: 16px 16px 40px; }
  .card { padding: 14px 16px; }
  .teamTitle input { width: 100%; }
  .empty { margin: 24px auto; }
}
@media (max-width: 600px) { .md-color-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } .md-color-dialog { padding: 16px; } }
