:root {
  color-scheme: dark;
  --bg: #05050b;
  --card: rgba(18, 14, 31, 0.82);
  --card-strong: rgba(27, 21, 47, 0.95);
  --line: rgba(255, 255, 255, 0.14);
  --text: #fff7ff;
  --muted: #c8bad6;
  --pink: #ff2abf;
  --cyan: #19d9ff;
  --amber: #ffbd25;
  --danger: #ff637d;
  --success: #6cffc7;
  --radius: 22px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background:
    radial-gradient(circle at 15% 25%, rgba(255, 42, 191, 0.28), transparent 30%),
    radial-gradient(circle at 85% 20%, rgba(25, 217, 255, 0.20), transparent 28%),
    radial-gradient(circle at 50% 100%, rgba(255, 189, 37, 0.16), transparent 28%),
    var(--bg);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image: linear-gradient(rgba(255,255,255,0.03) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,0.03) 1px, transparent 1px);
  background-size: 52px 52px;
  mask-image: radial-gradient(circle at center, black, transparent 82%);
}

button, input, textarea {
  font: inherit;
}

button {
  border: 0;
  border-radius: 999px;
  padding: 0.88rem 1.1rem;
  cursor: pointer;
  color: var(--text);
  transition: transform 0.15s ease, filter 0.15s ease, border-color 0.15s ease;
}

button:hover { transform: translateY(-1px); filter: brightness(1.1); }
button:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

input, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 0.9rem 1rem;
  color: var(--text);
  background: rgba(255, 255, 255, 0.06);
  outline: none;
}

textarea { resize: vertical; }
input:focus, textarea:focus { border-color: rgba(25, 217, 255, 0.7); box-shadow: 0 0 0 4px rgba(25, 217, 255, 0.11); }

label { display: grid; gap: 0.45rem; color: var(--muted); font-size: 0.95rem; }

.shell {
  width: min(1180px, calc(100% - 28px));
  margin: 0 auto;
  padding: 24px 0 42px;
}

.hero {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 22px;
  align-items: center;
  margin-bottom: 22px;
}

.logo {
  width: 140px;
  height: 140px;
  object-fit: contain;
  filter: drop-shadow(0 0 24px rgba(255, 42, 191, 0.4));
}

h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 0.5rem; font-size: clamp(2rem, 6vw, 4.6rem); line-height: 0.98; letter-spacing: -0.06em; }
h2 { margin-bottom: 0.7rem; letter-spacing: -0.03em; }

.eyebrow {
  margin-bottom: 0.35rem;
  color: var(--amber);
  text-transform: uppercase;
  letter-spacing: 0.28em;
  font-size: 0.72rem;
  font-weight: 800;
}

.muted { color: var(--muted); }
.error { color: var(--danger); min-height: 1.2em; }
.success { color: var(--success); min-height: 1.2em; }
.hidden { display: none !important; }

.card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.03)), var(--card);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.36), inset 0 0 0 1px rgba(255,255,255,0.03);
  backdrop-filter: blur(14px);
  padding: clamp(18px, 3vw, 28px);
}

.login-card { width: min(520px, 100%); margin: 0 auto; }
.grid { display: grid; grid-template-columns: 360px minmax(0, 1fr); gap: 20px; }
.grid.profile-closed { grid-template-columns: minmax(0, 1fr); }
.profile-card { align-self: start; }
.profile-actions { flex-wrap: wrap; justify-content: flex-end; }
.profile-actions .ghost { padding: 0.58rem 0.78rem; }
.stack { display: grid; gap: 1rem; }
.row { display: flex; gap: 0.7rem; align-items: center; }
.between { justify-content: space-between; }

.primary {
  background: linear-gradient(135deg, var(--pink), var(--cyan));
  box-shadow: 0 0 24px rgba(255, 42, 191, 0.25);
  font-weight: 800;
}
.secondary {
  background: rgba(25, 217, 255, 0.13);
  border: 1px solid rgba(25, 217, 255, 0.35);
}
.ghost {
  padding: 0.65rem 0.9rem;
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--line);
}
.danger {
  background: rgba(255, 99, 125, 0.14);
  border: 1px solid rgba(255, 99, 125, 0.4);
}

.checkline {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  color: var(--text);
}
.checkline input { width: auto; transform: scale(1.2); }

.status-panel {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: start;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
}
.timer {
  min-width: 112px;
  padding: 0.7rem 1rem;
  border-radius: 999px;
  text-align: center;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid rgba(255, 42, 191, 0.35);
  color: var(--cyan);
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 0 14px rgba(25, 217, 255, 0.5);
}

.partner-panel, .waiting-panel {
  margin: 18px 0;
  padding: 18px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.18);
}

.partner-name {
  font-size: clamp(1.5rem, 3vw, 2.3rem);
  margin: 0.1rem 0;
  color: var(--text);
}

