@font-face {
  font-family: "Fredoka";
  src: url("/fonts/fredoka-latin.woff2") format("woff2");
  font-weight: 300 700;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Nunito";
  src: url("/fonts/nunito-latin.woff2") format("woff2");
  font-weight: 200 1000;
  font-style: normal;
  font-display: swap;
}

/* Diseño plano: sin sombras ni degradados. Las superficies se distinguen por
   bloques de color y bordes de un mismo grosor. Tema claro: blanco con rojo. */
:root {
  color-scheme: light;
  --bg: #ffffff;
  --surface: #fdeceb;
  --surface-strong: #fbdcd9;
  --field: #ffffff;
  --dialog: #ffffff;
  --dialog-block: #fdeceb;
  --ink: #2a1215;
  --muted: #7a5c5f;
  --line: #efc4c0;
  --accent: #d92d32;
  --accent-hover: #bf2227;
  --accent-ink: #ffffff;
  --accent-soft: #fbdcd9;
  --accent-text: #b81f25;
  --danger: #7a1016;
  --danger-hover: #5f0b10;
  --danger-ink: #ffffff;
  --danger-text: #a3161c;
  --gold-soft: #ffe9b8;
  --gold-ink: #6e4500;
  --online: #1fa968;
  --toast: #2a1215;
  --toast-ink: #fff5f4;

  --border: 2px;
  --radius-card: 22px;
  --radius-control: 14px;
  --spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --display: "Fredoka", ui-rounded, "Arial Rounded MT Bold", system-ui, sans-serif;
  --font: "Nunito", ui-rounded, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Consolas, "Liberation Mono", monospace;
  --team: #6f7d8c;
}

/* Tema oscuro: mismo esquema sobre un fondo casi negro de matiz rojizo. El
   rojo se aclara para conservar contraste. */
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #170d0f;
  --surface: #261518;
  --surface-strong: #341c20;
  --field: #1c1012;
  --dialog: #261518;
  --dialog-block: #341c20;
  --ink: #fdeeee;
  --muted: #c9a9ac;
  --line: #4d2c31;
  --accent: #ff6b6e;
  --accent-hover: #ff8588;
  --accent-ink: #2b070a;
  --accent-soft: #4b1b20;
  --accent-text: #ff9193;
  --danger: #5c1a20;
  --danger-hover: #73222a;
  --danger-ink: #ffdada;
  --danger-text: #ff9d9f;
  --gold-soft: #4a3610;
  --gold-ink: #ffd98a;
  --online: #3ddc97;
  --toast: #fdeeee;
  --toast-ink: #2a1215;
}

