:root {
  --bg: #14101a;
  --bg2: #1e1828;
  --surface: #2a2236;
  --line: rgba(255, 255, 255, 0.08);
  --text: #f5f0ea;
  --muted: #a89bb0;
  --accent: #ff7a59;
  --accent2: #c9a0ff;
  --ok: #7dcea0;
  --radius: 18px;
  --shadow: 0 18px 40px rgba(0, 0, 0, 0.45);
  font-family: "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", "Microsoft YaHei", system-ui, sans-serif;
}

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

html, body {
  min-height: 100%;
  background: #0b0910;
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

body {
  display: flex;
  justify-content: center;
  padding: 24px 12px 40px;
}

.phone {
  width: 100%;
  max-width: 390px;
  min-height: 780px;
  background:
    radial-gradient(120% 80% at 10% -10%, rgba(201, 160, 255, 0.22), transparent 55%),
    radial-gradient(100% 70% at 100% 0%, rgba(255, 122, 89, 0.18), transparent 50%),
    var(--bg);
  border: 1px solid var(--line);
  border-radius: 28px;
  box-shadow: var(--shadow);
  padding: 22px 18px 28px;
  position: relative;
  overflow: hidden;
}

.view { display: none; animation: fadeIn 0.28s ease; }
.view.active { display: block; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

.hero { margin-bottom: 22px; padding-top: 8px; }
.eyebrow {
  color: var(--accent2);
  font-size: 12px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  margin-bottom: 10px;
}
.hero h1 {
  font-size: 30px;
  font-weight: 700;
  letter-spacing: 0.02em;
  line-height: 1.2;
}
.sub {
  margin-top: 10px;
  color: var(--muted);
  font-size: 13.5px;
  line-height: 1.65;
}

.label {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 10px;
  font-weight: 500;
}

.scene-grid {
  display: grid;
  gap: 10px;
}

.scene-card {
  display: grid;
  grid-template-columns: 40px 1fr;
  grid-template-rows: auto auto;
  column-gap: 12px;
  align-items: center;
  text-align: left;
  background: var(--bg2);
  border: 1.5px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 14px 14px 12px;
  color: var(--text);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, transform 0.12s;
}
.scene-card:active { transform: scale(0.985); }
.scene-card.selected {
  border-color: rgba(255, 122, 89, 0.7);
  background: linear-gradient(135deg, rgba(255, 122, 89, 0.12), rgba(201, 160, 255, 0.08));
}
.scene-icon {
  grid-row: 1 / span 2;
  font-size: 26px;
  width: 40px;
  text-align: center;
}
.scene-name { font-size: 16px; font-weight: 600; }
.scene-desc { font-size: 12px; color: var(--muted); margin-top: 2px; }

.block { margin-bottom: 20px; }

.actions-stack {
  display: grid;
  gap: 10px;
  margin-bottom: 22px;
}

.btn {
  border: none;
  border-radius: 14px;
  padding: 14px 16px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: transform 0.12s, opacity 0.12s, background 0.15s;
}
.btn:active { transform: scale(0.98); }
.btn.primary {
  background: linear-gradient(135deg, #ff8a65, #ff5c7a 60%, #c77dff);
  color: #1a1018;
  box-shadow: 0 8px 24px rgba(255, 92, 122, 0.35);
}
.btn.secondary {
  background: var(--accent2);
  color: #1a1020;
  padding: 12px 16px;
  white-space: nowrap;
}
.btn.ghost {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--line);
}
.btn.wide { width: 100%; }

.join-panel {
  background: var(--bg2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
}
.join-row {
  display: flex;
  gap: 8px;
}
.join-row input {
  flex: 1;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
  color: var(--text);
  font-size: 18px;
  letter-spacing: 0.28em;
  text-align: center;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  outline: none;
}
.join-row input:focus {
  border-color: rgba(201, 160, 255, 0.55);
}
.hint {
  margin-top: 10px;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.5;
}

.foot {
  margin-top: 22px;
  text-align: center;
  font-size: 11px;
  color: rgba(168, 155, 176, 0.75);
}

/* ROOM */
.room-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
}
.icon-btn {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--bg2);
  color: var(--text);
  font-size: 18px;
  cursor: pointer;
}
.room-meta {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.room-scene { font-weight: 650; font-size: 15px; }
.room-code-pill {
  font-size: 12px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.06em;
}

.depth-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.chip {
  font-size: 12px;
  padding: 5px 10px;
  border-radius: 999px;
  background: rgba(125, 206, 160, 0.15);
  color: var(--ok);
  border: 1px solid rgba(125, 206, 160, 0.35);
}
.chip.muted {
  background: transparent;
  color: var(--muted);
  border-color: var(--line);
}
.remain {
  margin-left: auto;
  font-size: 12px;
  color: var(--muted);
}

.slot-tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin-bottom: 16px;
  background: var(--bg2);
  padding: 5px;
  border-radius: 14px;
  border: 1px solid var(--line);
}
.slot-tab {
  border: none;
  background: transparent;
  color: var(--muted);
  padding: 10px 6px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}
.slot-tab.on {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 2px 8px rgba(0,0,0,0.25);
}

.card-stage {
  perspective: 1200px;
  margin-bottom: 18px;
  min-height: 280px;
  display: flex;
  align-items: stretch;
}

.card {
  flex: 1;
  border-radius: 22px;
  background: linear-gradient(160deg, #352843 0%, #241c30 55%, #1c1624 100%);
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: var(--shadow);
  position: relative;
  transform-style: preserve-3d;
  transition: transform 0.45s cubic-bezier(0.22, 1, 0.36, 1), box-shadow 0.3s;
}
.card.flip {
  animation: cardFlip 0.55s ease;
}
.card.shake {
  animation: cardShake 0.42s ease;
}

@keyframes cardFlip {
  0% { transform: rotateY(0) scale(1); }
  40% { transform: rotateY(88deg) scale(0.96); }
  100% { transform: rotateY(0) scale(1); }
}
@keyframes cardShake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-6px) rotate(-1deg); }
  40% { transform: translateX(6px) rotate(1deg); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(3px); }
}

.card-face {
  padding: 28px 22px 24px;
  min-height: 280px;
  display: flex;
  flex-direction: column;
  height: 100%;
}
.card-slot-tag {
  font-size: 12px;
  letter-spacing: 0.14em;
  color: var(--accent);
  margin-bottom: 18px;
  font-weight: 600;
}
.card-text {
  font-size: 24px;
  line-height: 1.45;
  font-weight: 650;
  letter-spacing: 0.01em;
  flex: 1;
}
.card-note {
  margin-top: 16px;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.5;
  min-height: 1.5em;
}

.room-actions { display: grid; gap: 10px; }
.btn-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

.sync-hint {
  margin-top: 14px;
  text-align: center;
  font-size: 11px;
  color: rgba(168, 155, 176, 0.7);
}

.toast {
  position: absolute;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%);
  background: rgba(40, 32, 52, 0.95);
  border: 1px solid var(--line);
  color: var(--text);
  padding: 10px 16px;
  border-radius: 999px;
  font-size: 13px;
  z-index: 20;
  white-space: nowrap;
  animation: toastIn 0.25s ease;
}
@keyframes toastIn {
  from { opacity: 0; transform: translate(-50%, 8px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

@media (max-width: 420px) {
  body { padding: 0; background: var(--bg); }
  .phone {
    max-width: none;
    min-height: 100vh;
    border: none;
    border-radius: 0;
    box-shadow: none;
  }
}
