:root {
  --bg: #080a0f;
  --panel: #11151d;
  --panel-2: #151b25;
  --panel-3: #0d1118;
  --text: #f4f8fb;
  --muted: #8995a8;
  --line: #252d3a;
  --cyan: #00c2ff;
  --green: #35d07f;
  --amber: #f5b849;
  --red: #ff5a66;
  --purple: #8b5cf6;
  --shadow: 0 24px 70px rgba(0, 0, 0, .34);
}

* { box-sizing: border-box; }

html { color-scheme: dark; }

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 50% -15%, rgba(0, 194, 255, .16), transparent 34rem),
    linear-gradient(180deg, #0a0d13 0%, #080a0f 52%, #0b0f15 100%);
  color: var(--text);
  font-family: Inter, "Segoe UI", Arial, sans-serif;
}

button, select, input { font: inherit; }
button { border: 0; cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .48; }
h1, h2, p { margin: 0; }

.app {
  width: min(1320px, calc(100% - 32px));
  margin: 0 auto;
  padding: 30px 0 46px;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 22px;
  align-items: start;
  margin-bottom: 22px;
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--cyan);
  font-size: .75rem;
  font-weight: 900;
  letter-spacing: .16em;
  text-transform: uppercase;
}

h1 {
  max-width: 820px;
  font-size: clamp(2.55rem, 6.5vw, 5.7rem);
  line-height: .9;
  letter-spacing: 0;
}

h2 {
  color: #f7fbff;
  font-size: 1rem;
  letter-spacing: 0;
}

.subtitle {
  max-width: 760px;
  margin-top: 16px;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.55;
}

.control-panel,
.gauge-card,
.chart-card,
.panel,
.metrics article {
  min-width: 0;
  background: linear-gradient(180deg, rgba(21, 27, 37, .96), rgba(13, 17, 24, .96));
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.control-panel {
  padding: 16px;
}

.status-line {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 30px;
  margin-bottom: 12px;
  color: #cdd5df;
}

.status-dot {
  width: 11px;
  height: 11px;
  border-radius: 99px;
  background: var(--amber);
  box-shadow: 0 0 0 5px rgba(245, 184, 73, .12), 0 0 22px rgba(245, 184, 73, .35);
}
.status-dot.ready {
  background: var(--green);
  box-shadow: 0 0 0 5px rgba(53, 208, 127, .13), 0 0 22px rgba(53, 208, 127, .35);
}
.status-dot.busy {
  background: var(--cyan);
  box-shadow: 0 0 0 5px rgba(0, 194, 255, .13), 0 0 22px rgba(0, 194, 255, .4);
}
.status-dot.error {
  background: var(--red);
  box-shadow: 0 0 0 5px rgba(255, 90, 102, .13), 0 0 22px rgba(255, 90, 102, .34);
}

label {
  display: block;
  margin: 12px 0 7px;
  color: #aab5c5;
  font-size: .72rem;
  font-weight: 900;
  letter-spacing: .08em;
  text-transform: uppercase;
}

select,
input {
  width: 100%;
  min-width: 0;
  height: 42px;
  padding: 0 12px;
  border: 1px solid #303948;
  border-radius: 8px;
  background: #0b0f16;
  color: var(--text);
  outline: none;
}

select:focus,
input:focus {
  border-color: var(--cyan);
  box-shadow: 0 0 0 4px rgba(0, 194, 255, .13);
}

.actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 15px;
}

.primary,
.secondary {
  min-height: 44px;
  border-radius: 8px;
  font-weight: 950;
}

.primary {
  color: #031018;
  background: var(--cyan);
  box-shadow: 0 0 28px rgba(0, 194, 255, .25);
}