[data-color="0"] { --team: #e5484d; }
[data-color="1"] { --team: #f76b15; }
[data-color="2"] { --team: #d99a00; }
[data-color="3"] { --team: #46a758; }
[data-color="4"] { --team: #12a594; }
[data-color="5"] { --team: #00a2c7; }
[data-color="6"] { --team: #3e63dd; }
[data-color="7"] { --team: #6e56cf; }
[data-color="8"] { --team: #ab4aba; }
[data-color="9"] { --team: #d6409f; }
[data-color="10"] { --team: #978365; }
[data-color="11"] { --team: #6f7d8c; }

*,
*::before,
*::after {
  box-sizing: border-box;
}

/* Las reglas de display de los componentes anularían el atributo hidden. */
[hidden] {
  display: none !important;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100dvh;
  font-family: var(--font);
  font-size: 16px;
  font-weight: 600;
  line-height: 1.45;
  color: var(--ink);
  background-color: var(--bg);
  -webkit-font-smoothing: antialiased;
}

h1,
h2,
h3,
p,
ul,
fieldset {
  margin: 0;
  padding: 0;
}

h1,
h2,
h3 {
  font-family: var(--display);
  font-weight: 600;
  line-height: 1.12;
}

ul {
  list-style: none;
}

fieldset {
  border: 0;
  min-width: 0;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

button {
  -webkit-tap-highlight-color: transparent;
}

:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--accent) 60%, transparent);
  outline-offset: 3px;
}

.icon {
  width: 1.15em;
  height: 1.15em;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.icon .solid {
  fill: currentColor;
  stroke: none;
}

.muted {
  color: var(--muted);
}

.eyebrow {
  font-family: var(--display);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--accent-text);
}

.noscript {
  padding: 24px;
  text-align: center;
}

/* Estructura general */

.page {
  max-width: 1140px;
  margin: 0 auto;
  padding: 16px 16px 72px;
  padding-left: max(16px, env(safe-area-inset-left));
  padding-right: max(16px, env(safe-area-inset-right));
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 22px;
  animation: page-in 0.45s var(--ease-out) both;
}

.page.narrow {
  max-width: 540px;
}

.page.intro > * {
  animation: rise 0.6s var(--ease-out) both;
}

.page.intro > :nth-child(2) { animation-delay: 0.05s; }
.page.intro > :nth-child(3) { animation-delay: 0.12s; }
.page.intro > :nth-child(4) { animation-delay: 0.19s; }
.page.intro > :nth-child(5) { animation-delay: 0.26s; }
.page.intro > :nth-child(6) { animation-delay: 0.33s; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 48px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.brand {
  flex: none;
  font-family: var(--display);
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--ink);
  text-decoration: none;
  border-radius: 8px;
}

.brand-accent {
  color: var(--accent);
}

/* Botones y campos */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  max-width: 100%;
  min-height: 46px;
  padding: 0 20px;
  border: var(--border) solid var(--line);
  border-radius: var(--radius-control);
  background: var(--field);
  color: var(--ink);
  font-family: var(--display);
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease, transform 0.2s var(--spring);
}

.btn:active {
  transform: scale(0.96);
}

.btn:disabled {
  opacity: 0.6;
  cursor: progress;
  transform: none;
}

.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}

.btn.danger {
  background: var(--danger);
  border-color: var(--danger);
  color: var(--danger-ink);
}

.btn.small {
  min-height: 40px;
  padding: 0 15px;
  font-size: 0.93rem;
  border-radius: 12px;
}

.btn.block {
  width: 100%;
}

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 44px;
  height: 44px;
  flex: none;
  border: var(--border) solid var(--line);
  border-radius: var(--radius-control);
  background: var(--field);
  color: var(--ink);
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease, transform 0.2s var(--spring);
}

.icon-btn:active {
  transform: scale(0.92);
}

.icon-btn.small {
  width: 34px;
  height: 34px;
  border-radius: 10px;
}

.icon.spin {
  animation: spin-in 0.5s var(--spring) both;
}

.form {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 16px;
}

.field {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 7px;
  min-width: 0;
}

.field-label {
  font-family: var(--display);
  font-size: 0.95rem;
  font-weight: 600;
}

.field-hint {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted);
}

.field-pair {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(auto-fit, minmax(min(170px, 100%), 1fr));
  align-items: start;
}

.input {
  width: 100%;
  min-width: 0;
  min-height: 50px;
  padding: 11px 15px;
  border: var(--border) solid var(--line);
  border-radius: var(--radius-control);
  background: var(--field);
  font-size: 1rem;
  font-weight: 700;
  transition: border-color 0.15s ease;
}

.input::placeholder {
  color: var(--muted);
  font-weight: 600;
  opacity: 0.75;
}

.input:focus {
  border-color: var(--accent);
  outline: none;
}

.input:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--accent) 35%, transparent);
  outline-offset: 0;
}

.input:disabled {
  opacity: 0.5;
}

textarea.input {
  resize: vertical;
  line-height: 1.4;
}

select.input {
  appearance: none;
  padding-right: 44px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23c4575c' stroke-width='3.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  background-size: 18px;
  cursor: pointer;
}

.code-input {
  min-height: 66px;
  font-family: var(--mono);
  font-size: clamp(1.3rem, 6vw, 1.7rem);
  font-weight: 800;
  letter-spacing: 0.24em;
  text-align: center;
  text-transform: uppercase;
}

.code-input::placeholder {
  opacity: 0.35;
}

.form-error {
  padding: 10px 14px;
  border-radius: 12px;
  background: var(--accent-soft);
  color: var(--accent-text);
  font-size: 0.92rem;
  font-weight: 700;
  animation: shake 0.4s ease both;
}

.check {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  cursor: pointer;
}

.check input {
  appearance: none;
  display: grid;
  place-content: center;
  width: 26px;
  height: 26px;
  margin: 0;
  flex: none;
  border: var(--border) solid var(--line);
  border-radius: 8px;
  background: var(--field);
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease, transform 0.2s var(--spring);
}

.check input[type="radio"] {
  border-radius: 50%;
}

.check input::after {
  content: "";
  width: 14px;
  height: 14px;
  background: var(--accent-ink);
  clip-path: polygon(12% 50%, 0 64%, 38% 100%, 100% 24%, 86% 10%, 37% 70%);
  transform: scale(0);
  transition: transform 0.25s var(--spring);
}

.check input[type="radio"]::after {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  clip-path: none;
}

.check input:checked {
  background: var(--accent);
  border-color: var(--accent);
}

.check input:checked::after {
  transform: scale(1);
}

.check input:active {
  transform: scale(0.9);
}

.check-text {
  display: grid;
  gap: 2px;
  min-width: 0;
  padding-top: 2px;
  font-weight: 700;
}

.options {
  border: var(--border) solid var(--line);
  border-radius: 16px;
}

.options summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 13px 15px;
  border-radius: 14px;
  font-family: var(--display);
  font-weight: 600;
  cursor: pointer;
  list-style: none;
}

.options summary::-webkit-details-marker {
  display: none;
}

.options summary::after {
  content: "";
  width: 9px;
  height: 9px;
  margin-right: 4px;
  border-right: 3px solid var(--accent-text);
  border-bottom: 3px solid var(--accent-text);
  border-radius: 2px;
  rotate: 45deg;
  transition: rotate 0.3s var(--spring);
}

.options[open] summary::after {
  rotate: 225deg;
}

.options > .form {
  padding: 2px 15px 15px;
  animation: rise 0.3s var(--ease-out) both;
}

/* Inicio */

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 16px;
  padding: clamp(10px, 3vw, 34px) 0 8px;
}

.hero-copy {
  display: grid;
  gap: 16px;
  min-width: 0;
}

.hero h1 {
  font-size: clamp(2.3rem, 8vw, 4.5rem);
  font-weight: 700;
  line-height: 1.04;
  letter-spacing: -0.02em;
  text-wrap: balance;
}

/* La palabra destacada es un bloque rojo sólido ligeramente girado. */
.hl {
  display: inline-block;
  padding: 0 0.22em 0.04em;
  border-radius: 0.22em;
  background: var(--accent);
  color: var(--accent-ink);
  rotate: -2deg;
  animation: stamp 0.6s var(--spring) 0.2s both;
}

.hero p {
  max-width: 54ch;
  font-size: clamp(1.02rem, 2.6vw, 1.18rem);
  color: var(--muted);
}

.home-grid {
  display: grid;
  gap: 22px;
  grid-template-columns: repeat(auto-fit, minmax(min(320px, 100%), 1fr));
  align-items: start;
}

.card {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 14px;
  min-width: 0;
  padding: clamp(20px, 4vw, 28px);
  border-radius: var(--radius-card);
  background: var(--surface);
}

.card h2 {
  font-size: 1.45rem;
}

.recent {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 12px;
}

.recent h2,
.section-head h2 {
  font-size: 1.25rem;
}

.recent-list {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fill, minmax(min(270px, 100%), 1fr));
}