.pill-row { display: flex; gap: 0.6rem; flex-wrap: wrap; margin-top: 0.9rem; }
.pill {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 0.75rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.06);
  color: var(--muted);
}

.icebreaker {
  margin-top: 1rem;
  padding: 1rem;
  border-radius: 16px;
  color: var(--text);
  background: linear-gradient(135deg, rgba(255, 189, 37, 0.16), rgba(255, 42, 191, 0.10));
  border: 1px solid rgba(255, 189, 37, 0.35);
}

.mutfrage {
  margin-top: 1rem;
  padding: 1rem;
  border-radius: 16px;
  color: var(--text);
  background: linear-gradient(135deg, rgba(255, 42, 191, 0.22), rgba(25, 217, 255, 0.12));
  border: 1px solid rgba(255, 42, 191, 0.42);
  box-shadow: 0 0 24px rgba(255, 42, 191, 0.14);
}

.chat-levels {
  margin-top: 1rem;
  padding: 1rem;
  border-radius: 16px;
  color: var(--text);
  background: rgba(25, 217, 255, 0.10);
  border: 1px solid rgba(25, 217, 255, 0.34);
}

.emoji-only-box {
  margin-top: 1rem;
  padding: 1rem;
  border-radius: 16px;
  color: var(--text);
  background: linear-gradient(135deg, rgba(255, 189, 37, 0.20), rgba(25, 217, 255, 0.13));
  border: 1px solid rgba(255, 189, 37, 0.42);
}

.challenge-box {
  margin-top: 1rem;
  padding: 1rem;
  border-radius: 16px;
  color: var(--text);
  background: linear-gradient(135deg, rgba(25, 217, 255, 0.18), rgba(255, 189, 37, 0.14));
  border: 1px solid rgba(25, 217, 255, 0.42);
  box-shadow: 0 0 22px rgba(25, 217, 255, 0.12);
}

.chat-level {
  display: grid;
  gap: 0.28rem;
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--line);
}

.chat-level span {
  color: var(--amber);
  font-size: 0.76rem;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.12em;
}

.chat-panel { display: grid; gap: 14px; }
.chat-heading {
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}
.chat-heading h2 { margin-bottom: 0; }
.chat-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.chat-subline { margin: 0.25rem 0 0; }
.mini-timer {
  display: none;
  flex: 0 0 auto;
  padding: 0.42rem 0.66rem;
  border-radius: 999px;
  color: var(--cyan);
  background: rgba(0, 0, 0, 0.26);
  border: 1px solid rgba(25, 217, 255, 0.36);
  font-size: 0.86rem;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
}
.messages {
  min-height: 340px;
  max-height: 54vh;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 6px 2px;
}

.message {
  max-width: min(78%, 620px);
  padding: 0.8rem 0.95rem;
  border-radius: 18px;
  background: rgba(255,255,255,0.08);
  border: 1px solid var(--line);
}
.message.mine {
  margin-left: auto;
  background: linear-gradient(135deg, rgba(255, 42, 191, 0.22), rgba(25, 217, 255, 0.15));
}
.system-message {
  max-width: min(92%, 680px);
  margin: 0.4rem auto;
  text-align: center;
  background: linear-gradient(135deg, rgba(255, 189, 37, 0.18), rgba(255, 42, 191, 0.16));
  border-color: rgba(255, 189, 37, 0.38);
}
.level-message {
  background: linear-gradient(135deg, rgba(25, 217, 255, 0.16), rgba(255, 42, 191, 0.14));
  border-color: rgba(25, 217, 255, 0.36);
}
.challenge-message {
  background: linear-gradient(135deg, rgba(25, 217, 255, 0.18), rgba(255, 189, 37, 0.16));
  border-color: rgba(25, 217, 255, 0.42);
}
.chat-card.is-emoji-only .chat-heading {
  border-bottom-color: rgba(255, 189, 37, 0.48);
}
.chat-card.is-emoji-only .chat-form input {
  border-color: rgba(255, 189, 37, 0.5);
}
.message-meta {
  margin-bottom: 0.35rem;
  color: var(--muted);
  font-size: 0.78rem;
}
.message-text { white-space: pre-wrap; overflow-wrap: anywhere; }
.chat-composer { display: grid; gap: 6px; }
.chat-form { display: grid; grid-template-columns: 1fr auto; gap: 10px; }
.chat-instructions {
  margin: 0;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.35;
}
.chat-card.is-emoji-only .chat-instructions {
  color: var(--amber);
  font-weight: 800;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  max-width: min(420px, calc(100vw - 36px));
  padding: 1rem 1.1rem;
  border-radius: 18px;
  background: var(--card-strong);
  border: 1px solid rgba(25, 217, 255, 0.35);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.42);
}

.profile-toggle {
  position: fixed;
  left: 18px;
  bottom: 18px;
  z-index: 10;
  padding: 0.58rem 0.9rem;
  background: rgba(25, 217, 255, 0.16);
  border: 1px solid rgba(25, 217, 255, 0.42);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.34);
}

