@import url('https://fonts.googleapis.com/css2?family=Orbitron:wght@500;700&family=Rajdhani:wght@400;600;700&display=swap');

:root {
  --bg-0: #0a0e17;
  --bg-1: #121a2b;
  --bg-2: #1a2942;
  --neon-1: #00f0ff;
  --neon-2: #ff2a6d;
  --neon-3: #f9f871;
  --text: #e9f1ff;
  --muted: #8aa0c8;
  --idle: #f3e9b4;
  --green: #36e27d;
  --red: #ff3b3b;
}

* {
  box-sizing: border-box;
}

html, body {
  height: 100%;
}

body {
  margin: 0;
  font-family: "Rajdhani", "Oxanium", "Orbitron", "Noto Sans SC", sans-serif;
  color: var(--text);
  background: radial-gradient(1200px 800px at 10% 10%, #1b2e4a 0%, var(--bg-0) 60%),
              radial-gradient(800px 800px at 90% 20%, #2c1940 0%, var(--bg-0) 55%),
              linear-gradient(180deg, var(--bg-1), var(--bg-0));
  letter-spacing: 0.2px;
  overflow: hidden;
  overscroll-behavior: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

.page {
  max-width: 1200px;
  margin: 0 auto;
  padding: 16px 22px 20px;
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto auto auto auto minmax(0, 1fr);
  grid-template-areas:
    "top"
    "rules"
    "stats"
    "main"
    "chart";
  gap: 10px;
}

.top { grid-area: top; }
.rules { grid-area: rules; }
.stats { grid-area: stats; }
.main { grid-area: main; }
.chart { grid-area: chart; }

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

.top-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.title h1 {
  margin: 6px 0 0;
  font-size: 34px;
  text-transform: uppercase;
}

.reset {
  padding: 10px 18px;
  border-radius: 999px;
  border: 1px solid rgba(255, 42, 109, 0.6);
  background: rgba(255, 42, 109, 0.1);
  color: #ffd9e6;
  font-size: 14px;
  cursor: pointer;
  transition: 0.25s ease;
}

.reset:hover {
  background: rgba(255, 42, 109, 0.25);
  box-shadow: 0 0 24px rgba(255, 42, 109, 0.45);
}

.rules {
  margin-top: 10px;
  padding: 10px 14px;
  border: 1px solid rgba(138, 160, 200, 0.2);
  border-radius: 14px;
  background: linear-gradient(120deg, rgba(19, 30, 49, 0.9), rgba(10, 14, 23, 0.9));
  box-shadow: inset 0 0 40px rgba(0, 0, 0, 0.3);
}

.rules h2 {
  margin: 0 0 8px;
  font-size: 18px;
  color: var(--neon-3);
}

.rules p {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
}

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

.main {
  margin-top: 0;
  display: grid;
  grid-template-columns: 1fr;
  gap: 4px;
  align-items: center;
  align-self: center;
}

.test-wrapper {
  position: relative;
  display: flex;
  justify-content: center;
}

.test-band {
  position: relative;
  height: 22vh;
  min-height: 200px;
  width: 100%;
  max-width: 1100px;
  border-radius: 24px;
  overflow: hidden;
  border: 1px solid rgba(0, 240, 255, 0.35);
  box-shadow: 0 0 40px rgba(0, 0, 0, 0.5), inset 0 0 40px rgba(0, 240, 255, 0.15);
  cursor: grab;
  user-select: none;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.25s ease, box-shadow 0.25s ease;
  touch-action: none;
  animation: breathe 4.2s ease-in-out infinite;
}

.test-band:active {
  cursor: grabbing;
}

.test-band.state-idle {
  background: linear-gradient(135deg, var(--idle), #f9f1c8);
  color: #2b2b2b;
}

.test-band.state-wait {
  background: linear-gradient(135deg, #b8f5ff, #e7fbff);
  color: #0c1a26;
}

.test-band.state-green {
  background: linear-gradient(135deg, #1ddf70, #6dffb0);
  box-shadow: 0 0 40px rgba(54, 226, 125, 0.6), inset 0 0 40px rgba(0, 0, 0, 0.2);
  color: #02230f;
}

.test-band.state-red {
  background: linear-gradient(135deg, #ff2f2f, #ff7b7b);
  box-shadow: 0 0 40px rgba(255, 59, 59, 0.7), inset 0 0 40px rgba(0, 0, 0, 0.2);
  color: #2a0000;
}

.test-band.state-done {
  background: linear-gradient(135deg, #bfe8ff, #e8f5ff);
  box-shadow: 0 0 40px rgba(0, 240, 255, 0.25), inset 0 0 40px rgba(0, 0, 0, 0.12);
  color: #0b1a24;
}

.band-content {
  text-align: center;
  padding: 24px;
  width: 100%;
}

.status {
  font-size: 28px;
  font-weight: 600;
  text-shadow: 0 0 12px rgba(0, 0, 0, 0.25);
  text-transform: uppercase;
  letter-spacing: 4px;
}

.rain {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  opacity: 0.65;
}

.rain-line {
  position: absolute;
  left: 0;
  display: flex;
  gap: 18px;
  white-space: nowrap;
  font-size: 16px;
  letter-spacing: 6px;
  text-transform: uppercase;
  color: rgba(0, 0, 0, 0.55);
  animation: rain-move linear infinite;
  padding-right: 100vw;
}

.rain-line span {
  padding-right: 40px;
}

@keyframes rain-move {
  from { transform: translateX(100%); }
  to { transform: translateX(-100%); }
}

@keyframes breathe {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.01); }
}

.panel-card {
  padding: 10px 12px;
  border-radius: 16px;
  background: rgba(10, 14, 23, 0.8);
  border: 1px solid rgba(0, 240, 255, 0.15);
  box-shadow: inset 0 0 30px rgba(0, 240, 255, 0.08);
  text-align: center;
}

.panel-title {
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.panel-value {
  margin-top: 8px;
  font-size: 22px;
  color: var(--neon-1);
}

.chart {
  margin-top: 2px;
  padding: 10px 12px 12px;
  border-radius: 18px;
  border: 1px solid rgba(255, 42, 109, 0.2);
  background: linear-gradient(135deg, rgba(16, 22, 36, 0.9), rgba(7, 9, 14, 0.9));
  box-shadow: inset 0 0 40px rgba(255, 42, 109, 0.08);
}

.chart-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}

.chart h2 {
  margin: 0 0 6px;
  font-size: 20px;
  color: var(--neon-2);
}

.chart-note {
  font-size: 12px;
  color: var(--muted);
}

#chartCanvas {
  width: 100%;
  height: auto;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.35);
  margin-top: 10px;
}

.chart-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  color: var(--muted);
  overflow: hidden;
  border-radius: 12px;
  border: 1px solid rgba(0, 240, 255, 0.2);
  margin-top: 10px;
}

.chart-table th,
.chart-table td {
  padding: 6px 8px;
  text-align: left;
}

.chart-table thead {
  background: rgba(0, 240, 255, 0.12);
  color: #d9fbff;
}

.chart-table tbody tr:nth-child(even) {
  background: rgba(0, 240, 255, 0.06);
}

.modal {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(5, 8, 14, 0.7);
  backdrop-filter: blur(6px);
  z-index: 50;
}

.modal.hidden {
  display: none;
}

.modal-card {
  width: min(90vw, 860px);
  border-radius: 20px;
  border: 1px solid rgba(0, 240, 255, 0.25);
  background: linear-gradient(160deg, rgba(12, 18, 32, 0.96), rgba(5, 7, 12, 0.96));
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
  padding: 20px 22px 24px;
}

.modal-title {
  font-size: 20px;
  color: var(--neon-3);
  margin-bottom: 14px;
  letter-spacing: 2px;
  text-transform: uppercase;
}

.modal-body {
  display: grid;
  gap: 14px;
}

.modal-metric {
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: var(--muted);
  font-size: 14px;
}

.modal-metric strong {
  color: var(--neon-1);
  font-size: 22px;
}

#modalChart {
  width: 100%;
  height: auto;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.35);
}

.modal-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  color: var(--muted);
  overflow: hidden;
  border-radius: 12px;
  border: 1px solid rgba(255, 42, 109, 0.25);
}