.recent-item {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  padding: 5px 7px 5px 5px;
  border: var(--border) solid var(--line);
  border-radius: 16px;
  background: var(--field);
  transition: border-color 0.15s ease;
}

.recent-open {
  flex: 1;
  min-width: 0;
  display: grid;
  gap: 2px;
  padding: 8px 11px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  text-align: left;
  cursor: pointer;
}

.recent-open strong,
.recent-open span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.recent-open strong {
  font-family: var(--display);
  font-weight: 600;
}

.recent-open span {
  font-size: 0.86rem;
}

.recent-item .icon-btn {
  width: 36px;
  height: 36px;
  border-color: transparent;
  background: transparent;
  color: var(--muted);
}

.features {
  display: grid;
  gap: 22px;
  grid-template-columns: repeat(auto-fit, minmax(min(215px, 100%), 1fr));
  padding-top: 6px;
}

.feature {
  display: grid;
  gap: 8px;
  align-content: start;
  min-width: 0;
}

.feature h3 {
  font-size: 1.1rem;
}

.feature p {
  font-size: 0.93rem;
}

.feature-icon {
  display: inline-grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border-radius: 12px;
  background: var(--accent);
  color: var(--accent-ink);
  transition: rotate 0.35s var(--spring), scale 0.35s var(--spring);
}

