:root {
  --bg: #f4f7f6;
  --bg-elevated: #ffffff;
  --ink: #14221f;
  --ink-soft: #3d524c;
  --muted: #6b7f78;
  --line: #d7e3de;
  --line-strong: #b7c9c2;
  --teal: #0f8b7d;
  --teal-deep: #0a6b60;
  --teal-soft: #d8f3ef;
  --coral: #e86 decou;
  --coral: #e4574d;
  --coral-deep: #c93d34;
  --coral-soft: #ffe3df;
  --gold: #d4a017;
  --gold-soft: #fff2cc;
  --shadow: 0 10px 30px rgba(20, 34, 31, 0.08);
  --shadow-lg: 0 18px 50px rgba(20, 34, 31, 0.12);
  --radius: 18px;
  --radius-sm: 12px;
  --radius-xs: 8px;
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --header-h: 64px;
  --team-0: #0f8b7d;
  --team-1: #e4574d;
  --team-2: #d4a017;
  --team-3: #3b6fd4;
  --team-4: #8b5cf6;
  --team-5: #0ea5e9;
  --team-6: #db2777;
  --team-7: #65a30d;
}

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

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

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  color: var(--ink);
  background:
    linear-gradient(180deg, rgba(244, 247, 246, 0.92), rgba(244, 247, 246, 0.96)),
    url("/api/asset/a437787ee7ad38890baf195d0221d4e8?slot=bg-pattern&j=joisk-asset&w=1600");
  background-size: auto, 256px 256px;
  line-height: 1.5;
}

img {
  max-width: 100%;
  height: auto;
  display: block;
}

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

a {
  color: var(--teal-deep);
  text-decoration-thickness: 1.5px;
  text-underline-offset: 2px;
}

a:hover {
  color: var(--teal);
}

.app-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: var(--header-h);
  padding: 10px 16px;
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--ink);
  font-weight: 800;
  letter-spacing: -0.02em;
  flex-shrink: 0;
}

.brand:hover {
  color: var(--ink);
}

.brand-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--teal-soft);
  padding: 4px;
}

.brand-text {
  font-size: 1.05rem;
}

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

.site-nav {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-left: auto;
}

.nav-link {
  text-decoration: none;
  color: var(--ink-soft);
  font-weight: 600;
  font-size: 0.92rem;
  padding: 8px 12px;
  border-radius: 999px;
}

.nav-link:hover {
  background: var(--teal-soft);
  color: var(--teal-deep);
}

.nav-link.active {
  background: var(--ink);
  color: #fff;
}

.header-user {
  display: none;
}

