/* Copyright (c) 2026 Yoda Games. All rights reserved.
   Darts — the dialog (js/ui/dialog.js; the frame of sudoku and bridge) and what goes inside it:
   New game (js/ui/setup.js) and Settings (.set-* rows and choices, .seg segmented buttons;
   js/ui/settings.js), How to play (.help), Statistics (.st-*; js/ui/stats.js) and the leg and end
   cards (.end-*; js/ui/endcard.js). The mask is position: fixed inside #app: on a short screen
   #app is scaled down whole, and the mask with it. It is also the size container the width rules
   query. Text 16 px and up, buttons 44 px and up. */

/* ── Dialog ── */
.dlg-mask {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(5, 10, 18, 0.66);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
  container-type: inline-size;
}
.dlg {
  position: relative;
  width: min(520px, 100%);
  max-height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--panel);
  border: 1px solid rgba(255, 215, 0, 0.3);
  border-radius: 18px;
  padding: 22px 24px 20px;
  box-shadow: 0 14px 44px rgba(0, 0, 0, 0.6);
  text-align: center;
  animation: dlg-in 0.22s ease both;
}
@keyframes dlg-in { from { opacity: 0; transform: translateY(10px) scale(0.98); } }
.dlg.dlg--wide { width: min(760px, 100%); }
.dlg-title {
  font-family: Orbitron, sans-serif;
  font-size: 21px;
  font-weight: 700;
  letter-spacing: 1px;
  color: var(--gold-soft);
  margin: 0 30px 10px;
}
/* a long body scrolls; the title and the buttons stay in view */
.dlg-body { flex: 0 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; font-size: 17px; color: #dbe6f1; text-wrap: pretty; }
.dlg-title, .dlg-btns { flex: none; }
/* more to scroll to (js/ui/dialog.js): the foot of the body fades and a "More below" button shows
   over it (it takes no room, so nothing moves when it comes and goes) */
.dlg.has-more .dlg-body {
  -webkit-mask-image: linear-gradient(180deg, #000 calc(100% - 64px), rgba(0, 0, 0, 0.15));
  mask-image: linear-gradient(180deg, #000 calc(100% - 64px), rgba(0, 0, 0, 0.15));
}
.dlg-more-wrap { position: relative; height: 0; flex: none; z-index: 2; }
.dlg-more {
  position: absolute;
  left: 50%;
  bottom: 4px;
  transform: translateX(-50%);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  padding: 0 16px 0 18px;
  border-radius: 22px;
  background: #22395a;
  border: 1px solid rgba(255, 215, 0, 0.55);
  color: #fff3c4;
  font-size: 16px;
  font-weight: 800;
  white-space: nowrap;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
}
.dlg-more svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; }
@media (hover: hover) { .dlg-more:hover { background: #2b4870; } }
.dlg-body p + p { margin-top: 8px; }
.dlg-btns {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  margin-top: 18px;
}
.dlg-btns:empty { display: none; }
.dlg-close {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.07);
  display: grid;
  place-items: center;
}
.dlg-close svg { width: 20px; height: 20px; stroke: #cfdbe7; stroke-width: 2.4; stroke-linecap: round; fill: none; }
@media (hover: hover) { .dlg-close:hover { background: rgba(255, 255, 255, 0.14); } }

.muted { color: var(--muted); }

/* ── Settings menu rows (from bridge; js/ui/settings.js) ── */
.settings { text-align: left; display: grid; gap: 12px; }
.set-actions { display: grid; gap: 6px; }
.set-act {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 48px;
  padding: 0 14px;
  border-radius: 12px;
  background: var(--chip);
  border: 1px solid var(--line-soft);
  color: var(--ink);
  font-size: 17px;
  font-weight: 700;
  text-align: left;
  transition: background 0.15s;
}
@media (hover: hover) { .set-act:hover { background: var(--chip-hover); } }
@container (min-width: 696px) { .set-actions { grid-template-columns: 1fr 1fr; } }
.set-act:focus-visible { outline: 3px solid #fff; outline-offset: 2px; }
.set-act__lbl { flex: 1 1 auto; }
.set-ic { width: 22px; height: 22px; flex: none; fill: none; stroke: var(--gold-soft); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.set-ic .fill { fill: var(--gold-soft); stroke: none; }
.set-chev { width: 20px; height: 20px; flex: none; fill: none; stroke: var(--muted); stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.set-switch {
  position: relative;
  flex: none;
  display: inline-flex;
  align-items: center;
  width: 74px;
  height: 32px;
  padding: 0 10px;
  border-radius: 16px;
  background: linear-gradient(135deg, var(--gold), var(--gold-2));
  color: #2a1a00;
  font-size: 16px;
  font-weight: 800;
}
.set-switch__knob { position: absolute; top: 4px; right: 4px; width: 24px; height: 24px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4); transition: right 0.15s; }
.set-act.is-off .set-switch { background: rgba(255, 255, 255, 0.16); color: #dbe6f1; justify-content: flex-end; }
.set-act.is-off .set-switch__knob { right: 46px; background: #cfdbe7; }
.set-act.is-off .set-ic { stroke: var(--muted); }
.set-act.is-off .set-ic .fill { fill: var(--muted); }
.set-note { color: var(--muted); font-size: 16px; }

/* ── Settings options: a heading, then label + hint and the choices (side by side in a wide
   dialog). Mistakes is a list of three choices, each with what it does. ── */
.set-head { margin-top: 4px; padding-top: 12px; border-top: 1px solid var(--line-soft); font-size: 16px; font-weight: 800; letter-spacing: 1px; text-transform: uppercase; color: var(--gold-soft); }
.set-row, .set-block { display: grid; gap: 8px; align-items: center; }
@container (min-width: 696px) { .set-row { grid-template-columns: minmax(0, 1fr) auto; column-gap: 18px; } }
.set-label { font-weight: 800; color: var(--ink); font-size: 17px; }
.set-label small { display: block; font-weight: 500; color: var(--muted); font-size: 16px; line-height: 1.3; margin-top: 2px; }
.set-row + .set-row, .set-block + .set-row { padding-top: 10px; border-top: 1px solid rgba(255, 255, 255, 0.07); }

.set-choices { display: grid; gap: 6px; }
@container (min-width: 696px) { .set-choices { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.set-choice {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  min-height: 48px;
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--chip);
  border: 1.5px solid var(--line-soft);
  color: var(--ink);
  text-align: left;
  transition: background 0.15s, border-color 0.15s;
}
@media (hover: hover) { .set-choice:hover { background: var(--chip-hover); } }
.set-choice__dot { flex: none; width: 22px; height: 22px; margin-top: 1px; border-radius: 50%; border: 2px solid var(--muted); display: grid; place-items: center; }
.set-choice__txt { display: grid; gap: 2px; }
.set-choice b { font-size: 17px; font-weight: 800; }
.set-choice small { font-size: 16px; font-weight: 500; color: var(--muted); line-height: 1.3; }
.set-choice[aria-pressed="true"] { border-color: var(--gold); background: rgba(255, 215, 0, 0.1); }
.set-choice[aria-pressed="true"] .set-choice__dot { border-color: var(--gold); }
.set-choice[aria-pressed="true"] .set-choice__dot::after { content: ''; width: 10px; height: 10px; border-radius: 50%; background: var(--gold); }

/* ── Segmented buttons (Settings options, the Statistics level) ── */
.seg {
  display: inline-flex;
  flex-wrap: wrap;
  justify-self: start;
  gap: 4px;
  padding: 4px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
}
.seg button {
  min-height: 44px;
  padding: 0 16px;
  border-radius: 10px;
  color: var(--ink);
  font-size: 17px;
  font-weight: 700;
  transition: background 0.15s;
}
@media (hover: hover) { .seg button:hover { background: rgba(255, 255, 255, 0.1); } }
.seg button[aria-pressed="true"] { background: linear-gradient(135deg, var(--gold), var(--gold-2)); color: #2a1a00; font-weight: 800; }
.seg button:focus-visible, .set-choice:focus-visible { outline: 3px solid #fff; outline-offset: 2px; }

/* ── How to play ── */
.help { text-align: left; display: grid; gap: 14px; }
.help h3 { font-size: 18px; color: var(--gold-soft); margin-bottom: 4px; }
.help p, .help li { font-size: 17px; line-height: 1.45; }
.help ul { padding-left: 22px; display: grid; gap: 6px; }
.help li { list-style: disc; }
.help b { color: var(--ink); }

.help-more { text-align: center; }
.setup .set-row[hidden] { display: none; }

/* ── Statistics ── */
.stats { display: grid; gap: 14px; justify-items: center; }
.st-tiles, .end-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(128px, 1fr)); gap: 8px; width: 100%; }
.st-tile, .end-tile { display: grid; gap: 2px; padding: 10px 8px; border-radius: 12px; background: rgba(255, 255, 255, 0.05); border: 1px solid rgba(255, 255, 255, 0.08); }
.st-tile b, .end-tile b { font-size: 24px; font-weight: 900; color: var(--gold-soft); font-variant-numeric: tabular-nums; }
.st-tile span, .end-tile span { font-size: 14px; font-weight: 600; color: var(--muted); }
.st-table, .end-table { border-collapse: separate; border-spacing: 0 4px; width: min(420px, 100%); font-size: 16px; font-variant-numeric: tabular-nums; }
.st-table caption { font-size: 14px; font-weight: 800; letter-spacing: 0.8px; text-transform: uppercase; color: var(--gold-soft); padding-bottom: 4px; }
.st-table th, .st-table td, .end-table th, .end-table td { padding: 7px 12px; text-align: right; }
.st-table thead th, .end-table thead th { font-size: 13px; font-weight: 700; color: var(--muted); padding-top: 0; padding-bottom: 0; }
.st-table tbody tr, .end-table tbody tr { background: rgba(255, 255, 255, 0.05); }
.st-table tbody th, .end-table tbody th { text-align: left; font-weight: 700; border-radius: 10px 0 0 10px; }
.st-table thead th:first-child, .end-table thead th:first-child { text-align: left; }
.st-table td:last-child, .end-table td:last-child { border-radius: 0 10px 10px 0; font-weight: 800; }
.st-note { color: var(--muted); font-size: 15px; text-align: center; max-width: 460px; }

/* ── Leg and end cards ── */
.end { display: grid; gap: 12px; justify-items: center; }
.end-score { display: flex; align-items: center; justify-content: center; gap: 12px; font-variant-numeric: tabular-nums; }
.end-score span { font-size: 14px; font-weight: 800; letter-spacing: 0.6px; text-transform: uppercase; color: var(--muted); }
.end-score b { font-size: 42px; font-weight: 900; color: var(--gold); line-height: 1; }
.end-score i { font-style: normal; font-size: 28px; color: var(--muted); }
.end-sub { color: #dbe6f1; }
.end-table tr.is-win { background: rgba(255, 215, 0, 0.12); }
.end-badges { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; }
.end-badge { padding: 4px 12px; border-radius: 12px; background: linear-gradient(135deg, var(--gold), var(--gold-2)); color: #2a1a00; font-size: 15px; font-weight: 900; letter-spacing: 0.3px; }
@container (max-width: 380px) {
  .st-tiles, .end-tiles { grid-template-columns: 1fr 1fr; }
  .end-score b { font-size: 34px; }
}

/* a short screen is drawn scaled down (#app.is-fit): the dialog's controls grow by as much (--btn,
   js/ui/layout.js), so they stay 42 px or more on the screen */
#app.is-fit .dlg .ctl, #app.is-fit .seg button, #app.is-fit .set-act, #app.is-fit .set-choice { min-height: var(--btn); }
#app.is-fit .dlg-close { width: var(--btn); height: var(--btn); }
