/* App-specific layout on top of 98.css (which provides all the Windows 98 widget chrome). */
/* 98.css ships only a Latin bitmap font; add the classic Korean bitmap fonts (Gulim/Dotum) so Hangul matches. */
body, .title-bar, .title-bar-text, .window, button, input, label, option, select, table, textarea, ul.tree-view, .menubar, .trlabel {
  font-family: "Pixelated MS Sans Serif", Gulim, "굴림", Dotum, "돋움", Arial, sans-serif;
  -webkit-font-smoothing: none;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: #008080; /* classic teal desktop */
  overflow: auto; display: flex; align-items: center; justify-content: center;
}
.hidden { display: none !important; }
.ticon { width: 16px; height: 16px; image-rendering: pixelated; }
.title-bar-text { display: flex; align-items: center; gap: 4px; }

/* ---- main window ---- */
#mainwin { display: flex; flex-direction: column; flex: none; margin: auto; }
.client { display: flex; margin-top: 2px; }
#stageWrap { background: #000; line-height: 0; box-shadow: inset -1px -1px #fff, inset 1px 1px #808080, inset -2px -2px #dfdfdf, inset 2px 2px #0a0a0a; }
#stage { display: block; width: 716px; height: 516px; image-rendering: pixelated; touch-action: none; }
#stage.smooth { image-rendering: auto; }

