/* ========================================
   NEUROTRAIN CSS v3 - CLEAN & FUTURE-PROOF
   Standardized card system, no redundancy
   ======================================== */

@font-face {
  font-family: "First Coffee";
  src:
    url("/font/First-Coffee.woff2") format("woff2"),
    url("/font/First-Coffee.woff") format("woff"),
    url("/font/First-Coffee.ttf") format("truetype");
  font-weight: normal;
  font-style: normal;
  font-display: swap;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  /* Core colors */
  --bg-dark: #050510;
  --text-primary: #ffffff;
  --text-secondary: rgba(255, 255, 255, 0.75);
  --text-muted: rgba(255, 255, 255, 0.5);

  /* Accent colors */
  --accent-cyan: #00ffff;
  --accent-magenta: #ff00ff;
  --accent-yellow: #ffff00;
  --accent-pink: #ff66cc;
  --accent-orange: #ff8800;
  --accent-purple: #9146ff;

  /* State colors */
  --danger: #ff4444;
  --success: #44ff88;

  /* Medal colors */
  --gold: #ffd700;
  --silver: #c0c0c0;
  --bronze: #cd7f32;

  /* Card system */
  --card-border: 6px;
  --card-padding: 35px;
}

body {
  font-family:
    "First Coffee", "Noto Color Emoji", "Comic Sans MS", cursive, sans-serif;
  background: var(--bg-dark);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
}

/* ========================================
   BACKGROUNDS
   ======================================== */

.background {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: -2;
  background: url("/img/wallpaper.jpeg") center center / cover no-repeat fixed;
}

.background-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: -1;
  background: linear-gradient(
    180deg,
    rgba(0, 0, 0, 0.5) 0%,
    rgba(0, 0, 0, 1) 100%
  );
}

/* Particle canvas - below main content but above background */
#particles {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 5;
  pointer-events: none;
}

/* ========================================
   LAYOUT
   ======================================== */

.container {
  position: relative;
  z-index: 10;
  max-width: 1100px;
  margin: 0 auto;
  padding: 20px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding-top: 30px;
  padding-bottom: 40px;
}

/* ========================================
   CARD SYSTEM - Standardized
   ======================================== */

.card {
  width: 95%;
  max-width: 1200px;
  padding: var(--card-padding);
  border: var(--card-border) solid;
  border-radius: 0;
  backdrop-filter: blur(6px);
}

.spacer {
  height: 40px;
}

/* Card variants by border color */
.card--rainbow {
  position: relative;
  border: var(--card-border) solid transparent;
  background:
    linear-gradient(var(--bg-dark), var(--bg-dark)) padding-box,
    conic-gradient(
        from var(--rainbow-angle, 0deg),
        var(--accent-magenta),
        var(--accent-cyan),
        var(--accent-yellow),
        var(--accent-pink),
        var(--accent-magenta)
      )
      border-box;
  box-shadow:
    0 0 60px rgba(255, 0, 255, 0.3),
    0 0 100px rgba(0, 255, 255, 0.2);
  animation: rotate-rainbow 4s linear infinite;
}

@keyframes rotate-rainbow {
  from {
    --rainbow-angle: 0deg;
  }
  to {
    --rainbow-angle: 360deg;
  }
}

@property --rainbow-angle {
  syntax: "<angle>";
  initial-value: 0deg;
  inherits: false;
}

.card--pink {
  border-color: var(--accent-pink);
  box-shadow: 0 0 40px rgba(255, 102, 204, 0.25);
}

.card--cyan {
  border-color: var(--accent-cyan);
  box-shadow: 0 0 40px rgba(0, 255, 255, 0.25);
}

.card--gold {
  border-color: var(--gold);
  box-shadow:
    0 0 50px rgba(255, 215, 0, 0.25),
    0 0 80px rgba(255, 215, 0, 0.1);
}

.card--grey {
  border-color: #666;
  box-shadow: none;
}

.card.idle {
  border-color: #555;
  box-shadow: none;
}

