/* =============================================================
   KOMANDINĖ VIKTORINA
   Vėsus mėlynas / žalsvas „komandinis" akcentas ant tamsaus fono.
   Mobile-first nuo 250px → centruotas, gyvas desktop.
   ============================================================= */

.team-body {
  --tm-cyan:        oklch(0.78 0.13 215);   /* pagrindinis akcentas (žalsvai mėlynas) */
  --tm-cyan-strong: oklch(0.70 0.15 230);   /* sodresnis */
  --tm-violet:      oklch(0.70 0.15 285);   /* antrinis akcentas */
  --tm-mint:        oklch(0.80 0.14 165);   /* sėkmė / teisinga */
  --tm-rose:        oklch(0.68 0.17 18);    /* klaida / neteisinga */
  --tm-gold:        oklch(0.83 0.13 85);    /* 1 vieta topuose */

  --tm-bg:          oklch(0.19 0.022 240);  /* pagrindinis fonas, vėsus */
  --tm-bg-deep:     oklch(0.15 0.02 240);   /* gilesnis */
  --tm-surface:     oklch(0.24 0.022 242);  /* kortelės paviršius */
  --tm-surface-2:   oklch(0.28 0.024 244);  /* pakeltas (inputai, eilutės) */
  --tm-border:      oklch(0.35 0.03 246);   /* kraštinės */
  --tm-border-soft: oklch(0.31 0.025 244);

  --tm-text:        oklch(0.96 0.012 250);  /* pagrindinis tekstas */
  --tm-text-soft:   oklch(0.80 0.02 248);   /* antrinis */
  --tm-text-mute:   oklch(0.66 0.02 246);   /* prislopintas */

  --tm-radius:      16px;
  --tm-radius-sm:   10px;
  --tm-ease:        cubic-bezier(0.22, 1, 0.36, 1); /* ease-out-quint */

  background:
    radial-gradient(120% 80% at 50% -10%, oklch(0.30 0.07 240 / 0.55), transparent 60%),
    linear-gradient(180deg, var(--tm-bg) 0%, var(--tm-bg-deep) 100%);
  background-attachment: fixed;
  color: var(--tm-text);
  min-height: 100vh;
}

/* =====================
   SHELL
   ===================== */
.team-shell {
  width: 100%;
  max-width: 860px;
  margin: 0 auto;
  padding: clamp(0.75rem, 3vw, 1.75rem);
  display: flex;
  flex-direction: column;
  gap: clamp(1rem, 3vw, 1.5rem);
}

/* =====================
   INTRO + VARTOTOJO KORTELĖ
   ===================== */
.team-intro {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.team-intro__title {
  font-size: clamp(1.4rem, 6vw, 2.1rem);
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -0.02em;
  color: var(--tm-text);
}

.team-intro__subtitle {
  margin-top: 0.4rem;
  font-size: clamp(0.9rem, 3.4vw, 1.05rem);
  color: var(--tm-text-soft);
  max-width: 56ch;
}

.team-intro__subtitle #user-name {
  color: var(--tm-cyan);
  font-weight: 600;
}

.team-user {
  display: flex;
  align-items: center;
  gap: clamp(0.6rem, 2.5vw, 1rem);
  padding: clamp(0.6rem, 2.5vw, 0.9rem);
  background: linear-gradient(135deg, var(--tm-surface) 0%, var(--tm-surface-2) 100%);
  border: 1px solid var(--tm-border-soft);
  border-radius: var(--tm-radius);
  box-shadow: 0 6px 22px oklch(0.1 0.02 240 / 0.4);
}

.team-user__avatar {
  flex-shrink: 0;
  width: clamp(44px, 14vw, 56px);
  height: clamp(44px, 14vw, 56px);
  border-radius: 12px;
  object-fit: cover;
  border: 2px solid var(--tm-cyan);
  box-shadow: 0 0 0 3px oklch(0.78 0.13 215 / 0.12);
}