.foot {
  padding-top: 18px;
  border-top: var(--border) solid var(--line);
  font-size: 0.88rem;
}

.join-card {
  margin-top: clamp(8px, 4vw, 28px);
}

.join-title {
  font-size: clamp(1.7rem, 7vw, 2.4rem);
  font-weight: 700;
  overflow-wrap: anywhere;
}

.loading {
  display: grid;
  justify-items: center;
  gap: 16px;
  padding: 72px 0;
  text-align: center;
}

.loader {
  display: inline-flex;
  gap: 9px;
}

.loader i {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent);
  animation: hop 0.9s ease-in-out infinite;
}

.loader i:nth-child(2) { animation-delay: 0.12s; }
.loader i:nth-child(3) { animation-delay: 0.24s; }

/* Sala */

.me-btn {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
  max-width: min(230px, 46vw);
  height: 44px;
  padding: 0 14px 0 5px;
  border: var(--border) solid var(--line);
  border-radius: 999px;
  background: var(--field);
  font-family: var(--display);
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.15s ease, transform 0.2s var(--spring);
}

.me-btn:active {
  transform: scale(0.96);
}

.me-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.avatar {
  display: inline-grid;
  place-items: center;
  width: 30px;
  height: 30px;
  flex: none;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 0.9rem;
  font-weight: 700;
}

.room-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  min-width: 0;
}

.room-title {
  display: grid;
  gap: 4px;
  min-width: 0;
  flex: 1 1 260px;
}

.room-title h1 {
  font-size: clamp(1.9rem, 6vw, 3.1rem);
  font-weight: 700;
  letter-spacing: -0.015em;
  overflow-wrap: anywhere;
}

