/* 基礎樣式：設計變數、版面骨架、按鈕、表單、面板、表格、提示 */

:root {
  --felt-950: #041a12;
  --felt-900: #062218;
  --felt-800: #0a3a2a;
  --felt-700: #0e5339;
  --felt-600: #146b49;
  --felt-500: #1a8a5f;
  --gold: #e3c06a;
  --gold-strong: #f3d78a;
  --gold-dim: #b8963f;
  --banker: #e5483d;
  --banker-dark: #a62d25;
  --player: #3f83e8;
  --player-dark: #2b5aa8;
  --tie: #34b86f;
  --tie-dark: #1f8049;
  --ink: #eaf1ec;
  --ink-soft: #c5d4cb;
  --muted: #8fa89b;
  --card: #fbfaf6;
  --card-ink: #1b1b1b;
  --win: #5be08f;
  --lose: #ff7b72;
  --panel: rgba(4, 24, 17, 0.74);
  --panel-solid: #0a2a1f;
  --panel-2: rgba(255, 255, 255, 0.045);
  --line: rgba(227, 192, 106, 0.22);
  --line-soft: rgba(255, 255, 255, 0.1);
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 10px 28px rgba(0, 0, 0, 0.38);
  --font: "Noto Sans TC", "Microsoft JhengHei", "PingFang TC", "Heiti TC", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: ui-monospace, "Cascadia Mono", Consolas, "Microsoft JhengHei", monospace;
  --gutter: 16px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--felt-900);
  background-image:
    radial-gradient(1300px 700px at 50% -12%, rgba(26, 138, 95, 0.55), transparent 62%),
    radial-gradient(900px 600px at 100% 100%, rgba(14, 83, 57, 0.5), transparent 60%),
    linear-gradient(180deg, #08301f 0%, #062218 55%, #041a12 100%);
  background-attachment: fixed;
  font-variant-numeric: tabular-nums;
  overflow-x: hidden;
}

h1,
h2,
h3,
h4 {
  margin: 0;
  line-height: 1.25;
  font-weight: 700;
}

p {
  margin: 0;
}

a {
  color: var(--gold-strong);
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

.skip-link {
  position: absolute;
  left: -999px;
  top: 8px;
  z-index: 100;
  padding: 8px 14px;
  background: var(--gold);
  color: #1d1600;
  border-radius: 8px;
}

.skip-link:focus {
  left: 8px;
}

:focus-visible {
  outline: 2px solid var(--gold-strong);
  outline-offset: 2px;
}

/* ---- 頂部列 ---- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 10px var(--gutter);
  background: linear-gradient(180deg, rgba(3, 18, 12, 0.96), rgba(5, 28, 19, 0.9));
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(8px);
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  flex: none;
  border-radius: 50%;
  font-size: 24px;
  color: var(--card);
  background: radial-gradient(circle at 35% 30%, var(--felt-500), var(--felt-900));
  border: 2px solid var(--gold);
  box-shadow: 0 0 0 3px rgba(227, 192, 106, 0.18);
}

.brand-text h1 {
  font-size: 18px;
  letter-spacing: 0.04em;
  color: var(--gold-strong);
}

.brand-text p {
  font-size: 12px;
  color: var(--muted);
}

.tabs {
  display: flex;
  gap: 4px;
  margin-left: auto;
  flex-wrap: wrap;
}

.tabs a {
  padding: 8px 16px;
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  color: var(--ink-soft);
  text-decoration: none;
  font-weight: 600;
  border: 1px solid transparent;
}

.tabs a:hover {
  background: var(--panel-2);
}

.tabs a[aria-current="page"] {
  color: #231a00;
  background: linear-gradient(180deg, var(--gold-strong), var(--gold));
  box-shadow: 0 2px 10px rgba(227, 192, 106, 0.3);
}

.topbar-status {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  font-size: 12px;
}

/* ---- 主要版面 ---- */

main {
  width: 100%;
  max-width: 1640px;
  margin: 0 auto;
  padding: 16px var(--gutter) 24px;
  outline: none;
}

.footer {
  max-width: 1640px;
  margin: 0 auto;
  padding: 8px var(--gutter) 28px;
  font-size: 12px;
  line-height: 1.6;
  color: var(--muted);
}

.boot {
  display: grid;
  place-items: center;
  gap: 14px;
  min-height: 50vh;
  color: var(--muted);
}

.boot-spinner {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 4px solid rgba(227, 192, 106, 0.2);
  border-top-color: var(--gold);
  animation: spin 0.9s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* 啟動逾時的診斷說明（boot-guard.js） */
.boot-fail {
  max-width: 720px;
  margin: 8vh auto 0;
  padding: 20px 22px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  line-height: 1.7;
}

.boot-fail h2 {
  margin: 0 0 8px;
  color: var(--gold);
  font-size: 18px;
}

.boot-fail ol {
  margin: 8px 0 14px;
  padding-left: 22px;
}

.boot-fail-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 12px;
}

.boot-fail pre {
  margin: 8px 0 0;
  padding: 10px;
  max-width: 100%;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-all;
  font-size: 12px;
  background: rgba(0, 0, 0, 0.25);
  border-radius: 6px;
}

/* ---- 面板 ---- */

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px 16px;
  min-width: 0;
}

