body[data-mission-mode="team"] {
  --paper: #fff9ee;
  --sheet: #fffdfa;
  --ink: #192f4c;
  --muted: #4b5b6e;
  --line: #d9c4b5;
  --game-ink: #76213e;
  --game-accent: #a4244b;
  --game-tint: #ffedf0;
  --stage-focus: #1859b7;
  min-height: 100vh;
  background: var(--paper);
  color: var(--ink);
}

body[data-mission-mode="team"] :is(button, a, summary, input, select):focus-visible {
  outline: 3px solid var(--stage-focus);
  outline-offset: 3px;
}

body[data-mission-mode="team"] .game-panel {
  border-color: #d8bcaa;
  box-shadow: 0 3px 0 #f2dfd1, 0 8px 22px #5740260d;
}

body[data-mission-mode="team"] :is(.btn-secondary, .btn-quiet) {
  border-color: #6c788c;
}

body[data-mission-mode="team"] .btn-secondary {
  background: #edf3ff;
  color: #244675;
}

body[data-mission-mode="team"] .btn-secondary:not(:disabled):hover {
  border-color: #244675;
  background: #dfeaff;
}

body[data-mission-mode="team"] .btn-quiet {
  color: #314761;
}

body[data-mission-mode="team"] #game {
  display: grid;
  min-width: 0;
  gap: .7rem;
}