.room-share {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.code-chip {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 46px;
  padding: 0 14px;
  border: var(--border) dashed var(--line);
  border-radius: var(--radius-control);
  background: var(--field);
  color: var(--muted);
  cursor: pointer;
  transition: border-color 0.15s ease, color 0.15s ease, transform 0.2s var(--spring);
}

.code-chip strong {
  font-family: var(--mono);
  font-size: 1.12rem;
  font-weight: 800;
  letter-spacing: 0.17em;
  color: var(--ink);
}

.code-chip-label {
  font-family: var(--display);
  font-size: 0.74rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.code-chip:active {
  transform: scale(0.96);
}

.notice {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  padding: 12px 16px;
  border-radius: 14px;
  background: var(--surface);
  font-size: 0.95rem;
  font-weight: 700;
  animation: rise 0.35s var(--ease-out) both;
}

.notice .icon {
  color: var(--accent-text);
}

.notice.warn {
  background: var(--gold-soft);
  color: var(--gold-ink);
  animation: breathe 1.4s ease-in-out infinite;
}

.mine {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  min-width: 0;
  padding: 18px 20px;
  border-left: 8px solid var(--line);
  border-radius: var(--radius-card);
  background: var(--surface);
}

.mine.has-team {
  border-left-color: var(--team);
}

.mine.wants {
  border-left-color: var(--accent);
}

.mine-text {
  display: grid;
  gap: 2px;
  min-width: 0;
  flex: 1 1 220px;
}

.mine-text strong {
  font-family: var(--display);
  font-size: 1.4rem;
  font-weight: 600;
  line-height: 1.15;
  overflow-wrap: anywhere;
}

.mine-text .muted {
  font-size: 0.92rem;
}

.mine.wants .btn .icon {
  animation: wiggle 1.5s ease-in-out infinite;
  transform-origin: 30% 90%;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  min-width: 0;
}

.board {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 22px;
  align-items: start;
}

.pool,
.teams {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 14px;
  min-width: 0;
}

.pool {
  padding: 18px;
  border-radius: var(--radius-card);
  background: var(--surface);
}

.section-head {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  min-width: 0;
}

.count {
  padding: 1px 11px;
  border-radius: 999px;
  background: var(--surface-strong);
  font-family: var(--display);
  font-size: 0.86rem;
  font-weight: 600;
  color: var(--muted);
}

.sub-head {
  margin-top: 6px;
  font-size: 0.78rem;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--muted);
}

.people {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-width: 0;
}

.people li {
  max-width: 100%;
  min-width: 0;
}

.people.column {
  flex-direction: column;
  flex-wrap: nowrap;
  gap: 2px;
}

/* El nombre y las etiquetas van en grupos separados: cuando no caben en una
   línea, las etiquetas bajan completas en lugar de salirse de la tarjeta. */
.member {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 8px;
  max-width: 100%;
  min-height: 40px;
  padding: 5px 12px;
  border: var(--border) solid var(--line);
  border-radius: 12px;
  background: var(--field);
  text-align: left;
  transition: border-color 0.15s ease, background-color 0.15s ease, transform 0.2s var(--spring);
}

.member-main {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  max-width: 100%;
}

.member-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 800;
}

.member-tags {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 4px;
  min-width: 0;
}

.people.column .member {
  display: flex;
  width: 100%;
  padding: 5px 9px;
  border-color: transparent;
  background: transparent;
}

.member.action {
  cursor: pointer;
}

.member.action:active {
  transform: scale(0.97);
}

.member[draggable="true"] {
  cursor: grab;
}

.dot {
  width: 10px;
  height: 10px;
  flex: none;
  border: 2px solid color-mix(in srgb, var(--muted) 65%, transparent);
  border-radius: 50%;
}

.dot.on {
  border-color: var(--online);
  background: var(--online);
}

.dot.manual {
  border-radius: 3px;
}

.tag {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  flex: none;
  padding: 2px 9px;
  border-radius: 999px;
  background: var(--surface-strong);
  font-family: var(--display);
  font-size: 0.74rem;
  font-weight: 600;
  color: var(--muted);
  white-space: nowrap;
}

.tag .icon {
  width: 0.95em;
  height: 0.95em;
}

.tag.you {
  background: var(--ink);
  color: var(--bg);
}

.tag.leader {
  background: var(--gold-soft);
  color: var(--gold-ink);
}

.tag.admin {
  background: var(--accent-soft);
  color: var(--accent-text);
}

.tag.wants {
  background: var(--accent);
  color: var(--accent-ink);
}

.empty {
  color: var(--muted);
  font-size: 0.92rem;
}

.empty-block {
  display: grid;
  justify-items: center;
  gap: 4px;
  padding: 40px 20px;
  border: var(--border) dashed var(--line);
  border-radius: var(--radius-card);
  text-align: center;
}