@media (max-width: 860px) {
  .hero { grid-template-columns: 94px 1fr; }
  .logo { width: 94px; height: 94px; }
  .grid { grid-template-columns: 1fr; }
  .profile-card { order: 2; }
  .chat-card { order: 1; }
  .status-panel { align-items: center; }
}

@media (max-width: 560px) {
  body { min-height: 100dvh; }
  body.app-active .hero { display: none; }
  .shell {
    width: 100%;
    min-height: 100dvh;
    padding: 10px 10px calc(82px + env(safe-area-inset-bottom));
  }
  .hero {
    grid-template-columns: 76px 1fr;
    gap: 12px;
    text-align: left;
    margin-bottom: 14px;
  }
  .logo {
    width: 76px;
    height: 76px;
    margin: 0;
  }
  h1 {
    font-size: 2rem;
    line-height: 1;
  }
  h2 { letter-spacing: 0; }
  .card {
    border-radius: 16px;
    padding: 14px;
  }
  .grid { gap: 10px; }
  .chat-card {
    display: flex;
    flex-direction: column;
    min-height: calc(100dvh - 20px);
    padding: 0;
    overflow: hidden;
  }
  .chat-panel { order: 1; }
  .partner-panel { order: 2; }
  .waiting-panel { order: 2; }
  .status-panel { order: 3; }
  .chat-card.is-paired .status-panel { display: none; }
  .chat-card.is-paired .chat-panel {
    display: flex;
    flex: 1;
    flex-direction: column;
    min-height: 66dvh;
    gap: 0;
  }
  .chat-heading {
    position: sticky;
    top: 0;
    z-index: 2;
    padding: 14px 14px 12px;
    background: linear-gradient(180deg, rgba(18, 14, 31, 0.98), rgba(18, 14, 31, 0.9));
    backdrop-filter: blur(12px);
  }
  .chat-heading .eyebrow { margin-bottom: 0.18rem; }
  .chat-heading h2 {
    max-width: 100%;
    overflow-wrap: anywhere;
    font-size: 1.58rem;
  }
  .chat-subline {
    font-size: 0.88rem;
    line-height: 1.25;
  }
  .mini-timer { display: inline-flex; }
  .messages {
    flex: 1;
    min-height: 0;
    max-height: none;
    padding: 12px 10px;
    gap: 8px;
    overscroll-behavior: contain;
  }
  .message {
    max-width: 86%;
    padding: 0.68rem 0.78rem;
    border-radius: 16px;
  }
  .message-meta {
    margin-bottom: 0.28rem;
    font-size: 0.72rem;
  }
  .chat-composer {
    position: sticky;
    bottom: 0;
    z-index: 3;
    padding: 10px;
    background: rgba(18, 14, 31, 0.96);
    border-top: 1px solid var(--line);
    padding-bottom: max(10px, env(safe-area-inset-bottom));
  }
  .chat-form {
    grid-template-columns: 1fr auto;
    gap: 8px;
  }
  .chat-instructions {
    padding: 0 4px;
    font-size: 0.78rem;
  }
  .chat-form input {
    min-height: 48px;
    border-radius: 999px;
    padding: 0.72rem 0.92rem;
  }
  .chat-form button {
    min-width: 78px;
    min-height: 48px;
    padding: 0.72rem 0.9rem;
  }
  .partner-panel, .waiting-panel {
    margin: 10px;
    padding: 13px;
    border-radius: 14px;
  }
  .partner-panel .eyebrow { margin-bottom: 0.18rem; }
  .partner-name {
    font-size: 1.45rem;
    line-height: 1.08;
    overflow-wrap: anywhere;
  }
  .icebreaker,
  .mutfrage,
  .emoji-only-box,
  .challenge-box,
  .chat-levels {
    margin-top: 0.72rem;
    padding: 0.78rem;
    border-radius: 13px;
  }
  .pill-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }
  .pill-row button { padding: 0.72rem 0.6rem; }
  .status-panel {
    flex-direction: row;
    align-items: center;
    padding: 13px;
    gap: 10px;
  }
  .status-panel h2 {
    margin-bottom: 0;
    font-size: 1.16rem;
  }
  .status-panel .eyebrow { margin-bottom: 0.12rem; }
  .timer {
    width: auto;
    min-width: 82px;
    padding: 0.52rem 0.68rem;
  }
  .profile-card {
    margin: 0 0 10px;
  }
  .profile-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    width: 100%;
  }
  .profile-actions .ghost { width: 100%; }
  .profile-toggle {
    left: 12px;
    bottom: max(72px, calc(66px + env(safe-area-inset-bottom)));
    min-height: 44px;
  }
  .toast {
    right: 10px;
    bottom: max(66px, calc(54px + env(safe-area-inset-bottom)));
    max-width: calc(100vw - 20px);
  }
}
