:root {
  color-scheme: light;
  --ink: #322f35;
  --muted: #77717c;
  --paper: #fffafc;
  --panel: rgba(255,255,255,.82);
  --line: #e9e1e6;
  --shadow: 0 20px 55px rgba(72, 56, 67, .13);
  --blue: #dbeeff;
  --pink: #f9dbe8;
  --green: #dff3e7;
  --danger: #f7dfe3;
  font-family: Inter, ui-rounded, "SF Pro Rounded", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--paper);
  color: var(--ink);
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--paper); }
body {
  min-height: 100dvh;
  background:
    radial-gradient(circle at 10% 0%, rgba(248, 218, 232, .65), transparent 31rem),
    radial-gradient(circle at 90% 15%, rgba(219, 238, 255, .72), transparent 30rem),
    #fffafc;
}
button, input { font: inherit; }
button { color: inherit; }
a { color: inherit; }

.app-shell {
  width: min(100%, 580px);
  margin: 0 auto;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: max(16px, env(safe-area-inset-top)) 18px max(22px, env(safe-area-inset-bottom));
}

.home-shell { justify-content: center; gap: 22px; }
.brand { text-align: center; margin-bottom: 4px; }
.brand-mark {
  width: 62px; height: 62px; margin: 0 auto 12px; border-radius: 22px;
  display: grid; place-items: center; font-size: 31px;
  background: linear-gradient(135deg, var(--pink), var(--blue));
  box-shadow: 0 12px 32px rgba(70, 62, 75, .12);
}
h1, h2, p { margin-top: 0; }
h1 { font-size: clamp(2rem, 8vw, 3.1rem); line-height: 1; letter-spacing: -.045em; margin-bottom: 10px; }
.brand p, .muted { color: var(--muted); }

.panel {
  background: var(--panel);
  border: 1px solid rgba(255,255,255,.9);
  backdrop-filter: blur(16px);
  border-radius: 24px;
  padding: 18px;
  box-shadow: var(--shadow);
}
.panel h2 { font-size: 1.05rem; margin-bottom: 12px; }
.stack { display: grid; gap: 11px; }
.row { display: flex; gap: 10px; align-items: center; }
.row > .grow { flex: 1; min-width: 0; }

