:root {
  --bg: #bac49c;
  --bg-deep: #8a956d;
  --panel: #dfe8c5;
  --panel-2: #c8d3aa;
  --line: #2f3a2b;
  --text: #1d241a;
  --muted: #47523f;
  --accent: #2f3a2b;
  --accent-soft: #c2cca4;
  --shadow: none;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Courier New", "Osaka-Mono", "Menlo", monospace;
  color: var(--text);
  background: linear-gradient(180deg, var(--bg) 0%, #aab58c 100%);
  image-rendering: pixelated;
}

.shell {
  width: min(980px, calc(100% - 24px));
  margin: 16px auto;
}

.panel {
  background: var(--panel);
  border: 4px solid var(--line);
  border-radius: 0;
  box-shadow: var(--shadow);
}

.hero-main {
  padding: 18px;
  position: relative;
  overflow: hidden;
}

.hero-main::after {
  content: "";
  position: absolute;
  right: 14px;
  top: 14px;
  width: 116px;
  height: 116px;
  background:
    linear-gradient(90deg, rgba(47, 58, 43, 0.12) 50%, transparent 50%),
    linear-gradient(rgba(47, 58, 43, 0.12) 50%, transparent 50%);
  background-size: 10px 10px;
  pointer-events: none;
  opacity: 0.55;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border: 3px solid var(--line);
  border-radius: 0;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

h1 {
  margin: 18px 0 10px;
  font-size: clamp(28px, 4vw, 48px);
  line-height: 1;
  letter-spacing: 0;
  text-transform: uppercase;
}

.lead {
  max-width: 720px;
  margin: 0;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.9;
}

.hero-actions,
.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 18px;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 12px 16px;
  border-radius: 0;
  border: 4px solid var(--line);
  background: #eef5d8;
  color: var(--text);
  text-decoration: none;
  font-weight: 700;
  transition: transform 0.12s ease;
  text-transform: uppercase;
  box-shadow: 6px 6px 0 #72805a;
}

.button:hover {
  transform: translate(1px, 1px);
  box-shadow: 5px 5px 0 #72805a;
}

.button.primary {
  background: var(--panel-2);
}

.section {
  margin-top: 12px;
  padding: 14px 16px;
}

.section-title {
  margin: 0 0 10px;
  font-size: 22px;
  line-height: 1.2;
  text-transform: uppercase;
}

.section-copy {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.8;
}

.tab-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tab-button {
  appearance: none;
  border: 4px solid var(--line);
  background: #eef5d8;
  color: var(--text);
  font: inherit;
  font-weight: 700;
  text-transform: uppercase;
  padding: 10px 14px;
  cursor: pointer;
  box-shadow: 6px 6px 0 #72805a;
}

.tab-button.is-active {
  background: var(--panel-2);
}

.tab-panel {
  display: none;
}

.tab-panel.is-active {
  display: block;
}

.deck-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 12px;
  align-items: stretch;
}

.deck-card {
  display: grid;
  grid-template-columns: 160px minmax(0, 1fr);
  gap: 12px;
  padding: 12px;
  align-items: start;
  min-height: 248px;
}

.deck-thumb {
  width: 100%;
  height: 112px;
  border: 4px solid var(--line);
  background: #cad4af;
  overflow: hidden;
}

.deck-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.deck-name {
  margin: 0;
  font-size: 16px;
  line-height: 1.45;
  min-height: 46px;
}

.deck-meta {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.75;
  min-height: 126px;
}

.deck-card-left {
  display: grid;
  grid-template-rows: auto auto auto;
  gap: 10px;
  min-height: 100%;
}

.deck-card-right {
  display: grid;
  grid-template-rows: auto 1fr;
  min-height: 0;
}

.deck-extra {
  display: block;
  min-height: 34px;
}

.deck-code-line {
  display: block;
}

.deck-button {
  width: 100%;
  margin-top: 0;
}

.detail-layout {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.detail-thumb {
  width: 100%;
  aspect-ratio: 16 / 9;
  border: 4px solid var(--line);
  background: #cad4af;
  overflow: hidden;
}

.detail-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.info-list {
  display: grid;
  gap: 10px;
  margin-top: 8px;
}

.info-list div {
  display: grid;
  gap: 4px;
  padding: 10px 12px;
  border: 3px solid var(--line);
  background: #eef5d8;
}

.info-list strong {
  font-size: 11px;
  text-transform: uppercase;
}

.info-list span {
  font-size: 13px;
  line-height: 1.6;
  color: var(--muted);
}

.note-list {
  margin: 0;
  padding-left: 20px;
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.8;
}

.card-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 8px;
}

.card-list li {
  display: grid;
  grid-template-columns: 56px minmax(0, 1fr);
  gap: 10px;
  padding: 10px 12px;
  border: 3px solid var(--line);
  background: #eef5d8;
  align-items: start;
}

.card-count {
  font-weight: 700;
}

.card-label {
  color: var(--muted);
  line-height: 1.5;
}

.tag-group {
  display: grid;
  gap: 14px;
}

