:root {
  --ink: #13201a;
  --ink-2: #31413a;
  --muted: #758078;
  --paper: #f4f2eb;
  --panel: #fffefa;
  --line: #deddd5;
  --line-strong: #cbc9be;
  --green-950: #0c1712;
  --green-900: #12251b;
  --green-800: #1b3828;
  --acid: #c8ee63;
  --acid-soft: #eaf7bd;
  --orange: #e07838;
  --orange-soft: #f9e1d2;
  --red: #b9433f;
  --red-soft: #f7dedb;
  --blue: #3d718e;
  --blue-soft: #dcecf4;
  --shadow: 0 18px 40px rgba(24, 35, 29, 0.07);
  --radius: 18px;
}

/* Account gate: the app opens only after Supabase authentication. */
body.auth-required .app-shell {
  filter: blur(9px) saturate(.55);
  pointer-events: none;
  user-select: none;
}

#data-dialog.auth-gate .icon-button[value="cancel"] { display: none; }
#data-dialog.auth-gate::backdrop {
  background: rgba(5, 7, 20, .82);
  backdrop-filter: blur(12px);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-width: 320px;
  color: var(--ink);
  background: var(--paper);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

button,
input,
select,
textarea {
  font: inherit;
}

button,
select {
  cursor: pointer;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
a:focus-visible {
  outline: 3px solid rgba(200, 238, 99, 0.6);
  outline-offset: 2px;
}

.app-shell {
  min-height: 100vh;
}

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 20;
  width: 246px;
  display: flex;
  flex-direction: column;
  padding: 24px 18px 18px;
  color: #ecf2ed;
  background:
    radial-gradient(circle at 20% 3%, rgba(200, 238, 99, 0.08), transparent 30%),
    var(--green-950);
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  color: inherit;
  text-decoration: none;
  padding: 2px 4px 26px;
}

.brand-mark {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
}

.brand-mark svg {
  width: 40px;
  fill: none;
  stroke: var(--acid);
  stroke-width: 2;
  stroke-linejoin: round;
}

.brand-mark svg path:last-child {
  fill: var(--acid);
  stroke: none;
}

.brand strong,
.brand small {
  display: block;
}

.brand strong {
  letter-spacing: -0.03em;
  font-size: 18px;
}

.brand small {
  margin-top: 1px;
  color: #91a096;
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.nav-list {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.nav-item {
  width: 100%;
  border: 0;
  border-radius: 10px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 13px;
  color: #9eaaa2;
  background: transparent;
  text-align: left;
  transition: 160ms ease;
}

.nav-item:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.05);
}

.nav-item.is-active {
  color: var(--green-950);
  background: var(--acid);
  font-weight: 760;
}

.nav-icon {
  width: 20px;
  color: inherit;
  font-size: 18px;
  line-height: 1;
  text-align: center;
}

.nav-coach {
  position: relative;
  margin-top: 13px;
}

.nav-coach::before {
  content: "";
  position: absolute;
  top: -8px;
  left: 12px;
  right: 12px;
  height: 1px;
  background: rgba(255, 255, 255, 0.09);
}

.sidebar-footer {
  margin-top: auto;
}

.privacy-card {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 13px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.035);
}

.privacy-card strong,
.privacy-card small {
  display: block;
}

.privacy-card strong {
  font-size: 12px;
}

.privacy-card small {
  margin-top: 3px;
  color: #819087;
  font-size: 10px;
  line-height: 1.35;
}

.status-dot {
  width: 8px;
  height: 8px;
  flex: 0 0 auto;
  margin-top: 4px;
  border-radius: 50%;
  background: var(--acid);
  box-shadow: 0 0 0 4px rgba(200, 238, 99, 0.12);
}

.sidebar-footer > .text-button {
  width: 100%;
  margin-top: 12px;
  color: #8f9c94;
  text-align: center;
  font-size: 11px;
}

.main-content {
  min-height: 100vh;
  margin-left: 246px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  min-height: 104px;
  display: flex;
  align-items: center;
  gap: 22px;
  padding: 20px clamp(24px, 4vw, 58px);
  border-bottom: 1px solid rgba(203, 201, 190, 0.8);
  background: rgba(244, 242, 235, 0.91);
  backdrop-filter: blur(18px);
}

.topbar-title {
  min-width: 0;
  flex: 1;
}

.eyebrow,
.panel-kicker {
  color: #6f7b73;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.topbar h1 {
  overflow: hidden;
  margin: 4px 0 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(22px, 2.4vw, 32px);
  font-weight: 500;
  letter-spacing: -0.035em;
  line-height: 1.08;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.topbar-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 18px;
}

.format-switch {
  display: inline-flex;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.72);
}

.format-switch button {
  border: 0;
  border-radius: 7px;
  padding: 7px 11px;
  color: var(--muted);
  background: transparent;
  font-size: 10px;
  font-weight: 800;
}

.format-switch button.is-active { color: var(--green-950); background: var(--acid); }
body[data-format="cedh"] { --acid: #cbb7ff; --acid-soft: #eee7ff; }
body[data-format="cedh"] .format-switch button.is-active { color: #fff; background: #7458b4; }

.format-context {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0 22px 14px;
  padding: 11px 13px;
  border-radius: 10px;
  background: var(--acid-soft);
}

.format-context span {
  border-radius: 999px;
  padding: 4px 8px;
  color: var(--green-950);
  background: var(--acid);
  font-size: 9px;
  font-weight: 850;
}

.format-context p { margin: 0; color: var(--ink-2); font-size: 11px; }

.save-state {
  color: var(--muted);
  font-size: 11px;
}

.save-state span {
  color: #6da03d;
  font-size: 9px;
}

.mobile-menu {
  display: none;
  width: 40px;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--panel);
}

.mobile-data,
.mobile-capture-note {
  display: none;
}

.view {
  display: none;
  padding: 30px clamp(24px, 4vw, 58px) 56px;
}

.view.is-visible {
  display: block;
  animation: view-in 220ms ease-out;
}

@keyframes view-in {
  from { opacity: 0; transform: translateY(5px); }
  to { opacity: 1; transform: none; }
}

.view-toolbar {
  min-height: 40px;
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
}

.segmented {
  display: inline-flex;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.6);
}

.segmented button {
  border: 0;
  border-radius: 7px;
  padding: 7px 12px;
  color: var(--muted);
  background: transparent;
  font-size: 11px;
}

.segmented button.is-active {
  color: var(--ink);
  background: #fff;
  box-shadow: 0 2px 8px rgba(20, 33, 26, 0.08);
  font-weight: 700;
}

.select-control,
.search-box {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--ink-2);
  background: rgba(255, 255, 255, 0.6);
}

.select-control {
  min-width: 178px;
  padding: 7px 34px 7px 11px;
}

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 14px;
}