.card.active {
  box-shadow:
    0 0 0 3px rgba(0, 0, 0, 0.5),
    0 0 100px rgba(255, 0, 255, 0.6),
    0 0 150px rgba(0, 255, 255, 0.4),
    inset 0 0 80px rgba(255, 0, 255, 0.2);
}

.card.urgent {
  animation: card-shake 0.3s ease-in-out infinite;
  border-image: linear-gradient(
      135deg,
      var(--danger),
      var(--accent-orange),
      var(--danger)
    )
    1;
}

@keyframes card-shake {
  0%,
  100% {
    transform: translateX(0) rotate(0);
  }
  25% {
    transform: translateX(-5px) rotate(-0.5deg);
  }
  75% {
    transform: translateX(5px) rotate(0.5deg);
  }
}

/* Card titles */
.card__title {
  font-size: 1.8rem;
  margin-bottom: 20px;
  text-align: center;
}

.card__title--pink {
  color: var(--accent-pink);
  text-shadow: 0 0 20px rgba(255, 102, 204, 0.5);
}

.card__title--cyan {
  color: var(--accent-cyan);
  text-shadow: 0 0 20px rgba(0, 255, 255, 0.5);
}

.card__title--gold {
  color: var(--gold);
  text-shadow: 0 0 20px rgba(255, 215, 0, 0.5);
}

.card__title--grey {
  color: #aaa;
  text-shadow: none;
}

.card__title.idle {
  color: var(--text-muted);
  text-shadow: none;
}

/* ========================================
   HEADER
   ======================================== */

.header {
  text-align: center;
  margin-bottom: 30px;
}

.logo {
  font-size: 4.5rem;
  font-weight: normal;
  letter-spacing: 4px;
  margin-top: 20px;
  background: linear-gradient(
    90deg,
    var(--accent-cyan),
    var(--accent-magenta),
    var(--accent-yellow),
    var(--accent-pink),
    var(--accent-cyan)
  );
  background-size: 400% 100%;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  animation: rgb-shift 8s linear infinite;
  filter: drop-shadow(0 0 30px rgba(255, 0, 255, 0.8))
    drop-shadow(0 0 60px rgba(0, 255, 255, 0.5));
}

@keyframes rgb-shift {
  0% {
    background-position: 0% 50%;
  }
  100% {
    background-position: 400% 50%;
  }
}

.subtitle {
  font-size: 1.4rem;
  color: var(--text-primary);
  margin-top: 10px;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
}

.subtitle a {
  color: var(--accent-pink);
  text-decoration: none;
  border-bottom: 3px solid var(--accent-pink);
  transition: all 0.3s ease;
}

.subtitle a:hover {
  color: var(--accent-cyan);
  border-color: var(--accent-cyan);
}

/* ========================================
   PROGRESS BAR (Main card content)
   ======================================== */

.progress-bar {
  height: 120px;
  background: rgba(0, 0, 0, 0.9);
  border-radius: 20px;
  overflow: hidden;
  position: relative;
  border: 5px solid var(--accent-magenta);
  box-shadow:
    0 0 30px rgba(255, 0, 255, 0.4),
    inset 0 0 40px rgba(0, 0, 0, 0.9);
}

.progress-bar.idle {
  border-color: #555;
  box-shadow: inset 0 0 30px rgba(0, 0, 0, 0.7);
}

.progress-bar__fill {
  height: 100%;
  border-radius: 15px;
  background: linear-gradient(
    90deg,
    #9146ff 0%,
    #772ce8 25%,
    #9146ff 50%,
    #bf94ff 75%,
    #9146ff 100%
  );
  background-size: 200% 100%;
  animation: twitch-gradient 8s ease-in-out infinite;
  transition: width 0.5s ease-out;
  position: relative;
  overflow: hidden;
  box-shadow: 0 0 20px rgba(145, 70, 255, 0.6);
}

@keyframes twitch-gradient {
  0%,
  100% {
    background-position: 0% 50%;
  }
  50% {
    background-position: 100% 50%;
  }
}

