/* DamnedX web client: the panel shell (dx-ui.js). Desktop: an icon strip on the right edge and a
   side panel that narrows the game canvas. Mobile (html.mobile): a corner button and a bottom sheet
   over the canvas, which keeps its full size. Colours follow index.html's tokens. */
:root {
  --dx-strip-w: 36px;
  --dx-panel-w: 242px;
  --dx-game-right: 0px;
  --dx-surface: #14100c;
  --dx-surface-2: #1d1812;
  --dx-line: #3a3226;
  --dx-hover: #2a231a;
}

/* Desktop: the canvas gives up the strip (and the open panel) on its right. */
html.dx-shell:not(.mobile) #game { width: calc(100% - var(--dx-game-right)); }
html.dx-shell:not(.mobile) #status { right: var(--dx-game-right); }

[data-dx-ui] { box-sizing: border-box; font: 13px/1.4 system-ui, -apple-system, "Segoe UI", sans-serif; color: var(--fg); }
[data-dx-ui] *, [data-dx-ui] *::before, [data-dx-ui] *::after { box-sizing: inherit; }
[data-dx-ui] button { font: inherit; color: inherit; }
[data-dx-ui] [hidden] { display: none !important; }
[data-dx-ui] :focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

#dx-strip { position: fixed; top: 0; right: 0; bottom: 0; width: var(--dx-strip-w); z-index: 4;
  display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 0;
  background: #0b0907; border-left: 1px solid var(--dx-line); }
html.mobile #dx-strip { display: none; }
.dx-icon-btn { width: 32px; height: 32px; padding: 0; border: 0; border-radius: 4px; background: transparent;
  display: grid; place-items: center; cursor: pointer; color: var(--muted); position: relative; }
.dx-icon-btn:hover { background: var(--dx-hover); color: var(--fg); }
.dx-icon-btn[aria-pressed="true"] { background: var(--dx-surface-2); color: var(--fg); box-shadow: inset 2px 0 0 var(--accent); }
.dx-icon-btn svg { width: 18px; height: 18px; }
.dx-icon-btn .dx-dot { position: absolute; top: 5px; right: 5px; width: 7px; height: 7px; border-radius: 50%;
  background: var(--accent); display: none; }
.dx-icon-btn.unread .dx-dot { display: block; }

#dx-panel { position: fixed; z-index: 4; display: flex; flex-direction: column; background: var(--dx-surface); }
#dx-panel[hidden] { display: none; }
html:not(.mobile) #dx-panel { top: 0; bottom: 0; right: var(--dx-strip-w); width: var(--dx-panel-w);
  border-left: 1px solid var(--dx-line); }
/* Too narrow to keep 765px of game beside it: the panel floats over the canvas instead. */
html.dx-overlay:not(.mobile) #dx-panel { box-shadow: -8px 0 24px rgba(0, 0, 0, .6); }
.dx-head { display: flex; align-items: center; gap: 6px; min-height: 40px; padding: 0 6px 0 12px;
  border-bottom: 1px solid var(--dx-line); flex: none; }
.dx-head h2 { margin: 0; font-size: 14px; font-weight: 600; letter-spacing: .02em; flex: 1; min-width: 0;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dx-tabs { display: none; gap: 2px; }
.dx-close { width: 32px; height: 32px; border: 0; border-radius: 4px; background: transparent; cursor: pointer;
  color: var(--muted); font-size: 18px; line-height: 1; }
.dx-close:hover { background: var(--dx-hover); color: var(--fg); }
.dx-body { flex: 1; overflow-y: auto; overscroll-behavior: contain; padding: 10px 12px 16px; }

/* Mobile: bottom sheet. */
html.mobile #dx-panel { left: 0; right: 0; bottom: 0; max-height: min(70vh, 520px); min-height: 40vh;
  border-top: 1px solid var(--dx-line); border-radius: 12px 12px 0 0;
  padding-bottom: env(safe-area-inset-bottom); box-shadow: 0 -8px 24px rgba(0, 0, 0, .6); }