.primary, .secondary, .ghost, .icon-text {
  border: 0; border-radius: 15px; padding: 13px 16px; cursor: pointer;
  transition: transform .12s ease, filter .12s ease, opacity .12s ease;
  font-weight: 700;
}
.primary { background: #3e3a42; color: white; }
.secondary { background: #efe9ee; }
.ghost { background: transparent; border: 1px solid var(--line); }
.primary:hover, .secondary:hover, .ghost:hover, .icon-text:hover { filter: brightness(.985); }
.primary:active, .secondary:active, .ghost:active, .icon-text:active { transform: scale(.98); }
button:disabled { opacity: .5; cursor: default; }

.join-input, .code-box {
  width: 100%; border: 1px solid var(--line); background: white; color: var(--ink);
  border-radius: 15px; padding: 13px 14px; outline: none;
}
.join-input:focus, .code-box:focus { border-color: #b8afba; box-shadow: 0 0 0 3px rgba(188,177,190,.15); }

.created { border: 1px solid #ded5dc; background: rgba(255,255,255,.7); border-radius: 18px; padding: 14px; }
.created strong { display: block; margin-bottom: 8px; }
.code-box { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .8rem; }

.topbar {
  display: flex; align-items: center; gap: 10px; min-height: 48px; margin-bottom: 10px;
}
.topbar .brand-mini { font-weight: 850; letter-spacing: -.03em; margin-right: auto; text-decoration: none; }
.nav-link { text-decoration: none; padding: 8px 10px; border-radius: 12px; color: var(--muted); font-weight: 700; font-size: .9rem; }
.nav-link.active { background: rgba(255,255,255,.78); color: var(--ink); box-shadow: 0 4px 14px rgba(67,55,64,.07); }

.session-strip {
  display: flex; align-items: center; gap: 8px; margin-bottom: 8px; color: var(--muted); font-size: .78rem;
}
.pill { padding: 6px 9px; border-radius: 999px; background: rgba(255,255,255,.7); border: 1px solid var(--line); }
.role-pill { text-transform: capitalize; font-weight: 800; color: var(--ink); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: #b8b1b8; display: inline-block; margin-right: 5px; }
.dot.online { background: #79ad8c; }

.picker-main {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 4px 0 8px;
}
.card-stage {
  position: relative;
  width: min(96vw, 519px);
  height: min(74dvh, 692px);
  min-height: min(519px, 64dvh);
  max-height: 758px;
  margin: 0 auto;
  perspective: 900px;
}
.name-card {
  position: absolute; inset: 0;
  border-radius: 31px;
  padding: 28px 24px 24px;
  box-shadow: 0 27px 60px rgba(66, 51, 62, .16), inset 0 0 0 1px rgba(255,255,255,.7);
  display: flex; flex-direction: column; justify-content: center; align-items: center;
  text-align: center;
  user-select: none; -webkit-user-select: none; touch-action: none;
  transform-origin: 50% 100%;
  will-change: transform;
  overflow: hidden;
}
.name-card::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(to bottom, rgba(255,255,255,.26), transparent 25%, rgba(255,255,255,.1));
}
.name-card.male { background: var(--blue); }
.name-card.female { background: var(--pink); }
.name-card.unisex { background: linear-gradient(135deg, #f8d8e8 0%, #f8dce9 38%, #d9edff 100%); }
.name-card.behind { transform: translateY(11px) scale(.965); opacity: .54; filter: saturate(.82); pointer-events: none; }
.name-card.dragging { cursor: grabbing; }

.card-name { position: relative; z-index: 2; font-size: clamp(1.675rem, 8.04vw, 2.982rem); line-height: .98; font-weight: 900; letter-spacing: -.055em; overflow-wrap: anywhere; }
.card-cyrillic { position: relative; z-index: 2; margin-top: 13px; font-size: clamp(.771rem, 3.35vw, 1.072rem); font-weight: 650; opacity: .68; }
.origin-row { position: relative; z-index: 2; display: flex; flex-wrap: wrap; justify-content: center; gap: 7px; margin-top: 22px; }
.origin-chip { background: rgba(255,255,255,.5); border: 1px solid rgba(255,255,255,.74); padding: 6px 10px; border-radius: 999px; font-size: .77rem; font-weight: 800; }
.gender-label { position: absolute; z-index: 2; left: 22px; top: 20px; text-transform: uppercase; letter-spacing: .13em; font-size: .67rem; font-weight: 900; opacity: .5; }
.swipe-hint { position: absolute; z-index: 3; top: 58px; border: 4px solid currentColor; border-radius: 12px; padding: 7px 10px; font-weight: 1000; font-size: 1.5rem; letter-spacing: .05em; opacity: 0; }
.swipe-hint.like { right: 20px; color: #4a8b66; transform: rotate(10deg); }
.swipe-hint.nope { left: 20px; color: #b65f6d; transform: rotate(-10deg); }

.progress-line { width: min(96vw,519px); margin: 12px auto 0; color: var(--muted); font-size: .78rem; display: flex; justify-content: space-between; }
.progress-track { width: min(96vw,519px); margin: 7px auto 0; height: 5px; background: rgba(86,71,82,.08); border-radius: 999px; overflow: hidden; }
.progress-fill { height: 100%; background: #9e949e; border-radius: inherit; transition: width .2s ease; }

.actions { display: flex; justify-content: center; align-items: center; gap: 21px; padding: 10px 0 2px; }
.circle-button {
  width: 68px; height: 68px; border: 0; border-radius: 50%; display: grid; place-items: center;
  font-size: 30px; font-weight: 300; cursor: pointer; box-shadow: 0 10px 24px rgba(67,54,65,.11);
  transition: transform .14s ease, filter .14s ease;
}
.circle-button:active { transform: scale(.92); }
.circle-button.reject { background: var(--danger); color: #a95261; }
.circle-button.accept { background: var(--green); color: #478260; }
.circle-button.undo { width: 50px; height: 50px; font-size: 23px; background: #eee9ed; color: #716a73; }

.empty-card { background: white; }
.empty-icon { font-size: 3.5rem; margin-bottom: 12px; }
.empty-card h2 { font-size: 1.7rem; margin-bottom: 8px; }

.history-head { display: flex; align-items: end; gap: 12px; margin: 10px 0 14px; }
.history-head > div:first-child { flex: 1; }
.history-head h1 { font-size: 2rem; margin-bottom: 3px; }
.history-head p { margin: 0; font-size: .88rem; }
.history-controls { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.toggle {
  display: inline-flex; align-items: center; gap: 8px; padding: 10px 12px; background: rgba(255,255,255,.75);
  border: 1px solid var(--line); border-radius: 13px; font-size: .85rem; font-weight: 750;
}
.toggle input { accent-color: #6c6570; }
.small-btn { padding: 10px 12px; font-size: .82rem; border-radius: 13px; }

.table-wrap { overflow: auto; border-radius: 18px; border: 1px solid var(--line); background: rgba(255,255,255,.78); box-shadow: 0 12px 32px rgba(70,58,68,.06); }
table { border-collapse: collapse; width: 100%; min-width: 390px; font-size: .86rem; }
th, td { padding: 11px 12px; border-bottom: 1px solid #eee8ec; text-align: left; }
th { position: sticky; top: 0; z-index: 2; background: #fffafd; color: var(--muted); font-size: .74rem; text-transform: uppercase; letter-spacing: .08em; }
th:nth-child(2), th:nth-child(3), td:nth-child(2), td:nth-child(3) { width: 82px; text-align: center; }
tr:last-child td { border-bottom: 0; }
.name-cell strong { display: block; }
.name-cell small { display: block; color: var(--muted); margin-top: 2px; }
.status { font-weight: 950; font-size: 1.08rem; }
.status.like { color: #4d916a; }
.status.dislike { color: #b45e6b; }
.status.pending { color: #aaa2aa; }
.match-row { background: rgba(224, 246, 231, .38); }

.error-page, .loading-page { min-height: 70dvh; display: grid; place-items: center; text-align: center; }
.error-box { max-width: 360px; background: rgba(255,255,255,.8); padding: 24px; border-radius: 24px; box-shadow: var(--shadow); }
.error-box .emoji { font-size: 3rem; }
.spinner { width: 32px; height: 32px; border: 3px solid #e6dfe4; border-top-color: #736b74; border-radius: 50%; animation: spin .7s linear infinite; margin: auto; }
@keyframes spin { to { transform: rotate(360deg); } }

.toast {
  position: fixed; left: 50%; bottom: calc(18px + env(safe-area-inset-bottom)); transform: translate(-50%, 15px);
  background: #38343a; color: white; border-radius: 999px; padding: 10px 15px; font-size: .85rem; font-weight: 700;
  opacity: 0; pointer-events: none; transition: .2s ease; z-index: 1000; max-width: calc(100vw - 30px); text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

.data-credit { text-align: center; color: #928b93; font-size: .68rem; line-height: 1.55; margin-top: 18px; }
.data-credit a { text-underline-offset: 2px; }

@media (max-height: 700px) {
  .app-shell { padding-top: 9px; padding-bottom: 8px; }
  .card-stage { height: 68dvh; min-height: min(452px, 58dvh); }
  .circle-button { width: 59px; height: 59px; }
  .circle-button.undo { width: 45px; height: 45px; }
  .actions { padding-top: 5px; }
}

@media (min-width: 760px) {
  .history-shell { width: min(100%, 900px); }
}
