* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --bg-primary: #1a1a2e;
  --bg-secondary: #16213e;
  --bg-message-sent: #0f3460;
  --bg-message-received: rgba(37, 37, 71, 0.8);
  --text-primary: #e8e8e8;
  --text-secondary: #a0a0b8;
  --accent: #7c5cbf;
  --input-bg: rgba(37, 37, 71, 0.9);
  --border: #333360;
  --danger: #e74c3c;
  --char-color: var(--accent);
  --sheet-bg: rgba(15, 15, 30, 0.88);
}

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }

/* ======================== */
/* Access Gate              */
/* ======================== */

#access-gate {
  position: fixed; inset: 0;
  background: var(--bg-primary);
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.4s ease;
}

#access-gate.fade-out { opacity: 0; pointer-events: none; }

.access-content {
  text-align: center;
  padding: 24px;
  width: 100%;
  max-width: 320px;
}

.access-logo {
  font-size: 42px;
  font-weight: 800;
  background: linear-gradient(135deg, var(--accent), #9b6dd7);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 8px;
}

.access-subtitle {
  font-size: 16px;
  color: var(--text-secondary);
  margin-bottom: 28px;
}

.access-input {
  width: 100%;
  background: rgba(37, 37, 71, 0.6);
  border: 1.5px solid var(--border);
  border-radius: 14px;
  padding: 14px 18px;
  color: var(--text-primary);
  font-size: 18px;
  font-family: inherit;
  text-align: center;
  letter-spacing: 1px;
  outline: none;
  transition: border-color 0.2s;
}

.access-input:focus { border-color: var(--accent); }
.access-input::placeholder { color: var(--text-secondary); }

.access-submit {
  width: 100%;
  margin-top: 16px;
  padding: 14px;
  border: none;
  border-radius: 14px;
  background: var(--accent);
  color: white;
  font-size: 16px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: opacity 0.2s, transform 0.1s;
}

.access-submit:active { transform: scale(0.97); }

.access-error {
  color: var(--danger);
  font-size: 14px;
  margin-top: 16px;
}

@keyframes accessShake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-12px); }
  40% { transform: translateX(10px); }
  60% { transform: translateX(-6px); }
  80% { transform: translateX(4px); }
}

.access-shake { animation: accessShake 0.4s ease; }

/* ======================== */
/* Video Call Chat Layout   */
/* ======================== */

#app {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  max-width: 600px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* --- Avatar area (fixed height, never shrinks) --- */

#avatar-area {
  position: relative;
  height: 250px;
  min-height: 200px;
  flex-shrink: 0;
  overflow: hidden;
  background: linear-gradient(135deg, #2d1b4e, #1a1a2e, #0f1a3e);
}

#avatar-bg {
  width: 100%;
  height: 100%;
  object-fit: cover;
  animation: subtleZoom 30s ease-in-out infinite alternate;
}

#avatar-bg.avatar-fallback {
  display: flex;
  align-items: center;
  justify-content: center;
}

#avatar-letter {
  font-size: 72px;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.15);
  text-shadow: 0 0 40px rgba(124, 92, 191, 0.3);
}

@keyframes subtleZoom {
  from { transform: scale(1); }
  to { transform: scale(1.05); }
}

/* Vignette fade at bottom */
#avatar-area::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 50%;
  background: linear-gradient(transparent, rgba(15, 15, 30, 0.7));
  pointer-events: none;
}

/* Overlay controls */
#avatar-overlay-top {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 12px;
  padding-top: max(12px, env(safe-area-inset-top));
  z-index: 5;
}

.overlay-btn {
  background: rgba(0, 0, 0, 0.3);
  border: none;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  backdrop-filter: blur(8px);
  transition: background 0.2s;
}

.overlay-btn:active { background: rgba(0, 0, 0, 0.5); transform: scale(0.92); }

#session-nudge {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  color: rgba(255, 255, 255, 0.6);
  background: rgba(0, 0, 0, 0.3);
  padding: 4px 10px;
  border-radius: 12px;
  backdrop-filter: blur(8px);
}

#session-nudge svg { width: 14px; height: 14px; }

#avatar-overlay-bottom {
  position: absolute;
  bottom: 24px;
  left: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
  z-index: 5;
}

#avatar-overlay-bottom h1 {
  font-size: 22px;
  font-weight: 700;
  color: white;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
}

#status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #4ade80;
  flex-shrink: 0;
}