.panel > h2,
.panel-head h2 {
  font-size: 16px;
  color: var(--gold-strong);
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}

.panel-head .sub {
  font-size: 12px;
  color: var(--muted);
}

.stack {
  display: grid;
  gap: 14px;
}

.row {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.grow {
  flex: 1 1 auto;
  min-width: 0;
}

.muted {
  color: var(--muted);
}

.small {
  font-size: 12px;
}

.mono {
  font-family: var(--mono);
}

.pos {
  color: var(--win);
}

.neg {
  color: var(--lose);
}

.hidden {
  display: none !important;
}

/* ---- 按鈕 ---- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 40px;
  padding: 8px 16px;
  border-radius: 10px;
  border: 1px solid var(--line-soft);
  background: rgba(255, 255, 255, 0.07);
  color: var(--ink);
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, transform 0.05s, box-shadow 0.15s, border-color 0.15s;
  user-select: none;
  white-space: nowrap;
}

.btn:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.13);
  border-color: rgba(255, 255, 255, 0.22);
}

.btn:active:not(:disabled) {
  transform: translateY(1px);
}

.btn:disabled {
  opacity: 0.42;
  cursor: not-allowed;
}

.btn.primary {
  color: #231a00;
  border-color: var(--gold-dim);
  background: linear-gradient(180deg, var(--gold-strong), var(--gold));
  box-shadow: 0 3px 12px rgba(227, 192, 106, 0.28);
}

.btn.primary:hover:not(:disabled) {
  background: linear-gradient(180deg, #ffe7a3, var(--gold-strong));
}

.btn.danger {
  border-color: rgba(229, 72, 61, 0.55);
  color: #ffd3cf;
  background: rgba(229, 72, 61, 0.18);
}

.btn.danger:hover:not(:disabled) {
  background: rgba(229, 72, 61, 0.32);
}

.btn.small {
  min-height: 32px;
  padding: 4px 10px;
  font-size: 13px;
  border-radius: 8px;
}

.btn.ghost {
  background: transparent;
}

.btn.active {
  border-color: var(--gold);
  background: rgba(227, 192, 106, 0.2);
  color: var(--gold-strong);
}

.chip-btn {
  min-width: 46px;
  min-height: 38px;
  padding: 4px 12px;
  border-radius: 999px;
  border: 1px solid var(--line-soft);
  background: rgba(255, 255, 255, 0.06);
  font-weight: 700;
  cursor: pointer;
}

.chip-btn:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.14);
}

.chip-btn[aria-pressed="true"] {
  background: linear-gradient(180deg, var(--gold-strong), var(--gold));
  color: #231a00;
  border-color: var(--gold-dim);
}

.chip-btn:disabled {
  opacity: 0.42;
  cursor: not-allowed;
}

/* ---- 表單 ---- */

input[type="text"],
input[type="number"],
input[type="search"],
select,
textarea {
  min-height: 40px;
  padding: 7px 10px;
  border-radius: 9px;
  border: 1px solid var(--line-soft);
  background: rgba(0, 0, 0, 0.35);
  color: var(--ink);
  width: 100%;
  min-width: 0;
}

textarea {
  min-height: 90px;
  resize: vertical;
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.5;
}

select {
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--gold) 50%), linear-gradient(135deg, var(--gold) 50%, transparent 50%);
  background-position: calc(100% - 17px) 50%, calc(100% - 12px) 50%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 30px;
}

select option {
  background: #0a2a1f;
  color: var(--ink);
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--gold);
  outline: none;
  box-shadow: 0 0 0 3px rgba(227, 192, 106, 0.18);
}

input[type="checkbox"],
input[type="radio"] {
  width: 18px;
  height: 18px;
  accent-color: var(--gold);
  flex: none;
}

input[type="range"] {
  accent-color: var(--gold);
  width: 100%;
}

input.invalid,
select.invalid {
  border-color: var(--lose);
}

label.check {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  min-height: 32px;
}

/* ---- 標籤、徽章 ---- */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  border: 1px solid var(--line-soft);
  background: rgba(255, 255, 255, 0.07);
  white-space: nowrap;
}

.badge.gold {
  border-color: var(--gold-dim);
  color: var(--gold-strong);
  background: rgba(227, 192, 106, 0.12);
}

.badge.b {
  background: rgba(229, 72, 61, 0.2);
  border-color: rgba(229, 72, 61, 0.6);
  color: #ffb9b3;
}

.badge.p {
  background: rgba(63, 131, 232, 0.2);
  border-color: rgba(63, 131, 232, 0.6);
  color: #b9d3ff;
}

.badge.t {
  background: rgba(52, 184, 111, 0.2);
  border-color: rgba(52, 184, 111, 0.6);
  color: #b9f0d1;
}

