:root {
  --color-1: #fff200;
  --color-x: #e89194;
  --color-2: #e89194;
  --grid-border: #c9c9c9;
  --header-bg: #f4f6f8;
  --text: #171717;
  --muted: #6c727a;
  --panel: #ffffff;
  --focus: #1458d4;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--text);
  background: #f7f8fa;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  min-height: 76px;
  padding: 14px 20px;
  background: #ffffff;
  border-bottom: 1px solid #d9dde3;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: 22px;
  font-weight: 750;
}

.topbar p {
  margin-top: 3px;
  color: var(--muted);
  font-size: 13px;
}

.season-form {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 13px;
}

select,
button,
input {
  font: inherit;
}

select {
  min-width: 112px;
  height: 36px;
  border: 1px solid #b8c0cc;
  border-radius: 6px;
  background: #fff;
  color: var(--text);
}

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 14px;
  height: calc(100vh - 76px);
  padding: 14px;
}

.toolbar {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 44px;
}

.color-control {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 36px;
  padding: 0 10px;
  background: #fff;
  border: 1px solid #d3d8df;
  border-radius: 6px;
  font-weight: 700;
}

.color-control input {
  width: 30px;
  height: 24px;
  padding: 0;
  border: 0;
  background: transparent;
}

button {
  height: 36px;
  padding: 0 12px;
  border: 1px solid #c5ccd6;
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  cursor: pointer;
}

button:hover {
  border-color: #8f9bad;
}

.sheet-shell {
  min-width: 0;
  overflow: auto;
  background: #ffffff;
  border: 1px solid #d4d9df;
}

.sheet {
  border-collapse: separate;
  border-spacing: 0;
  width: max-content;
  min-width: 100%;
  table-layout: fixed;
  font-variant-numeric: tabular-nums;
}

.sheet th,
.sheet td {
  width: 64px;
  min-width: 64px;
  height: 38px;
  padding: 4px 7px;
  border-right: 1px solid var(--grid-border);
  border-bottom: 1px solid var(--grid-border);
  text-align: right;
  font-size: 18px;
  line-height: 1;
}

.sheet thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--header-bg);
  color: #3f4348;
  font-size: 13px;
  font-weight: 700;
}

.sheet .corner,
.sheet .row-head {
  position: sticky;
  left: 0;
  z-index: 3;
  width: 48px;
  min-width: 48px;
  background: var(--header-bg);
  color: #3f4348;
  text-align: center;
  font-size: 13px;
}

.sheet .corner {
  z-index: 4;
}

.result-cell {
  cursor: pointer;
  font-weight: 750;
  color: #080808;
}

.result-cell:hover,
.result-cell:focus {
  outline: 2px solid var(--focus);
  outline-offset: -2px;
}

.result-1 {
  background: var(--color-1);
}

.result-x {
  background: var(--color-x);
}

.result-2 {
  background: var(--color-2);
}

.empty-cell {
  background: #fafafa;
}

.detail-panel {
  overflow: auto;
  background: var(--panel);
  border: 1px solid #d4d9df;
  padding: 18px;
}

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

.panel-empty h2,
.panel-content h3 {
  color: var(--text);
}

.panel-empty h2 {
  margin-bottom: 8px;
  font-size: 18px;
}

.panel-heading {
  display: grid;
  gap: 6px;
  padding-bottom: 14px;
  border-bottom: 1px solid #e1e5eb;
}

#panel-position {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
}

#panel-title {
  font-size: 18px;
}

.match-facts {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin: 14px 0;
}

.match-facts div {
  min-width: 0;
  padding: 10px;
  border: 1px solid #e1e5eb;
  border-radius: 6px;
}

dt {
  color: var(--muted);
  font-size: 12px;
}

dd {
  margin: 5px 0 0;
  font-size: 14px;
  font-weight: 700;
}

.pool,
.stats,
.recent {
  margin-top: 18px;
}

.pool h3,
.stats h3,
.recent h3 {
  margin-bottom: 10px;
  font-size: 15px;
}

.stats h4 {
  margin: 12px 0 8px;
  color: var(--muted);
  font-size: 13px;
}

.bars,
.stat-list,
.example-list {
  display: grid;
  gap: 8px;
}

.bar-row,
.stat-row {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr) 48px;
  align-items: center;
  gap: 8px;
  font-size: 13px;
}

.bar-track,
.stat-track {
  height: 10px;
  overflow: hidden;
  background: #edf0f4;
  border-radius: 999px;
}

.bar-fill,
.stat-fill {
  height: 100%;
  background: #3f6fb5;
}

.example {
  padding: 8px 0;
  border-bottom: 1px solid #eef1f5;
  font-size: 13px;
}

.example strong {
  display: block;
  margin-bottom: 2px;
}

.tooltip {
  position: fixed;
  z-index: 20;
  max-width: 300px;
  padding: 9px 10px;
  background: #111827;
  color: #fff;
  border-radius: 6px;
  box-shadow: 0 10px 30px rgb(0 0 0 / 25%);
  pointer-events: none;
  font-size: 12px;
  line-height: 1.4;
}

.tooltip strong {
  display: block;
  font-size: 13px;
}

@media (max-width: 900px) {
  .layout {
    grid-template-columns: 1fr;
    height: auto;
  }

  .sheet-shell {
    min-height: 58vh;
  }

  .detail-panel {
    min-height: 260px;
  }
}

@media (max-width: 620px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
    gap: 10px;
  }

  .layout {
    height: auto;
  }

  .toolbar {
    flex-wrap: wrap;
  }

  .sheet th,
  .sheet td {
    width: 54px;
    min-width: 54px;
    height: 34px;
    font-size: 16px;
  }
}