html.mobile .dx-head { padding-left: 8px; }
html.mobile .dx-head h2 { font-size: 15px; }
html.mobile .dx-tabs:not([hidden]) { display: flex; }
html.mobile .dx-icon-btn, html.mobile .dx-close { width: 40px; height: 40px; }
html.mobile [data-dx-ui] { font-size: 15px; }
#dx-sheet-backdrop { position: fixed; inset: 0; z-index: 4; background: rgba(0, 0, 0, .35); }
#dx-sheet-backdrop[hidden] { display: none; }
#dx-ui-button { position: fixed; z-index: 3; display: none; width: 44px; height: 44px; border-radius: 22px;
  right: max(8px, env(safe-area-inset-right)); bottom: calc(max(8px, env(safe-area-inset-bottom)) + 52px);
  border: 1px solid var(--dx-line); background: rgba(20, 16, 12, .78); color: var(--fg); padding: 0;
  place-items: center; }
html.mobile #dx-ui-button { display: grid; }
html.mobile:not(.touch) #dx-ui-button { bottom: max(8px, env(safe-area-inset-bottom)); }
#dx-ui-button svg { width: 20px; height: 20px; }

/* Panel content building blocks. */
.dx-section { margin: 0 0 14px; }
.dx-section h3 { margin: 0 0 6px; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .08em;
  color: var(--muted); }
.dx-rows { display: grid; grid-template-columns: auto 1fr; gap: 3px 10px; margin: 0; }
.dx-rows dt { color: var(--muted); }
.dx-rows dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.dx-muted { color: var(--muted); }
.dx-field { display: block; width: 100%; padding: 6px 8px; border: 1px solid var(--dx-line); border-radius: 4px;
  background: #0b0907; color: var(--fg); font: inherit; }
textarea.dx-field { min-height: 84px; resize: vertical; }
html.mobile .dx-field { font-size: 16px; } /* below 16px iOS zooms the page on focus */
.dx-links { display: flex; flex-direction: column; gap: 4px; }
.dx-link { display: block; padding: 6px 8px; border-radius: 4px; color: var(--fg); text-decoration: none;
  background: var(--dx-surface-2); }
.dx-link:hover { background: var(--dx-hover); }
.dx-toggle { display: flex; align-items: center; gap: 8px; padding: 4px 0; cursor: pointer; }
.dx-toggle input { accent-color: var(--accent); width: 16px; height: 16px; margin: 0; }
.dx-btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 32px;
  padding: 0 12px; border: 1px solid var(--dx-line); border-radius: 4px; background: var(--dx-surface-2);
  color: var(--fg); cursor: pointer; text-decoration: none; font: inherit; }
.dx-btn:hover { background: var(--dx-hover); }
.dx-btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.dx-btn.primary:hover { filter: brightness(1.1); }
html.mobile .dx-btn { min-height: 44px; }
.dx-btn:disabled { opacity: .5; cursor: default; filter: none; }
.dx-btn.primary:disabled:hover { filter: none; }
#dx-ui-button .dx-dot { position: absolute; top: 6px; right: 6px; width: 8px; height: 8px; border-radius: 50%;
  background: var(--accent); display: none; }
#dx-ui-button.unread .dx-dot { display: block; }