.team-hero {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(78px, 26%);
  align-items: center;
  overflow: hidden;
  gap: .45rem;
  padding: clamp(17px, 4vw, 30px);
  border: 1px solid #bc754f;
  border-radius: 1.1rem;
  background:
    repeating-linear-gradient(115deg, #ffffff00 0 22px, #fff6cf75 23px 25px),
    radial-gradient(ellipse at 88% 0%, #fff3ad, #ffdfc2 62%, #ffd7cc);
  color: var(--ink);
}

.team-hero h1 {
  margin: 0 0 .2rem;
  font-size: clamp(1.52rem, 6vw, 2.65rem);
  line-height: 1.22;
  overflow-wrap: anywhere;
}

.team-hero p {
  margin: 0;
  color: #344a66;
  font-size: .91rem;
}

.team-emblem {
  position: relative;
  min-height: clamp(72px, 12vw, 126px);
}

.team-emblem i {
  position: absolute;
  top: 14%;
  left: 10%;
  display: grid;
  place-items: center;
  width: 45%;
  aspect-ratio: .76;
  border: 2px solid #9b3f52;
  border-radius: .55rem;
  background: #ffc1c2;
  color: #8a3047;
  box-shadow: 0 4px 0 #bc6a60;
  font-size: clamp(1rem, 4vw, 1.85rem);
  font-style: normal;
  font-weight: 900;
  transform: rotate(-16deg);
}

.team-emblem i:not(:last-child)::before {
  content: "";
  width: 55%;
  height: 45%;
  border-block: 2px solid currentColor;
  border-radius: 30%;
}

.team-emblem i:nth-child(2) {
  top: 18%;
  left: 45%;
  border-color: #326477;
  background: #bcf0df;
  color: #22586a;
  box-shadow: 0 4px 0 #719f9e;
  transform: rotate(13deg);
}

.team-emblem i:last-child {
  top: -6%;
  left: 78%;
  width: auto;
  border: 0;
  background: transparent;
  color: #9b4f12;
  box-shadow: none;
}

.team-setup,
.team-stage,
#team-adjust-content {
  display: grid;
  min-width: 0;
  gap: clamp(.58rem, 2vw, .92rem);
}

.team-stage h1,
.team-stage h2,
.team-stage p,
.team-setup p {
  margin: 0;
}

.team-mode-picker {
  min-width: 0;
  padding: 0;
  margin: 0;
  border: 0;
}

.team-mode-picker legend {
  margin: 0 0 .35rem;
  padding: 0;
  font-weight: 850;
}

.team-mode-choices,
.team-settings {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: .5rem;
}

.team-setup > .team-settings {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.team-mode-choices label {
  position: relative;
  display: block;
  cursor: pointer;
}

.team-mode-choices input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}

.team-mode-choices label > span {
  display: grid;
  align-content: center;
  justify-items: center;
  gap: .15rem;
  min-height: 55px;
  padding: .38rem .35rem;
  border: 1px solid #78849a;
  border-radius: .65rem;
  color: #294975;
  text-align: center;
  line-height: 1.27;
  overflow-wrap: anywhere;
}

.team-mode-choices small,
.team-names small,
.team-adjust small,
.team-roster-list small {
  color: var(--muted);
  font-size: .75rem;
  font-weight: 700;
}

.team-mode-choices input:checked + span {
  border-color: var(--game-accent);
  background: #ffedf0;
  color: var(--game-ink);
  box-shadow: inset 0 0 0 1px var(--game-accent);
}

.team-mode-choices input:focus-visible + span {
  outline: 3px solid var(--stage-focus);
  outline-offset: 3px;
}

.team-field {
  min-width: 0;
  align-self: end;
  gap: .32rem;
}

.team-field select {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  min-width: 0;
  height: 46px;
  min-height: 46px;
  padding-inline-end: 1.6rem;
  border: 1px solid #6f7b8f;
  border-radius: .58rem;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='m4 6 4 4 4-4' fill='none' stroke='%23244675' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right .42rem center;
  background-size: .88rem;
}

.team-names input {
  border-color: #6f7b8f;
}

.team-names,
.team-adjust,
.team-live-roster {
  min-width: 0;
  padding-inline: .6rem;
  border: 1px solid #8c8494;
  border-radius: .6rem;
}

.team-names summary,
.team-adjust summary,
.team-live-roster summary {
  min-height: 44px;
  padding-block: .52rem;
  color: #294975;
  font-size: .9rem;
  font-weight: 820;
  cursor: pointer;
  overflow-wrap: anywhere;
}

.team-names[open],
.team-adjust[open],
.team-live-roster[open] {
  padding-block-end: .65rem;
}

.team-roster-list,
.team-scoreboard,
.team-ranking,
.team-history {
  padding: 0;
  margin: 0;
  list-style: none;
}

.team-roster-list {
  display: grid;
  gap: .3rem;
}

.team-roster-list li {
  display: grid;
  grid-template-columns: minmax(5rem, max-content) minmax(0, 1fr);
  align-items: start;
  gap: .32rem;
  padding: .35rem .45rem;
  border: 1px solid var(--team-tone, #8692a4);
  border-radius: .52rem;
  background: var(--team-soft, #f3f6fb);
  color: var(--team-tone, #314761);
  font-size: .82rem;
  overflow-wrap: anywhere;
}

.team-adjust-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) max-content;
  align-items: end;
  gap: .5rem;
}

.team-adjust-row > .btn {
  min-height: 46px;
  padding-inline: .62rem;
  font-size: .84rem;
}

.team-kicker {
  margin: 0;
  color: #294975;
  font-size: .75rem;
  font-weight: 850;
}

.team-note {
  color: var(--muted);
  font-size: .86rem;
  overflow-wrap: anywhere;
}

.team-error {
  padding: .6rem;
  border: 1px solid #ce9d96;
  border-radius: .55rem;
  background: #fbede9;
  color: #822d22;
  font-weight: 800;
}

.team-scoreboard {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: .36rem;
}

.team-score {
  display: flex;
  min-width: 0;
  min-height: 36px;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: .1rem .3rem;
  padding: .24rem .45rem;
  border: 1px solid var(--team-tone);
  border-radius: .53rem;
  background: var(--team-soft);
  color: var(--team-tone);
  font-size: .78rem;
  font-weight: 800;
  overflow-wrap: anywhere;
}

:is([data-team-id="A"], [data-team-roster="A"], [data-team-color="A"]) {
  --team-tone: #6e4812;
  --team-soft: #fff0c9;
}

:is([data-team-id="B"], [data-team-roster="B"], [data-team-color="B"]) {
  --team-tone: #603879;
  --team-soft: #f3e8ff;
}

:is([data-team-id="C"], [data-team-roster="C"], [data-team-color="C"]) {
  --team-tone: #1d5d4d;
  --team-soft: #e4f6ec;
}

:is([data-team-id="D"], [data-team-roster="D"], [data-team-color="D"]) {
  --team-tone: #65401c;
  --team-soft: #ffe3c1;
}

:is([data-team-id="E"], [data-team-roster="E"], [data-team-color="E"]) {
  --team-tone: #55305f;
  --team-soft: #f0e2f5;
}

:is([data-team-id="F"], [data-team-roster="F"], [data-team-color="F"]) {
  --team-tone: #315818;
  --team-soft: #edf6da;
}

.team-score.is-active {
  border-color: currentColor;
  box-shadow: inset 0 0 0 1px currentColor;
}

.team-score strong {
  font-variant-numeric: tabular-nums;
}

.team-score small {
  margin-inline-start: .14rem;
  font-size: .65rem;
}

.team-spotlight {
  display: grid;
  min-width: 0;
  gap: .24rem;
  padding: clamp(14px, 4vw, 22px);
  border: 1px solid var(--team-tone, #a76739);
  border-radius: .76rem;
  background:
    repeating-linear-gradient(115deg, #ffffff00 0 20px, #ffffff66 21px 23px),
    linear-gradient(120deg, var(--team-soft, #fff0c6), #fff9ed);
  color: var(--team-tone, #573315);
}

.team-spotlight .team-kicker {
  color: inherit;
}

.team-spotlight h1 {
  font-size: clamp(1.28rem, 5vw, 2rem);
  line-height: 1.25;
}

.team-actor-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .5rem;
  padding: .48rem .58rem;
  border: 1px solid #bd8d9e;
  border-radius: .58rem;
  background: #fff1f1;
}

.team-actor-row > div {
  min-width: 0;
}

.team-actor {
  color: var(--ink);
  font-size: clamp(1.24rem, 5.2vw, 1.72rem);
  font-weight: 850;
  line-height: 1.32;
  overflow-wrap: anywhere;
}

.team-actor-row > .btn {
  flex: 0 0 auto;
  min-height: 44px;
  padding: .35rem .6rem;
  font-size: .8rem;
}

.team-answerers {
  display: grid;
  min-width: 0;
  gap: .42rem;
  padding: .55rem .65rem;
  border: 1px solid #8798af;
  border-radius: .58rem;
  background: #f1f6ff;
}

.team-answerers h2 {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: .38rem;
  color: #244675;
  font-size: .88rem;
}

.team-answerers h2 span {
  color: #435c7e;
  font-size: .76rem;
}

.team-guessers {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: .28rem .34rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.team-guessers > li {
  display: block;
  max-width: 100%;
  min-width: 0;
  padding: .12rem .43rem;
  border: 1px solid #8093ac;
  border-radius: .42rem;
  background: #fff;
  color: #213b5c;
  font-size: .82rem;
  font-weight: 750;
  line-height: 1.42;
  overflow-wrap: anywhere;
}

.team-guessers bdi,
.team-roster-list bdi {
  overflow-wrap: anywhere;
}

.team-clock {
  display: grid;
  min-width: 0;
  justify-items: start;
  gap: .12rem;
  padding: .58rem .7rem;
  border: 1px solid #748eb7;
  border-radius: .68rem;
  background: #eaf2ff;
  color: #294975;
  font-size: .83rem;
  font-weight: 850;
}

.team-clock p {
  display: flex;
  align-items: baseline;
  gap: .28rem;
  line-height: 1.05;
}

.team-clock strong {
  font-size: clamp(2.55rem, 10vw, 4.1rem);
  font-variant-numeric: tabular-nums;
}

.team-clock progress {
  width: 100%;
  height: .48rem;
  margin-top: .2rem;
  accent-color: #294975;
}

.team-clock:has([data-team-timer="5"], [data-team-timer="4"], [data-team-timer="3"], [data-team-timer="2"], [data-team-timer="1"]) {
  border-color: #9b3751;
  background: #ffece4;
  color: #842945;
}

.team-clock-cue {
  justify-items: center;
  padding: .8rem;
}

.team-clock-cue strong {
  font-size: clamp(4.2rem, 16vw, 7rem);
}

.team-prompt {
  display: grid;
  align-content: center;
  min-width: 0;
  gap: .3rem;
  padding: .7rem .85rem;
  border: 1px solid #ab7435;
  border-inline-start: 5px solid #a85d20;
  border-radius: .68rem;
  background: #fff3cb;
  color: #4b351d;
  overflow-wrap: anywhere;
}

.team-prompt .team-kicker {
  color: #744719;
}

.team-prompt h2 {
  font-size: clamp(1.32rem, 6vw, 2.15rem);
  line-height: 1.24;
}

.team-stage > .btn,
.team-setup > .btn {
  min-height: 48px;
}

.team-live-status {
  display: grid;
  gap: .52rem;
}

.team-rapid .team-live-status {
  grid-template-columns: minmax(0, 1fr) minmax(84px, .45fr);
}

.team-running-score {
  display: grid;
  align-content: center;
  justify-items: center;
  padding: .45rem;
  border: 1px solid #a97a37;
  border-radius: .65rem;
  background: #fff1d1;
  color: #664916;
  font-size: .83rem;
  font-weight: 850;
  line-height: 1.2;
}

.team-running-score strong {
  font-size: clamp(1.6rem, 7vw, 2.55rem);
  font-variant-numeric: tabular-nums;
}

.team-perform [data-team-prompt-slot] {
  display: grid;
  min-height: 112px;
}

.team-live-controls {
  display: grid;
  gap: .6rem;
}

.team-live-controls .btn {
  min-height: 65px;
  font-size: 1.12rem;
  touch-action: manipulation;
}

.team-live-controls [data-team-action="correct"] {
  border-color: #12513e;
  background: #17664e;
  box-shadow: 0 2px 0 #104433;
}

.team-live-controls [data-team-action="correct"]:not(:disabled):hover {
  background: #104b3a;
}

.team-rapid .team-live-controls {
  position: sticky;
  inset-block-end: max(.4rem, env(safe-area-inset-bottom));
  z-index: 2;
  grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr);
  padding: .45rem;
  border: 1px solid #99a9a7;
  border-radius: .7rem;
  background: #fffdfa;
  box-shadow: 0 3px 12px #314b4b1c;
}

.team-history-panel {
  display: grid;
  gap: .5rem;
}

.team-history-panel h2 {
  color: var(--ink);
  font-size: 1.04rem;
}

.team-history,
.team-ranking {
  display: grid;
  gap: .35rem;
}

.team-history-entry,
.team-ranking li {
  display: grid;
  grid-template-columns: minmax(0, 1fr) max-content;
  align-items: baseline;
  gap: .55rem;
  padding: .48rem .55rem;
  border: 1px solid var(--team-tone, #8796a9);
  border-radius: .55rem;
  background: var(--team-soft, #f5f8fd);
  color: var(--team-tone, #294665);
  overflow-wrap: anywhere;
}

.team-history-entry[data-entry-status="correct"] {
  border-color: #658c77;
  background: #eff7ee;
  color: #285645;
}

.team-history-entry strong {
  font-size: .8rem;
}

.team-ranking li {
  grid-template-columns: minmax(2.7rem, auto) minmax(0, 1fr) max-content;
}

.team-ranking li[data-team-rank="1"] {
  box-shadow: inset 0 0 0 1px currentColor;
  font-weight: 800;
}

.team-ranking li[data-team-rank="1"] > strong:first-child {
  justify-self: start;
  padding: .08rem .36rem;
  border: 1px solid #956727;
  border-radius: .4rem;
  background: #ffde83;
  color: #503314;
}

#game[data-team-outcome="correct"] .team-feedback-banner {
  --team-soft: #def4e6;
  --team-tone: #245b43;
}

.team-final {
  position: relative;
}

.team-final .team-feedback-banner {
  --team-tone: #5b3b12;
  --team-soft: #ffe59b;
}

.team-confetti {
  position: absolute;
  z-index: 3;
  inset: 0;
  overflow: hidden;
  border-radius: inherit;
  pointer-events: none;
  animation: team-confetti-window 1.55s both;
}

.team-confetti i {
  position: absolute;
  top: -12px;
  left: var(--x);
  width: 8px;
  height: 12px;
  border-radius: 2px;
  background: #edac48;
  animation: team-confetti-fall 1.37s var(--delay) ease-out both;
}

.team-confetti i:nth-child(4n) { background: #df5275; }
.team-confetti i:nth-child(4n + 1) { background: #529b7f; }
.team-confetti i:nth-child(4n + 2) { background: #6887cf; }

@keyframes team-confetti-window {
  from { opacity: 1; }
  to { opacity: .85; }
}

@keyframes team-confetti-fall {
  0% { transform: translateY(0); opacity: 1; }
  66% { opacity: 1; }
  100% { transform: translate(var(--drift), 310px) rotate(var(--spin)); opacity: 0; }
}

@media (max-width: 360px) {
  body[data-mission-mode="team"] .header-inner {
    gap: 6px;
    padding-inline: 10px;
  }

  body[data-mission-mode="team"] .lab-brand {
    gap: 5px;
    font-size: .84rem;
  }

  .team-setup > .team-settings {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (prefers-reduced-motion: reduce) {
  .team-confetti { display: none; }
}