.team-user__body {
  min-width: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.team-user__name {
  font-size: clamp(0.9rem, 3.6vw, 1.05rem);
  font-weight: 600;
  color: var(--tm-text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.team-user__balance {
  font-size: clamp(1.05rem, 4.5vw, 1.35rem);
  font-weight: 700;
  color: var(--tm-cyan);
  line-height: 1.1;
}
/* Sufiksą „litų" prideda small_user_info.js — čia nedubliuojam. */

.team-user__meta {
  margin: 0.35rem 0 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem 0.85rem;
}

.team-user__meta-item {
  display: flex;
  align-items: baseline;
  gap: 0.3rem;
  font-size: var(--font-size-xs, 0.75rem);
}

.team-user__meta-item dt { color: var(--tm-text-mute); }
.team-user__meta-item dd { margin: 0; font-weight: 600; color: var(--tm-text-soft); }

/* =====================
   KORTELĖS
   ===================== */
.team-card {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  padding: clamp(1rem, 4vw, 1.75rem);
  background: var(--tm-surface);
  border: 1px solid var(--tm-border-soft);
  border-radius: var(--tm-radius);
  box-shadow: 0 12px 36px oklch(0.1 0.02 240 / 0.45);
  animation: team-card-in 0.5s var(--tm-ease) both;
}

/* display:flex perrašytų [hidden] numatytąjį display:none — grąžinam */
.team-card[hidden] { display: none; }

@keyframes team-card-in {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

.team-card__head {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.team-card__step {
  align-self: flex-start;
  font-size: var(--font-size-xs, 0.75rem);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--tm-cyan);
  background: oklch(0.78 0.13 215 / 0.14);
  padding: 0.2rem 0.6rem;
  border-radius: var(--tm-radius-sm);
}

.team-card__title {
  font-size: clamp(1.1rem, 4.5vw, 1.4rem);
  font-weight: 700;
  line-height: 1.2;
  color: var(--tm-text);
}

.team-card__lead {
  font-size: clamp(0.85rem, 3.4vw, 0.98rem);
  color: var(--tm-text-soft);
  line-height: 1.5;
  max-width: 60ch;
}

/* =====================
   KOMANDOS PASIRINKIMAS (sukurti / prisijungti)
   ===================== */
.team-choice {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.team-choice__col {
  flex: 1;
  padding: clamp(0.85rem, 3vw, 1.15rem);
  background: var(--tm-bg-deep);
  border: 1px solid var(--tm-border-soft);
  border-radius: var(--tm-radius-sm);
}

.team-choice__or {
  display: flex;
  align-items: center;
  text-align: center;
  color: var(--tm-text-mute);
  font-size: var(--font-size-sm, 0.875rem);
}
.team-choice__or span { padding: 0 0.6rem; }
.team-choice__or::before,
.team-choice__or::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--tm-border-soft);
}

.team-form__heading {
  font-size: clamp(0.95rem, 3.6vw, 1.1rem);
  font-weight: 700;
  color: var(--tm-text);
  margin-bottom: 0.6rem;
}

/* =====================
   FORMOS
   ===================== */
.team-form {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.team-form__label {
  font-size: clamp(0.82rem, 3.3vw, 0.92rem);
  font-weight: 600;
  color: var(--tm-text);
}

.team-form__input {
  width: 100%;
  padding: 0.7rem 0.85rem;
  font-family: inherit;
  font-size: 1rem; /* ≥16px — iOS nedidina zoom */
  color: var(--tm-text);
  background: var(--tm-surface-2);
  border: 1px solid var(--tm-border);
  border-radius: var(--tm-radius-sm);
  transition: border-color 0.25s var(--tm-ease), box-shadow 0.25s var(--tm-ease);
}

.team-form__input::placeholder { color: var(--tm-text-mute); }

.team-form__input:focus {
  outline: none;
  border-color: var(--tm-cyan);
  box-shadow: 0 0 0 3px oklch(0.78 0.13 215 / 0.2);
}

.team-form__input--code {
  text-transform: uppercase;
  letter-spacing: 0.15em;
  font-weight: 700;
}

.team-form__note {
  font-size: var(--font-size-sm, 0.875rem);
  color: var(--tm-mint);
  min-height: 1.1rem;
  line-height: 1.4;
}
.team-form__note.is-error { color: var(--tm-rose); }

/* =====================
   MYGTUKAI
   ===================== */
.team-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.75rem 1.1rem;
  font-family: inherit;
  font-size: 1rem;
  font-weight: 600;
  color: var(--tm-text);
  border: 1px solid transparent;
  border-radius: var(--tm-radius-sm);
  cursor: pointer;
  transition: transform 0.2s var(--tm-ease), box-shadow 0.25s var(--tm-ease), background 0.25s var(--tm-ease);
}

.team-btn:focus-visible {
  outline: 2px solid var(--tm-cyan);
  outline-offset: 2px;
}

.team-btn--primary {
  margin-top: 0.3rem;
  color: #07151c; /* fallback senoms naršyklėms */
  color: oklch(0.18 0.02 230);
  background: linear-gradient(135deg, var(--tm-cyan) 0%, var(--tm-cyan-strong) 100%);
  box-shadow: 0 6px 18px oklch(0.70 0.15 230 / 0.32);
}
.team-btn--primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 9px 24px oklch(0.70 0.15 230 / 0.42);
}

.team-btn--ghost {
  margin-top: 0.3rem;
  color: var(--tm-cyan);
  background: oklch(0.78 0.13 215 / 0.1);
  border-color: var(--tm-border);
}
.team-btn--ghost:hover {
  background: oklch(0.78 0.13 215 / 0.18);
  border-color: var(--tm-cyan);
}

.team-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none !important;
  box-shadow: none;
}

/* =====================
   TAVO KOMANDOS JUOSTA (arenoje)
   ===================== */
.team-banner {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1.5rem;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 0.9rem;
  background: linear-gradient(135deg, oklch(0.78 0.13 215 / 0.12), oklch(0.70 0.15 285 / 0.1));
  border: 1px solid var(--tm-border-soft);
  border-radius: var(--tm-radius-sm);
}
.team-banner__label {
  display: block;
  font-size: var(--font-size-2xs, 0.625rem);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--tm-text-mute);
}
.team-banner__name {
  font-size: clamp(1rem, 4vw, 1.25rem);
  font-weight: 700;
  color: var(--tm-text);
}
.team-banner__codeval {
  font-family: inherit;
  font-size: clamp(0.95rem, 3.8vw, 1.15rem);
  font-weight: 700;
  letter-spacing: 0.15em;
  color: var(--tm-cyan);
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
}
.team-banner__members {
  font-size: var(--font-size-sm, 0.875rem);
  color: var(--tm-text-soft);
}