.empty-block .icon {
  width: 54px;
  height: 54px;
  margin-bottom: 10px;
  padding: 13px;
  border-radius: 14px;
  background: var(--accent);
  color: var(--accent-ink);
}

.empty-block p:first-of-type {
  font-family: var(--display);
  font-size: 1.15rem;
}

.team-grid {
  display: grid;
  gap: 18px;
  grid-template-columns: repeat(auto-fill, minmax(min(240px, 100%), 1fr));
  align-items: start;
}

/* La franja superior lleva el color del equipo. El borde lateral existe
   siempre, transparente, para que marcar el equipo propio no mueva nada. */
.team {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 10px;
  min-width: 0;
  padding: 13px;
  border: 3px solid transparent;
  border-top: 8px solid var(--team);
  border-radius: 20px;
  background: var(--surface);
  transition: scale 0.25s var(--spring);
}

.team.is-mine {
  border-color: var(--team);
  background: color-mix(in srgb, var(--team) 12%, var(--surface));
}

.team-head {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
  min-height: 34px;
}

.team-head h3 {
  flex: 1;
  min-width: 0;
  font-size: 1.15rem;
  overflow-wrap: anywhere;
}

.team-count {
  flex: none;
  padding: 1px 11px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--team) 22%, var(--surface));
  font-family: var(--display);
  font-size: 0.86rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.team-count.full {
  background: var(--team);
  color: #ffffff;
}

.team .icon-btn {
  border-color: transparent;
  background: transparent;
}

.btn.join {
  width: 100%;
  border-style: dashed;
  background: transparent;
  color: var(--accent-text);
}

.drop-target {
  outline: 3px dashed var(--accent);
  outline-offset: 3px;
  scale: 1.02;
}

.pop {
  animation: pop 0.45s var(--spring) both;
}

.bump {
  animation: bump 0.45s var(--spring) both;
}

/* Diálogos */

.dialog {
  width: min(470px, calc(100vw - 24px));
  max-width: none;
  max-height: calc(100dvh - 24px);
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--ink);
  overflow: visible;
}

.dialog.wide {
  width: min(600px, calc(100vw - 24px));
}

.dialog::backdrop {
  background: rgb(30 10 12 / 0.6);
  animation: fade-in 0.2s ease both;
}

.dialog-panel {
  display: flex;
  flex-direction: column;
  max-height: calc(100dvh - 24px);
  border-radius: var(--radius-card);
  background: var(--dialog);
  overflow: hidden;
  animation: dialog-in 0.4s var(--spring) both;
}

.dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 16px 12px 24px;
}

.dialog-head h2 {
  min-width: 0;
  font-size: 1.35rem;
  overflow-wrap: anywhere;
}

.dialog-head .icon-btn {
  width: 38px;
  height: 38px;
  border-color: transparent;
  background: var(--dialog-block);
  color: var(--muted);
}

.dialog-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 18px;
  padding: 6px 24px 24px;
  overflow-y: auto;
}

.dialog-text {
  color: var(--muted);
  font-size: 0.97rem;
}

.dialog-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
  padding-top: 4px;
}

.menu {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 4px;
  margin: 0 -10px;
}

.menu-item {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  min-height: 54px;
  padding: 8px 10px;
  border: 0;
  border-radius: 14px;
  background: transparent;
  text-align: left;
  font-family: var(--display);
  font-size: 1.02rem;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 0.15s ease, transform 0.2s var(--spring);
}

.menu-item > .icon {
  width: 40px;
  height: 40px;
  padding: 10px;
  border-radius: 12px;
  background: var(--accent-soft);
  color: var(--accent-text);
  transition: rotate 0.3s var(--spring);
}

.menu-item:active {
  transform: scale(0.98);
}

.menu-item.danger {
  color: var(--danger-text);
}

.menu-item.danger > .icon {
  background: var(--danger);
  color: var(--danger-ink);
}

.menu-item-text {
  display: grid;
  gap: 1px;
  min-width: 0;
}

.menu-item-text .field-hint {
  font-family: var(--font);
}