#status-text {
  font-size: 13px;
  color: rgba(255, 255, 255, 0.7);
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.5);
}

#avatar-subtitle-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

#user-nickname-badge {
  color: rgba(255, 255, 255, 0.5);
  font-size: 13px;
  font-style: italic;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.5);
  margin-left: 4px;
}

/* --- Chat sheet (bottom, overlapping avatar) --- */

#chat-sheet {
  flex: 1;
  min-height: 0;
  margin-top: -18px;
  background: var(--sheet-bg);
  border-radius: 20px 20px 0 0;
  display: flex;
  flex-direction: column;
  z-index: 10;
  position: relative;
  backdrop-filter: blur(12px);
}

#offline-banner {
  background: rgba(231, 76, 60, 0.85);
  color: white;
  text-align: center;
  padding: 6px;
  font-size: 13px;
  flex-shrink: 0;
  border-radius: 20px 20px 0 0;
}

#messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 14px 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

.message {
  max-width: 82%;
  padding: 10px 14px;
  border-radius: 20px;
  font-size: 15px;
  line-height: 1.45;
  word-wrap: break-word;
  overflow-wrap: break-word;
  animation: messageIn 0.25s ease-out;
}

@keyframes messageIn {
  from { opacity: 0; transform: translateY(6px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.message-sent {
  align-self: flex-end;
  background: var(--bg-message-sent);
  border-bottom-right-radius: 6px;
}

.message-received {
  align-self: flex-start;
  background: var(--bg-message-received);
  border-bottom-left-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.04);
}

.message-time {
  font-size: 11px;
  color: var(--text-secondary);
  opacity: 0;
  max-height: 0;
  overflow: hidden;
  transition: opacity 0.2s, max-height 0.2s;
}

.message.show-time .message-time,
.message-time.always-visible {
  opacity: 0.6;
  max-height: 20px;
  padding-top: 4px;
}

.message-error { opacity: 0.65; font-style: italic; }

/* Typing indicator */
#typing-indicator { align-self: flex-start; padding: 0 0 4px; }

.typing-bubble {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: var(--bg-message-received);
  padding: 12px 18px;
  border-radius: 20px;
  border-bottom-left-radius: 6px;
  animation: messageIn 0.2s ease-out;
}

.typing-bubble span {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--text-secondary);
  animation: typingBounce 1.4s infinite ease-in-out;
}

.typing-bubble span:nth-child(2) { animation-delay: 0.16s; }
.typing-bubble span:nth-child(3) { animation-delay: 0.32s; }

@keyframes typingBounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.35; }
  30% { transform: translateY(-5px); opacity: 1; }
}

/* Input area */
#input-area {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 8px 12px;
  padding-bottom: max(8px, env(safe-area-inset-bottom));
  flex-shrink: 0;
}

#message-input {
  flex: 1;
  background: var(--input-bg);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 22px;
  padding: 10px 16px;
  color: var(--text-primary);
  font-size: 15px;
  font-family: inherit;
  resize: none;
  max-height: 100px;
  outline: none;
  transition: border-color 0.2s;
  line-height: 1.4;
}

#message-input:focus { border-color: var(--accent); }
#message-input::placeholder { color: var(--text-secondary); }

#send-btn {
  width: 40px; height: 40px;
  border-radius: 50%;
  border: none;
  background: var(--accent);
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: opacity 0.2s, transform 0.1s;
  -webkit-tap-highlight-color: transparent;
}

#send-btn:disabled { opacity: 0.35; cursor: default; }
#send-btn:not(:disabled):active { transform: scale(0.9); }

/* Scrollbar */
#messages::-webkit-scrollbar { width: 3px; }
#messages::-webkit-scrollbar-track { background: transparent; }
#messages::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 2px; }

/* Short viewport */
@media (max-height: 550px) {
  #avatar-area { height: 180px; min-height: 150px; }
}

/* ======================== */
/* Character Creation       */
/* ======================== */

#create-overlay {
  position: fixed; inset: 0;
  background: var(--bg-primary);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.3s ease;
}

#create-overlay.active { opacity: 1; }

.create-container {
  width: 100%; max-width: 600px;
  height: 100vh; height: 100dvh;
  display: flex; flex-direction: column;
  padding: 16px 24px;
  padding-bottom: max(16px, env(safe-area-inset-bottom));
}

.create-progress {
  display: flex; justify-content: center;
  gap: 6px; padding: 12px 0 20px;
}

.dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--border);
  transition: background 0.3s, transform 0.3s;
}

.dot.active { background: var(--accent); transform: scale(1.4); }
.dot.done { background: var(--accent); opacity: 0.5; }

.create-header {
  display: flex; align-items: center;
  gap: 12px; margin-bottom: 24px; min-height: 40px;
}

.create-back {
  background: none; border: none;
  color: var(--text-secondary); cursor: pointer;
  padding: 8px; border-radius: 8px;
  transition: background 0.2s; flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
}

.create-back:hover { background: rgba(255, 255, 255, 0.08); }

.create-title { font-size: 22px; font-weight: 700; }

.create-body {
  flex: 1; overflow-y: auto;
  display: flex; flex-direction: column; gap: 20px;
}

.create-question {
  font-size: 16px; color: var(--text-secondary); line-height: 1.5;
}

.create-section-label {
  font-size: 13px; color: var(--text-secondary);
  text-transform: uppercase; letter-spacing: 0.5px;
  margin-top: 8px;
}

/* Slide transitions */
.slide-out-left  { animation: slideOutL 0.2s ease forwards; }
.slide-out-right { animation: slideOutR 0.2s ease forwards; }
.slide-in-left   { animation: slideInL 0.25s ease forwards; }
.slide-in-right  { animation: slideInR 0.25s ease forwards; }

@keyframes slideOutL  { to { opacity: 0; transform: translateX(-40px); } }
@keyframes slideOutR { to { opacity: 0; transform: translateX(40px); } }
@keyframes slideInL   { from { opacity: 0; transform: translateX(40px); } to { opacity: 1; transform: translateX(0); } }
@keyframes slideInR  { from { opacity: 0; transform: translateX(-40px); } to { opacity: 1; transform: translateX(0); } }

/* Option cards */
.card-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 12px;
}

.option-card {
  background: rgba(37, 37, 71, 0.6);
  border: 2px solid transparent;
  border-radius: 16px;
  padding: 20px 16px;
  color: var(--text-primary);
  font-size: 16px; font-family: inherit; font-weight: 500;
  cursor: pointer; text-align: center;
  transition: border-color 0.15s, transform 0.1s, background 0.15s;
  -webkit-tap-highlight-color: transparent;
}

.option-card:active { transform: scale(0.95); border-color: var(--accent); }
.option-card.selected { border-color: var(--accent); background: rgba(124, 92, 191, 0.2); }

.vibe-card {
  display: flex; flex-direction: column;
  align-items: center; gap: 8px; padding: 24px 16px;
}

.vibe-emoji { font-size: 32px; }

/* Chips */
.chip-grid { display: flex; flex-wrap: wrap; gap: 10px; }

.chip {
  background: rgba(37, 37, 71, 0.6);
  border: 1.5px solid var(--border);
  border-radius: 20px;
  padding: 8px 16px;
  color: var(--text-primary);
  font-size: 14px; font-family: inherit;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, transform 0.1s;
  -webkit-tap-highlight-color: transparent;
}

.chip:active { transform: scale(0.94); }
.chip.selected { background: rgba(124, 92, 191, 0.25); border-color: var(--accent); color: white; }

/* Swatches */
.swatch-grid { display: flex; flex-wrap: wrap; gap: 14px 10px; padding-bottom: 8px; }

.swatch {
  width: 56px; height: 56px;
  border-radius: 14px;
  border: 3px solid transparent;
  cursor: pointer;
  transition: border-color 0.15s, transform 0.1s;
  position: relative;
  -webkit-tap-highlight-color: transparent;
}

.swatch:active { transform: scale(0.92); }
.swatch.selected { border-color: var(--accent); }

.swatch-label {
  position: absolute; bottom: -18px; left: 50%;
  transform: translateX(-50%);
  font-size: 10px; color: var(--text-secondary);
  white-space: nowrap; pointer-events: none;
}

/* Inputs */
.create-input {
  background: rgba(37, 37, 71, 0.6);
  border: 1.5px solid var(--border);
  border-radius: 14px;
  padding: 14px 18px;
  color: var(--text-primary);
  font-size: 15px; font-family: inherit;
  outline: none; width: 100%;
  transition: border-color 0.2s;
}

.create-input:focus { border-color: var(--accent); }
.create-input::placeholder { color: var(--text-secondary); }
.create-input-small { margin-top: 4px; }