/* =====================
   KLAUSIMAS (arena)
   ===================== */
.team-question {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}
.team-question__top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}
.team-timer {
  font-size: var(--font-size-sm, 0.875rem);
  font-weight: 700;
  color: var(--tm-text-mute);
  font-variant-numeric: tabular-nums;
}
.team-question__text {
  font-size: clamp(1.1rem, 4.6vw, 1.45rem);
  font-weight: 600;
  line-height: 1.3;
  color: var(--tm-text);
}

.team-answer-row {
  display: flex;
  gap: 0.5rem;
  align-items: stretch;
}
.team-answer-row .team-form__input { flex: 1; min-width: 0; }
.team-answer-row .team-btn { margin-top: 0; flex-shrink: 0; }

/* Paimto taško pranešimas */
.team-flash {
  padding: 0.7rem 0.9rem;
  border-radius: var(--tm-radius-sm);
  font-weight: 600;
  font-size: clamp(0.85rem, 3.4vw, 0.98rem);
  animation: team-flash-in 0.35s var(--tm-ease) both;
}
.team-flash[hidden] { display: none; }
.team-flash.is-mine  { background: oklch(0.80 0.14 165 / 0.18); color: var(--tm-mint); }
.team-flash.is-other { background: var(--tm-surface-2); color: var(--tm-text-soft); }
.team-flash.is-timeout { background: var(--tm-surface-2); color: var(--tm-text-mute); }