.primary:hover { background: #2bd1ff; }

.secondary {
  color: #d8e0eb;
  background: #1a212c;
  border: 1px solid #313b4d;
}

.secondary:hover { background: #222b38; }

.stage {
  display: grid;
  grid-template-columns: minmax(330px, 420px) minmax(0, 1fr);
  gap: 22px;
  margin-bottom: 22px;
}

.gauge-card {
  min-height: 484px;
  padding: 22px;
  display: grid;
  align-content: center;
}

.gauge {
  position: relative;
  width: min(100%, 370px);
  aspect-ratio: 1;
  margin: 0 auto;
}

.gauge::before {
  content: "";
  position: absolute;
  inset: 42px;
  border: 1px solid rgba(255, 255, 255, .08);
  border-radius: 50%;
  background: radial-gradient(circle, rgba(0, 194, 255, .09), rgba(0, 0, 0, .08) 58%, transparent 70%);
}

.gauge canvas {
  position: relative;
  z-index: 1;
  width: 100%;
  height: 100%;
  display: block;
}

.gauge-value {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: grid;
  align-content: center;
  justify-items: center;
  pointer-events: none;
}

.gauge-value strong {
  font-size: clamp(2.6rem, 7vw, 4.45rem);
  line-height: .9;
  letter-spacing: 0;
  font-weight: 950;
}

.gauge-value span {
  margin-top: 8px;
  color: #e4ebf3;
  font-weight: 900;
}

.gauge-value small {
  margin-top: 9px;
  color: var(--cyan);
  font-weight: 900;
  text-transform: uppercase;
}

.confidence {
  margin-top: 18px;
  padding: 14px;
  border: 1px solid #2b3442;
  border-radius: 8px;
  background: #0c1118;
  color: var(--muted);
  display: grid;
  gap: 5px;
}

.confidence strong { color: var(--text); }
.confidence.good strong { color: var(--green); }
.confidence.warn strong { color: var(--amber); }
.confidence.bad strong { color: var(--red); }

.chart-card,
.panel {
  padding: 18px;
}

.chart-card {
  min-height: 484px;
  display: grid;
  grid-template-rows: auto minmax(280px, 1fr);
}

.panel-head {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: start;
  margin-bottom: 14px;
}

.panel-head > div { min-width: 0; }

.panel-head p {
  margin-top: 5px;
  color: var(--muted);
  font-size: .88rem;
  line-height: 1.45;
}

#engineBadge,
#gameBadge {
  flex: 0 0 auto;
  padding: 6px 10px;
  border: 1px solid #313b4d;
  border-radius: 99px;
  color: #cbd5e1;
  background: #0b0f16;
  font-weight: 900;
  font-size: .76rem;
}

#chartCanvas {
  width: 100%;
  height: 100%;
  min-height: 300px;
  display: block;
  border: 1px solid #263142;
  border-radius: 8px;
  background: #080c12;
}

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

.metrics article {
  min-height: 118px;
  padding: 15px;
  display: grid;
  align-content: space-between;
}

.metrics span,
.game-focus span,
.game-grid span,
.region-summary span {
  color: var(--muted);
  font-size: .72rem;
  font-weight: 900;
  letter-spacing: .07em;
  text-transform: uppercase;
}

.metrics strong {
  margin-top: 10px;
  font-size: clamp(1.5rem, 3vw, 2.45rem);
  line-height: 1;
  letter-spacing: 0;
}

.metrics article:nth-child(1) strong { color: var(--cyan); }
.metrics article:nth-child(2) strong { color: var(--green); }
.metrics small { color: var(--muted); font-weight: 800; }

.gaming-panel,
.region-panel {
  margin-bottom: 22px;
}

.conversion-note {
  margin: -2px 0 15px;
  color: var(--muted);
  font-size: .9rem;
  line-height: 1.5;
}

.game-controls,
.region-controls {
  display: grid;
  gap: 14px;
  align-items: end;
  margin-bottom: 15px;
}

.game-controls {
  grid-template-columns: minmax(0, 1.35fr) minmax(160px, .65fr);
}

.region-controls {
  grid-template-columns: minmax(220px, 360px) minmax(160px, 240px);
}