.metrics-grid.compact {
  margin-bottom: 14px;
}

.metric-card {
  position: relative;
  overflow: hidden;
  min-height: 126px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: 0 8px 24px rgba(23, 31, 27, 0.035);
}

.metric-card::after {
  content: "";
  position: absolute;
  right: -20px;
  bottom: -42px;
  width: 100px;
  height: 100px;
  border-radius: 50%;
  border: 20px solid rgba(200, 238, 99, 0.1);
}

.metric-label {
  color: var(--muted);
  font-size: 10px;
  font-weight: 750;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.metric-value {
  display: flex;
  align-items: baseline;
  gap: 4px;
  margin-top: 8px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 36px;
  line-height: 1;
  letter-spacing: -0.05em;
}

.metric-value small {
  color: var(--muted);
  font-family: Inter, ui-sans-serif, sans-serif;
  font-size: 12px;
  letter-spacing: 0;
}

.metric-foot {
  margin-top: 10px;
  color: var(--muted);
  font-size: 10px;
}

.metric-foot strong.good { color: #4a7a24; }
.metric-foot strong.warn { color: var(--orange); }
.metric-foot strong.bad { color: var(--red); }

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(280px, 0.85fr);
  gap: 14px;
}

.field-help { display: block; margin-top: 6px; color: var(--muted); font-size: 10px; }
.inline-link { border: 0; padding: 0; color: var(--green-700, #4f702f); background: none; font: inherit; font-weight: 800; text-decoration: underline; cursor: pointer; }
.deck-performance { padding: 0 22px 22px; }
.deck-library { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.deck-card { display: grid; grid-template-columns: 124px minmax(0, 1fr); overflow: hidden; }
.deck-cover { min-height: 178px; border: 0; padding: 0; background: #132019; cursor: pointer; overflow: hidden; }
.deck-cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.deck-cover span { display: grid; height: 100%; place-items: center; color: var(--acid); font-size: 46px; }
.deck-card-body { min-width: 0; padding: 20px; }
.deck-card-body h2 { margin: 5px 0 8px; font: 500 23px/1.1 Georgia, serif; }
.deck-card-body p { margin: 0; color: var(--muted); font-size: 12px; }
.deck-card-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin-top: 22px; }
.danger-text { color: var(--red); }
.empty-deck-library { grid-column: 1 / -1; padding: 38px; text-align: center; }
.empty-deck-library .button { margin-top: 18px; }
.deck-import-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.auth-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.auth-fields > p, .auth-fields > .button { grid-column: 1 / -1; }
.deck-detail-summary { display: flex; align-items: center; flex-wrap: wrap; gap: 12px; padding: 0 22px 18px; color: var(--muted); }
.deck-detail-summary strong { color: var(--ink); font: 500 23px Georgia, serif; }
.deck-detail-summary a { margin-left: auto; color: inherit; }
.deck-analysis-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 8px; padding: 0 22px 24px; }
.deck-analysis-grid > div { min-width: 0; padding: 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--paper); }
.deck-analysis-grid span, .deck-analysis-grid small { display: block; color: var(--muted); font-size: 9px; }
.deck-analysis-grid strong { display: block; margin: 5px 0 3px; overflow: hidden; font: 500 18px Georgia, serif; text-overflow: ellipsis; white-space: nowrap; }
.card-section { padding: 0 22px 24px; }
.card-section h3 { margin: 0 0 12px; font: 500 18px Georgia, serif; }
.card-board-section { padding: 0 22px 28px; }
.card-board-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding-bottom: 11px; border-bottom: 1px solid var(--line); }
.card-board-heading h3 { margin: 0; font: 500 20px Georgia, serif; }
.card-board-heading span { color: var(--muted); font-size: 10px; font-weight: 750; }
.card-type-group { padding-top: 18px; }
.card-type-group h4 { display: flex; align-items: center; gap: 8px; margin: 0 0 10px; color: var(--ink-2); font-size: 10px; font-weight: 850; letter-spacing: .12em; text-transform: uppercase; }
.card-type-group h4::before { content: ""; width: 15px; height: 1px; background: var(--acid); box-shadow: 0 0 8px var(--acid); }
.card-type-group h4 span { color: var(--muted); font-size: 9px; }
.card-gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); gap: 10px; }
.magic-card { min-width: 0; }
.magic-card img, .card-placeholder { width: 100%; aspect-ratio: 488 / 680; border-radius: 8px; object-fit: cover; background: #18241e; }
.card-placeholder { display: grid; place-items: center; padding: 10px; color: #eef3e8; text-align: center; }
.magic-card span { display: block; margin-top: 5px; overflow: hidden; color: var(--muted); font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.magic-card small { display: block; margin-top: 1px; overflow: hidden; color: #9596ae; font-size: 8px; text-overflow: ellipsis; white-space: nowrap; }
.deck-detail-dialog,
#deck-detail-dialog { width: min(940px, calc(100vw - 28px)); }
.deck-detail-card { width: 100%; }

.panel {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: 0 8px 28px rgba(23, 31, 27, 0.035);
}

.span-2 {
  grid-column: 1 / -1;
}

.panel-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 22px 14px;
}

.panel-heading h2 {
  margin: 4px 0 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 19px;
  font-weight: 500;
  letter-spacing: -0.025em;
}

.panel-note,
.required-note,
.sample-hint {
  color: var(--muted);
  font-size: 10px;
}

.sample-hint {
  margin-right: auto;
}

.trend-chart {
  min-height: 238px;
  padding: 8px 22px 22px;
}

.trend-svg {
  width: 100%;
  height: 170px;
  overflow: visible;
}

.trend-grid-line {
  stroke: #e8e5dd;
  stroke-width: 1;
}

.trend-area { fill: url(#trend-gradient); }
.trend-line { fill: none; stroke: #5b7f36; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.trend-point { fill: var(--panel); stroke: #5b7f36; stroke-width: 2; }

.chart-labels {
  display: flex;
  justify-content: space-between;
  margin-top: 2px;
  color: #8d958f;
  font-size: 9px;
}

.empty-state {
  min-height: 140px;
  display: grid;
  place-items: center;
  padding: 24px;
  color: var(--muted);
  text-align: center;
}

.focus-panel {
  background:
    radial-gradient(circle at 100% 0, rgba(200, 238, 99, 0.12), transparent 40%),
    var(--green-900);
  color: #f1f4ef;
  border-color: var(--green-900);
}

.focus-panel .panel-kicker { color: var(--acid); }
.focus-panel .panel-heading h2 { color: #f1f4ef; }

.focus-content {
  padding: 10px 22px 22px;
}

.focus-icon {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(200, 238, 99, 0.28);
  border-radius: 12px;
  color: var(--acid);
  background: rgba(200, 238, 99, 0.08);
  font-size: 20px;
}

.focus-content h3 {
  margin: 16px 0 7px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 22px;
  font-weight: 500;
}

.focus-content p {
  color: #aebbb2;
  font-size: 12px;
}

.focus-content .button {
  margin-top: 10px;
}

.button {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 9px 15px;
  font-size: 12px;
  font-weight: 750;
  text-decoration: none;
  transition: transform 150ms ease, box-shadow 150ms ease, background 150ms ease;
}

.button:hover { transform: translateY(-1px); }
.button:active { transform: none; }

.button-primary {
  color: var(--green-950);
  background: var(--acid);
  box-shadow: 0 7px 16px rgba(96, 119, 40, 0.14);
}

.button-primary:hover { background: #d5f781; }

.button-secondary {
  color: #fff;
  background: var(--green-800);
}

.button-ghost {
  color: var(--ink-2);
  border-color: var(--line-strong);
  background: transparent;
}

.button-danger {
  color: var(--red);
  border-color: #e4aaa5;
  background: var(--red-soft);
}

.button-compact {
  min-height: 36px;
  padding: 7px 13px;
  font-size: 11px;
}

.full-width { width: 100%; }

.text-button,
.icon-button {
  border: 0;
  padding: 0;
  color: #4f6657;
  background: transparent;
  font-weight: 700;
}

.text-button {
  font-size: 10px;
  letter-spacing: 0.02em;
}

.icon-button {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  font-size: 22px;
}

.icon-button:hover { background: var(--paper); }

.table-wrap {
  overflow: auto;
  border-top: 1px solid #e9e7df;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

th,
td {
  padding: 14px 22px;
  border-bottom: 1px solid #eceae2;
  text-align: left;
  white-space: nowrap;
}

th {
  color: #8a928c;
  background: #faf9f4;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: #fbfaf5; }

.deck-cell {
  display: flex;
  align-items: center;
  gap: 10px;
}

.deck-swatch {
  width: 8px;
  height: 28px;
  border-radius: 5px;
  background: var(--acid);
}

.deck-cell strong,
.deck-cell small {
  display: block;
}

.deck-cell small {
  color: var(--muted);
  font-size: 9px;
}

.result-pill,
.privacy-pill,
.tag-pill {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.result-pill { padding: 5px 8px; }
.result-win { color: #42631e; background: var(--acid-soft); }
.result-loss { color: #9a3734; background: var(--red-soft); }
.result-draw { color: #53626d; background: #e8ecef; }
.privacy-pill { padding: 5px 9px; color: #4e702b; background: var(--acid-soft); }
.tag-pill { padding: 4px 7px; color: #566159; background: #efeee8; }

.form-progress {
  max-width: 520px;
  display: flex;
  align-items: center;
  margin: 0 auto 25px;
  color: #9ca39e;
  font-size: 10px;
}

.form-progress span {
  display: flex;
  align-items: center;
  gap: 7px;
}

.form-progress span::first-letter {
  font-size: 0;
}

.form-progress span {
  min-width: 27px;
}

.form-progress span b {
  font-size: 10px;
  font-weight: 700;
}

.form-progress i {
  height: 1px;
  flex: 1;
  margin: 0 9px;
  background: var(--line);
}

.form-progress .is-active { color: #456022; }

.form-progress .is-active::before {
  background: var(--acid);
}

.form-panel {
  max-width: 1120px;
  margin: 0 auto 14px;
}

.form-grid {
  display: grid;
  gap: 16px;
  padding: 8px 22px 24px;
}

.form-grid.four-cols { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.form-grid.two-cols { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-grid.one-col { grid-template-columns: 1fr; }
.span-2-field { grid-column: span 2; }

label > span,
.coach-label > span {
  display: block;
  margin-bottom: 6px;
  color: #59655e;
  font-size: 10px;
  font-weight: 760;
  letter-spacing: 0.045em;
  text-transform: uppercase;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  color: var(--ink);
  background: #fff;
}

input,
select {
  min-height: 41px;
  padding: 9px 11px;
}

textarea {
  resize: vertical;
  padding: 10px 11px;
  line-height: 1.45;
}

input::placeholder,
textarea::placeholder { color: #a4aaa6; }

input:focus,
select:focus,
textarea:focus {
  border-color: #7c9a4c;
  outline: 0;
  box-shadow: 0 0 0 3px rgba(200, 238, 99, 0.2);
}

input:disabled {
  color: #8d958f;
  background: #f1f0eb;
}

.game-tabs {
  max-width: 1120px;
  display: flex;
  gap: 4px;
  margin: 22px auto 0;
  padding-left: 18px;
}

.game-tabs button {
  border: 1px solid transparent;
  border-bottom: 0;
  border-radius: 10px 10px 0 0;
  padding: 10px 18px;
  color: var(--muted);
  background: transparent;
  font-size: 11px;
  font-weight: 750;
}

.game-tabs button span {
  margin-left: 4px;
  font-size: 8px;
  font-weight: 500;
  text-transform: uppercase;
}

.game-tabs button.is-active {
  position: relative;
  z-index: 2;
  color: var(--ink);
  border-color: var(--line);
  background: var(--panel);
}

.game-panel {
  display: none;
  max-width: 1120px;
  margin: -1px auto 14px;
  border-radius: var(--radius);
}

.game-panel.is-visible { display: block; }

.game-section {
  padding: 20px 22px;
  border-top: 1px solid #e9e7df;
}

.game-section:first-of-type { border-top: 0; }

.game-section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.game-section-title h3 {
  margin: 0;
  font-size: 12px;
}

.game-section-title small {
  color: var(--muted);
  font-size: 9px;
}

.game-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.game-grid .wide { grid-column: span 2; }
.game-grid .full { grid-column: 1 / -1; }

.game-enabled {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 10px;
}

.game-enabled input {
  width: 16px;
  min-height: 16px;
  accent-color: #668631;
}

.game-panel.is-disabled .game-section { opacity: 0.46; }
.game-panel.is-disabled .game-section input,
.game-panel.is-disabled .game-section select,
.game-panel.is-disabled .game-section textarea { pointer-events: none; }

.form-actions {
  max-width: 1120px;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin: 20px auto 0;
}

.analysis-stack {
  padding: 6px 22px 22px;
}

.analysis-row {
  padding: 13px 0;
  border-bottom: 1px solid #eceae2;
}

.analysis-row:last-child { border-bottom: 0; }

.analysis-row-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
  font-size: 11px;
}

.analysis-row-head strong { font-weight: 750; }
.analysis-row-head span { color: var(--muted); font-size: 10px; }

.bar-track {
  height: 7px;
  overflow: hidden;
  border-radius: 999px;
  background: #ecebe5;
}

.bar-fill {
  height: 100%;
  min-width: 3px;
  border-radius: inherit;
  background: #6e9139;
}

.bar-fill.warn { background: var(--orange); }
.bar-fill.bad { background: var(--red); }
.bar-fill.blue { background: var(--blue); }

.matchup-rate {
  min-width: 130px;
  display: flex;
  align-items: center;
  gap: 9px;
}

.matchup-rate .bar-track { flex: 1; }
.matchup-rate strong { width: 34px; font-size: 10px; }

.trend-arrow { font-weight: 850; }
.trend-up { color: #59812d; }
.trend-down { color: var(--red); }
.trend-even { color: var(--muted); }

.decision-log {
  padding: 2px 22px 20px;
}

.decision-entry {
  display: grid;
  grid-template-columns: 82px minmax(0, 1fr) auto;
  gap: 18px;
  padding: 17px 0;
  border-top: 1px solid #eceae2;
}

.decision-entry:first-child { border-top: 0; }

.decision-meta {
  color: var(--muted);
  font-size: 9px;
  text-transform: uppercase;
}

.decision-body strong {
  display: block;
  margin-bottom: 4px;
  font-size: 12px;
}

.decision-body p {
  margin: 0;
  color: var(--ink-2);
  font-size: 11px;
}

.decision-body small {
  display: block;
  margin-top: 6px;
  color: #738078;
  font-size: 10px;
}

.severity {
  align-self: start;
  border-radius: 999px;
  padding: 4px 7px;
  font-size: 8px;
  font-weight: 800;
  text-transform: uppercase;
}

.severity-low { color: #547530; background: var(--acid-soft); }
.severity-medium { color: #9a551f; background: var(--orange-soft); }
.severity-high { color: #983c38; background: var(--red-soft); }

.history-toolbar { justify-content: space-between; }

.search-box {
  width: min(420px, 100%);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 11px;
}

.search-box input {
  min-height: 36px;
  border: 0;
  padding: 0;
  background: transparent;
  box-shadow: none;
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.history-card {
  display: grid;
  grid-template-columns: 68px minmax(170px, 1.1fr) 32px minmax(170px, 1fr) 100px auto 32px;
  align-items: center;
  gap: 16px;
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--panel);
}

.history-card:hover { box-shadow: 0 9px 24px rgba(23, 31, 27, 0.05); }

.history-date strong,
.history-date small,
.history-deck strong,
.history-deck small {
  display: block;
}

.history-date strong { font-family: Georgia, serif; font-size: 18px; }
.history-date small,
.history-deck small { color: var(--muted); font-size: 9px; }
.history-deck strong { overflow: hidden; font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.history-vs { color: #a1a7a3; font-family: Georgia, serif; font-style: italic; }
.history-meta { color: var(--muted); font-size: 9px; }

.delete-match {
  width: 32px;
  height: 32px;
  border: 1px solid transparent;
  border-radius: 8px;
  color: #9aa19c;
  background: transparent;
}

.delete-match:hover { color: var(--red); border-color: #efd1ce; background: var(--red-soft); }

.coach-layout {
  display: grid;
  grid-template-columns: minmax(300px, 0.75fr) minmax(420px, 1.25fr);
  gap: 14px;
}

.coach-setup {
  padding: 28px;
  color: #eff3ef;
  border-color: var(--green-900);
  background:
    radial-gradient(circle at 100% 0, rgba(200, 238, 99, 0.14), transparent 35%),
    var(--green-900);
}

.coach-badge {
  display: inline-flex;
  border: 1px solid rgba(200, 238, 99, 0.26);
  border-radius: 999px;
  padding: 5px 9px;
  color: var(--acid);
  background: rgba(200, 238, 99, 0.07);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.12em;
}

.coach-setup h2 {
  margin: 18px 0 9px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 29px;
  font-weight: 500;
  line-height: 1.08;
  letter-spacing: -0.035em;
}

.coach-setup > p {
  margin: 0;
  color: #adbbb1;
  font-size: 12px;
}

.coach-steps {
  margin: 24px 0;
  padding: 8px 0;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.coach-steps > div {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 10px 0;
}

.coach-steps > div > span {
  width: 24px;
  height: 24px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border: 1px solid rgba(200, 238, 99, 0.34);
  border-radius: 50%;
  color: var(--acid);
  font-size: 9px;
}

.coach-steps p { margin: 0; }
.coach-steps strong { display: block; font-size: 11px; }
.coach-steps small { display: block; margin-top: 2px; color: #88998e; font-size: 9px; }

.coach-label {
  display: block;
  margin-top: 14px;
}

.coach-label > span { color: #a5b2aa; }

.coach-label select,
.coach-label textarea {
  color: #edf3ee;
  border-color: rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.06);
}

.coach-label option { color: var(--ink); background: white; }

.coach-setup > .button { margin-top: 18px; }

.dossier-panel {
  min-height: 680px;
  display: flex;
  flex-direction: column;
}

.dossier-preview {
  min-height: 520px;
  flex: 1;
  margin: 0 22px;
  border-color: #e2e0d7;
  color: #39443e;
  background: #faf9f4;
  font-family: "Cascadia Code", Consolas, monospace;
  font-size: 10px;
  line-height: 1.65;
}

.dossier-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 16px 22px 8px;
}

.microcopy {
  margin: 0;
  padding: 0 22px 18px;
  color: var(--muted);
  font-size: 9px;
  text-align: right;
}

.toast-region {
  position: fixed;
  z-index: 100;
  right: 24px;
  bottom: 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  min-width: 240px;
  max-width: 360px;
  padding: 12px 14px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  color: #eef3ef;
  background: var(--green-900);
  box-shadow: var(--shadow);
  font-size: 11px;
  animation: toast-in 180ms ease-out;
}

@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px); }
}

.data-dialog {
  width: min(560px, calc(100vw - 28px));
  border: 0;
  border-radius: 18px;
  padding: 0;
  background: transparent;
}

.data-dialog::backdrop { background: rgba(8, 16, 12, 0.62); backdrop-filter: blur(3px); }

.dialog-card {
  padding-bottom: 20px;
  border-radius: 18px;
  background: var(--panel);
  box-shadow: 0 30px 80px rgba(6, 13, 9, 0.26);
}

.dialog-card > p {
  margin: 0;
  padding: 0 22px;
  color: var(--muted);
  font-size: 11px;
}

.dialog-actions {
  display: flex;
  gap: 10px;
  padding: 22px;
}

.dialog-form-grid { padding-top: 18px; }

.end-session-actions { justify-content: flex-end; }

.file-button input { display: none; }

.danger-zone {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin: 0 22px;
  padding: 16px;
  border: 1px solid #ecd2d0;
  border-radius: 11px;
  background: #fff9f8;
}

.danger-zone strong,
.danger-zone small { display: block; }
.danger-zone strong { font-size: 11px; }
.danger-zone small { margin-top: 3px; color: var(--muted); font-size: 9px; }

.cloud-setup {
  margin: 18px 22px 0;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: #f7f8f4;
}

.cloud-setup h3 { margin: 3px 0 4px; font-size: 16px; }
.cloud-setup p { margin: 0 0 15px; color: var(--muted); font-size: 10px; }
.cloud-setup label { display: block; margin-top: 12px; }
.cloud-setup .dialog-actions { padding: 14px 0 0; flex-wrap: wrap; }
.secondary-setup { margin-top: 12px; background: #fff; }
.account-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; }
.account-badge { flex: 0 0 auto; padding: 7px 10px; border-radius: 999px; background: #e9ece7; color: var(--muted); font-size: 9px; font-weight: 750; }
.account-badge.is-ready { background: #dcebd0; color: #31551c; }
.sync-actions .button:disabled { cursor: not-allowed; opacity: 0.45; }
.sync-status { margin-top: 14px; color: var(--muted); font-size: 10px; }
.sync-status.is-ready { color: #3d6a22; font-weight: 750; }
.sync-status.is-error { padding: 10px 11px; border: 1px solid #eab4b4; border-radius: 10px; color: #8b2525; background: #fff0ef; font-weight: 750; }

.is-hidden {
  display: none !important;
}

.session-create-panel,
.active-session-panel,
.session-recap-card {
  max-width: 1120px;
  margin: 0 auto 16px;
}

.session-closure {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 4px 12px;
  margin: 0 22px 16px;
  padding: 13px 15px;
  border: 1px solid #dce5d4;
  border-radius: 11px;
  background: #f6f9f2;
  color: var(--muted);
  font-size: 10px;
}

.session-closure strong { color: var(--green-900); font-size: 11px; }
.session-closure p { grid-column: 1 / -1; margin: 4px 0 0; color: var(--ink); }
.session-closure.is-drop { border-color: #ead7b3; background: #fff9ed; }

.session-form-actions,
.session-card-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 0 22px 22px;
}

.session-hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 28px;
  border-radius: 17px 17px 0 0;
  color: #edf3ee;
  background:
    radial-gradient(circle at 88% 5%, rgba(200, 238, 99, 0.16), transparent 35%),
    var(--green-900);
}

.session-hero h2 {
  margin: 10px 0 5px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 30px;
  font-weight: 500;
  letter-spacing: -0.035em;
}

.session-hero p {
  margin: 0;
  color: #9caba1;
  font-size: 11px;
}

.session-live {
  color: var(--acid);
  font-size: 9px;
  font-weight: 850;
  letter-spacing: 0.14em;
}

.session-live i {
  width: 7px;
  height: 7px;
  display: inline-block;
  margin-right: 6px;
  border-radius: 50%;
  background: var(--acid);
  box-shadow: 0 0 0 5px rgba(200, 238, 99, 0.1);
}

.session-record {
  min-width: 92px;
  padding: 14px;
  border: 1px solid rgba(200, 238, 99, 0.2);
  border-radius: 13px;
  background: rgba(200, 238, 99, 0.07);
  text-align: center;
}

.session-record strong,
.session-record small {
  display: block;
}

.session-record strong {
  color: var(--acid);
  font-family: Georgia, serif;
  font-size: 26px;
}

.session-record small {
  color: #8f9f95;
  font-size: 8px;
  text-transform: uppercase;
}

.session-progress {
  padding: 20px 24px 12px;
}

.session-progress > div:first-child {
  display: flex;
  justify-content: space-between;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 10px;
}

.session-rounds,
.session-round-list {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  padding: 10px 24px 22px;
}

.session-round {
  min-height: 78px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 3px;
  padding: 11px;
  border: 1px dashed var(--line-strong);
  border-radius: 11px;
  color: var(--muted);
  background: #faf9f5;
}

.session-round.is-complete {
  border-style: solid;
  color: var(--ink);
  background: #fff;
}

.session-round > span,
.session-round > small {
  font-size: 8px;
  text-transform: uppercase;
}

.session-round > strong {
  overflow: hidden;
  font-size: 10px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.session-round .result-pill {
  align-self: flex-start;
  margin-top: 4px;
}

.session-recap-metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1px;
  margin: 0 22px 16px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--line);
}

.session-recap-metrics > div {
  min-height: 90px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 14px;
  background: #fff;
}

.session-recap-metrics span {
  color: var(--muted);
  font-size: 8px;
  text-transform: uppercase;
}

.session-recap-metrics strong {
  margin-top: 7px;
  font-family: Georgia, serif;
  font-size: 20px;
  font-weight: 500;
}

.session-round-list {
  display: block;
}

.session-round-list > div:not(.empty-state) {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  border-top: 1px solid #eceae2;
}

.session-round-list > div > span {
  color: var(--muted);
  font-size: 9px;
}

.session-round-list > div > strong {
  font-size: 11px;
}

.meta-stamp {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 0 22px 20px;
  padding: 9px 11px;
  border: 1px solid #dce7b9;
  border-radius: 9px;
  color: #5e6e4a;
  background: #f4fadf;
  font-size: 9px;
}

.meta-stamp a {
  color: #496329;
  font-weight: 800;
  text-decoration: none;
}

.voice-capture { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 12px; align-items: center; margin: 0 22px 22px; padding: 13px; border: 1px solid #d9d7ef; border-radius: 12px; background: linear-gradient(120deg, #f3f1ff, #fbfbff); }
.voice-capture strong, .voice-capture small { display: block; }
.voice-capture strong { color: #303769; font-size: 11px; }
.voice-capture small, .voice-status { color: var(--muted); font-size: 9px; }
.voice-status { grid-column: 1 / -1; min-height: 12px; margin: 0; color: #575bb1; }

.arena-topline { display: flex; align-items: flex-end; justify-content: space-between; gap: 18px; max-width: 1120px; margin: 0 auto 16px; }
.arena-topline h2 { margin: 4px 0 0; font: 500 30px/1 Georgia, serif; letter-spacing: -.04em; }
.arena-board { max-width: 1120px; margin: 0 auto 14px; padding: 16px; border: 1px solid rgba(167, 169, 238, .32); border-radius: 20px; color: #f8f8ff; background: radial-gradient(circle at 80% 0%, rgba(145, 135, 239, .38), transparent 31%), linear-gradient(145deg, #11163a, #191a4d); box-shadow: 0 20px 42px rgba(24, 24, 70, .2); }
.arena-status { display: flex; align-items: center; flex-wrap: wrap; gap: 11px; padding: 4px 5px 16px; color: #bfc2eb; font-size: 10px; }
.arena-status strong { color: #fff; font-size: 12px; }
.arena-status small { margin-left: auto; color: #c4c8ee; }
.arena-players { display: grid; gap: 10px; }.arena-players.cedh { grid-template-columns: repeat(4, minmax(0, 1fr)); }.arena-players.pauper { grid-template-columns: repeat(2, minmax(0, 1fr)); max-width: 580px; margin: auto; }
.arena-player { min-width: 0; padding: 13px 9px 10px; border: 1px solid rgba(215,215,255,.14); border-radius: 15px; background: rgba(255,255,255,.06); transition: transform .18s ease, background .18s ease; }.arena-player.is-selected { border-color: #c7c5ff; background: rgba(181, 177, 255, .17); }.arena-player.is-active { box-shadow: inset 0 0 0 1px rgba(255,255,255,.14), 0 0 22px rgba(158, 151, 255, .17); }
.arena-player-name { width: 100%; overflow: hidden; border: 0; color: #eef0ff; background: none; font: 700 10px/1.2 inherit; text-overflow: ellipsis; white-space: nowrap; }.arena-player-name b { color: #f3d685; }
.life-row { display: grid; grid-template-columns: 30px 25px 1fr 25px 30px; align-items: center; gap: 3px; margin-top: 12px; }.life-row button, .arena-counters button { border: 0; border-radius: 8px; color: #d9dbff; background: rgba(255,255,255,.1); font-weight: 800; }.life-row button { height: 30px; }.life-row strong { color: #fff; font: 500 36px/.9 Georgia, serif; text-align: center; letter-spacing: -.05em; }.arena-counters { display: flex; justify-content: center; gap: 5px; margin-top: 10px; }.arena-counters button { padding: 5px 7px; font-size: 9px; }
.arena-control-panel, .arena-history-panel { max-width: 1120px; margin: 0 auto 14px; }.arena-actions { display: flex; flex-wrap: wrap; gap: 9px; padding: 18px 22px 10px; }.arena-dungeon { min-height: 120px; margin: 0 22px 22px; padding: 18px; border: 1px solid rgba(153, 149, 236, .28); border-radius: 14px; color: #e9eaff; background: radial-gradient(circle at 100% 0%, rgba(147,139,240,.25), transparent 45%), #12163b; }.dungeon-head { display: flex; justify-content: space-between; gap: 12px; color: #c9caff; font-size: 10px; }.dungeon-head strong { color: #fff; font: 500 20px Georgia, serif; }.arena-dungeon p { margin: 13px 0; color: #d5d7f7; font-size: 12px; }.dungeon-route { display: flex; flex-wrap: wrap; gap: 8px; }.dungeon-empty { display: grid; min-height: 83px; place-items: center; color: #9ba0c9; font-size: 11px; text-align: center; }
.arena-history { max-height: 340px; overflow: auto; padding: 0 22px 22px; }.arena-history > div { display: grid; grid-template-columns: 48px 1fr; gap: 12px; padding: 11px 0; border-top: 1px solid var(--line); }.arena-history time { color: #777bd0; font-size: 9px; }.arena-history p { margin: 0; color: var(--ink-2); font-size: 11px; }
.arena-dungeon:fullscreen { display: grid; place-content: center; gap: 15px; padding: 40px; background: radial-gradient(circle at 50% 20%, #393784, #080b22); }.arena-dungeon:fullscreen .dungeon-head { font-size: 18px; }.arena-dungeon:fullscreen .dungeon-head strong { font-size: 42px; }.arena-dungeon:fullscreen p { font-size: 20px; }

/* Mana Trace identity — spectral mana, constellations and the trail left by play. */
:root {
  --ink: #0d1024;
  --ink-2: #303452;
  --muted: #73758e;
  --paper: #f7f5f2;
  --panel: rgba(255, 255, 255, 0.82);
  --line: #e3e1ee;
  --line-strong: #cbc9df;
  --green-950: #090d25;
  --green-900: #11163a;
  --green-800: #252d67;
  --acid: #aeb5ff;
  --acid-soft: #ecebff;
  --blue: #696de5;
  --blue-soft: #e5e6ff;
  --shadow: 0 18px 44px rgba(37, 42, 103, 0.1);
}

body {
  background:
    radial-gradient(circle at 76% -10%, rgba(152, 143, 255, 0.16), transparent 31%),
    radial-gradient(circle at 25% 90%, rgba(91, 126, 255, 0.09), transparent 34%),
    var(--paper);
}

.app-shell { position: relative; isolation: isolate; }
.app-shell::before {
  content: "";
  position: fixed;
  z-index: -1;
  inset: 0;
  pointer-events: none;
  opacity: 0.75;
  background-image: radial-gradient(rgba(89, 94, 190, 0.28) 0.7px, transparent 0.8px);
  background-size: 29px 29px;
  mask-image: linear-gradient(to bottom, #000, transparent 68%);
}

.sidebar {
  background:
    radial-gradient(circle at 74% 6%, rgba(166, 171, 255, 0.24), transparent 22%),
    radial-gradient(circle at 10% 64%, rgba(129, 105, 220, 0.16), transparent 34%),
    linear-gradient(160deg, #10163b, #090c21 72%);
}
.sidebar::after {
  content: "✦  ·  ✧";
  position: absolute;
  right: 15px;
  bottom: 16px;
  color: rgba(198, 198, 255, 0.23);
  letter-spacing: 7px;
  font-size: 14px;
}
.brand { position: relative; z-index: 1; }
.brand-mark { width: 47px; height: 47px; filter: drop-shadow(0 7px 10px rgba(137, 125, 255, 0.3)); }
.brand-mark svg { width: 47px; stroke: none; }
.brand-mark .mana-flame { fill: url(#mana-flame); }
.brand-mark .mana-flame-cut { fill: none; stroke: #fbfaff; stroke-width: 3.1; stroke-linecap: round; }
.brand-mark .mana-orbit { fill: none; stroke: #b7bcff; stroke-width: 1.35; stroke-linecap: round; stroke-dasharray: 1 3; }
.brand-mark .orbit-one { animation: orbit-drift 7s linear infinite; }
.brand-mark .orbit-two { opacity: .72; animation: orbit-drift 5s linear infinite reverse; }
.brand-mark .mana-star { fill: #ecebff; animation: star-pulse 2.6s ease-in-out infinite; transform-origin: 50px 16px; }
.brand strong { font-family: Georgia, "Times New Roman", serif; font-size: 22px; font-weight: 500; letter-spacing: -0.045em; }
.brand small { color: #b4b8de; font-size: 8px; letter-spacing: .12em; }

.nav-item { position: relative; overflow: hidden; border: 1px solid transparent; }
.nav-item::after { content: ""; position: absolute; inset: 0 auto 0 0; width: 2px; background: #bfc3ff; transform: scaleY(0); transition: transform .22s ease; }
.nav-item:hover { background: rgba(183, 188, 255, .09); transform: translateX(2px); }
.nav-item.is-active { color: #fbfaff; border-color: rgba(190, 192, 255, .22); background: linear-gradient(100deg, rgba(129, 126, 231, .45), rgba(83, 91, 184, .25)); box-shadow: inset 0 1px rgba(255,255,255,.12), 0 8px 18px rgba(0,0,0,.12); }
.nav-item.is-active::after { transform: scaleY(1); }
.status-dot { background: #b8bdff; box-shadow: 0 0 0 4px rgba(184, 189, 255, .11), 0 0 14px rgba(184, 189, 255, .7); }

.topbar { border-bottom-color: rgba(210, 208, 232, .74); background: rgba(247, 245, 242, .76); }
.topbar h1 { font-family: Georgia, "Times New Roman", serif; }
.eyebrow, .panel-kicker { color: #6267b9; }
.format-switch { border-color: #d8d7eb; background: rgba(255,255,255,.68); box-shadow: 0 3px 11px rgba(31, 37, 97, .05); }
.format-switch button.is-active { color: #fff; background: linear-gradient(120deg, #6268d8, #8e7add); box-shadow: 0 3px 9px rgba(93, 89, 192, .25); }
body[data-format="cedh"] .format-switch button.is-active { background: linear-gradient(120deg, #6c4d9b, #a96fbc); }

.panel, .metric-card, .history-card { position: relative; border-color: rgba(212, 210, 232, .94); background: var(--panel); box-shadow: 0 10px 30px rgba(39, 44, 104, .055); }
.panel { overflow: hidden; }
.panel::before, .metric-card::before { content: ""; position: absolute; inset: 0; pointer-events: none; background: linear-gradient(125deg, rgba(255,255,255,.52), transparent 32%); }
.metric-card { transition: transform .24s ease, box-shadow .24s ease, border-color .24s ease; }
.metric-card:hover { transform: translateY(-4px); border-color: #bfc2f0; box-shadow: 0 18px 34px rgba(51, 56, 126, .13); }
.metric-card::after { border-color: rgba(130, 129, 228, .12); }
.metric-value { color: #20255d; }
.metric-foot strong.good, .trend-up { color: #515bc6; }

.button { border-radius: 11px; transition: transform .18s ease, box-shadow .18s ease, filter .18s ease; }
.button-primary { color: #fff; background: linear-gradient(120deg, #6870de, #9279dc); box-shadow: 0 8px 18px rgba(92, 89, 202, .25); }
.button-primary:hover { background: linear-gradient(120deg, #737bea, #a184ea); box-shadow: 0 12px 25px rgba(92, 89, 202, .34); }
.button-secondary { background: linear-gradient(120deg, #222957, #3a4385); }
.button-ghost { border-color: #d1d0e4; background: rgba(255,255,255,.48); }
.button:hover { transform: translateY(-2px); }
.panel-heading { position: relative; }
.panel-heading::after { content: "✦"; color: #9a99e9; font-size: 11px; opacity: .65; }

.deck-card { border: 1px solid rgba(212, 210, 232, .94); border-radius: 15px; background: rgba(255,255,255,.77); box-shadow: 0 10px 28px rgba(39, 44, 104, .05); transition: transform .28s ease, box-shadow .28s ease; }
.deck-card:hover { transform: translateY(-5px); box-shadow: 0 20px 38px rgba(55, 54, 142, .15); }
.deck-cover { background: linear-gradient(150deg, #191a46, #5d5ec5); }
.deck-cover img { transition: transform .45s ease; }
.deck-card:hover .deck-cover img { transform: scale(1.06); }
.magic-card { transition: transform .22s ease, filter .22s ease; }
.magic-card:hover { transform: translateY(-5px) rotate(-1deg); filter: drop-shadow(0 10px 12px rgba(35, 35, 88, .2)); }

.toast { border-color: rgba(189, 190, 255, .22); background: linear-gradient(135deg, #171b49, #2f3473); box-shadow: 0 16px 34px rgba(19, 20, 63, .28); }
.data-dialog::backdrop { background: rgba(7, 8, 29, .68); backdrop-filter: blur(8px); }
.dialog-card { background: linear-gradient(145deg, #fffefd, #f3f1ff); }

.view.is-visible { animation: mana-rise .46s cubic-bezier(.2,.8,.2,1) both; }
@keyframes mana-rise { from { opacity: 0; transform: translateY(12px); filter: blur(3px); } to { opacity: 1; transform: none; filter: none; } }
@keyframes orbit-drift { to { stroke-dashoffset: -42; } }
@keyframes star-pulse { 50% { opacity: .35; transform: scale(.72); } }
@media (prefers-reduced-motion: no-preference) {
  .panel, .history-card, .deck-card { animation: mana-rise .42s cubic-bezier(.2,.8,.2,1) both; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; scroll-behavior: auto !important; transition-duration: .01ms !important; }
}

@media (max-width: 1120px) {
  .metrics-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .form-grid.four-cols { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .game-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .history-card { grid-template-columns: 60px minmax(150px, 1fr) 24px minmax(150px, 1fr) auto; }
  .history-meta { display: none; }
}

@media (max-width: 900px) {
  .sidebar {
    inset: auto 0 0;
    width: 100%;
    height: calc(68px + env(safe-area-inset-bottom));
    padding: 6px 8px env(safe-area-inset-bottom);
    transform: none;
    box-shadow: 0 -10px 30px rgba(7, 15, 10, 0.16);
  }
  .sidebar .brand,
  .sidebar-footer { display: none; }
  .nav-list {
    height: 100%;
    flex-direction: row;
    gap: 3px;
    overflow-x: auto;
    scrollbar-width: none;
  }
  .nav-list::-webkit-scrollbar { display: none; }
  .nav-item {
    min-width: 66px;
    flex: 1 0 66px;
    flex-direction: column;
    justify-content: center;
    gap: 4px;
    padding: 6px 4px;
    font-size: 9px;
    text-align: center;
  }
  .nav-icon { height: 18px; font-size: 17px; }
  .nav-coach { margin-top: 0; }
  .nav-coach::before { display: none; }
  .main-content { margin-left: 0; padding-bottom: calc(68px + env(safe-area-inset-bottom)); }
  .mobile-menu { display: none; }
  .mobile-data {
    width: 36px;
    height: 36px;
    display: inline-grid;
    place-items: center;
    border: 1px solid var(--line);
    border-radius: 9px;
    color: var(--ink-2);
    background: var(--panel);
  }
  .dashboard-grid,
  .coach-layout { grid-template-columns: 1fr; }
  .span-2 { grid-column: auto; }
  .mobile-capture-note {
    max-width: 1120px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin: -8px auto 16px;
    padding: 10px 12px;
    border: 1px solid #d9e5b5;
    border-radius: 10px;
    color: #486226;
    background: var(--acid-soft);
  }
  .mobile-capture-note span { font-size: 10px; font-weight: 800; }
  .mobile-capture-note small { color: #64734f; font-size: 9px; text-align: right; }
}

@media (max-width: 640px) {
  html,
  body { overflow-x: hidden; }
  .topbar {
    min-height: calc(76px + env(safe-area-inset-top));
    padding: calc(10px + env(safe-area-inset-top)) 14px 10px;
  }
  .topbar .eyebrow { display: none; }
  .topbar h1 { margin-top: 0; font-size: 18px; }
  .topbar-actions .save-state { display: none; }
  .topbar-actions { gap: 7px; }
  .format-switch { order: -1; }
  .format-switch button { padding: 6px 8px; }
  .topbar-actions .button { width: 36px; overflow: hidden; padding: 0; font-size: 0; }
  .topbar-actions .button::before { content: "+"; color: var(--green-950); font-size: 20px; line-height: 1; }
  .view { padding: 18px 12px 110px; }
  .view-toolbar { flex-wrap: wrap; justify-content: stretch; }
  .view-toolbar > * { flex: 1; }
  .metrics-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
  .nav-item {
    min-width: 0;
    flex: 1 1 0;
    padding-inline: 2px;
    font-size: 8px;
  }
  .metric-card { min-height: 112px; padding: 16px; }
  .metric-value { font-size: 30px; }
  .form-grid.four-cols,
  .form-grid.two-cols { grid-template-columns: 1fr; }
  .game-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .mobile-hide { display: none; }
  input,
  select,
  textarea {
    font-size: 16px;
  }
  input,
  select { min-height: 50px; }
  textarea { min-height: 88px; }
  .form-progress { display: none; }
  .mobile-capture-note { margin-top: 0; }
  .form-panel,
  .game-panel { border-radius: 14px; }
  .panel-heading { padding: 17px 16px 12px; }
  .form-grid { padding: 8px 16px 19px; }
  .game-section { padding: 17px 16px; }
  .span-2-field,
  .game-grid .wide,
  .game-grid .full { grid-column: 1 / -1; }
  .game-tabs {
    position: sticky;
    top: calc(76px + env(safe-area-inset-top));
    z-index: 8;
    gap: 3px;
    margin-top: 14px;
    padding: 7px 2px 0;
    background: var(--paper);
  }
  .game-tabs button {
    min-height: 48px;
    flex: 1;
    padding: 9px 7px;
  }
  .game-tabs button span { display: block; margin: 1px 0 0; }
  .form-actions {
    position: sticky;
    z-index: 7;
    bottom: calc(68px + env(safe-area-inset-bottom));
    padding: 12px 0;
    background: linear-gradient(to bottom, rgba(244, 242, 235, 0), var(--paper) 28%);
  }
  .form-actions .button-primary { flex: 1; min-height: 50px; }
  .form-actions .button-ghost { min-height: 50px; }
  .session-hero { padding: 21px 17px; }
  .session-hero h2 { font-size: 24px; }
  .session-record { min-width: 78px; }
  .session-rounds { grid-template-columns: repeat(2, minmax(0, 1fr)); padding: 9px 16px 18px; }
  .session-progress { padding-inline: 16px; }
  .session-card-actions,
  .session-form-actions { padding: 0 16px 18px; }
  .session-card-actions { flex-direction: column-reverse; }
  .session-card-actions .button { min-height: 48px; }
  .session-recap-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); margin-inline: 16px; }
  .session-round-list { padding-inline: 16px; }
  .meta-stamp { margin-inline: 16px; }
  .history-toolbar { align-items: stretch; }
  .history-card { grid-template-columns: 56px 1fr auto; gap: 10px; }
  .history-vs { display: none; }
  .history-card .history-deck:nth-of-type(2) { grid-column: 2 / 3; }
  .history-card .result-pill { grid-column: 3; grid-row: 1; }
  .delete-match { grid-column: 3; grid-row: 2; }
  .decision-entry { grid-template-columns: 65px 1fr; }
  .decision-entry .severity { grid-column: 2; justify-self: start; }
  .dossier-actions { flex-direction: column; }
  .dialog-actions { flex-direction: column; }
  .format-context { margin-inline: 16px; align-items: flex-start; }
  .sync-actions .button { width: 100%; }
  .deck-library { grid-template-columns: 1fr; }
  .deck-card { grid-template-columns: 96px minmax(0, 1fr); }
  .deck-cover { min-height: 158px; }
  .deck-card-body { padding: 15px; }
  .deck-card-body h2 { font-size: 20px; }
  .deck-card-actions { margin-top: 14px; }
  .auth-fields { grid-template-columns: 1fr; }
  .card-gallery { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .card-board-section { padding: 0 16px 24px; }
  .card-type-group { padding-top: 15px; }
  .deck-detail-summary a { margin-left: 0; }

  /* Dialogs are used for adding decks and account actions: on iPhone they
     must scroll inside the card instead of overflowing below the viewport. */
  .data-dialog {
    width: calc(100vw - 16px);
    max-height: calc(100dvh - 16px);
    margin: 8px;
  }
  #deck-detail-dialog { width: calc(100vw - 16px); }
  .dialog-card {
    max-height: calc(100dvh - 16px);
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
  }
  .dialog-card > p,
  .dialog-actions { padding-inline: 16px; }
  .dialog-actions { gap: 8px; }
  .dialog-actions .button { flex: 1 1 100%; min-height: 48px; }
  .danger-zone,
  .cloud-setup,
  .session-closure { margin-inline: 16px; }
  .deck-import-actions { align-items: stretch; }
  .deck-import-actions .button { flex: 1 1 140px; min-height: 48px; }
  .deck-dialog-card textarea { min-height: 220px; }
  .voice-capture { grid-template-columns: 1fr; margin: 0 16px 18px; }
  .voice-capture .button { min-height: 48px; }
  .arena-topline { align-items: stretch; flex-direction: column; }
  .arena-topline .segmented { width: 100%; }
  .arena-topline .segmented button { flex: 1; }
  .arena-board { padding: 12px; border-radius: 16px; }
  .arena-status { padding-bottom: 12px; }
  .arena-status small { width: 100%; margin-left: 0; }
  .arena-players.cedh { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .arena-player { padding: 12px 7px 9px; }
  .life-row strong { font-size: 32px; }
  .arena-actions { padding: 14px 16px 8px; }
  .arena-actions .button { flex: 1 1 calc(50% - 5px); min-height: 46px; padding-inline: 8px; }
  .arena-dungeon { margin: 0 16px 16px; padding: 15px; }
  .dungeon-head { align-items: flex-start; flex-direction: column; }
  .arena-history { padding: 0 16px 18px; }
}

