/* Newspaper Manager. Everything is under .nm-root (or the popup's .nm-* classes) so it cannot restyle the page.
   The 800x600 stage is scaled to fit #sgGame and centred; .nm-root carries the screen's background to the edges. */
.nm-root {
  --panel: #004900; --panel-hi: #1f8f1f; --panel-lo: #001f00; --panel-in: #003300;
  --red: #ff5a48; --green: #3ee03e; --yellow: #f0e030; --blue: #46b4ff; --brown: #e09848; --grey: #c8c8c8;
  --paper: #f7f1d8; --paper-line: #a9c4e4; --paper-margin: #e8908c; --ink: #1d2a5a; --ink-red: #a8231a;
  --font: "Trebuchet MS", "Segoe UI", Verdana, sans-serif;
  --mono: Consolas, "Lucida Console", "Courier New", monospace;
  --np-line: 24px; --np-gap: 3px; --np-base: 18px;
  position: absolute; inset: 0; overflow: hidden; color-scheme: dark;
  -webkit-tap-highlight-color: transparent;
  /* Newsroom background behind and around the stage: a dim sheet of newsprint (columns of text, headlines and
     halftone photos, drawn once by newsprintTile() into --nm-print) on warm dark ink, darker towards the edges.
     Every layer tiles or stretches, so it fills the frame at any aspect ratio. */
  background:
    radial-gradient(ellipse 80% 75% at 50% 50%, rgba(10,8,5,0) 35%, rgba(10,8,5,.35) 75%, rgba(10,8,5,.7) 100%),
    var(--nm-print, none) 50% 50% / 600px 450px repeat,
    linear-gradient(#2b261f, #1e1b16) #24201a;
}
.nm-root .nm-stage {
  position: absolute; left: 0; top: 0; width: 800px; height: 600px; transform-origin: 0 0; overflow: hidden;
  box-sizing: border-box; padding: 14px 16px 30px; user-select: none; -webkit-user-select: none;
  font: 15px var(--font); color: var(--green); text-align: left;
}
.nm-root .nm-stage *, .nm-root .nm-stage *::before, .nm-root .nm-stage *::after { box-sizing: border-box; }
.nm-root h1 { margin: 0; font-weight: bold; }
.nm-root p { margin: 0; }
.nm-root table { border-collapse: collapse; }

.nm-root .c-red { color: var(--red); } .nm-root .c-green { color: var(--green); } .nm-root .c-yellow { color: var(--yellow); }
.nm-root .c-blue { color: var(--blue); } .nm-root .c-brown { color: var(--brown); } .nm-root .c-grey { color: var(--grey); }
.nm-root .r { text-align: right; }
.nm-root .small { font-size: 12px; }
.nm-root .title { font-weight: bold; letter-spacing: .5px; margin-bottom: 6px; }
.nm-root .row-c { display: flex; gap: 6px; justify-content: center; align-items: center; flex-wrap: wrap; }
.nm-root .gap { flex: 1; }

/* green bevelled panels (PlotIconBack) */
.nm-root .panel {
  background: var(--panel); border: 3px solid; border-color: var(--panel-hi) var(--panel-lo) var(--panel-lo) var(--panel-hi);
  border-radius: 6px; padding: 8px; box-shadow: 0 3px 10px rgba(0,0,0,.45);
}

/* icon buttons - the original 32x32 sprites */
.nm-root .ico {
  position: relative; width: 36px; height: 36px; padding: 0; margin: 0; border: 0; background: none; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; flex: none; border-radius: 4px;
}
.nm-root .ico img { position: absolute; left: 2px; top: 2px; width: 32px; height: 32px; image-rendering: pixelated; pointer-events: none; }
.nm-root .ico .dn, .nm-root .ico .x { display: none; }
.nm-root .ico:active:not(:disabled) .up, .nm-root .ico.on .up { display: none; }
.nm-root .ico:active:not(:disabled) .dn, .nm-root .ico.on .dn { display: block; }
.nm-root .ico:disabled { cursor: not-allowed; }
.nm-root .ico:disabled .x { display: block; }
.nm-root .ico:focus-visible { outline: 2px solid var(--yellow); outline-offset: 1px; }
.nm-root .ico:hover:not(:disabled) { filter: brightness(1.15); }

/* text boxes */
.nm-root .tb {
  font: bold 16px var(--mono); background: var(--panel-in); color: var(--yellow); text-align: right;
  border: 2px solid; border-color: var(--panel-lo) var(--panel-hi) var(--panel-hi) var(--panel-lo); border-radius: 3px;
  padding: 3px 6px; height: 28px; margin: 0; user-select: text; -webkit-user-select: text;
}
.nm-root .tb:focus { outline: 2px solid var(--yellow); background: #004f00; }
.nm-root .tb:disabled { opacity: .55; }
.nm-root .tb-static { font: bold 16px var(--mono); padding: 3px 6px; }
.nm-root .w3 { width: 72px; } .nm-root .w4 { width: 84px; } .nm-root .w6 { width: 104px; } .nm-root .w7 { width: 118px; } .nm-root .w10 { width: 136px; }
.nm-root .stepper { display: inline-flex; align-items: center; gap: 4px; }

.nm-root .desc-bar {
  position: absolute; left: 0; right: 0; bottom: 0; height: 22px; line-height: 22px; padding: 0 12px;
  color: var(--yellow); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  text-shadow: 0 1px 2px #000, 0 0 4px #000;   /* just the text, kept readable over the background */
}
.nm-root .screen-title { font-size: 24px; margin: 4px 0 12px; text-align: center; letter-spacing: 1px; text-shadow: 2px 2px 0 #000; }
.nm-root .screen-foot { position: absolute; left: 16px; right: 16px; bottom: 30px; display: flex; justify-content: space-between; align-items: center; }
.nm-root .budget-foot { font-weight: bold; font-size: 17px; text-shadow: 1px 1px 0 #000; }

/* notepad (PlotPadBitmap). The rules are on .np-body: one --np-line per line of text, each rule --np-gap
   below that line's baseline (--np-base is measured from the font at start-up). Tiles of exactly one line
   repeat, so wrapped, blank and scrolled lines all stay on the rules at any scale. */
.nm-root .notepad {
  position: relative; display: flex; flex-direction: column; background-color: var(--paper); color: var(--ink);
  border-radius: 4px; padding: 22px 0 4px; font: 15px/var(--np-line) var(--font);
  background-image: linear-gradient(90deg, transparent 38px, var(--paper-margin) 38px, var(--paper-margin) 40px, transparent 40px);
  box-shadow: 0 4px 14px rgba(0,0,0,.5), inset 0 14px 0 #c53b2f;
}
.nm-root .np-body {
  position: relative; display: flex; flex-direction: column; overflow-x: hidden; overflow-y: auto; padding: 0 14px 0 52px;
  line-height: var(--np-line); scrollbar-width: thin; scrollbar-color: #c9b98a transparent;
  background: linear-gradient(to bottom, transparent calc(var(--np-line) - 1px), var(--paper-line) 0)
    0 calc(var(--np-base) + var(--np-gap) - var(--np-line) + 1px) / 100% var(--np-line) repeat-y local;
}
.nm-root .np-body > * { flex: none; }
.nm-root .np-measure { position: absolute; visibility: hidden; left: 0; top: 0; width: 200px; }
.nm-root .np-probe { display: inline-block; width: 0; height: 0; vertical-align: baseline; }
.nm-root .pad-text { white-space: pre-wrap; overflow-wrap: anywhere; }
.nm-root .pad-title { font-weight: bold; color: var(--ink-red); }
.nm-root .pad-link {
  display: block; width: 100%; text-align: start; background: none; border: 0; padding: 0; margin: 0;
  font: inherit; line-height: var(--np-line); color: var(--ink); cursor: pointer; white-space: normal;
}
.nm-root .pad-link:hover, .nm-root .pad-link:focus-visible { color: var(--ink-red); text-decoration: underline; outline: none; }
.nm-root .pad-foot { margin-top: auto; }
.nm-root .notepad .kv { display: flex; gap: 10px; white-space: nowrap; }
.nm-root .notepad .kv .k { min-width: 190px; }
.nm-root .notepad .kv .diff { margin-left: auto; }
.nm-root .notepad .c-yellow { color: #6b5a00; font-weight: bold; } .nm-root .notepad .c-red { color: var(--ink-red); font-weight: bold; }
.nm-root .notepad .kv .total { text-decoration: underline; }
.nm-root .memo-head { font-weight: bold; color: var(--ink-red); margin-bottom: var(--np-line); position: relative; }
.nm-root .memo-count { position: absolute; right: 0; top: 0; color: var(--ink); font-weight: normal; }

/* title */
.nm-root .brand { position: absolute; left: 144px; top: 56px; width: 512px; display: block; border-radius: 6px; }
.nm-root .brand:focus-visible { outline: 2px solid var(--yellow); outline-offset: 4px; }
/* vector redraw of the original title art (logoSvg), so it stays sharp at any scale */
.nm-root .logo { display: block; width: 512px; height: 96px; overflow: visible; }
.nm-root .logo text { font-family: Arial, "Helvetica Neue", Helvetica, "Liberation Sans", "Nimbus Sans", sans-serif; font-weight: bold; }

/* task select */
.nm-root .level-pad { width: 560px; margin: 0 auto; }
.nm-root .level-pad .np-body { height: calc(12 * var(--np-line)); }
.nm-root .task-status { text-align: center; margin: 14px 0; font-size: 18px; font-weight: bold; text-shadow: 1px 1px 0 #000; }
.nm-root .level-icons { position: absolute; left: 50%; transform: translateX(-50%); bottom: 40px; display: flex; gap: 6px; min-width: 330px; }

/* main screen: one player, so the left column is the paper, its budget and the icons, top to bottom,
   and the notepad takes the right column under the date */
.nm-root [data-screen=main] .date-box { position: absolute; left: 290px; top: 14px; width: 494px; height: 92px; text-align: center;
  background: #3a1a06; border-color: #8a4a20 #1a0800 #1a0800 #8a4a20; }
.nm-root .date { display: block; font: bold 46px/58px var(--mono); color: #ffd36a; letter-spacing: 4px; text-shadow: 3px 3px 0 #000; }
.nm-root .weekday { font-size: 16px; color: var(--yellow); }
.nm-root .main-left { position: absolute; left: 16px; top: 14px; bottom: 30px; width: 250px; display: flex; flex-direction: column; gap: 10px; }
.nm-root .paper-name { font: bold 22px/28px var(--font); text-shadow: 2px 2px 0 #000; height: 28px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nm-root .budget-left { text-align: center; }
.nm-root .budget-left .num { font: bold 20px var(--mono); }
.nm-root .action-icons { flex: 1; display: grid; grid-template-columns: repeat(2, 68px); gap: 22px 30px; justify-content: center; align-content: center; }
.nm-root .action-icons .ico { width: 68px; height: 68px; }
.nm-root .action-icons .ico img { width: 64px; height: 64px; }
.nm-root .sys-icons { display: flex; gap: 30px; justify-content: center; align-items: center; height: 58px; }
.nm-root .main-right { position: absolute; left: 282px; top: 118px; bottom: 30px; width: 502px; display: flex; flex-direction: column; gap: 8px; }
.nm-root .main-pad .np-body { height: calc(15 * var(--np-line)); }
.nm-root .pad-bottom { display: flex; gap: 8px; align-items: stretch; height: 58px; }
.nm-root .pad-icons { display: flex; gap: 3px; flex: 1; justify-content: center; align-items: center; padding: 4px; }
.nm-root .inbox { display: flex; align-items: center; justify-content: center; min-width: 130px; max-width: 170px; font-weight: bold; text-align: center; line-height: 1.1; }

/* page layout */
.nm-root .pages-left { position: absolute; left: 16px; top: 14px; width: 400px; }
.nm-root .sec-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 3px 0; }
.nm-root .sec-row .sec-name { color: var(--green); font-weight: bold; }
.nm-root .sec-row.locked .sec-name { opacity: .45; text-decoration: line-through; }
.nm-root .sec-row.unused { border-top: 1px solid var(--panel-hi); margin-top: 6px; padding-top: 8px; }
.nm-root .pages-right { position: absolute; left: 430px; top: 14px; width: 354px; display: flex; flex-direction: column; gap: 8px; }
.nm-root .field { display: flex; flex-direction: column; align-items: center; padding: 6px; }
.nm-root .field .title { margin-bottom: 4px; }
.nm-root .hint { font-size: 12px; color: var(--green); opacity: .85; margin-top: 3px; }

/* marketing */
.nm-root .market-panel { padding: 6px 12px; }
.nm-root .market { width: 100%; }
.nm-root .market th { color: var(--brown); text-align: left; padding: 4px 6px; border-bottom: 2px solid var(--panel-hi); }
.nm-root .market th.r { text-align: right; }
.nm-root .market td { padding: 2px 6px; font-weight: bold; }
.nm-root .market td.r { font-family: var(--mono); }
.nm-root .market tr.locked td:first-child { opacity: .45; text-decoration: line-through; }
.nm-root .market tfoot td { border-top: 2px solid var(--panel-hi); padding-top: 6px; font: bold 17px var(--mono); }
.nm-root .market tfoot td.c-brown { font-family: var(--font); }

/* reporters */
.nm-root .rep-head { font: bold 18px var(--font); margin-bottom: 4px; text-shadow: 1px 1px 0 #000; }
.nm-root .rep-scroll { height: 400px; overflow-y: auto; background: var(--panel); border: 3px solid;
  border-color: var(--panel-lo) var(--panel-hi) var(--panel-hi) var(--panel-lo); border-radius: 6px; scrollbar-color: var(--panel-hi) var(--panel-in); }
.nm-root .reps { width: 100%; font-size: 15px; }
.nm-root .reps th { position: sticky; top: 0; background: #003000; color: var(--brown); text-align: left; padding: 5px 8px; border-bottom: 2px solid var(--panel-hi); }
.nm-root .reps th.r { text-align: right; }
.nm-root .reps td { padding: 2px 8px; font-weight: bold; white-space: nowrap; }
.nm-root .reps tbody tr { cursor: pointer; }
.nm-root .reps tbody tr:hover, .nm-root .reps tbody tr:focus-visible { background: #006400; outline: none; }
.nm-root .reps td.empty { text-align: center; padding: 20px; cursor: default; }
.nm-root .rep-foot { display: flex; gap: 8px; margin-top: 8px; align-items: stretch; }
.nm-root .rep-stats { font-weight: bold; flex: 1.2; font-size: 14px; }
.nm-root .rep-budget { flex: 1; text-align: center; font-weight: bold; display: flex; flex-direction: column; justify-content: center; font-size: 17px; }
.nm-root .rep-icons { display: flex; gap: 4px; align-items: center; }

/* reporter info / transfer */
.nm-root .rep-info { width: 560px; margin: 0 auto; font-size: 17px; font-weight: bold; }
.nm-root .rep-info .kv { display: flex; padding: 4px 6px; border-bottom: 1px solid #0a5f0a; }
.nm-root .rep-info .kv > span:first-child { width: 190px; flex: none; }
.nm-root .rep-info.compact { font-size: 15px; margin-top: 10px; }
.nm-root .repinfo-icons { position: absolute; right: 30px; bottom: 40px; display: flex; gap: 6px; }
.nm-root .trans-sides { display: flex; gap: 14px; }
.nm-root .trans-side { flex: 1; display: flex; flex-direction: column; gap: 8px; font-weight: bold; }
.nm-root .trans-side .kv { display: flex; gap: 8px; align-items: center; }
.nm-root .trans-msg { margin-top: 10px; font-weight: bold; min-height: 46px; }

/* options */
.nm-root .opt-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; width: 620px; margin: 0 auto; }
.nm-root .opt-group { text-align: center; }
.nm-root .opt-group.wide { grid-column: span 2; }

/* charts */
.nm-root .chart { position: absolute; left: 16px; top: 14px; width: 650px; height: 528px; display: flex; flex-direction: column; }
.nm-root .chart-title { text-align: center; font-weight: bold; font-size: 18px; margin-bottom: 6px; }
.nm-root .axis-title { text-align: center; font-size: 13px; margin-top: 6px; }
.nm-root .plot { flex: 1; position: relative; min-height: 0; }
.nm-root .plot.bars { display: flex; align-items: stretch; gap: 8px; padding: 0 6px 22px 46px; }
.nm-root .axis-y { position: absolute; left: 0; top: 0; bottom: 22px; width: 40px; border-right: 2px solid #9fd09f; }
.nm-root .axis-y .tick { position: absolute; right: -2px; width: 8px; border-top: 2px solid #9fd09f; }
.nm-root .axis-y .tick span { position: absolute; right: 12px; top: -9px; font-size: 12px; color: var(--grey); }
.nm-root .bar-slot { flex: 1; position: relative; border-bottom: 2px solid #9fd09f; }
.nm-root .bar-slot.wide { flex: 0 0 150px; margin: 0 auto; }
.nm-root .bar { position: absolute; left: 18%; right: 18%; bottom: 0; border-radius: 4px 4px 0 0; min-height: 1px; }
.nm-root .bar.up { background: #2fbf3a; } .nm-root .bar.down { background: #e0453a; } .nm-root .bar.limit { background: #d39a36; }
.nm-root .bar-slot:hover .bar { filter: brightness(1.25); }
.nm-root .bar-label { position: absolute; left: -4px; right: -4px; text-align: center; font-size: 11px; line-height: 13px; font-weight: bold; }
.nm-root .bar-x { position: absolute; left: 0; right: 0; bottom: -21px; text-align: center; font-size: 13px; color: var(--grey); font-weight: bold; }
.nm-root .bar-slot.wide .bar-x { font-size: 12px; line-height: 13px; bottom: auto; top: calc(100% + 3px); }
.nm-root .line-svg { width: 100%; height: 100%; }
.nm-root .line-svg .grid { stroke: #ffffff22; stroke-width: 1; }
.nm-root .line-svg .axis { stroke: #9fd09f; stroke-width: 2; }
.nm-root .line-svg .ylab { fill: var(--grey); font-size: 12px; text-anchor: end; }
.nm-root .line-svg .xlab { fill: var(--grey); font-size: 11px; text-anchor: middle; }
.nm-root .line-svg .series { fill: none; stroke: var(--yellow); stroke-width: 2; stroke-linejoin: round; }
.nm-root .line-svg .dot { fill: var(--yellow); stroke: var(--panel); stroke-width: 2; }
.nm-root .line-svg .hit { fill: transparent; }
.nm-root .line-svg .pt:hover .dot { r: 5; }
.nm-root .line-svg .start-line { stroke: #fff8; stroke-width: 2; stroke-dasharray: 4 4; }
.nm-root .line-svg .start-lab { fill: #fffc; font-size: 11px; }
.nm-root .graph-side { position: absolute; right: 16px; top: 14px; width: 100px; display: flex; flex-direction: column; gap: 10px; height: 528px; }
.nm-root .paper-icons { display: grid; grid-template-columns: repeat(2, 38px); gap: 4px; justify-content: center; }
.nm-root .graph-icons { display: flex; flex-direction: column; align-items: center; gap: 6px; margin-top: auto; }
.nm-root .budget-chart { left: 50%; transform: translateX(-50%); width: 700px; height: 500px; }
.nm-root .budget-chart .plot.bars { padding-bottom: 34px; }
.nm-root .budget-chart .axis-y { bottom: 34px; }

/* sales figures */
.nm-root .figs { width: 100%; font-size: 17px; font-weight: bold; }
.nm-root .figs th { color: var(--brown); text-align: left; padding: 6px 10px; border-bottom: 2px solid var(--panel-hi); }
.nm-root .figs th.r { text-align: right; }
.nm-root .figs td { padding: 5px 10px; }
.nm-root .figs td.r { font-family: var(--mono); }
.nm-root .panel.figs { width: 620px; margin: 0 auto; }

/* phones held upright */
.nm-root .nm-rotate { display: none; position: absolute; inset: 0; z-index: 50; background: rgba(0,0,0,.88); align-items: center; justify-content: center; padding: 40px; color: #fff; font: 24px/1.3 var(--font); text-align: center; }
@media (pointer: coarse) and (orientation: portrait) { .nm-root .nm-rotate { display: flex; } }

/* popups (sgpopup lives on #sgGame, outside .nm-root) */
.sgp .sgp-card.nm-start { background: none; -webkit-backdrop-filter: none; backdrop-filter: none; border: 0; box-shadow: none; padding: 0; min-width: 0; overflow: visible; }
/* the title card is just the Play button, centred on the screen (align-self overrides the dock's flex-end);
   the help text hangs below it so it does not push the button off centre */
.sgp .sgp-card.nm-start { align-self: center; margin: 0; }
.sgp .sgp-card.nm-start .sgp-text {
  position: absolute; top: 100%; left: 50%; transform: translateX(-50%); width: min(34em, calc(100cqw - 32px)); margin-top: .9em;
  color: #f4f8ff; text-shadow: 0 1px 3px #000c;
}