.create-textarea { min-height: 120px; resize: none; line-height: 1.5; }
.create-hint { font-size: 13px; color: var(--text-secondary); }

/* Buttons */
.create-footer { padding-top: 16px; flex-shrink: 0; }

.create-next-btn {
  width: 100%; padding: 16px;
  border: none; border-radius: 14px;
  background: var(--accent); color: white;
  font-size: 16px; font-weight: 600; font-family: inherit;
  cursor: pointer;
  transition: opacity 0.2s, transform 0.1s;
  -webkit-tap-highlight-color: transparent;
}

.create-next-btn:disabled { opacity: 0.35; cursor: default; }
.create-next-btn:not(:disabled):active { transform: scale(0.97); }
.create-finish-btn { background: linear-gradient(135deg, var(--accent), #9b6dd7); }

.skip-btn {
  background: none; border: none;
  color: var(--text-secondary); font-size: 14px;
  font-family: inherit; cursor: pointer;
  padding: 12px; width: 100%; text-align: center;
  -webkit-tap-highlight-color: transparent;
}

.creating-animation {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 20px;
}

.creating-animation p { font-size: 18px; color: var(--text-secondary); }

.creating-spinner {
  width: 48px; height: 48px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* Name grid & reveal */
.name-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.name-card {
  background: rgba(37, 37, 71, 0.6);
  border: 2px solid transparent;
  border-radius: 14px; padding: 14px;
  color: var(--text-primary);
  font-size: 17px; font-weight: 600;
  font-family: inherit; text-align: center;
  cursor: pointer;
  transition: border-color 0.15s, transform 0.1s;
  -webkit-tap-highlight-color: transparent;
}

.name-card:active { transform: scale(0.95); }
.name-card.selected { border-color: var(--accent); background: rgba(124, 92, 191, 0.2); }

.more-names-btn {
  background: none;
  border: 1.5px solid var(--border);
  border-radius: 12px; padding: 10px 20px;
  color: var(--accent); font-size: 14px;
  font-family: inherit; font-weight: 500;
  cursor: pointer; align-self: center;
  -webkit-tap-highlight-color: transparent;
}

.reveal-avatar-wrap {
  display: flex; flex-direction: column;
  align-items: center; gap: 10px;
  position: relative;
}

.reveal-avatar {
  width: 180px; height: 180px;
  border-radius: 24px; object-fit: cover;
  border: 3px solid var(--accent);
  box-shadow: 0 0 30px rgba(124, 92, 191, 0.3);
}

.reveal-avatar-fallback {
  background: linear-gradient(135deg, var(--accent), #1a1a2e);
  display: flex; align-items: center; justify-content: center;
  font-size: 56px; font-weight: 700; color: white;
}

.reveal-live-badge {
  background: #e74c3c;
  color: white;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 1px;
  padding: 3px 10px;
  border-radius: 6px;
  margin-top: -6px;
}

.reveal-tag {
  font-size: 28px;
  font-weight: 800;
  text-align: center;
  background: linear-gradient(135deg, var(--accent), #9b6dd7);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.reveal-subtitle {
  font-size: 14px;
  color: var(--text-secondary);
  text-align: center;
}


/* ======================== */
/* Character Selection      */
/* ======================== */

#select-overlay {
  position: fixed; inset: 0;
  background: var(--bg-primary);
  z-index: 90;
  display: flex; align-items: flex-start; justify-content: center;
  opacity: 0; transition: opacity 0.3s ease;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

#select-overlay.active { opacity: 1; }

.select-container {
  width: 100%; max-width: 600px;
  min-height: 100vh; min-height: 100dvh;
  padding: 24px; padding-bottom: max(24px, env(safe-area-inset-bottom));
  display: flex; flex-direction: column; gap: 16px;
}

.select-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 0 8px;
}

.select-title {
  font-size: 28px;
  font-weight: 800;
  background: linear-gradient(135deg, var(--accent), #9b6dd7);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.settings-btn {
  background: none; border: none;
  color: var(--text-secondary);
  cursor: pointer; padding: 8px;
  border-radius: 8px;
  -webkit-tap-highlight-color: transparent;
}

.settings-btn:active { transform: scale(0.9); }

.select-empty {
  text-align: center; padding: 48px 24px;
  color: var(--text-secondary); font-size: 16px; line-height: 1.5;
}

.select-list { display: flex; gap: 16px; overflow-x: auto; padding-bottom: 4px; }

/* Round avatar character cards */
.char-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 16px 12px;
  background: rgba(37, 37, 71, 0.4);
  border: 1.5px solid var(--border);
  border-radius: 16px;
  min-width: 110px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: border-color 0.2s, transform 0.1s;
  position: relative;
  flex-shrink: 0;
}

.char-card:active { transform: scale(0.97); }
.char-card:hover { border-color: rgba(124, 92, 191, 0.4); }

.char-card-avatar {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--border);
  flex-shrink: 0;
}

.char-card-avatar-fallback {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.5);
}

.char-card-avatar-add {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  border: 2px dashed rgba(255, 255, 255, 0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(255, 255, 255, 0.2);
}

.char-card-add { border-style: dashed; border-color: rgba(255, 255, 255, 0.1); }
.char-card-add:hover { border-color: rgba(124, 92, 191, 0.3); }

.char-card-info { text-align: center; }

.char-card-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
}

.char-card-nick {
  font-size: 12px;
  color: var(--text-secondary);
  font-style: italic;
}

.char-card-delete {
  position: absolute;
  top: 6px;
  right: 6px;
  background: rgba(0, 0, 0, 0.4);
  border: none;
  border-radius: 50%;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: rgba(255, 255, 255, 0.6);
  -webkit-tap-highlight-color: transparent;
  transition: background 0.2s;
}

.char-card-delete:active {
  background: rgba(231, 76, 60, 0.8);
  transform: scale(0.9);
}

/* Home page sections */
.home-section-label {
  font-size: 13px; font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 4px 0;
}

.home-card {
  background: rgba(37, 37, 71, 0.4);
  border-radius: 14px;
  padding: 14px 16px;
  margin-bottom: 4px;
}

.home-card-row {
  display: flex; align-items: center; gap: 10px;
  font-size: 14px;
}

.home-usage-text { color: var(--text-secondary); font-size: 13px; }

.home-progress-bar {
  height: 6px;
  background: rgba(255,255,255,0.08);
  border-radius: 3px;
  margin-top: 10px;
  overflow: hidden;
}

.home-progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 3px;
  transition: width 0.3s;
  width: 0%;
}

.home-code-label {
  font-size: 13px;
  color: var(--text-secondary);
  text-align: center;
  margin-top: 8px;
}

.home-code-display {
  font-size: 22px;
  font-weight: 700;
  color: var(--accent);
  text-align: center;
  letter-spacing: 2px;
  padding: 4px 0 10px;
}

.home-share-btns {
  display: flex;
  gap: 8px;
  margin-top: 4px;
}

.home-share-btn {
  flex: 1;
  padding: 8px 4px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: transparent;
  color: var(--text-primary);
  font-size: 12px;
  font-family: inherit;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  text-align: center;
}

.home-share-btn:active { transform: scale(0.95); background: rgba(255,255,255,0.05); }

.home-card-settings {
  cursor: pointer;
  font-size: 15px;
  -webkit-tap-highlight-color: transparent;
}

.home-card-settings:active { transform: scale(0.98); }

/* (old tall card sub-elements removed — now using .char-card round cards) */

/* Delete modal */
.delete-modal {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.6);
  display: flex; align-items: center; justify-content: center;
  z-index: 200; opacity: 0;
  transition: opacity 0.2s ease; padding: 24px;
  backdrop-filter: blur(4px);
}