.user-pill {
  display: inline-flex;
  align-items: center;
  max-width: 160px;
  padding: 6px 10px;
  border-radius: 999px;
  background: var(--gold-soft);
  color: var(--ink);
  font-size: 0.78rem;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.main {
  width: min(1120px, calc(100% - 28px));
  margin: 0 auto;
  padding: 22px 0 48px;
  flex: 1;
}

.hero {
  display: grid;
  gap: 18px;
  margin-bottom: 22px;
}

.hero-copy h1 {
  margin: 0 0 10px;
  font-size: clamp(1.7rem, 4.5vw, 2.55rem);
  line-height: 1.12;
  letter-spacing: -0.03em;
}

.eyebrow {
  display: inline-block;
  margin: 0 0 10px;
  padding: 5px 10px;
  border-radius: 999px;
  background: var(--coral-soft);
  color: var(--coral-deep);
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.lede {
  margin: 0;
  color: var(--ink-soft);
  font-size: 1.02rem;
  max-width: 52ch;
}

.hero-art {
  border-radius: calc(var(--radius) + 4px);
  overflow: hidden;
  box-shadow: var(--shadow);
  border: 1px solid var(--line);
  background: #e8f2ef;
}

.hero-art img {
  width: 100%;
  height: auto;
  object-fit: cover;
  aspect-ratio: 1200 / 480;
}

.workspace {
  display: grid;
  gap: 16px;
  margin-bottom: 36px;
}

.panel {
  background: var(--bg-elevated);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.panel-title-row {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.panel-title-row h2 {
  margin: 0;
  font-size: 1.15rem;
  letter-spacing: -0.02em;
}

.panel-title-row img {
  width: 28px;
  height: 28px;
}

.chip {
  display: inline-flex;
  align-items: center;
  padding: 5px 10px;
  border-radius: 999px;
  background: var(--teal-soft);
  color: var(--teal-deep);
  font-size: 0.78rem;
  font-weight: 750;
}

.field-label {
  display: block;
  margin-bottom: 6px;
  font-size: 0.84rem;
  font-weight: 700;
  color: var(--ink-soft);
}

.muted {
  color: var(--muted);
  font-weight: 500;
}

.names-input,
.text-input {
  width: 100%;
  border: 1.5px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: #fbfcfb;
  padding: 12px 14px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.names-input {
  min-height: 220px;
  resize: vertical;
  font-family: var(--mono);
  font-size: 0.92rem;
  line-height: 1.55;
}

.names-input:focus,
.text-input:focus {
  outline: none;
  border-color: var(--teal);
  background: #fff;
  box-shadow: 0 0 0 4px rgba(15, 139, 125, 0.15);
}

.input-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.controls-grid {
  display: grid;
  gap: 12px;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px dashed var(--line);
}

.control-wide {
  grid-column: 1 / -1;
}

.stepper {
  display: grid;
  grid-template-columns: 44px 1fr 44px;
  gap: 8px;
  align-items: center;
}

.stepper input {
  width: 100%;
  text-align: center;
  border: 1.5px solid var(--line-strong);
  border-radius: var(--radius-sm);
  padding: 10px 8px;
  font-weight: 800;
  font-size: 1.1rem;
  background: #fbfcfb;
}

.stepper input:focus {
  outline: none;
  border-color: var(--teal);
  box-shadow: 0 0 0 4px rgba(15, 139, 125, 0.15);
}

.stepper-btn {
  height: 44px;
  border: 1.5px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: #fff;
  font-size: 1.25rem;
  font-weight: 700;
  cursor: pointer;
  color: var(--ink);
}

.stepper-btn:hover {
  background: var(--teal-soft);
  border-color: var(--teal);
}

.stepper-btn:active {
  transform: translateY(1px);
}

.seed-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
}

.primary-actions {
  display: grid;
  gap: 10px;
  margin-top: 18px;
}

.btn {
  appearance: none;
  border: none;
  border-radius: 999px;
  padding: 10px 16px;
  font-weight: 750;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: transform 0.12s ease, background 0.15s ease, box-shadow 0.15s ease, opacity 0.15s ease;
  text-decoration: none;
  line-height: 1.2;
  user-select: none;
}

.btn:active:not(:disabled) {
  transform: translateY(1px);
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn img {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.btn-primary {
  background: linear-gradient(180deg, #14a394, var(--teal-deep));
  color: #fff;
  box-shadow: 0 8px 18px rgba(10, 107, 96, 0.28);
}

.btn-primary:hover:not(:disabled) {
  background: linear-gradient(180deg, #17b3a2, var(--teal));
}

.btn-secondary {
  background: var(--ink);
  color: #fff;
}

.btn-secondary:hover:not(:disabled) {
  background: #243833;
}

.btn-ghost {
  background: transparent;
  color: var(--ink-soft);
  border: 1.5px solid var(--line-strong);
}

.btn-ghost:hover:not(:disabled) {
  background: #eef5f2;
  color: var(--ink);
}

.btn-lg {
  padding: 14px 18px;
  font-size: 1rem;
  min-height: 52px;
}

.btn-sm {
  padding: 8px 12px;
  font-size: 0.84rem;
}

.btn-block {
  width: 100%;
}

.btn-danger-ghost {
  color: var(--coral-deep);
  border-color: #f0b8b3;
}

.btn-danger-ghost:hover:not(:disabled) {
  background: var(--coral-soft);
  color: var(--coral-deep);
}

.hint {
  margin: 12px 0 0;
  font-size: 0.86rem;
  color: var(--muted);
}

.alert {
  margin-top: 12px;
  padding: 11px 13px;
  border-radius: var(--radius-xs);
  font-size: 0.9rem;
  font-weight: 600;
}

.alert-error {
  background: var(--coral-soft);
  color: var(--coral-deep);
  border: 1px solid #f0b8b3;
}

.alert-success {
  background: var(--teal-soft);
  color: var(--teal-deep);
  border: 1px solid #9ed9d0;
}

.alert-info {
  background: #eaf1ff;
  color: #274a9e;
  border: 1px solid #c5d4f5;
}

.results-panel {
  position: relative;
  min-height: 360px;
  overflow: hidden;
}

.results-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.empty-results {
  display: grid;
  place-items: center;
  text-align: center;
  gap: 8px;
  padding: 28px 12px 18px;
  color: var(--ink-soft);
}

.empty-results img {
  width: min(240px, 70%);
  border-radius: var(--radius-sm);
  margin-bottom: 6px;
}

.empty-results h3 {
  margin: 0;
  color: var(--ink);
  font-size: 1.15rem;
}

.empty-results p {
  margin: 0;
  max-width: 34ch;
  font-size: 0.95rem;
}

.teams-grid {
  display: grid;
  gap: 12px;
}

.team-card {
  border: 1.5px solid var(--line);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: #fbfcfb;
  animation: card-in 0.35s ease both;
}

@keyframes card-in {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.team-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 12px 14px;
  color: #fff;
  background: var(--team-0);
}

.team-card:nth-child(8n + 2) .team-card-head { background: var(--team-1); }
.team-card:nth-child(8n + 3) .team-card-head { background: var(--team-2); color: #1d1600; }
.team-card:nth-child(8n + 4) .team-card-head { background: var(--team-3); }
.team-card:nth-child(8n + 5) .team-card-head { background: var(--team-4); }
.team-card:nth-child(8n + 6) .team-card-head { background: var(--team-5); }
.team-card:nth-child(8n + 7) .team-card-head { background: var(--team-6); }
.team-card:nth-child(8n + 8) .team-card-head { background: var(--team-7); }

.team-name {
  margin: 0;
  font-size: 1rem;
  font-weight: 800;
  letter-spacing: -0.01em;
}

.team-size {
  font-size: 0.78rem;
  font-weight: 750;
  opacity: 0.92;
  background: rgba(255, 255, 255, 0.18);
  padding: 4px 8px;
  border-radius: 999px;
}

.team-card:nth-child(8n + 3) .team-size {
  background: rgba(0, 0, 0, 0.1);
}

.member-list {
  list-style: none;
  margin: 0;
  padding: 6px;
  display: grid;
  gap: 4px;
}

.member-row {
  display: grid;
  grid-template-columns: 28px 1fr auto;
  align-items: center;
  gap: 8px;
  padding: 8px 8px;
  border-radius: 10px;
  background: #fff;
  border: 1px solid transparent;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.member-row.locked {
  background: var(--gold-soft);
  border-color: #efd58a;
}

.member-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--teal-soft);
}

.member-name {
  font-weight: 650;
  font-size: 0.94rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.member-actions {
  display: inline-flex;
  gap: 4px;
}

.icon-btn {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: 1.5px solid var(--line);
  background: #fff;
  display: inline-grid;
  place-items: center;
  cursor: pointer;
  padding: 0;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.12s ease;
}

.icon-btn:hover {
  background: var(--teal-soft);
  border-color: var(--teal);
}

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

.icon-btn img {
  width: 18px;
  height: 18px;
}

.icon-btn[aria-pressed="true"] {
  background: var(--gold-soft);
  border-color: #dfc05a;
}

.move-select {
  height: 36px;
  border-radius: 10px;
  border: 1.5px solid var(--line);
  background: #fff;
  padding: 0 8px;
  font-size: 0.78rem;
  font-weight: 650;
  color: var(--ink-soft);
  max-width: 110px;
}

.move-select:focus {
  outline: none;
  border-color: var(--teal);
}

.balance-bar {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px dashed var(--line);
}

.balance-meta {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 6px 12px;
  margin-bottom: 8px;
  font-size: 0.88rem;
  font-weight: 700;
}

.balance-track {
  height: 10px;
  border-radius: 999px;
  background: #e5eeea;
  overflow: hidden;
}

.balance-fill {
  height: 100%;
  width: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--teal), #45c4a8, var(--gold));
  transition: width 0.35s ease;
}

.copy-toast {
  position: absolute;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  background: var(--ink);
  color: #fff;
  padding: 10px 16px;
  border-radius: 999px;
  font-weight: 750;
  font-size: 0.88rem;
  box-shadow: var(--shadow-lg);
  animation: toast-in 0.25s ease;
  z-index: 5;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translate(-50%, 8px);
  }
  to {
    opacity: 1;
    transform: translate(-50%, 0);
  }
}

.confetti-layer {
  pointer-events: none;
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  opacity: 0;
  transition: opacity 0.25s ease;
  z-index: 4;
}

.confetti-layer.show {
  opacity: 1;
}

.confetti-layer img {
  width: min(280px, 70%);
  mix-blend-mode: multiply;
  animation: confetti-pop 0.9s ease both;
}

@keyframes confetti-pop {
  0% { transform: scale(0.6); opacity: 0; }
  30% { opacity: 1; }
  100% { transform: scale(1.08); opacity: 0; }
}

.how-it-works {
  margin-top: 8px;
}

.how-it-works h2 {
  margin: 0 0 14px;
  font-size: 1.25rem;
  letter-spacing: -0.02em;
}

.steps {
  display: grid;
  gap: 12px;
}

.step-card {
  background: var(--bg-elevated);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
}

.step-num {
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--coral-soft);
  color: var(--coral-deep);
  font-weight: 800;
  font-size: 0.85rem;
  margin-bottom: 8px;
}

.step-card h3 {
  margin: 0 0 6px;
  font-size: 1.02rem;
}

.step-card p {
  margin: 0;
  color: var(--ink-soft);
  font-size: 0.94rem;
}

.site-footer {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  justify-content: space-between;
  align-items: center;
  padding: 18px 16px 28px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.86rem;
  width: min(1120px, calc(100% - 28px));
  margin: 0 auto;
}

.site-footer p {
  margin: 0;
}

/* Account page */
.main-account {
  width: min(880px, calc(100% - 28px));
}

.account-hero {
  text-align: center;
  margin-bottom: 20px;
}

.account-hero-icon {
  width: 48px;
  height: 48px;
  margin: 0 auto 10px;
  padding: 8px;
  border-radius: 14px;
  background: var(--teal-soft);
}

.account-hero h1 {
  margin: 0 0 8px;
  font-size: clamp(1.6rem, 4vw, 2.1rem);
  letter-spacing: -0.03em;
}

.account-hero .lede {
  margin: 0 auto;
}

.account-layout {
  display: grid;
  gap: 16px;
}

.tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  padding: 5px;
  background: #eef4f2;
  border-radius: 999px;
  margin-bottom: 16px;
}

.tab {
  border: none;
  background: transparent;
  border-radius: 999px;
  padding: 10px 12px;
  font-weight: 750;
  color: var(--ink-soft);
  cursor: pointer;
}

.tab.active {
  background: #fff;
  color: var(--ink);
  box-shadow: 0 2px 8px rgba(20, 34, 31, 0.08);
}

.auth-form {
  display: grid;
  gap: 12px;
}

.field {
  display: grid;
}

.account-hint {
  text-align: center;
}

.session-body {
  display: grid;
  gap: 14px;
}

.session-status {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 12px;
  border-radius: var(--radius-sm);
  background: #f3f7f5;
  border: 1px solid var(--line);
}

.session-status strong {
  display: block;
  margin-bottom: 2px;
}

.session-status p {
  margin: 0;
  font-size: 0.9rem;
}

.status-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  margin-top: 5px;
  flex-shrink: 0;
  background: var(--muted);
}

.status-in .status-dot {
  background: var(--teal);
  box-shadow: 0 0 0 4px rgba(15, 139, 125, 0.18);
}

.status-out .status-dot {
  background: #b7c9c2;
}

.session-perks {
  margin: 0;
  padding-left: 1.15rem;
  color: var(--ink-soft);
  font-size: 0.94rem;
}

.session-perks li {
  margin-bottom: 4px;
}

.session-meta {
  margin: 0;
  display: grid;
  gap: 10px;
  padding: 12px;
  border-radius: var(--radius-sm);
  background: #fbfcfb;
  border: 1px solid var(--line);
}

.session-meta div {
  display: grid;
  gap: 2px;
}

.session-meta dt {
  font-size: 0.75rem;
  font-weight: 750;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}

.session-meta dd {
  margin: 0;
  font-family: var(--mono);
  font-size: 0.88rem;
  word-break: break-all;
}

.session-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.btn.loading {
  position: relative;
  pointer-events: none;
}

.btn.loading > span,
.btn.loading > img {
  opacity: 0.35;
}

.shake {
  animation: shake 0.35s ease;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-4px); }
  75% { transform: translateX(4px); }
}

@media (min-width: 640px) {
  .site-header {
    padding: 10px 22px;
  }

  .header-user {
    display: block;
    margin-left: 8px;
  }

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

  .primary-actions {
    grid-template-columns: 1.3fr 1fr;
  }

  .steps {
    grid-template-columns: repeat(3, 1fr);
  }

  .teams-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (min-width: 960px) {
  .hero {
    grid-template-columns: 1.05fr 0.95fr;
    align-items: center;
    gap: 28px;
  }

  .workspace {
    grid-template-columns: 0.95fr 1.05fr;
    align-items: start;
  }

  .account-layout {
    grid-template-columns: 1.05fr 0.95fr;
    align-items: start;
  }

  .teams-grid.teams-3 {
    grid-template-columns: repeat(3, 1fr);
  }

  .teams-grid.teams-4plus {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 380px) {
  .brand-text {
    font-size: 0.95rem;
  }

  .nav-link {
    padding: 8px 10px;
    font-size: 0.85rem;
  }
}

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