.member-head {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.member-head strong {
  font-family: var(--display);
  font-size: 1.5rem;
  font-weight: 600;
  line-height: 1.15;
  overflow-wrap: anywhere;
}

.member-head .muted {
  font-size: 0.92rem;
}

.invite-code {
  padding: 12px 0 12px 0.2em;
  border-radius: 16px;
  background: var(--accent);
  color: var(--accent-ink);
  font-family: var(--mono);
  font-size: clamp(1.9rem, 11vw, 2.9rem);
  font-weight: 800;
  letter-spacing: 0.2em;
  text-align: center;
  user-select: all;
}

.invite-qr {
  display: grid;
  place-items: center;
}

/* El QR conserva fondo blanco en ambos temas para que las cámaras lo lean. */
.qr {
  width: min(210px, 58vw);
  height: auto;
  padding: 8px;
  border: var(--border) solid var(--line);
  border-radius: 16px;
  background: #ffffff;
  image-rendering: pixelated;
}

.input-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.input-row .input,
.input-row .key {
  flex: 1 1 190px;
  min-width: 0;
}

.key {
  padding: 11px 15px;
  border: var(--border) dashed var(--line);
  border-radius: var(--radius-control);
  background: var(--field);
  font-family: var(--mono);
  font-weight: 800;
  letter-spacing: 0.06em;
  overflow-wrap: anywhere;
  user-select: all;
}

.panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 12px;
  justify-items: start;
  padding: 18px;
  border-radius: 16px;
  background: var(--dialog-block);
}

.panel h3 {
  font-size: 1.08rem;
}

.panel .input-row {
  width: 100%;
}

.radio-group {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 12px;
}

.radio-group legend {
  padding: 0 0 10px;
  font-family: var(--display);
  font-size: 1rem;
  font-weight: 600;
}

.radio {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 10px;
}

.radio-extra {
  padding-left: 38px;
  max-width: 280px;
  animation: rise 0.3s var(--ease-out) both;
}

/* Avisos emergentes */

.toasts {
  position: fixed;
  left: 50%;
  bottom: max(18px, env(safe-area-inset-bottom));
  translate: -50% 0;
  z-index: 2147483647;
  display: grid;
  gap: 10px;
  justify-items: center;
  width: min(460px, calc(100vw - 24px));
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: 100%;
  padding: 12px 18px;
  border-radius: 999px;
  background: var(--toast);
  color: var(--toast-ink);
  font-family: var(--display);
  font-size: 0.97rem;
  font-weight: 500;
  animation: toast-in 0.45s var(--spring) both;
  transition: opacity 0.3s ease, translate 0.3s ease;
}

.toast::before {
  content: "";
  width: 12px;
  height: 12px;
  flex: none;
  border-radius: 50%;
  background: var(--muted);
}

.toast.success::before {
  background: #2ecc85;
}

.toast.error::before {
  background: #ff5a5f;
}

.toast.error {
  animation: toast-in 0.45s var(--spring) both, shake 0.45s ease 0.3s;
}

.toast.leaving {
  opacity: 0;
  translate: 0 10px;
}

/* Festejo: círculos de color que salen disparados desde el centro. */

.confetti {
  position: fixed;
  left: 50%;
  top: 42%;
  z-index: 2147483646;
  pointer-events: none;
}

.confetti i {
  position: absolute;
  width: var(--s, 12px);
  height: var(--s, 12px);
  border-radius: 50%;
  background: var(--c, var(--accent));
  animation: burst 1.15s cubic-bezier(0.16, 0.8, 0.3, 1) both;
}

/* Animaciones */

@keyframes page-in {
  from {
    opacity: 0;
  }
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
}

@keyframes stamp {
  from {
    opacity: 0;
    scale: 1.5;
    rotate: 6deg;
  }
}

@keyframes pop {
  from {
    opacity: 0;
    transform: scale(0.6);
  }
}