.progress-bar__fill::after {
  content: "";
  position: absolute;
  top: 0;
  left: -100%;
  width: 30%;
  height: 100%;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255, 255, 255, 0.2),
    transparent
  );
  animation: shine 4s ease-in-out infinite;
}

@keyframes shine {
  0% {
    left: -100%;
  }
  100% {
    left: 200%;
  }
}

.progress-bar__waiting {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 1.6rem;
  color: var(--text-muted);
  white-space: nowrap;
  z-index: 5;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.9);
}

.progress-bar__overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 30px;
  z-index: 10;
  pointer-events: none;
}

.progress-bar__left {
  display: flex;
  align-items: center;
  gap: 15px;
}

.progress-bar__icon {
  font-size: 3rem;
  filter: drop-shadow(0 0 10px rgba(255, 255, 255, 0.8));
}

.progress-bar__level-wrap {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

.progress-bar__level-label {
  font-size: 0.9rem;
  color: rgba(255, 255, 255, 0.8);
  text-transform: uppercase;
  letter-spacing: 3px;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.9);
}

.progress-bar__level-num {
  font-size: 3.5rem;
  font-weight: bold;
  line-height: 1;
  color: #fff;
  text-shadow:
    0 0 20px rgba(255, 0, 255, 0.8),
    0 0 40px rgba(0, 255, 255, 0.6),
    0 2px 10px rgba(0, 0, 0, 0.9);
}

.progress-bar__level-num.idle {
  color: var(--text-muted);
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.9);
}

.progress-bar__center {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
}

.progress-bar__percent {
  font-size: 3rem;
  font-weight: bold;
  color: #fff;
  text-shadow:
    0 0 20px rgba(255, 255, 0, 0.8),
    0 2px 10px rgba(0, 0, 0, 0.9);
}

.progress-bar__percent.idle {
  color: var(--text-muted);
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.9);
}

.progress-bar__values {
  font-size: 1rem;
  color: rgba(255, 255, 255, 0.7);
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.9);
}

.progress-bar__right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 5px;
}

.progress-bar__time-label {
  font-size: 0.9rem;
  color: rgba(255, 255, 255, 0.8);
  text-transform: uppercase;
  letter-spacing: 2px;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.9);
}

.progress-bar__time {
  font-size: 2.5rem;
  font-weight: bold;
  font-variant-numeric: tabular-nums;
  color: #fff;
  text-shadow:
    0 0 20px rgba(0, 255, 255, 0.8),
    0 2px 10px rgba(0, 0, 0, 0.9);
}

.progress-bar__time.idle {
  color: var(--text-muted);
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.9);
}

.progress-bar__time.warning {
  color: var(--accent-orange);
  text-shadow: 0 0 30px rgba(255, 136, 0, 0.8);
}

.progress-bar__time.danger {
  color: var(--danger);
  text-shadow: 0 0 30px rgba(255, 68, 68, 1);
  animation: timer-pulse 0.3s ease-in-out infinite;
}

@keyframes timer-pulse {
  0%,
  100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.6;
    transform: scale(1.1);
  }
}

/* ========================================
   STATS GRID
   ======================================== */

.stats {
  margin-top: 30px;
}

.stats__title {
  font-size: 1.4rem;
  color: var(--accent-cyan);
  text-transform: uppercase;
  letter-spacing: 2px;
  margin-bottom: 20px;
  text-shadow: 0 0 15px rgba(0, 255, 255, 0.5);
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 2px solid rgba(0, 255, 255, 0.3);
  padding-bottom: 12px;
}

.stats__title.idle {
  color: var(--text-muted);
  text-shadow: none;
  border-color: rgba(255, 255, 255, 0.1);
}

.stats__grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
}

.stats__item {
  display: flex;
  flex-direction: column;
  padding: 15px;
  background: rgba(0, 0, 0, 0.4);
  border-radius: 10px;
  text-align: center;
}

.stats__item--big {
  background: linear-gradient(
    135deg,
    rgba(145, 70, 255, 0.2),
    rgba(0, 0, 0, 0.5)
  );
  border: 3px solid rgba(145, 70, 255, 0.5);
}

