:root {
  --cp-player-accent: #2457db;
  --cp-player-accent-dark: #1743b6;
  --cp-player-canvas: #fff9f2;
  --cp-player-soft: #edf3ff;
  --cp-player-highlight: #ffd54a;
}

.cp-profile-slot {
  position: relative;
  z-index: 50;
  display: flex;
  flex: 0 0 auto;
  align-items: center;
}

.cp-profile-slot[hidden] {
  display: none !important;
}

.cp-profile-button {
  display: inline-flex;
  width: auto;
  min-width: 48px;
  max-width: 168px;
  min-height: 48px;
  align-items: center;
  justify-content: center;
  gap: 0.55rem;
  margin: 0;
  padding: 0.4rem 0.8rem 0.4rem 0.45rem;
  border: 2px solid var(--cp-player-accent);
  border-radius: 999px;
  color: #19233d;
  background: #fff;
  box-shadow: none;
  font: 800 0.9rem/1.1 'Nunito Variable', 'Avenir Next', 'Trebuchet MS', Arial, sans-serif;
  letter-spacing: 0;
  text-transform: none;
  cursor: pointer;
  touch-action: manipulation;
}

.cp-profile-button:hover {
  color: #19233d;
  background: var(--cp-player-soft);
  transform: none;
}

.cp-profile-button:focus-visible {
  outline: 3px solid #19233d;
  outline-offset: 3px;
}

.cp-profile-avatar {
  display: grid;
  width: 34px;
  height: 34px;
  flex: 0 0 34px;
  place-items: center;
  border-radius: 50%;
  color: #fff;
  background: var(--cp-player-accent);
  font-size: 0.94rem;
  font-weight: 950;
}

.cp-profile-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cp-profile-dialog {
  width: min(620px, calc(100% - 2rem));
  max-width: 620px;
  max-height: min(820px, calc(100dvh - 2rem));
  margin: auto;
  padding: 0;
  overflow: auto;
  border: 3px solid #19233d;
  border-radius: 28px;
  color: #19233d;
  background: #fffdf9;
  box-shadow: 0 14px 0 #19233d, 0 28px 80px rgba(25, 35, 61, 0.28);
  font: 400 16px/1.45 'Nunito Variable', 'Avenir Next', 'Trebuchet MS', Arial, sans-serif;
}

.cp-profile-dialog:not([open]) {
  display: none;
}

.cp-profile-dialog::backdrop {
  background: rgba(25, 35, 61, 0.62);
  backdrop-filter: blur(5px);
}

.cp-profile-dialog *,
.cp-profile-dialog *::before,
.cp-profile-dialog *::after {
  box-sizing: border-box;
}

.cp-profile-form {
  display: grid;
  gap: 1.05rem;
  padding: clamp(1.25rem, 4vw, 2rem);
}

.cp-profile-heading {
  padding: 0.25rem 0 0.35rem;
}