@keyframes bump {
  40% {
    transform: scale(1.3);
  }
}

@keyframes dialog-in {
  from {
    opacity: 0;
    transform: translateY(22px) scale(0.94);
  }
}

@keyframes fade-in {
  from {
    opacity: 0;
  }
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(22px) scale(0.85);
  }
}

@keyframes shake {
  20% { transform: translateX(-6px); }
  40% { transform: translateX(5px); }
  60% { transform: translateX(-3px); }
  80% { transform: translateX(2px); }
}

@keyframes spin-in {
  from {
    opacity: 0;
    transform: rotate(-120deg) scale(0.4);
  }
}

@keyframes hop {
  0%,
  60%,
  100% {
    transform: translateY(0);
  }
  30% {
    transform: translateY(-12px);
  }
}

@keyframes wiggle {
  0%,
  60%,
  100% {
    rotate: 0deg;
  }
  15% {
    rotate: -14deg;
  }
  30% {
    rotate: 12deg;
  }
  45% {
    rotate: -6deg;
  }
}

@keyframes breathe {
  50% {
    opacity: 0.6;
  }
}

@keyframes burst {
  from {
    transform: translate(0, 0) scale(0.3);
    opacity: 1;
  }
  75% {
    opacity: 1;
  }
  to {
    transform: translate(var(--dx), var(--dy)) scale(1);
    opacity: 0;
  }
}

/* Los efectos al pasar el cursor se limitan a dispositivos con puntero real:
   en pantallas táctiles quedarían pegados después de tocar. */
@media (hover: hover) {
  .btn:hover:not(:disabled),
  .icon-btn:hover,
  .me-btn:hover,
  .recent-item:hover,
  .code-chip:hover,
  .member.action:hover {
    border-color: var(--accent);
  }

  .btn:hover:not(:disabled),
  .code-chip:hover {
    color: var(--accent-text);
  }

  .btn.primary:hover:not(:disabled) {
    background: var(--accent-hover);
    border-color: var(--accent-hover);
    color: var(--accent-ink);
  }

  .btn.danger:hover:not(:disabled) {
    background: var(--danger-hover);
    border-color: var(--danger-hover);
    color: var(--danger-ink);
  }

  .btn.join:hover {
    background: var(--accent-soft);
  }

  .feature:hover .feature-icon {
    rotate: -8deg;
    scale: 1.08;
  }

  .recent-open:hover strong {
    color: var(--accent-text);
  }

  .people.column .member.action:hover {
    border-color: transparent;
    background: var(--surface-strong);
  }

  .team .icon-btn:hover,
  .recent-item .icon-btn:hover {
    border-color: transparent;
    background: var(--surface-strong);
  }

  .dialog-head .icon-btn:hover {
    border-color: transparent;
    color: var(--ink);
  }

  .menu-item:hover {
    background: var(--dialog-block);
  }

  .menu-item:hover > .icon {
    rotate: -8deg;
  }
}

@media (min-width: 760px) {
  .page {
    padding-top: 22px;
    gap: 26px;
  }
}

@media (min-width: 900px) {
  .board {
    grid-template-columns: minmax(250px, 310px) minmax(0, 1fr);
  }

  .pool {
    position: sticky;
    top: 16px;
    max-height: calc(100dvh - 32px);
    overflow-y: auto;
  }
}

@media (max-width: 520px) {
  .toolbar .btn {
    flex: 1 1 auto;
  }

  .dialog-actions .btn {
    flex: 1 1 auto;
  }

  .dialog-head {
    padding-left: 18px;
  }

  .dialog-body {
    padding: 6px 18px 20px;
  }

  .room-share .btn {
    flex: 1 1 auto;
  }
}

/* En pantallas muy angostas el nombre no cabe junto a la marca: queda solo la
   inicial, que sigue abriendo el mismo menú. */
@media (max-width: 420px) {
  .me-name {
    display: none;
  }

  .me-btn {
    padding: 0 5px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}