.stats__label {
  font-size: 0.95rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 8px;
}

.stats__item--big .stats__label {
  color: rgba(255, 255, 255, 0.95);
  font-size: 1.15rem;
}

.stats__value {
  font-size: 2rem;
  font-weight: bold;
  color: var(--accent-yellow);
  text-shadow: 0 0 15px rgba(255, 255, 0, 0.4);
}

.stats__value.idle {
  color: var(--text-muted);
  text-shadow: none;
}

.stats__value.ahead {
  color: #00ff88;
  text-shadow: 0 0 15px rgba(0, 255, 136, 0.5);
}

.stats__value.behind {
  color: #ff4444;
  text-shadow: 0 0 15px rgba(255, 68, 68, 0.5);
}

.stats__item--big .stats__value {
  font-size: 2.8rem;
  color: #bf94ff;
  text-shadow: 0 0 25px rgba(145, 70, 255, 0.7);
}

/* ========================================
   CONTRIBUTORS (Two-column layout)
   ======================================== */

.contributors__grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 40px;
}

.contributors__column {
  min-width: 0;
}

.contributors__subtitle {
  font-size: 1.2rem;
  color: var(--accent-cyan);
  margin-bottom: 15px;
  text-shadow: 0 0 10px rgba(0, 255, 255, 0.3);
  text-align: center;
}

.contributors__subtitle.idle {
  color: var(--text-muted);
  text-shadow: none;
}

.contributors__list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 400px;
  overflow-y: auto;
}

.contributors__item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: rgba(0, 0, 0, 0.4);
  border-radius: 8px;
  border-left: 4px solid var(--accent-magenta);
}

.contributors__item.latest {
  border-left-color: var(--accent-yellow);
  background: rgba(255, 255, 0, 0.08);
}

.contributors__item--gold {
  border-left-color: var(--gold);
  background: rgba(255, 215, 0, 0.08);
}

.contributors__item--silver {
  border-left-color: var(--silver);
}

.contributors__item--bronze {
  border-left-color: var(--bronze);
}

.contributors__rank {
  font-size: 1.2rem;
  min-width: 28px;
}

.contributors__amount {
  font-size: 1rem;
  color: var(--accent-yellow);
  font-weight: bold;
  min-width: 90px;
}

