:root {
  --bg: #f3efe4;
  --panel: rgba(255, 252, 245, 0.92);
  --panel-strong: #fffaf0;
  --ink: #18221d;
  --muted: #5d695f;
  --line: rgba(24, 34, 29, 0.14);
  --accent: #0e7a53;
  --accent-2: #d88a2a;
  --shadow: 0 24px 60px rgba(41, 43, 25, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(circle at top right, rgba(216, 138, 42, 0.18), transparent 30%),
    radial-gradient(circle at bottom left, rgba(14, 122, 83, 0.18), transparent 35%),
    linear-gradient(180deg, #f8f4ea 0%, var(--bg) 100%);
  font-family: Georgia, "Times New Roman", serif;
}

.layout {
  width: min(1100px, calc(100% - 32px));
  margin: 0 auto;
  padding: 40px 0 56px;
}

.hero {
  padding: 24px 0 12px;
}

.eyebrow {
  margin: 0 0 12px;
  color: var(--accent);
  font-size: 0.88rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  max-width: 900px;
  font-size: clamp(2.2rem, 4vw, 4.3rem);
  line-height: 0.95;
}

.lead {
  max-width: 780px;
  color: var(--muted);
  font-size: 1.08rem;
  line-height: 1.7;
}

.panel,
.card,
.game-card {
  border: 1px solid var(--line);
  background: var(--panel);
  box-shadow: var(--shadow);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
}

.panel {
  padding: 24px;
  border-radius: 28px;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 16px;
}

label {
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 0.95rem;
}

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

input,
textarea,
select {
  width: 100%;
  border: 1px solid rgba(24, 34, 29, 0.16);
  border-radius: 16px;
  padding: 14px 16px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.8);
}

textarea {
  resize: vertical;
  min-height: 260px;
  line-height: 1.6;
}

.history-box {
  margin-top: 18px;
}

.source-panel {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
  border: 1px solid var(--line);
  background: var(--panel-strong);
  border-radius: 20px;
  padding: 14px 16px;
}

#official-status {
  margin: 8px 0 0;
  color: var(--muted);
  line-height: 1.4;
}

.source-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.api-token-box {
  margin: 0;
  min-width: 170px;
}

.api-token-box span {
  display: block;
  font-size: 0.75rem;
  margin-bottom: 4px;
  color: var(--muted);
}

.api-token-box input {
  padding: 8px 10px;
  border-radius: 10px;
}

.inline-toggle {
  flex-direction: row;
  align-items: center;
  margin: 0;
  white-space: nowrap;
}