.game-focus,
.game-grid,
.region-summary {
  display: grid;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: rgba(8, 12, 18, .56);
}

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

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

.region-summary {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-bottom: 14px;
}

.game-focus article,
.game-grid article,
.region-summary article {
  min-width: 0;
  padding: 15px;
  display: grid;
  gap: 8px;
  border-right: 1px solid var(--line);
}

.game-focus article:last-child,
.game-grid article:last-child,
.region-summary article:last-child {
  border-right: 0;
}

.game-focus strong,
.game-grid strong,
.region-summary strong {
  font-size: clamp(1.1rem, 2vw, 1.75rem);
  line-height: 1.08;
  letter-spacing: 0;
}

.game-focus small,
.game-grid small,
.region-summary small {
  color: var(--muted);
  font-weight: 800;
  overflow-wrap: anywhere;
}

.download-times {
  min-width: 0;
  margin-top: 14px;
  overflow: auto;
}

.download-times table { min-width: 520px; }

.compact {
  min-height: 36px;
  padding: 0 14px;
  white-space: nowrap;
}

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

.details {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(340px, .8fr);
  gap: 22px;
}

.stage > *,
.details > * {
  min-width: 0;
}

.table-wrap {
  min-width: 0;
  max-width: 100%;
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 640px;
}

th,
td {
  text-align: left;
  padding: 12px 10px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

th {
  color: var(--muted);
  font-size: .74rem;
  letter-spacing: .06em;
  text-transform: uppercase;
}

td { color: #d6dee8; }

.info-list {
  margin: 0;
  display: grid;
  gap: 9px;
}

.info-list div {
  display: grid;
  grid-template-columns: 120px minmax(0, 1fr);
  gap: 10px;
  border-bottom: 1px solid var(--line);
  padding: 8px 0;
}

.info-list dt {
  color: var(--muted);
  font-weight: 900;
  font-size: .82rem;
}

.info-list dd {
  margin: 0;
  overflow-wrap: anywhere;
  font-weight: 750;
}

.log {
  min-height: 120px;
  max-height: 190px;
  overflow: auto;
  margin-top: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #080c12;
  color: #a9b5c6;
  font: .78rem/1.55 Consolas, "Cascadia Mono", monospace;
}

@media (max-width: 1080px) {
  .hero,
  .stage,
  .details {
    grid-template-columns: 1fr;
  }

  .control-panel {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0 12px;
  }

  .status-line,
  .actions {
    grid-column: 1 / -1;
  }

  .metrics {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .game-controls {
    grid-template-columns: 1fr;
  }

  .game-focus {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .game-focus article:nth-child(2n),
  .game-grid article:nth-child(2n),
  .region-summary article {
    border-right: 0;
  }

  .game-focus article,
  .game-grid article,
  .region-summary article {
    border-bottom: 1px solid var(--line);
  }

  .game-focus article:nth-last-child(-n+2),
  .region-summary article:last-child {
    border-bottom: 0;
  }

  .game-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .game-grid article:last-child {
    border-bottom: 0;
  }

  .region-summary {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .app {
    width: min(100% - 20px, 1320px);
    padding-top: 18px;
  }

  h1 {
    font-size: clamp(2.25rem, 13vw, 3.7rem);
  }

  .control-panel,
  .actions,
  .metrics,
  .game-focus,
  .game-grid,
  .region-controls {
    grid-template-columns: 1fr;
  }

  .stage,
  .details {
    gap: 14px;
  }

  .gauge-card,
  .chart-card {
    min-height: auto;
    padding: 14px;
  }

  #chartCanvas {
    min-height: 230px;
  }

  .game-focus article,
  .game-grid article {
    border-right: 0;
  }

  .game-focus article:nth-last-child(-n+2) {
    border-bottom: 1px solid var(--line);
  }

  .game-focus article:last-child,
  .game-grid article:last-child {
    border-bottom: 0;
  }

  .info-list div {
    grid-template-columns: 1fr;
    gap: 4px;
  }
}