.contributors__name {
  font-size: 1.1rem;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.contributors__empty {
  color: var(--text-muted);
  text-align: center;
  padding: 40px 20px;
  font-size: 1.1rem;
}

/* ========================================
   HISTORY GRAPH
   ======================================== */

.history__canvas {
  width: 100%;
  height: 200px;
  background: rgba(0, 0, 0, 0.4);
  border-radius: 0;
  border: none;
}

.history__empty {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 200px;
  color: var(--text-muted);
  font-size: 1.2rem;
}

/* ========================================
   WORLD RECORDS
   ======================================== */

.record {
  display: flex;
  align-items: center;
  padding: 12px 15px;
  margin-bottom: 10px;
  border-radius: 0;
  transition: all 0.3s ease;
  background: rgba(0, 0, 0, 0.4);
}

.record:last-child {
  margin-bottom: 0;
}

.record--gold {
  border-left: 4px solid var(--gold);
}

.record--silver {
  border-left: 4px solid var(--silver);
}

.record--bronze {
  border-left: 4px solid var(--bronze);
}

.record__avatar {
  width: 70px;
  height: 70px;
  border-radius: 50%;
  margin-right: 15px;
  overflow: hidden;
  border: 3px solid;
  flex-shrink: 0;
}

.record__avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.record__avatar--gold {
  border-color: var(--gold);
}

.record__avatar--silver {
  border-color: var(--silver);
}

.record__avatar--bronze {
  border-color: var(--bronze);
}

.record__info {
  flex: 1;
}

.record__place {
  font-size: 1rem;
  color: var(--text-secondary);
  margin-bottom: 2px;
}

.record__name {
  font-size: 1.4rem;
  margin-bottom: 2px;
}

.record--gold .record__name {
  color: var(--gold);
}

.record--silver .record__name {
  color: var(--silver);
}

.record--bronze .record__name {
  color: var(--bronze);
}

.record__date {
  font-size: 0.9rem;
  color: var(--text-muted);
}

.record__level {
  font-size: 2.2rem;
  font-weight: bold;
  min-width: 100px;
  text-align: right;
}

.record--gold .record__level {
  color: var(--gold);
}

.record--silver .record__level {
  color: var(--silver);
}

.record--bronze .record__level {
  color: var(--bronze);
}

/* ========================================
   CREDITS
   ======================================== */

.credits__title {
  font-size: 1.5rem;
  color: #aaa;
  margin-bottom: 20px;
}

.credits__list {
  list-style: none;
  font-size: 1.1rem;
  line-height: 2;
  color: #888;
}

.credits__list a {
  color: #bbb;
  text-decoration: none;
  border-bottom: 2px solid #666;
  transition: all 0.3s ease;
}

.credits__list a:hover {
  color: #fff;
  border-color: #fff;
}

.credits__heart {
  margin-top: 25px;
  font-size: 1.4rem;
  color: #888;
}

.credits__heart .heart {
  display: inline-block;
  color: #ff6666;
}

/* ========================================
   UI CONTROLS
   ======================================== */

.sound-toggle {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 100;
  background: rgba(0, 0, 0, 0.8);
  border: 4px solid var(--accent-magenta);
  border-radius: 50%;
  width: 60px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 1.8rem;
  backdrop-filter: blur(10px);
  transition: all 0.3s ease;
  box-shadow: 0 0 25px rgba(255, 0, 255, 0.4);
}

.sound-toggle:hover {
  transform: scale(1.2) rotate(10deg);
  box-shadow: 0 0 50px rgba(255, 0, 255, 0.8);
}

.sound-toggle.disabled {
  border-color: var(--text-muted);
  box-shadow: none;
}

.connection-status {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 100;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 20px;
  background: rgba(0, 0, 0, 0.8);
  border: 4px solid var(--success);
  border-radius: 30px;
  font-size: 1rem;
  backdrop-filter: blur(10px);
  box-shadow: 0 0 20px rgba(68, 255, 136, 0.3);
}

.connection-status__dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 10px var(--success);
}

.connection-status__dot.disconnected {
  background: var(--danger);
  box-shadow: 0 0 10px var(--danger);
}

.connection-status.disconnected {
  border-color: var(--danger);
  box-shadow: 0 0 30px rgba(255, 68, 68, 0.4);
}

/* ========================================
   RESPONSIVE
   ======================================== */

@media (max-width: 900px) {
  .container {
    padding: 15px;
    padding-top: 40px;
  }

  .logo {
    font-size: 2.8rem;
    letter-spacing: 2px;
  }

  .card {
    padding: 25px;
    border-width: 4px;
    max-width: 100%;
  }

  .progress-bar {
    height: 80px;
    border-width: 4px;
  }

  .progress-bar__overlay {
    padding: 0 15px;
  }

  .progress-bar__icon {
    font-size: 1.8rem;
  }

  .progress-bar__level-num {
    font-size: 2rem;
  }

  .progress-bar__percent {
    font-size: 2rem;
  }

  .progress-bar__time {
    font-size: 1.5rem;
  }

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

  .contributors__grid {
    grid-template-columns: 1fr;
    gap: 30px;
  }

  .record {
    flex-direction: column;
    text-align: center;
    padding: 15px;
  }

  .record__medal {
    margin-right: 0;
    margin-bottom: 10px;
  }

  .record__level {
    min-width: auto;
    margin-top: 10px;
    font-size: 3rem;
  }

  .record__name {
    font-size: 1.8rem;
  }

  .connection-status {
    top: 10px;
    right: 10px;
    padding: 8px 14px;
    font-size: 0.9rem;
  }

  .sound-toggle {
    width: 50px;
    height: 50px;
    font-size: 1.4rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