@keyframes team-flash-in {
  from { opacity: 0; transform: scale(0.98); }
  to   { opacity: 1; transform: scale(1); }
}

/* =====================
   TOPAI
   ===================== */
.team-tops__head {
  flex-direction: row;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
}

.team-period {
  display: inline-flex;
  gap: 0.25rem;
  padding: 0.2rem;
  background: var(--tm-bg-deep);
  border: 1px solid var(--tm-border-soft);
  border-radius: var(--tm-radius-sm);
}
.team-period__btn {
  font-family: inherit;
  font-size: var(--font-size-xs, 0.75rem);
  font-weight: 600;
  color: var(--tm-text-mute);
  background: none;
  border: none;
  padding: 0.35rem 0.6rem;
  border-radius: 7px;
  cursor: pointer;
  transition: background 0.2s var(--tm-ease), color 0.2s var(--tm-ease);
}
.team-period__btn.is-active {
  color: #07151c;
  color: oklch(0.18 0.02 230);
  background: var(--tm-cyan);
}

.team-tops__grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
}

.team-top__title {
  font-size: clamp(0.9rem, 3.4vw, 1rem);
  font-weight: 700;
  color: var(--tm-cyan);
  margin-bottom: 0.5rem;
}

.team-top__list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  counter-reset: tm-rank;
}

.team-top__list:not(.team-top__list--plain) li {
  counter-increment: tm-rank;
}

.team-top__list li {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  padding: 0.45rem 0.65rem;
  background: var(--tm-surface-2);
  border: 1px solid var(--tm-border-soft);
  border-radius: var(--tm-radius-sm);
  font-size: var(--font-size-sm, 0.875rem);
}

.team-top__list:not(.team-top__list--plain) li::before {
  content: counter(tm-rank);
  flex-shrink: 0;
  min-width: 1.4rem;
  font-weight: 700;
  color: var(--tm-text-mute);
}
.team-top__list:not(.team-top__list--plain) li:first-child::before { color: var(--tm-gold); }

.team-top__name  { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--tm-text); }
.team-top__value { font-weight: 700; color: var(--tm-text-soft); flex-shrink: 0; }

.team-top__empty {
  color: var(--tm-text-mute);
  font-size: var(--font-size-sm, 0.875rem);
  padding: 0.45rem 0;
}

/* Live indikatorius */
.team-top__list--plain li::before { display: none; }
.team-top__list--plain .team-top__value::after {
  content: "🟢";
  margin-left: 0.3rem;
  font-size: 0.6em;
  vertical-align: middle;
}

/* =====================
   RESPONSIVE
   ===================== */
@media (max-width: 320px) {
  .team-user__balance { font-size: 1rem; }
}

/* Nuo 560px: komandos pasirinkimas dviem stulpeliais; topai 2 stulpeliai */
@media (min-width: 560px) {
  .team-choice {
    flex-direction: row;
    align-items: stretch;
  }
  .team-choice__or {
    flex-direction: column;
  }
  .team-choice__or::before,
  .team-choice__or::after {
    width: 1px;
    height: auto;
  }
  .team-tops__grid {
    grid-template-columns: 1fr 1fr;
  }
}

/* Desktop (≥760px): intro dviguba, topai 4 stulpeliai */
@media (min-width: 760px) {
  .team-intro {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 1.5rem;
  }
  .team-intro__heading { flex: 1; }
  .team-user {
    flex-shrink: 0;
    width: 300px;
  }
  .team-tops__grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

@media (prefers-reduced-motion: reduce) {
  .team-card,
  .team-flash { animation: none; }
  .team-btn:hover { transform: none; }
}