.secondary {
  margin: 0;
  width: auto;
  padding: 10px 16px;
  border-radius: 14px;
  color: white;
  background: linear-gradient(90deg, #8f7654 0%, #9f8561 100%);
  box-shadow: 0 10px 20px rgba(56, 48, 33, 0.2);
  border: 0;
  cursor: pointer;
  transition: transform 180ms ease, box-shadow 180ms ease;
}

button[type="submit"],
.btn-primary {
  margin-top: 20px;
  width: 100%;
  border: 0;
  border-radius: 999px;
  padding: 16px 20px;
  color: white;
  background: linear-gradient(90deg, var(--accent) 0%, #159a68 60%, #1baf79 100%);
  cursor: pointer;
  transition: transform 180ms ease, box-shadow 180ms ease;
  box-shadow: 0 16px 32px rgba(14, 122, 83, 0.22);
}

button[type="submit"]:hover,
.btn-primary:hover,
.secondary:hover {
  transform: translateY(-1px);
}

.results {
  margin-top: 24px;
}

.metrics-overview {
  margin-top: 20px;
  border: 1px solid var(--line);
  background: var(--panel);
  box-shadow: var(--shadow);
  border-radius: 26px;
  padding: 22px;
}

.accuracy-overview {
  margin-top: 16px;
  border: 1px solid var(--line);
  background: var(--panel);
  box-shadow: var(--shadow);
  border-radius: 26px;
  padding: 22px;
}

.accuracy-message {
  margin-top: 10px;
  color: var(--muted);
}

.accuracy-grid {
  margin-top: 12px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 12px;
}

.distribution-bars {
  display: grid;
  gap: 8px;
}

.dist-row {
  display: grid;
  grid-template-columns: 48px 1fr 48px;
  gap: 8px;
  align-items: center;
  font-size: 0.9rem;
}

.dist-track {
  height: 10px;
  border-radius: 999px;
  background: rgba(24, 34, 29, 0.08);
  overflow: hidden;
}

.dist-fill {
  height: 100%;
  background: linear-gradient(90deg, #0e7a53 0%, #1baf79 100%);
}

.metrics-header h2 {
  margin: 0;
}

.metrics-header p {
  margin: 8px 0 0;
  color: var(--muted);
}

.kpi-strip {
  margin-top: 14px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 12px;
}

.kpi {
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--panel-strong);
  padding: 12px;
}

.kpi strong {
  display: block;
  font-size: 1.16rem;
  color: var(--accent);
}

.kpi small {
  color: var(--muted);
}

.chart-card {
  margin-top: 14px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.7);
  padding: 10px 12px;
}

.metric-chart {
  width: 100%;
  height: 240px;
  display: block;
}

.chart-legend {
  display: flex;
  gap: 18px;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 0.9rem;
  margin-top: 8px;
}

.dot {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  margin-right: 6px;
}

.dot.objective {
  background: #0e7a53;
}

.dot.best {
  background: #d88a2a;
}

.dot.drift {
  background: #3d5ea3;
}

.cycle-list {
  margin-top: 14px;
  display: grid;
  gap: 8px;
}

.cycle-item {
  border-bottom: 1px dashed rgba(24, 34, 29, 0.16);
  padding-bottom: 8px;
  color: var(--muted);
  font-size: 0.92rem;
}

.summary,
.insights,
.games {
  display: grid;
  gap: 16px;
}

.ranking-board {
  margin-bottom: 16px;
}

.ranking-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
}

.ranking-head h3 {
  margin: 0;
}

.ranking-head p {
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.ranking-table-wrap {
  margin-top: 10px;
  overflow-x: auto;
}

.ranking-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 620px;
}

.ranking-table th,
.ranking-table td {
  text-align: left;
  padding: 10px 8px;
  border-bottom: 1px dashed rgba(24, 34, 29, 0.16);
  font-size: 0.92rem;
}

.ranking-table th {
  color: var(--muted);
  font-weight: 600;
}

.ranking-table .numbers-cell {
  font-weight: 700;
  color: var(--accent-2);
  letter-spacing: 0.02em;
}

.ranking-table tr.top-1 td:first-child,
.ranking-table tr.top-2 td:first-child,
.ranking-table tr.top-3 td:first-child {
  color: var(--accent);
  font-weight: 700;
}

.summary,
.insights {
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  margin-bottom: 16px;
}

.card,
.game-card {
  border-radius: 22px;
  padding: 20px;
}

.card h3,
.game-card strong {
  margin-top: 0;
}

.error {
  color: #8c2c24;
  background: rgba(255, 236, 232, 0.95);
}

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

.number-list li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 10px;
  border-bottom: 1px dashed rgba(24, 34, 29, 0.14);
}

.number-list span {
  font-weight: 700;
  color: var(--accent);
}

.number-list small,
.meta {
  color: var(--muted);
}

.games {
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}

.game-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
}

.numbers {
  margin: 14px 0;
  font-size: 1.22rem;
  line-height: 1.6;
  font-weight: 700;
  color: var(--accent-2);
}

@media (max-width: 640px) {
  .layout {
    width: min(100% - 20px, 1100px);
    padding-top: 24px;
  }

  .source-panel {
    flex-direction: column;
    align-items: stretch;
  }

  .source-actions {
    justify-content: space-between;
  }

  .panel {
    padding: 18px;
    border-radius: 22px;
  }

  .metrics-overview {
    padding: 16px;
  }

  .accuracy-overview {
    padding: 16px;
  }

  h1 {
    line-height: 1;
  }
}