.delete-modal.active { opacity: 1; }

.delete-modal-content {
  background: var(--bg-secondary); border: 1px solid var(--border);
  border-radius: 16px; padding: 24px;
  max-width: 320px; width: 100%; text-align: center;
}

.delete-modal-content p { font-size: 16px; margin-bottom: 8px; }

.delete-modal-sub { font-size: 13px !important; color: var(--text-secondary); margin-bottom: 20px !important; }

.delete-modal-actions { display: flex; gap: 12px; }

.delete-modal-actions button {
  flex: 1; padding: 12px; border: none; border-radius: 12px;
  font-size: 15px; font-weight: 600; font-family: inherit;
  cursor: pointer; -webkit-tap-highlight-color: transparent;
}

.delete-modal-actions button:active { transform: scale(0.96); }

.delete-modal-cancel { background: rgba(37,37,71,0.8); color: var(--text-primary); }
.delete-modal-confirm { background: var(--danger); color: white; }

/* ======================== */
/* Welcome Screen           */
/* ======================== */

#welcome-overlay {
  position: fixed; inset: 0;
  background: var(--bg-primary);
  z-index: 300;
  display: flex; align-items: center; justify-content: center;
  opacity: 0; transition: opacity 0.4s ease;
}

#welcome-overlay.active { opacity: 1; }
#welcome-overlay.fade-out { opacity: 0; }