/* Forms (account dialog, bug report). */
.dx-form { display: flex; flex-direction: column; gap: 10px; }
.dx-form p { margin: 0; }
.dx-form-row { display: flex; flex-direction: column; gap: 4px; }
.dx-form-row > span { font-weight: 600; font-size: 12px; }
select.dx-field { appearance: auto; }
.dx-hint { color: var(--muted); font-size: 12px; }
.dx-warn { color: #f0b25a; }
.dx-status { margin: 0; padding: 6px 8px; border-radius: 4px; background: var(--dx-surface-2); }
.dx-status[hidden] { display: none; }
.dx-status.error { color: #ff9a8a; background: rgba(200, 70, 46, .14); }
.dx-status.ok { color: #9ee0a8; background: rgba(60, 160, 90, .14); }
.dx-status a, .dx-dialog a:not(.dx-btn):not(.dx-link) { color: #f0a58f; }
.dx-codes { margin: 0; padding: 8px 8px 8px 32px; border: 1px dashed var(--dx-line); border-radius: 4px; background: #0b0907;
  columns: 2; column-gap: 24px; font: 13px/1.7 ui-monospace, "Cascadia Mono", Consolas, monospace; user-select: all; }
.dx-row-btns { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.dx-choices { display: flex; flex-direction: column; gap: 6px; }
.dx-choice { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; padding: 10px 12px; text-align: left;
  border: 1px solid var(--dx-line); border-radius: 6px; background: var(--dx-surface-2); cursor: pointer; }
.dx-choice:hover { background: var(--dx-hover); border-color: var(--muted); }
.dx-choice span { color: var(--muted); font-size: 12px; }
.dx-seg { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; }
.dx-seg button { min-height: 30px; border: 1px solid var(--dx-line); border-radius: 4px; background: var(--dx-surface-2); cursor: pointer; }
.dx-seg button[aria-checked="true"] { background: var(--accent); border-color: var(--accent); color: #fff; }
html.mobile .dx-seg button { min-height: 44px; }
.dx-task { margin: 0; padding: 6px 8px; border-left: 3px solid var(--accent); background: var(--dx-surface-2); }
.dx-shot-wrap[hidden] { display: none; }
.dx-shot { display: block; width: 100%; border: 1px solid var(--dx-line); border-radius: 4px; }
.dx-report .dx-actions { margin-top: 2px; }

/* News. */
.dx-news-head { display: flex; align-items: baseline; justify-content: space-between; margin: 12px 0 6px; }
.dx-news-head h3, .dx-news-events h3 { margin: 0; font-size: 11px; font-weight: 600; text-transform: uppercase;
  letter-spacing: .08em; color: var(--muted); }
.dx-news-events h3 { margin: 14px 0 6px; }
.dx-results { font-size: 12px; }
.dx-news { display: flex; flex-direction: column; gap: 6px; }
.dx-card { border: 1px solid var(--dx-line); border-radius: 6px; background: var(--dx-surface-2); overflow: hidden; }
.dx-card-head { display: flex; align-items: center; gap: 6px; width: 100%; padding: 8px 10px; border: 0; background: none;
  cursor: pointer; text-align: left; }
.dx-card-head:hover { background: var(--dx-hover); }
.dx-card-title { flex: 1; min-width: 0; font-weight: 600; }
.dx-card-date { color: var(--muted); font-size: 11px; white-space: nowrap; }
.dx-badge { padding: 0 5px; border-radius: 3px; background: var(--accent); color: #fff; font-size: 10px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .04em; }
.dx-card-preview { margin: 0; padding: 0 10px 8px; color: var(--muted); font-size: 12px; overflow: hidden;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.dx-notes { margin: 0; padding: 0 10px 8px 26px; }
.dx-notes li { margin: 3px 0; }
.dx-notes mark, .dx-card-title mark { background: #5a3d0e; color: inherit; border-radius: 2px; }
.dx-more { display: block; margin: 0 10px 8px; padding: 0; border: 0; background: none; color: #f0a58f; cursor: pointer;
  font-size: 12px; text-decoration: none; }
.dx-event { display: flex; justify-content: space-between; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--dx-line); }
.dx-foot { margin: 6px 0 0; text-align: center; font-size: 12px; }

/* Active bonuses: chips over the top-left of the game, below the hover-text line. They never take a
   click (the game under them still gets it: walking there works); bonuses.js finds the chip under the
   pointer itself and opens its details on hover, or on a tap. */
#dx-bonuses { position: fixed; z-index: 3; left: max(6px, env(safe-area-inset-left)); top: 26px; display: flex;
  flex-wrap: wrap; gap: 4px; max-width: min(420px, calc(100vw - var(--dx-game-right) - 16px)); pointer-events: none; }
#dx-bonuses[hidden] { display: none; }
.dx-bonus { pointer-events: none; display: inline-flex; align-items: center; gap: 4px; height: 26px; padding: 0 7px 0 4px;
  border: 1px solid rgba(255, 255, 255, .16); border-radius: 13px; background: rgba(12, 10, 8, .72); color: #fff;
  font: 600 12px/1 system-ui, sans-serif; font-variant-numeric: tabular-nums; }
.dx-bonus svg { width: 18px; height: 18px; flex: none; }
.dx-bonus.soon .dx-bonus-text { color: #ffa53a; }
.dx-bonus-detail { font-weight: 400; color: var(--fg); white-space: nowrap; }
html.mobile .dx-bonus { height: 30px; }

/* Modal dialog (account links) and toasts. */
#dx-modal { position: fixed; inset: 0; z-index: 6; display: grid; place-items: center; padding: 16px;
  background: rgba(0, 0, 0, .55); }
#dx-modal[hidden] { display: none; }
.dx-dialog { width: min(380px, 100%); max-height: calc(100vh - 32px); max-height: calc(100dvh - 32px); overflow-y: auto; padding: 18px;
  border: 1px solid var(--dx-line); border-radius: 8px; background: var(--dx-surface);
  box-shadow: 0 12px 40px rgba(0, 0, 0, .7); }
.dx-dialog h2 { margin: 0 0 8px; font-size: 17px; }
.dx-dialog.wide { width: min(460px, 100%); }
.dx-dialog-head { display: flex; align-items: flex-start; gap: 8px; }
.dx-dialog-head h2 { flex: 1; min-width: 0; }
.dx-dialog-head .dx-close { margin: -8px -8px 0 0; flex: none; }
.dx-dialog p { margin: 0 0 10px; }
.dx-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; margin-top: 14px; }
#dx-toasts { position: fixed; z-index: 5; left: 50%; top: 12px; transform: translateX(-50%); display: flex;
  flex-direction: column; gap: 6px; width: max-content; max-width: calc(100vw - 32px); pointer-events: none; }
.dx-toast { pointer-events: auto; display: flex; align-items: center; gap: 10px; padding: 8px 12px;
  border: 1px solid var(--dx-line); border-radius: 6px; background: rgba(20, 16, 12, .96);
  box-shadow: 0 6px 18px rgba(0, 0, 0, .5); transition: opacity .4s; }
.dx-toast.gone { opacity: 0; }
.dx-toast a { color: #f0a58f; }

/* Settings panel (settings.js) */
.dx-set-note { margin: 6px 0; font-size: 12px; }
.dx-set-groups { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; }
.dx-set-group { border: 1px solid var(--dx-line); border-radius: 6px; background: var(--dx-surface-2); }
.dx-set-group > summary { cursor: pointer; padding: 7px 10px; font-weight: 600; list-style-position: inside; }
.dx-set-group > summary:hover { background: var(--dx-hover); }
.dx-set-group[open] > summary { border-bottom: 1px solid var(--dx-line); }
.dx-set-group > .dx-toggle, .dx-set-group > .dx-set-row { padding: 4px 10px; }
.dx-set-group > :last-child { padding-bottom: 8px; }
.dx-set-row { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.dx-set-row > label { flex: 1; min-width: 0; }
.dx-set-ctl { display: flex; align-items: center; gap: 4px; flex: none; }
.dx-set-num { width: 48px; min-height: 26px; padding: 2px 4px; }
.dx-set-color { width: 36px; height: 26px; padding: 0; border: 1px solid var(--dx-line); border-radius: 4px; background: none; }
.dx-set-reset { min-height: 26px; padding: 0 6px; font-size: 11px; }
.dx-set-group > .dx-set-color-item { padding: 4px 10px; }
.dx-set-alpha-row { margin-top: 4px; }
.dx-set-alpha { width: 96px; margin: 0; accent-color: var(--accent); }
.dx-set-pct { width: 34px; text-align: right; font-size: 11px; font-variant-numeric: tabular-nums; }
.dx-plugin-link { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 4px 0; }