.badge.warn {
  background: rgba(255, 190, 70, 0.16);
  border-color: rgba(255, 190, 70, 0.55);
  color: #ffd98f;
}

.badge.bad {
  background: rgba(255, 123, 114, 0.16);
  border-color: rgba(255, 123, 114, 0.55);
  color: #ffb3ad;
}

/* ---- 表格 ---- */

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-sm);
  max-width: 100%;
}

table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

table.data th,
table.data td {
  padding: 7px 10px;
  text-align: right;
  border-bottom: 1px solid var(--line-soft);
  white-space: nowrap;
}

table.data th:first-child,
table.data td:first-child {
  text-align: left;
}

table.data thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #0d3426;
  color: var(--gold-strong);
  font-weight: 700;
}

table.data tbody tr:hover {
  background: rgba(255, 255, 255, 0.05);
}

table.data td.l,
table.data th.l {
  text-align: left;
}

table.data td.c,
table.data th.c {
  text-align: center;
}

/* ---- 通知、對話框 ---- */

.toasts {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 90;
  display: grid;
  gap: 8px;
  max-width: min(420px, calc(100vw - 32px));
}

.toast {
  padding: 10px 14px;
  border-radius: 10px;
  background: #0d3426;
  border: 1px solid var(--gold-dim);
  box-shadow: var(--shadow);
  animation: toast-in 0.2s ease-out;
}

.toast.error {
  border-color: var(--lose);
  background: #3a1411;
}

.toast.ok {
  border-color: var(--tie);
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
}

.modal-back {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(0, 0, 0, 0.62);
}

.modal {
  width: min(560px, 100%);
  max-height: calc(100vh - 32px);
  overflow: auto;
  padding: 18px 20px;
  background: var(--panel-solid);
  border: 1px solid var(--gold-dim);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.modal.wide {
  width: min(1040px, 100%);
}

.modal h3 {
  color: var(--gold-strong);
  margin-bottom: 10px;
}

.modal .actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 16px;
  flex-wrap: wrap;
}

/* ---- 提示、說明 ---- */

.notice {
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: rgba(227, 192, 106, 0.08);
  font-size: 13px;
  line-height: 1.6;
}

.notice.warn {
  border-color: rgba(255, 190, 70, 0.5);
  background: rgba(255, 190, 70, 0.1);
}

.notice.bad {
  border-color: rgba(255, 123, 114, 0.55);
  background: rgba(255, 123, 114, 0.1);
}

.notice ul {
  margin: 4px 0 0;
  padding-left: 20px;
}

.progress {
  height: 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
  overflow: hidden;
}

.progress > i {
  display: block;
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--gold-dim), var(--gold-strong));
  transition: width 0.15s linear;
}

/* ---- 捲軸 ---- */

* {
  scrollbar-width: thin;
  scrollbar-color: rgba(227, 192, 106, 0.4) transparent;
}

::-webkit-scrollbar {
  width: 9px;
  height: 9px;
}

::-webkit-scrollbar-thumb {
  background: rgba(227, 192, 106, 0.35);
  border-radius: 6px;
}

/* ---- 手機與平板 ---- */

@media (max-width: 900px) {
  .topbar {
    gap: 8px 12px;
  }

  .tabs {
    margin-left: 0;
    width: 100%;
    overflow-x: auto;
    flex-wrap: nowrap;
    padding-bottom: 2px;
  }

  .tabs a {
    padding: 8px 14px;
    flex: none;
  }

  .topbar-status {
    display: none;
  }
}

@media (max-width: 560px) {
  :root {
    --gutter: 12px;
  }

  body {
    font-size: 14px;
  }

  .brand-text h1 {
    font-size: 15px;
  }

  .brand-text p {
    display: none;
  }

  .brand-mark {
    width: 36px;
    height: 36px;
    font-size: 20px;
  }

  .panel {
    padding: 12px;
  }

  .toasts {
    left: 12px;
    right: 12px;
    bottom: 12px;
    max-width: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
/* Both interfaces share the mounted controls and storage; only presentation changes. */
[data-interface="classic"] .modern-only,
[data-interface="classic"] .home-slogan,
[data-interface="classic"] .home-footer-brand,
html:not([data-interface="classic"]) .classic-only { display: none !important; }
.interface-switch { position: absolute; right: 18px; top: 6px; z-index: 5; min-height: 30px; white-space: nowrap; }
[data-interface="classic"] .topbar { padding-top: 44px; }
#classic-levels-table { table-layout: auto; min-width: 1080px; }
#classic-levels-table th:first-child { width: auto; }
@media (max-width: 1000px) {
  html:not([data-interface="classic"]) .topbar { padding-top: 46px; }
}
@media print { .interface-switch { display: none !important; } }
/* Wide printable reports scroll inside their preview, keeping mobile navigation usable. */
@media screen { #reports-host { max-width: 100%; overflow-x: auto; } }