/* ---- menu bar (no equivalent in 98.css): plain application menu bar ---- */
.menubar { display: flex; align-items: center; gap: 0; flex: none; margin-top: 1px; padding: 0 1px; background: silver; user-select: none; }
.menu { position: relative; }
.menubar button.mtop {
  background: none; box-shadow: none; border: 0; min-width: 0; min-height: 0; color: #000; cursor: default;
  padding: 3px 8px; font: inherit; white-space: nowrap; text-shadow: none;
}
.menubar .mtop:hover { box-shadow: inset -1px -1px #808080, inset 1px 1px #fff; }
.menubar button.mtop:active:not(:disabled), .menu.open .mtop { box-shadow: inset -1px -1px #fff, inset 1px 1px #808080; padding: 3px 8px; }
.mpop {
  display: none; position: absolute; top: 100%; left: 0; min-width: 150px; z-index: 30; padding: 3px; background: silver;
  box-shadow: inset -1px -1px #0a0a0a, inset 1px 1px #dfdfdf, inset -2px -2px #808080, inset 2px 2px #fff, 2px 2px 4px rgba(0,0,0,.35);
}
.menu.open .mpop { display: block; }
.menubar .mpop button, .menubar .mpop button:active {
  display: block; width: 100%; text-align: left; background: none; box-shadow: none; border: 0; min-width: 0; min-height: 0;
  padding: 4px 18px 4px 24px; color: #000; cursor: default; white-space: nowrap; font: inherit; text-shadow: none;
}
.menubar .mpop button:hover { background: navy; color: #fff; }
.msep { height: 2px; margin: 3px 1px; box-shadow: inset 0 1px #808080, inset 0 -1px #fff; }

/* ---- modal dialogs ---- */
.modal { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; z-index: 20; background: rgba(0,0,0,.1); }
/* native-dialog feel: dialog chrome (labels, legends, notes) isn't selectable; only editable fields stay selectable */
.modal, #mainwin { -webkit-user-select: none; user-select: none; }
.modal input:not([readonly]):not([type=checkbox]):not([type=radio]), .modal textarea { -webkit-user-select: text; user-select: text; cursor: text; }
.dlg { max-width: calc(100vw - 16px); max-height: calc(100vh - 16px); display: flex; flex-direction: column; }
.dlgbody { display: flex; flex-direction: column; gap: 8px; min-height: 0; }
.dlgfoot { display: flex; align-items: center; gap: 8px; justify-content: flex-end; }
.dlgfoot .status { flex: 1; color: #222; }
.dlgfoot button, .about button, .msgbox button { min-width: 75px; }

/* tab panel (98.css styles the tab chrome; we only size it so switching tabs never resizes the window) */
.tabpanel { display: flex; flex-direction: column; min-height: 0; }
.page { display: flex; flex-direction: column; gap: 8px; min-height: 0; }
#dlgSel .tabpanel { height: 456px; }
#dlgSel .page { flex: 1; min-height: 0; }
#dlgOpt .tabpanel { min-height: 272px; justify-content: flex-start; }
/* no flex gap between the tab row and the panel (they must overlap so the active tab merges into the frame) */
#dlgSel .dlgbody, #dlgOpt .dlgbody { gap: 0; }
#dlgSel .dlgfoot, #dlgOpt .dlgfoot { margin-top: 10px; }
/* a little breathing room inside the tab panels, and one consistent column width for the Options selects */
#dlgOpt .tabpanel, #dlgSel .tabpanel { padding: 12px; }
#dlgOpt fieldset.grp > select { width: 240px; max-width: 100%; }

.row1 { display: flex; gap: 8px; }
.row1 .lv { flex: 1.7; }
.row1 .search { flex: 1; }
fieldset.grp { display: flex; flex-wrap: wrap; gap: 7px 10px; align-items: center; }
fieldset.search { flex-wrap: nowrap; }
fieldset.search input { flex: 1; min-width: 60px; }
fieldset.fx { flex-direction: column; align-items: flex-start; gap: 4px 10px; }
/* 전적: label | value | label | value — labels right-aligned so the value boxes line up in true columns */
fieldset.stats { display: grid; grid-template-columns: max-content 56px max-content 56px; gap: 8px 14px; align-items: center; }
fieldset.stats label { text-align: right; white-space: nowrap; }
fieldset.stats input { width: 56px; text-align: right; }
/* difficulty checks: align rows by text baseline. 98.css draws the checkbox as an absolutely-positioned
   box on label::before, which makes the first item's flex line taller and (with center/top alignment)
   floats its number above the rest; baseline alignment pins every number to one line. */
.checks { display: flex; flex-wrap: wrap; gap: 5px 14px; align-items: baseline; }
.checks .field-row { white-space: nowrap; }
.btnrow { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.btnrow .grow { flex: 1; }
.keysrow { display: flex; gap: 8px; width: 100%; }
.keycap { width: 100%; padding: 4px; background: #fff; box-shadow: inset -1px -1px #fff, inset 1px 1px #808080, inset -2px -2px #dfdfdf, inset 2px 2px #0a0a0a; }
.note { color: #222; margin: 4px 0 0; line-height: 1.5; }
/* system-settings sliders: label top-left, value readout top-right (a clean right column), slider full width below */
.trrow { display: grid; grid-template-columns: auto 1fr; align-items: center; gap: 3px 8px; margin-bottom: 11px; }
.trrow > label { white-space: nowrap; }
.trrow > output { text-align: right; font-weight: bold; }
.trrow > input[type=range] { grid-column: 1 / -1; width: 100%; margin: 3px 0 0; }
.about { flex-direction: row; align-items: flex-start; gap: 14px; }
.about > div { flex: 1; line-height: 1.5; }
.about img, .msgbox img, .ticon { image-rendering: pixelated; }
.msgbox { flex-direction: row; align-items: center; gap: 14px; flex-wrap: wrap; }
.msgbox #msgText { flex: 1; min-width: 200px; line-height: 1.5; }
.msgbox button { margin-left: auto; }

/* ---- list view: 98.css .sunken-panel + table ---- */
.lv-wrap { height: 330px; }
.lv-wrap.tall { height: 400px; }
#dlgSel .lv-wrap, #dlgSel .lv-wrap.tall { flex: 1; height: auto; min-height: 0; }
.lv-wrap table { width: 100%; table-layout: fixed; }
.lv-wrap th { cursor: default; user-select: none; overflow: hidden; text-overflow: ellipsis; }
.lv-wrap th.num, .lv-wrap td.num { text-align: right; }
.lv-wrap tbody tr { height: 16px; }
.lv-wrap tbody td { height: 16px; padding: 0 6px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.lv-wrap tbody tr.spacer { height: auto; }
.lv-wrap tbody tr.spacer td { padding: 0; }
/* sort arrow (CSS triangle; a bare ▲/▼ glyph renders as a colour emoji) */
.lv-wrap th[data-sort]::after { content: ''; display: inline-block; width: 0; height: 0; margin-left: 6px; vertical-align: middle; border: 4px solid transparent; }
.lv-wrap th[data-sort=asc]::after { border-bottom-color: #000; border-top-width: 0; }
.lv-wrap th[data-sort=desc]::after { border-top-color: #000; border-bottom-width: 0; }

/* default button (98.css 0.1.20 omits it): black frame flush on the outer edge, bevel inside */
button.default {
  box-shadow: inset -2px -2px #0a0a0a, inset 1px 1px #0a0a0a, inset 2px 2px #fff, inset -3px -3px #808080, inset 3px 3px #dfdfdf;
}

/* ---- classic Windows tab control (faithful raised edge; overrides 98.css's approximation) ---- */
menu[role=tablist] { display: flex; margin: 0 0 -2px 0; padding-left: 2px; }
/* top-left bevel matches the panel (.window) exactly — light-gray outer, white inner — so the active tab's
   left edge lines up pixel-for-pixel with the panel's left edge instead of protruding or tucking in. */
menu[role=tablist] > li {
  border-radius: 2px 2px 0 0; background: silver; position: relative; z-index: 1;
  box-shadow: inset 1px 1px #dfdfdf, inset 2px 2px #fff, inset -1px 0 #0a0a0a, inset -2px 0 #808080;
}
menu[role=tablist] > li > a { display: block; margin: 4px 10px 5px; color: #000; text-decoration: none; }
menu[role=tablist] > li[aria-selected=true] {
  margin: -2px -2px 0 -2px; padding-bottom: 2px; z-index: 8; background: silver;
  box-shadow: inset 1px 1px #dfdfdf, inset 2px 2px #fff, inset -1px 0 #0a0a0a, inset -2px 0 #808080;
}