.cp-profile-kicker {
  display: block;
  margin-bottom: 0.35rem;
  color: var(--cp-player-accent-dark);
  font-size: 0.76rem;
  font-weight: 950;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.cp-profile-heading h2 {
  margin: 0 0 0.45rem;
  color: #19233d;
  font-size: clamp(2rem, 7vw, 3rem);
  font-weight: 900;
  letter-spacing: -0.035em;
  line-height: 1;
}

.cp-profile-heading p,
.cp-profile-note,
.cp-profile-status {
  margin: 0;
  color: #536079;
}

.cp-profile-field {
  display: grid;
  gap: 0.4rem;
  color: #19233d;
  font-weight: 850;
}

.cp-profile-field input,
.cp-profile-field select {
  width: 100%;
  height: 50px;
  min-height: 50px;
  margin: 0;
  padding: 0.7rem 0.85rem;
  border: 2px solid #cbd4e3;
  border-radius: 14px;
  color: #19233d;
  background: #fff;
  font-family: inherit;
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.2;
}

.cp-profile-field input:focus,
.cp-profile-field select:focus {
  border-color: var(--cp-player-accent);
  outline: 3px solid color-mix(in srgb, var(--cp-player-accent), transparent 70%);
  outline-offset: 2px;
}

.cp-team-picker {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.65rem;
  margin: 0;
  padding: 0;
  border: 0;
}

.cp-team-picker legend {
  grid-column: 1 / -1;
  margin-bottom: -0.15rem;
  padding: 0;
  color: #19233d;
  font-weight: 850;
}

.cp-team-card {
  position: relative;
  display: grid;
  min-height: 92px;
  grid-template-columns: auto 1fr;
  align-items: start;
  gap: 0.55rem;
  padding: 0.8rem;
  border: 2px solid #d8deea;
  border-radius: 16px;
  color: #19233d;
  background: #fff;
  cursor: pointer;
}

.cp-team-card::after {
  position: absolute;
  right: 0.65rem;
  bottom: 0.65rem;
  width: 24px;
  height: 12px;
  border-radius: 999px;
  background: var(--team-swatch);
  box-shadow: -10px 0 0 var(--team-swatch-2);
  content: '';
}

.cp-team-card--neutral { --team-swatch: #2457db; --team-swatch-2: #ffd54a; }
.cp-team-card--girl { --team-swatch: #7b2d6f; --team-swatch-2: #ffd166; }
.cp-team-card--boy { --team-swatch: #075e69; --team-swatch-2: #b8dc65; }

.cp-team-card:has(input:checked) {
  border-color: var(--team-swatch);
  background: color-mix(in srgb, var(--team-swatch), white 90%);
  box-shadow: inset 0 0 0 1px var(--team-swatch);
}

.cp-team-card input {
  width: 20px;
  height: 20px;
  margin: 0.1rem 0 0;
  accent-color: var(--team-swatch);
}

.cp-team-card span,
.cp-team-card strong,
.cp-team-card small {
  display: block;
}

.cp-team-card strong {
  font-size: 1rem;
  line-height: 1.2;
}

.cp-team-card small {
  margin-top: 0.18rem;
  color: #5e687d;
  font-size: 0.76rem;
  line-height: 1.25;
}

.cp-profile-note {
  padding: 0.75rem 0.85rem;
  border-radius: 12px;
  background: #f3f6fb;
  font-size: 0.82rem;
}

.cp-profile-status {
  min-height: 1.2em;
  color: #8b2340;
  font-size: 0.84rem;
  font-weight: 750;
}

.cp-profile-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.cp-profile-actions > span {
  display: flex;
  gap: 0.65rem;
  margin-left: auto;
}

.cp-profile-actions button {
  display: inline-flex;
  width: auto;
  min-width: 88px;
  min-height: 48px;
  align-items: center;
  justify-content: center;
  margin: 0;
  padding: 0.65rem 1rem;
  border: 2px solid #19233d;
  border-radius: 14px;
  color: #19233d;
  background: #fff;
  box-shadow: none;
  font-family: inherit;
  font-size: 0.94rem;
  font-weight: 850;
  line-height: 1;
  text-decoration: none;
  cursor: pointer;
}

.cp-profile-actions button:hover {
  color: #19233d;
  background: #edf1f8;
  transform: none;
}

.cp-profile-actions .cp-profile-save {
  color: #fff;
  background: var(--cp-player-accent);
}

.cp-profile-actions .cp-profile-save:hover {
  color: #fff;
  background: var(--cp-player-accent-dark);
}

.cp-profile-actions .cp-profile-remove {
  border-color: transparent;
  color: #7d2940;
  background: transparent;
  text-decoration: underline;
  text-underline-offset: 0.18em;
}

.cp-profile-actions .cp-profile-remove[hidden] {
  display: none;
}

html[data-player-team='girl'] {
  --canvas: #fff7fb;
  --ink: #3d243f;
  --blue: #7b2d6f;
  --blue-dark: #5d2054;
  --accent: #f29abd;
  --paper: #fff8fb;
  --pink: #7b2d6f;
  --purple: #7b2d6f;
  --sky: #f7e7ef;
  --background: #fff9fb;
  --foreground: #3f2942;
  --primary: #7b2d6f;
  --primary-foreground: #fff7fb;
  --secondary: #f7e3ed;
  --muted: #f2e6ec;
  --muted-foreground: #74556f;
  --border: #ead5df;
  --ring: #7b2d6f;
}

html[data-player-team='boy'] {
  --canvas: #f3fbfc;
  --ink: #183b4a;
  --blue: #075e69;
  --blue-dark: #06464f;
  --accent: #80d6d0;
  --paper: #f5fcfb;
  --pink: #075e69;
  --purple: #075e69;
  --sky: #dff3f2;
  --background: #f7fcfa;
  --foreground: #173e45;
  --primary: #075e69;
  --primary-foreground: #f4ffff;
  --secondary: #dff2ec;
  --muted: #e2f1ec;
  --muted-foreground: #4a706e;
  --border: #cee5df;
  --ring: #075e69;
}

html[data-player-team='girl'] body[data-player-profile-surface='game'] {
  --accent: #f29abd !important;
}

html[data-player-team='boy'] body[data-player-profile-surface='game'] {
  --accent: #80d6d0 !important;
}

html[data-player-team='girl'] body[data-player-game='bunny-bakery'] { background: #fff1f7; }
html[data-player-team='boy'] body[data-player-game='bunny-bakery'] { background: #edf9f8; }
html[data-player-team='girl'] body[data-player-game='hippo-and-friends'] { background: #f9edf3; }
html[data-player-team='boy'] body[data-player-game='hippo-and-friends'] { background: #eaf7f4; }

html[data-player-team='girl'] body[data-player-game='hippo-and-friends'] .primary-button {
  border-color: #ffd0df;
  color: #4b2342;
  background: #f5a6c0;
  box-shadow: 0 5px 0 #9d5577, 0 8px 18px #4a224029;
}

html[data-player-team='boy'] body[data-player-game='hippo-and-friends'] .primary-button {
  border-color: #bceee6;
  color: #173e45;
  background: #86d8cf;
  box-shadow: 0 5px 0 #397f7c, 0 8px 18px #214a4729;
}

html[data-player-team='girl'] body[data-player-game='hippo-and-friends'] :is(.brand-heart, .all-games, .utility-button) {
  color: #6c2d60;
  background: #f8e4ed;
}

html[data-player-team='boy'] body[data-player-game='hippo-and-friends'] :is(.brand-heart, .all-games, .utility-button) {
  color: #075e69;
  background: #dff2ec;
}

body[data-player-game='space-shooter'] .cp-profile-button {
  border-color: var(--cp-player-accent);
  color: #fff;
  background: #272347;
}

body[data-player-game='space-shooter'] .cp-profile-button:hover {
  color: #fff;
  background: #403a6a;
}

html[data-player-team='girl'] body[data-player-game='space-shooter'] #play-button {
  border-color: #ffb5cf;
  color: #3d1633;
  background: #ffb5cf;
}

html[data-player-team='boy'] body[data-player-game='space-shooter'] #play-button {
  border-color: #9ce7df;
  color: #103a40;
  background: #9ce7df;
}

@media (max-width: 600px) {
  .cp-profile-dialog {
    width: min(100% - 1rem, 620px);
    max-height: calc(100dvh - 1rem);
    border-radius: 22px;
    box-shadow: 0 8px 0 #19233d, 0 18px 54px rgba(25, 35, 61, 0.3);
  }

  .cp-profile-form {
    gap: 0.8rem;
    padding: 1rem;
  }

  .cp-team-picker {
    grid-template-columns: 1fr;
  }

  .cp-team-card {
    min-height: 64px;
    align-items: center;
    padding: 0.65rem 0.75rem;
  }

  .cp-profile-actions {
    align-items: stretch;
    flex-direction: column-reverse;
  }

  .cp-profile-actions > span,
  .cp-profile-actions button {
    width: 100%;
  }
}

@media (max-width: 480px) {
  body[data-player-profile-surface='game'] .cp-profile-button,
  body[data-player-profile-surface='resource'] .cp-profile-button {
    width: 44px;
    min-width: 44px;
    min-height: 44px;
    padding: 4px;
  }

  body[data-player-profile-surface='game'] .cp-profile-label,
  body[data-player-profile-surface='resource'] .cp-profile-label {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }

  body[data-player-profile-surface='game'] .cp-profile-avatar,
  body[data-player-profile-surface='resource'] .cp-profile-avatar {
    width: 32px;
    height: 32px;
    flex-basis: 32px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .cp-profile-dialog::backdrop {
    backdrop-filter: none;
  }
}

@media print {
  .cp-profile-slot,
  .cp-profile-dialog {
    display: none !important;
  }
}
