/* 커스텀 게임 tab (js/features/custom.js): the list of the player's own games and the 게임 추가 / 바꾸기 window.
   Desktop and tablet first; the phone layout is its own block at the end. */
#tab-custom { max-width: 1100px; }
.cg-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 2px 0 12px; }
.cg-head h2 { margin: 0; }
.cg-addbtn, .cg-empty .primary { display: inline-flex; align-items: center; gap: 6px; }
/* the rows: as the library's (css/style.css .entries .entry) - cover, name, tags; pressing one opens the game card */
.cg-list { display: flex; flex-direction: column; gap: 6px; }
.cg-empty { padding: 22px 18px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); text-align: center; }
.cg-empty p { margin: 0 0 12px; color: var(--muted); }
.cg-item { display: grid; grid-template-columns: 84px minmax(0, 1fr); gap: 8px; align-items: start; padding: 8px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); position: relative; cursor: pointer; }
.cg-item:hover { border-color: var(--line2); }
.cg-item:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.cg-item.selected { border-color: var(--accent); background: #22241f; }
.cg-item.running { box-shadow: inset 3px 0 0 var(--ok); }
.cg-cover { width: 84px; height: 63px; border-radius: 4px; background: #000; display: block; }
.cg-cover:not(.done) { background: var(--panel2); }
.cg-item.miss .cg-cover { filter: grayscale(.7); opacity: .6; }
.cg-info { min-width: 0; }
.cg-name { font-weight: 600; font-size: 13.5px; line-height: 1.25; overflow-wrap: anywhere; }
.cg-info .tags { display: flex; flex-wrap: wrap; gap: 3px; margin-top: 4px; }
.cg-item .tag { font-size: 10.5px; padding: 0 6px; border-radius: 4px; background: var(--panel3); color: var(--muted); border: 1px solid var(--line2); line-height: 16px; margin: 0; vertical-align: baseline; }
.cg-item .tag.vol { color: var(--accent); border-color: #5a4a2a; background: #2a251c; }
.cg-it .tag { margin-left: 0; }
.tag.warn, .cg-item .tag.warn { color: var(--warn); border-color: var(--warn); }
.cg-last { margin-top: 3px; font-size: 11px; color: var(--warn); overflow-wrap: anywhere; }
.cg-item .endmark { position: absolute; left: 10px; top: 10px; background: rgba(16, 16, 16, .85); color: #ffd36e; border: 1px solid #ffd36e; border-radius: 3px;
  font-size: 10.5px; font-weight: 700; padding: 0 4px; line-height: 15px; pointer-events: none; }
/* its game card (js/features/card.js): one 「실행」, the files and the program it starts, 지우기 at the end of the buttons */
.gc-play button.run { border-color: #4a4f58; }
.gc-line { display: flex; gap: 6px; min-width: 0; }
.gc-line .gc-k { flex: none; }
.gc-line .gc-v { min-width: 0; overflow-wrap: anywhere; color: var(--fg); }
.gc-more button.gc-del { margin-left: auto; }

/* the window */
dialog.cg-dlg { border: 1px solid var(--line2); border-radius: 12px; padding: 0; width: min(560px, calc(100vw - 32px)); max-height: calc(100vh - 48px);
  background: var(--panel); color: var(--fg); box-shadow: 0 10px 40px rgba(0, 0, 0, .5); overflow: hidden; }
dialog.cg-dlg::backdrop { background: rgba(0, 0, 0, .6); }
.cg-body { padding: 12px 16px 16px; overflow: auto; max-height: calc(100vh - 50px); }
.cg-dhead { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 6px; }
.cg-dhead h3 { margin: 0; color: var(--fg); font-size: 16px; }
.cg-x { width: 34px; height: 34px; padding: 0; border-color: transparent; background: transparent; color: var(--muted); font-size: 16px; display: inline-flex; align-items: center; justify-content: center; }
.cg-row { display: grid; grid-template-columns: 80px minmax(0, 1fr); align-items: center; gap: 10px; margin: 10px 0; }
.cg-row.top { align-items: start; } .cg-row.top > .cg-lab { padding-top: 7px; }
.cg-lab { color: var(--muted); font-size: 13px; }
.cg-plat { justify-self: start; }
.cg-plat button { padding: 5px 14px; font-size: 13px; }
.cg-body:focus { outline: none; }
.cg-plat button small { color: var(--muted); font-size: 11px; }
.cg-plat button:disabled { opacity: .5; }
.cg-fcol { min-width: 0; }
.cg-files { display: flex; flex-wrap: wrap; gap: 6px; }
.cg-files button { display: inline-flex; align-items: center; gap: 5px; }
.cg-hint { margin-top: 5px; }
.cg-items, .cg-disks { margin-top: 8px; border: 1px solid var(--line); border-radius: 6px; background: var(--bg2); }
.cg-disks { margin-top: 0; }
.cg-it, .cg-disk { display: flex; align-items: center; gap: 8px; padding: 5px 8px; border-top: 1px solid var(--line); min-width: 0; }
.cg-it:first-child, .cg-disk:first-child { border-top: 0; }
.cg-it.gone .cg-it-n { color: var(--muted); }
/* a disc with music tracks and no table of contents: the .ccd asked for, under its row (features/custom.js itemsList) */
.cg-toc { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; padding: 4px 8px 6px; font-size: 12.5px; color: var(--warn); }
.cg-toc span { flex: 1 1 200px; min-width: 0; }
.cg-it-n { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.cg-dn { width: 18px; text-align: center; color: var(--muted); font-size: 12px; flex: none; }
.cg-it .iconbtn, .cg-disk .iconbtn { padding: 2px 6px; min-width: 28px; min-height: 26px; display: inline-flex; align-items: center; justify-content: center; }
.cg-status { min-height: 18px; margin: 6px 0 0; font-size: 12.5px; overflow-wrap: anywhere; }
.cg-status.busy { color: var(--accent); }
.cg-status:empty { display: none; }
.cg-name-in { width: 100%; background: var(--panel2); color: var(--fg); border: 1px solid var(--line2); border-radius: 6px; padding: 6px 8px; font: inherit; font-size: 14px; }
.cg-row select { max-width: 100%; min-width: 0; }
.cg-exe { width: 100%; }
.cg-checks { display: flex; flex-wrap: wrap; gap: 6px 16px; }
.cg-note { margin: 4px 0 0; }
/* 소리 카드 · 직접 고르기 (DOS4, features/custom.js sndOptions): a line for each card - its switch, then its port, IRQ and DMA */
.cg-snd { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.cg-card { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; min-width: 0; }
.cg-res { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; min-width: 0; }
.cg-res1 { white-space: nowrap; font-size: 12.5px; color: var(--muted); }
.cg-foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; padding: 12px 0 2px; border-top: 1px solid var(--line); position: sticky; bottom: -16px; background: var(--panel); }
.cg-foot button { min-width: 88px; min-height: 36px; }

/* phones */
@media (max-width: 720px) {
  .cg-head { margin-bottom: 10px; }
  .cg-addbtn { min-height: 40px; }
  .cg-item { grid-template-columns: 72px minmax(0, 1fr); column-gap: 8px; }
  .cg-cover { width: 72px; height: 54px; }
  dialog.cg-dlg { width: 100vw; max-width: 100vw; margin: auto 0 0; border-radius: 14px 14px 0 0; max-height: 92vh; border-bottom: 0; }
  .cg-body { max-height: 92vh; padding: 10px 14px max(16px, env(safe-area-inset-bottom, 0px)); }
  .cg-row { grid-template-columns: 72px minmax(0, 1fr); gap: 8px; }
  .cg-plat button { min-height: 40px; padding: 4px 12px; }
  .cg-row-files { grid-template-columns: minmax(0, 1fr); }
  .cg-row-files > .cg-lab { display: none; }
  .cg-files { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 6px; }
  .cg-files button { min-height: 40px; justify-content: center; padding: 4px 6px; }
  .cg-row select, .cg-name-in { min-height: 40px; font-size: 16px; }
  .cg-it .iconbtn, .cg-disk .iconbtn { min-width: 40px; min-height: 36px; }
  .cg-checks label, .cg-card label.toggle { min-height: 36px; }
  .cg-foot button { flex: 1; min-height: 44px; }
}
/* the top bar with eight tabs (커스텀 게임 added): one row of them was wider than a 721-1040 px window (a tablet, a phone held
   sideways - it was already at 768 px), so the page scrolled sideways; there the tabs take a row of their own */
@media (min-width: 721px) and (max-width: 1040px) {
  :root { --topbar-h: 66px; }
  #topbar { height: auto; min-height: 48px; flex-wrap: wrap; row-gap: 0; column-gap: 12px; padding: 3px 16px 4px; }
  #topbar .brand { flex: 1; }
  #topbar .tabs { order: 3; flex: 1 0 100%; }
}
/* phone held sideways: a short screen */
@media (max-height: 500px) and (orientation: landscape) {
  dialog.cg-dlg { max-height: 100vh; }
  .cg-body { max-height: 100vh; }
}

/* 애드온 (js/features/addons.js): the card's 「애드온」 list - a button per addon (its name, a line about it); its own save slots marked */
.gc-pane .gc-addon { display: flex; flex-direction: column; align-items: flex-start; gap: 3px; width: 100%; min-height: 44px; margin: 4px 0; padding: 8px 12px; text-align: left; }
.gc-addon-t { display: inline-flex; align-items: center; gap: 4px; font-weight: 700; }
.gc-addon-n { color: var(--muted); font-size: 12px; font-weight: 400; line-height: 1.35; }
.pl-slotgroup.pl-addon, .gc-group.pl-addon { color: var(--accent); }

/* 플랫폼 · 게임 찾기: the library's filter row (style.css .libfilter - its menu, chips and 「검색 결과가 없습니다.」); on a phone the search and
   플랫폼 ▾ share one row, 44px high as the library's */
.cg-filter { margin: 0 0 8px; }
.cg-chips { margin: -2px 0 8px; }
.cg-none { margin: 0 0 8px; }
/* (UI9) 정렬 ▾ after 플랫폼 ▾; on a phone the search has the first row and 플랫폼 · 정렬 the second (as the DS library: 2026-11-08) */
@media (max-width: 720px) {
  .row.libfilter.cg-filter { display: flex; flex-wrap: wrap; gap: 6px; align-items: stretch; }
  .cg-filter #cg-q { flex: 1 1 100%; box-sizing: border-box; width: auto; min-width: 0; max-width: none; height: 44px; margin: 0; padding: 0 12px; font-size: 16px; border-radius: 6px; }
  .cg-filter > .volsel { flex: 0 0 auto; width: 116px; }
  .cg-filter > .volsel.cg-sortsel { flex: 1 1 0; width: auto; min-width: 0; }
}
/* (UI9) 360 px and less: 플랫폼's four kinds and the disks' list under their labels - beside them 「피처폰」 was cut off at 320 and
   a disk's name had room for a letter or two (「D…」) */
@media (max-width: 360px) {
  .cg-row:has(> .cg-plat), .cg-row:has(> .cg-disks) { grid-template-columns: minmax(0, 1fr); gap: 6px; }
  .cg-row.top:has(> .cg-disks) > .cg-lab { padding-top: 0; }
  .cg-plat button { padding: 4px 10px; }
}