.modal-table th,
.modal-table td {
  padding: 8px 10px;
  text-align: left;
}

.modal-table thead {
  background: rgba(255, 42, 109, 0.12);
  color: #ffd9e6;
}

.modal-table tbody tr:nth-child(even) {
  background: rgba(0, 240, 255, 0.06);
}

.modal-actions {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  margin-top: 18px;
}

.ghost {
  padding: 10px 18px;
  border-radius: 999px;
  border: 1px solid rgba(0, 240, 255, 0.35);
  background: rgba(0, 240, 255, 0.08);
  color: var(--text);
  cursor: pointer;
  transition: 0.25s ease;
}

.ghost:hover {
  background: rgba(0, 240, 255, 0.2);
  box-shadow: 0 0 24px rgba(0, 240, 255, 0.35);
}

@media (min-width: 901px) {
  .chart-table {
    display: none;
  }

  body.done-show .chart-table {
    display: table;
  }

  body.done-show .page {
    grid-template-areas:
      "top"
      "rules"
      "stats"
      "chart"
      "main";
  }

  .chart {
    transition: opacity 0.4s ease, transform 0.4s ease;
  }

  body.done-show .chart {
    opacity: 1;
    transform: translateY(0);
  }

  body:not(.done-show) .chart {
    opacity: 1;
    transform: translateY(0);
  }

  .main {
    transition: opacity 0.35s ease, transform 0.35s ease;
  }

  body.done-show .main {
    opacity: 0;
    transform: translateY(6px);
    pointer-events: none;
  }

  body.done-show .chart {
    animation: fade-in 0.45s ease;
  }
}

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

@media (max-width: 900px) {
  body {
    overflow: auto;
  }

  .title h1 {
    font-size: 24px;
  }

  .top {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }

  .top-actions {
    width: 100%;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px;
  }

  .reset,
  .ghost {
    padding: 8px 12px;
    font-size: 12px;
    white-space: nowrap;
  }

  .page {
    grid-template-areas:
      "top"
      "rules"
      "main"
      "stats"
      "chart";
  }

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

  .test-band {
    width: 100%;
  }

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

  .page {
    grid-template-rows: auto auto auto auto;
  }

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

  .chart {
    display: none;
  }

  .status {
    font-size: 20px;
    letter-spacing: 2px;
  }
}

@media (min-width: 901px) {
  .chart-table {
    display: none;
  }

  .chart {
    opacity: 1;
    transform: translateY(0);
  }

  body.done-show .main {
    display: none;
  }

  body.done-show .chart-table {
    display: table;
  }
}
