/* Score Board — original theme.
   Warm "countryside" palette, light & dark. No third-party assets. */

:root {
  --bg: #f3efe4;
  --surface: #fffdf7;
  --surface-2: #efe9da;
  --ink: #2b2a24;
  --ink-soft: #6c6859;
  --line: #ded7c4;
  --green: #5a7d3c;
  --green-dark: #3f5c2a;
  --green-ink: #2f471d;
  --accent: #c9792b;
  --danger: #b23b35;
  --felt: #6f8f49;
  --felt-dark: #43611f;
  --felt-line: rgba(255, 255, 255, 0.28);
  --radius: 14px;
  --shadow: 0 2px 8px rgba(40, 35, 20, 0.08), 0 8px 24px rgba(40, 35, 20, 0.06);
  --maxw: 980px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1c1d18;
    --surface: #26271f;
    --surface-2: #2e2f26;
    --ink: #ece7d7;
    --ink-soft: #a7a08c;
    --line: #3c3d32;
    --green: #8fb264;
    --green-dark: #6f8f49;
    --green-ink: #cfe0b4;
    --accent: #e0995a;
    --danger: #e0756d;
    --felt: #415a28;
    --felt-dark: #2c3f1a;
    --felt-line: rgba(255, 255, 255, 0.18);
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.25);
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, Helvetica, Arial, sans-serif;
  line-height: 1.5;
}

a { color: var(--green-dark); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) a { color: var(--green); } }