.welcome-home {
  text-align: center;
  padding: 24px;
  width: 100%;
  max-width: 360px;
}

.welcome-logo {
  font-size: 52px;
  font-weight: 800;
  background: linear-gradient(135deg, var(--accent), #9b6dd7);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 12px;
}

.welcome-tagline {
  font-size: 18px;
  color: var(--text-secondary);
  margin-bottom: 48px;
}

.welcome-create-btn {
  width: 100%;
  padding: 18px;
  border: none;
  border-radius: 16px;
  background: linear-gradient(135deg, var(--accent), #9b6dd7);
  color: white;
  font-size: 18px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  transition: transform 0.1s, opacity 0.2s;
  -webkit-tap-highlight-color: transparent;
}

.welcome-create-btn:active { transform: scale(0.97); }

.welcome-refresh-btn {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 12px;
  font-family: inherit;
  cursor: pointer;
  margin-top: 12px;
  opacity: 0.5;
  -webkit-tap-highlight-color: transparent;
}

.welcome-refresh-btn:active { opacity: 1; }

.welcome-parent-section {
  margin-top: 48px;
  padding-top: 24px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.welcome-parent-label {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 12px;
}

.welcome-parent-row {
  display: flex;
  gap: 8px;
}

.welcome-parent-input {
  flex: 1;
  background: rgba(37, 37, 71, 0.6);
  border: 1.5px solid var(--border);
  border-radius: 10px;
  padding: 10px 14px;
  color: var(--text-primary);
  font-size: 14px;
  font-family: inherit;
  text-align: center;
  letter-spacing: 1px;
  outline: none;
  transition: border-color 0.2s;
}

.welcome-parent-input:focus { border-color: var(--accent); }
.welcome-parent-input::placeholder { color: var(--text-secondary); }

.welcome-parent-connect {
  padding: 10px 18px;
  border: none;
  border-radius: 10px;
  background: rgba(37, 37, 71, 0.8);
  color: var(--accent);
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.welcome-parent-connect:active { transform: scale(0.95); }

.welcome-parent-msg {
  font-size: 13px;
  margin-top: 10px;
  text-align: center;
}

/* ======================== */
/* Settings Overlay         */
/* ======================== */

.settings-overlay {
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 200;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.2s ease;
  backdrop-filter: blur(4px);
}

.settings-overlay.active { opacity: 1; }

.settings-container {
  width: 100%; max-width: 600px;
  max-height: 80vh;
  background: var(--bg-primary);
  border-radius: 20px 20px 0 0;
  padding: 20px 24px;
  padding-bottom: max(20px, env(safe-area-inset-bottom));
  overflow-y: auto;
}

.settings-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.settings-header h2 { font-size: 20px; font-weight: 700; }

.settings-close-btn {
  background: none; border: none;
  color: var(--text-secondary);
  cursor: pointer; padding: 4px;
  -webkit-tap-highlight-color: transparent;
}

.settings-section {
  background: rgba(37, 37, 71, 0.4);
  border-radius: 14px;
  padding: 18px;
  margin-bottom: 16px;
}

.settings-section-title {
  font-size: 16px; font-weight: 600;
  margin-bottom: 6px;
}

.settings-section-desc {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 14px;
  line-height: 1.4;
}

.family-code-display {
  background: rgba(0, 0, 0, 0.3);
  border-radius: 12px;
  padding: 14px;
  text-align: center;
  margin-bottom: 12px;
}

.family-code-value {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: 2px;
  color: var(--accent);
}

.family-code-loading {
  font-size: 14px;
  color: var(--text-secondary);
}

.family-code-actions {
  display: flex;
  gap: 10px;
  margin-bottom: 12px;
}

.family-code-actions button {
  flex: 1;
  padding: 10px;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  background: transparent;
  color: var(--accent);
  font-size: 14px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.family-code-actions button:active { transform: scale(0.96); }

.family-status {
  font-size: 13px;
  color: var(--text-secondary);
  text-align: center;
}

.family-status.connected {
  color: #4ade80;
}