.mini-label {
  margin-bottom: 8px;
  font-size: 11px;
  text-transform: uppercase;
  color: var(--muted);
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tag-chip {
  display: inline-flex;
  align-items: center;
  padding: 8px 10px;
  border: 3px solid var(--line);
  background: var(--panel-2);
  font-size: 11px;
  line-height: 1.3;
  text-transform: uppercase;
}

.tag-chip.alt {
  background: #eef5d8;
}

.matchup-columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.matchup-box {
  padding: 10px 12px;
  border: 3px solid var(--line);
  background: #eef5d8;
}

.matchup-box h3 {
  margin: 0 0 10px;
  font-size: 14px;
  line-height: 1.4;
  text-transform: uppercase;
}

.histogram-box {
  display: grid;
  grid-template-columns: repeat(10, minmax(0, 1fr));
  gap: 8px;
  align-items: end;
  margin-top: 10px;
}

.hist-col {
  display: grid;
  grid-template-rows: 20px 140px 28px 16px;
  gap: 6px;
  align-items: end;
}

.hist-col-average .hist-label,
.hist-col-average .hist-count,
.hist-col-average .hist-average-note {
  font-weight: 700;
}

.hist-label,
.hist-count,
.hist-average-note {
  font-size: 12px;
  text-align: center;
}

.hist-column-track {
  height: 140px;
  border: 3px solid var(--line);
  background: #eef5d8;
  overflow: hidden;
  display: flex;
  align-items: end;
}

.hist-column-fill {
  width: 100%;
  background: var(--bg-deep);
}

.hist-col-average .hist-column-fill {
  background: var(--line);
}

.hist-average-note {
  color: var(--muted);
}

.summary-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 8px;
}

.summary-list li {
  display: grid;
  gap: 2px;
}

.summary-list strong {
  font-size: 12px;
}

.summary-list span {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.6;
}

.summary-list em {
  font-style: normal;
  font-size: 12px;
  color: var(--text);
  line-height: 1.6;
}

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

.stat-card {
  display: grid;
  gap: 4px;
  padding: 10px 12px;
  border: 3px solid var(--line);
  background: #eef5d8;
}

.stat-card strong {
  font-size: 11px;
  text-transform: uppercase;
}

.stat-card span {
  font-size: 13px;
  line-height: 1.5;
  color: var(--muted);
}

.table-wrap {
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 6px;
  font-size: 12px;
  line-height: 1.6;
}

.matchup-table {
  min-width: 760px;
}

.data-table th,
.data-table td {
  border: 3px solid var(--line);
  padding: 8px 10px;
  text-align: left;
  vertical-align: top;
  background: #eef5d8;
}

.data-table thead th {
  background: var(--panel-2);
}

.stacked-cell {
  display: grid;
  gap: 2px;
}

.stacked-cell.one-line {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: nowrap;
  white-space: nowrap;
}

.stacked-cell strong {
  font-size: 12px;
}

.stacked-cell span {
  font-size: 11px;
  color: var(--muted);
  line-height: 1.4;
}

.opponent-cell {
  word-break: break-all;
  line-height: 1.45;
  min-width: 170px;
}

.opponent-link-cell {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.opponent-link-cell span {
  min-width: 0;
}

.games-cell {
  text-align: center;
  white-space: nowrap;
  min-width: 56px;
}

.table-button {
  padding: 8px 10px;
  border-width: 3px;
  box-shadow: 4px 4px 0 #72805a;
  font-size: 11px;
  width: auto;
}

.table-button.ghost {
  padding: 6px 8px;
  font-size: 10px;
  white-space: nowrap;
}

.replay-frame-wrap {
  border: 4px solid var(--line);
  background: #eef5d8;
  overflow: hidden;
}

.replay-frame {
  width: 100%;
  min-height: 1200px;
  border: 0;
  display: block;
  background: #eef5d8;
}

.deck-code-chip {
  display: block;
  padding: 8px 10px;
  border: 3px solid var(--line);
  background: var(--accent-soft);
  font-size: 11px;
  line-height: 1.5;
  word-break: break-all;
}

.footer {
  margin-top: 12px;
  padding: 14px 16px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.8;
}

@media (max-width: 980px) {
  .shell {
    width: min(100% - 16px, 980px);
    margin: 10px auto 18px;
  }

  .hero-main,
  .section,
  .footer {
    padding: 14px;
  }

  .button {
    width: 100%;
  }

  .deck-grid {
    grid-template-columns: 1fr;
  }

  .deck-card {
    grid-template-columns: 1fr;
    min-height: auto;
  }

  .detail-layout {
    grid-template-columns: 1fr;
  }

  .stats-grid {
    grid-template-columns: 1fr 1fr;
  }

  .matchup-columns {
    grid-template-columns: 1fr;
  }

  .histogram-box {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }

  .deck-thumb {
    width: 100%;
    height: auto;
    aspect-ratio: 16 / 9;
  }

  .deck-name,
  .deck-meta {
    min-height: 0;
  }
}