/* ---- layout ---- */
.site-header {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 16px;
  max-width: var(--maxw);
  margin: 0 auto;
  flex-wrap: wrap;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  font-size: 1.15rem;
  text-decoration: none;
  color: var(--ink);
  margin-right: auto;
}
.brand-mark {
  width: 26px; height: 26px; border-radius: 8px;
  background:
    radial-gradient(circle at 70% 30%, var(--accent) 0 18%, transparent 19%),
    linear-gradient(135deg, var(--green) 0%, var(--green-dark) 100%);
  box-shadow: inset 0 0 0 2px rgba(255,255,255,0.25);
}
.site-nav { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.site-main { max-width: var(--maxw); margin: 0 auto; padding: 8px 16px 90px; }
.site-footer {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 24px 16px 40px;
  display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  color: var(--ink-soft);
  font-size: 0.85rem;
}

/* ---- buttons ---- */
.btn {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  padding: 8px 14px;
  border-radius: 10px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex; align-items: center; gap: 6px;
  transition: transform .05s ease, background .15s ease, border-color .15s ease;
}
.btn:hover { border-color: var(--green); }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--green); border-color: var(--green-dark); color: #fff; }
.btn-primary:hover { background: var(--green-dark); }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-ghost:hover { background: var(--surface-2); border-color: transparent; }
.btn-danger { color: #fff; background: var(--danger); border-color: var(--danger); }
.btn-sm { padding: 5px 10px; font-size: .85rem; border-radius: 8px; }

.user-chip {
  font-size: .85rem; color: var(--ink-soft);
  background: var(--surface-2); padding: 5px 10px; border-radius: 999px;
}

/* language switch */
.lang-switch { display: inline-flex; border: 1px solid var(--line); border-radius: 999px; overflow: hidden; }
.lang-opt { padding: 4px 10px; font-size: .8rem; font-weight: 700; text-decoration: none; color: var(--ink-soft); }
.lang-opt.is-active { background: var(--green); color: #fff; }

/* ---- hero / index ---- */
.hero { padding: 24px 0 8px; }
.hero h1 { margin: 0 0 4px; font-size: 1.8rem; }
.hero-sub { margin: 0; color: var(--ink-soft); }

.game-grid { list-style: none; padding: 0; margin: 16px 0; display: grid; gap: 14px;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.game-card a {
  display: flex; gap: 14px; align-items: flex-start;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 16px; text-decoration: none; color: var(--ink);
  box-shadow: var(--shadow); height: 100%;
  transition: transform .08s ease, border-color .15s ease;
}
.game-card a:hover { transform: translateY(-2px); border-color: var(--green); }
.game-icon {
  flex: 0 0 auto; width: 48px; height: 48px; border-radius: 12px;
  background: linear-gradient(135deg, var(--felt), var(--felt-dark));
  color: #fff; display: grid; place-items: center;
}
.game-icon .ic { width: 28px; height: 28px; }
.game-icon--sm { width: 34px; height: 34px; border-radius: 9px; vertical-align: middle; }
.game-icon--sm .ic { width: 20px; height: 20px; }
.game-body { display: flex; flex-direction: column; gap: 4px; }
.game-name { font-weight: 800; font-size: 1.1rem; }
.game-desc { color: var(--ink-soft); font-size: .9rem; }
.game-versions { margin-top: 6px; display: flex; flex-wrap: wrap; gap: 6px; }
.pill { font-size: .72rem; background: var(--surface-2); color: var(--ink-soft);
  padding: 3px 8px; border-radius: 999px; }

/* ---- game header / toolbar ---- */
.back-link { font-size: .9rem; text-decoration: none; color: var(--ink-soft); }
.game-header h1 { margin: 6px 0 12px; font-size: 1.6rem; display: flex; align-items: center; gap: 10px; }
.toolbar {
  display: flex; gap: 12px; align-items: center; flex-wrap: wrap;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 12px; box-shadow: var(--shadow);
}
.version-select { display: flex; flex-direction: column; gap: 2px; font-size: .78rem; color: var(--ink-soft); }
.version-select select, .meta-field input, .guided-input {
  font: inherit; padding: 8px 10px; border-radius: 9px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
}
.mode-toggle { display: inline-flex; border: 1px solid var(--line); border-radius: 999px; overflow: hidden; }
.mode-btn { appearance: none; border: 0; background: transparent; padding: 8px 14px;
  font: inherit; font-weight: 600; cursor: pointer; color: var(--ink-soft); }
.mode-btn.is-active { background: var(--green); color: #fff; }
.toolbar-actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }
.storage-hint { margin: 8px 2px 0; font-size: .82rem; color: var(--ink-soft); min-height: 1.1em; }
.storage-hint.is-error { color: var(--danger); }

/* ---- cards ---- */
.card { background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 16px; margin: 14px 0; box-shadow: var(--shadow); }
.card-title { margin: 0 0 12px; font-size: 1.1rem; color: var(--green-ink); }

.meta-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.meta-field { display: flex; flex-direction: column; gap: 4px; }
.meta-label { font-size: .8rem; color: var(--ink-soft); }

/* ---- score grid (the "felt") ---- */
.grid-card { background: linear-gradient(160deg, var(--felt), var(--felt-dark)); border-color: var(--felt-dark); }
.grid-card .card-title { color: #fff; }
.grid-scroll { overflow-x: auto; }
.score-grid { width: 100%; border-collapse: separate; border-spacing: 4px; color: #fff; min-width: 520px; }
.score-grid th, .score-grid td { text-align: center; }
.col-head, .sum-head {
  background: var(--felt-dark); border-radius: 8px; padding: 8px 6px; font-size: .8rem;
}
.col-icon .ic { width: 24px; height: 24px; display: block; margin: 0 auto 2px; }
.corner { background: transparent; width: 92px; }
.row-head { text-align: left; padding: 6px 8px; font-weight: 700; white-space: nowrap; }
.row-head .ic { width: 18px; height: 18px; vertical-align: -3px; }
.cell { background: rgba(255,255,255,0.14); border-radius: 8px; padding: 4px; position: relative; }
.cell-hint { display: block; font-size: .62rem; opacity: .85; margin-bottom: 2px; }
.num-in {
  width: 100%; min-width: 48px; font: inherit; font-weight: 700; text-align: center;
  padding: 7px 4px; border-radius: 7px; border: 1px solid var(--felt-line);
  background: rgba(255,255,255,0.92); color: #23311a;
}
.num-in:focus { outline: 2px solid var(--accent); }
.cell-total { background: transparent; font-weight: 800; }
.cell-grand { background: var(--accent); border-radius: 8px; font-weight: 800; color: #fff; }
.grid-foot .row-head { color: #fff; }

/* ---- tiles ---- */
.tiles-grid { display: grid; gap: 8px; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.tile-row { display: flex; align-items: center; gap: 10px; justify-content: space-between;
  padding: 8px 10px; background: var(--surface-2); border-radius: 10px; }
.tile-info { display: flex; flex-direction: column; }
.tile-name { font-weight: 700; }
.tile-note { font-size: .74rem; color: var(--ink-soft); }
.tile-input { display: flex; align-items: center; gap: 6px; }
.tile-input .num-in { width: 70px; background: var(--surface); color: var(--ink); border-color: var(--line); }
.tile-eq { color: var(--ink-soft); }
.tile-score { min-width: 2.2em; text-align: right; font-weight: 800; color: var(--green-dark); }
.tiles-foot { display: flex; justify-content: flex-end; gap: 10px; align-items: baseline;
  margin-top: 12px; font-weight: 700; }
.tiles-sum { font-size: 1.3rem; color: var(--accent); }

/* ---- rank table ---- */
.rank-list { display: grid; gap: 8px; }
.rank-row { display: grid; grid-template-columns: 90px 110px 1fr; gap: 10px; align-items: center;
  padding: 8px 10px; background: var(--surface-2); border-radius: 10px; }
.rank-round { font-weight: 700; color: var(--ink-soft); }
.rank-in { background: var(--surface); color: var(--ink); border-color: var(--line); }
.rank-badge { font-weight: 700; color: var(--green-dark); }

/* ---- checklist ---- */
.check-group { margin-bottom: 14px; }
.check-head { display: flex; justify-content: space-between; font-weight: 700; margin-bottom: 6px;
  color: var(--green-ink); }
.check-progress { color: var(--ink-soft); font-weight: 600; }
.check-items { display: grid; gap: 4px; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
.check-item { display: flex; gap: 8px; align-items: center; padding: 4px 6px; border-radius: 8px; }
.check-item:hover { background: var(--surface-2); }

/* ---- guided mode ---- */
.guided-card { max-width: 520px; margin: 16px auto; }
.guided-progress { color: var(--ink-soft); font-size: .85rem; margin: 0 0 8px; }
.guided-context { font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--accent); }
.guided-label { margin: 4px 0 6px; font-size: 1.4rem; display: flex; align-items: center; gap: 8px; }
.guided-label .ic { width: 26px; height: 26px; color: var(--green); }
.guided-note { color: var(--ink-soft); margin: 0 0 12px; }
.guided-input { width: 100%; font-size: 1.3rem; text-align: center; padding: 12px; }
.num-in.guided-input { background: var(--surface); color: var(--ink); border-color: var(--line); }
.guided-live { min-height: 1.4em; font-weight: 700; color: var(--green-dark); margin: 8px 0; }
.guided-nav { display: flex; justify-content: space-between; gap: 10px; margin-top: 14px; }
.guided-nav .btn { flex: 1; justify-content: center; }
.guided-running { text-align: center; margin: 14px 0 0; color: var(--ink-soft); }
.guided-running strong { font-size: 1.3rem; color: var(--accent); }

/* ---- result bar ---- */
.result-bar {
  position: fixed; left: 50%; bottom: 16px; transform: translateX(-50%);
  background: var(--green-dark); color: #fff; border-radius: 999px;
  padding: 10px 22px; display: flex; align-items: center; gap: 12px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.25); z-index: 20;
}
.result-label { font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; opacity: .85; }
.result-total { font-size: 1.6rem; font-weight: 800; }

/* ---- history drawer ---- */
.drawer { position: fixed; inset: 0; background: rgba(0,0,0,0.4); z-index: 40;
  display: flex; justify-content: flex-end; }
.drawer-panel { width: min(440px, 100%); background: var(--bg); height: 100%;
  display: flex; flex-direction: column; box-shadow: -8px 0 24px rgba(0,0,0,0.2); }
.drawer-head { display: flex; justify-content: space-between; align-items: center;
  padding: 16px; border-bottom: 1px solid var(--line); }
.drawer-head h2 { margin: 0; }
.drawer-body { padding: 12px 16px; overflow-y: auto; }
.hist-row { display: flex; justify-content: space-between; gap: 10px; align-items: center;
  padding: 10px 0; border-bottom: 1px solid var(--line); }
.hist-info { display: flex; flex-direction: column; }
.hist-title { font-weight: 700; }
.hist-meta { font-size: .78rem; color: var(--ink-soft); }
.hist-acts { display: flex; gap: 6px; }
.hist-empty { color: var(--ink-soft); }

/* ---- prose (privacy) ---- */
.prose { max-width: 720px; }
.prose h1 { font-size: 1.7rem; }
.prose h2 { color: var(--green-ink); margin-top: 1.5em; }
.prose code { background: var(--surface-2); padding: 1px 5px; border-radius: 5px; }
.gdpr-actions { display: flex; gap: 10px; flex-wrap: wrap; margin: 12px 0; }
.erase-status { color: var(--danger); font-weight: 600; }

@media (max-width: 560px) {
  .toolbar-actions { margin-left: 0; width: 100%; }
  .result-total { font-size: 1.3rem; }
}
