:root {
  --bg-deep: #1a0f14;
  --bg-mid: #2d1a24;
  --bg-card: rgba(255, 240, 245, 0.08);
  --rose: #e8a0b4;
  --rose-light: #f5c6d0;
  --rose-dark: #b85c7a;
  --gold: #d4a574;
  --gold-light: #f0d4a8;
  --cream: #fff5f7;
  --text: #fce8ef;
  --text-muted: #c9a8b4;
  --male: #8eb8e8;
  --female: #e8a0c8;
  --success: #7ec8a0;
  --danger: #e87878;
  --radius: 16px;
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.35);
}

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

html {
  font-size: 16px;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: 'Noto Sans TC', sans-serif;
  background: linear-gradient(145deg, var(--bg-deep) 0%, var(--bg-mid) 50%, #3d2030 100%);
  color: var(--text);
  min-height: 100dvh;
  line-height: 1.6;
  overflow-x: hidden;
}

.bg-hearts {
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.04;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='60' height='60' viewBox='0 0 60 60'%3E%3Cpath fill='%23e8a0b4' d='M30 52c-1-1-18-12-18-24 0-7 5-12 12-12 4 0 7 2 9 5 2-3 5-5 9-5 7 0 12 5 12 12 0 12-17 23-18 24z'/%3E%3C/svg%3E");
  background-size: 60px 60px;
}

.app {
  max-width: 480px;
  margin: 0 auto;
  padding: 1.5rem 1.25rem 2rem;
  position: relative;
  z-index: 1;
}

.app-header {
  text-align: center;
  margin-bottom: 1.75rem;
}

.app-title {
  font-family: 'Noto Serif TC', serif;
  font-size: 2rem;
  font-weight: 600;
  background: linear-gradient(135deg, var(--rose-light), var(--gold-light));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: 0.15em;
}

.app-subtitle {
  color: var(--text-muted);
  font-size: 0.875rem;
  margin-top: 0.25rem;
  letter-spacing: 0.2em;
}

.web-hint {
  margin-top: 0.5rem;
  font-size: 0.75rem;
  color: var(--gold-light);
  opacity: 0.85;
}

.mode-badge {
  display: inline-block;
  margin-top: 0.75rem;
  padding: 0.35rem 0.75rem;
  border-radius: 20px;
  font-size: 0.75rem;
  background: rgba(142, 184, 232, 0.2);
  color: var(--male);
  border: 1px solid rgba(142, 184, 232, 0.3);
}

.mode-badge.hidden { display: none; }

.mode-grid {
  display: flex;
  flex-direction: column;
  gap: 0.875rem;
  margin-bottom: 1rem;
}

.mode-card {
  background: var(--bg-card);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius);
  padding: 1.5rem;
  text-align: center;
  cursor: pointer;
  color: inherit;
  font-family: inherit;
  transition: transform 0.15s;
}

.mode-card:active { transform: scale(0.98); }
.mode-card.highlight { border-color: rgba(232, 160, 180, 0.4); }

.mode-icon {
  display: block;
  font-size: 2rem;
  margin-bottom: 0.5rem;
}

.mode-title {
  display: block;
  font-family: 'Noto Serif TC', serif;
  font-size: 1.2rem;
  font-weight: 600;
  margin-bottom: 0.35rem;
}

.mode-desc {
  display: block;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.privacy-hint {
  color: var(--gold-light) !important;
}

.remote-status {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: 1rem;
  min-height: 1.5rem;
}

.room-code {
  text-align: center;
  font-family: 'Noto Serif TC', serif;
  font-size: 3rem;
  font-weight: 700;
  color: var(--gold-light);
  letter-spacing: 0.3em;
  margin: 1rem 0 1.5rem;
  padding: 1rem;
  background: rgba(212, 165, 116, 0.15);
  border-radius: var(--radius);
  border: 1px dashed rgba(212, 165, 116, 0.4);
}

.room-code.hidden { display: none; }

.lobby-card {
  margin-bottom: 1rem;
}

.lobby-title {
  font-size: 1rem;
  color: var(--rose-light);
  margin-bottom: 0.35rem;
}

.lobby-desc {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 1rem;
}

.role-btns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

.room-input, .room-select {
  width: 100%;
  padding: 0.875rem 1rem;
  margin-bottom: 0.75rem;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.2);
  color: var(--cream);
  font-family: inherit;
  font-size: 1.1rem;
  text-align: center;
}

.room-select { text-align-last: center; }

.waiting-panel {
  text-align: center;
  padding: 2rem 1rem;
  margin-bottom: 1rem;
}

.waiting-panel.hidden { display: none; }

.waiting-text {
  color: var(--text-muted);
  margin-bottom: 1rem;
}

.waiting-inline {
  text-align: center;
  color: var(--gold-light);
  font-size: 0.9rem;
  margin-bottom: 1rem;
}

.waiting-inline.hidden { display: none; }

#lobby-forms.hidden { display: none; }

.screen {
  display: none;
  animation: fadeIn 0.35s ease;
}

.screen.active {
  display: block;
}

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

.screen-title {
  font-family: 'Noto Serif TC', serif;
  font-size: 1.35rem;
  text-align: center;
  margin-bottom: 0.5rem;
  color: var(--rose-light);
}

.screen-desc {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: 1.5rem;
}

/* 積分板 */
.score-board {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  margin-bottom: 1rem;
}

.score-card {
  flex: 1;
  background: var(--bg-card);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius);
  padding: 1.25rem 1rem;
  text-align: center;
  backdrop-filter: blur(12px);
  box-shadow: var(--shadow);
}

.score-card.male { border-color: rgba(142, 184, 232, 0.3); }
.score-card.female { border-color: rgba(232, 160, 200, 0.3); }

.score-icon {
  display: block;
  font-size: 1.5rem;
  margin-bottom: 0.25rem;
}

.score-card.male .score-icon { color: var(--male); }
.score-card.female .score-icon { color: var(--female); }

.score-label {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.score-value {
  display: block;
  font-family: 'Noto Serif TC', serif;
  font-size: 2.5rem;
  font-weight: 600;
  line-height: 1.2;
  color: var(--cream);
}

.score-unit {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.score-divider {
  font-size: 1.25rem;
  color: var(--rose);
  animation: pulse 2s ease infinite;
}

@keyframes pulse {
  0%, 100% { transform: scale(1); opacity: 0.7; }
  50% { transform: scale(1.15); opacity: 1; }
}

.round-info {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-bottom: 1.25rem;
}

/* 卡片 */
.card {
  background: var(--bg-card);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-bottom: 1.5rem;
  backdrop-filter: blur(12px);
}

.card-title {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
  letter-spacing: 0.1em;
}

.preview-item {
  padding: 0.6rem 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.preview-item:last-child { border-bottom: none; }

.preview-round {
  font-size: 0.75rem;
  color: var(--gold);
  display: block;
}

.preview-detail {
  font-size: 0.875rem;
  color: var(--text);
}

.empty-hint {
  color: var(--text-muted);
  font-size: 0.875rem;
  text-align: center;
  padding: 0.5rem 0;
}

/* 按鈕 */
.btn {
  display: block;
  width: 100%;
  padding: 0.875rem 1.25rem;
  border: none;
  border-radius: 12px;
  font-family: inherit;
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s, opacity 0.15s;
}

.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary {
  background: linear-gradient(135deg, var(--rose-dark), var(--rose));
  color: white;
  box-shadow: 0 4px 20px rgba(184, 92, 122, 0.4);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.1);
  color: var(--cream);
  border: 1px solid rgba(255, 255, 255, 0.15);
}

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  margin-top: 0.75rem;
}

.btn-lg {
  padding: 1.1rem;
  font-size: 1.05rem;
}

.btn-group {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

/* 等級選擇 */
.level-grid {
  display: flex;
  flex-direction: column;
  gap: 0.875rem;
  margin-bottom: 1rem;
}

.level-card {
  background: var(--bg-card);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius);
  padding: 1.25rem;
  text-align: left;
  cursor: pointer;
  transition: transform 0.15s, border-color 0.15s;
  color: inherit;
  font-family: inherit;
}

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

.level-general { border-left: 4px solid var(--gold); }
.level-intimate { border-left: 4px solid var(--rose); }
.level-spicy { border-left: 4px solid #e85050; }

.level-name {
  display: block;
  font-family: 'Noto Serif TC', serif;
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: 0.25rem;
}

.level-desc {
  display: block;
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}

.level-points {
  font-size: 0.8rem;
  color: var(--gold-light);
}

.hint-text {
  text-align: center;
  font-size: 0.8rem;
  color: var(--danger);
  margin-bottom: 0.5rem;
}

.level-badge {
  display: inline-block;
  padding: 0.2rem 0.6rem;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 500;
}

.level-badge.level-general { background: rgba(212, 165, 116, 0.25); color: var(--gold-light); }
.level-badge.level-intimate { background: rgba(232, 160, 180, 0.25); color: var(--rose-light); }
.level-badge.level-spicy { background: rgba(232, 80, 80, 0.25); color: #ffaaaa; }

/* 骰子 */
.dice-arena {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  margin: 2rem 0;
}

.dice-player {
  text-align: center;
}

.dice-label {
  display: block;
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
}

.dice {
  width: 80px;
  height: 80px;
  background: linear-gradient(145deg, #fff5f7, #f0d0d8);
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Noto Serif TC', serif;
  font-size: 2.5rem;
  font-weight: 700;
  color: var(--rose-dark);
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.3), inset 0 2px 4px rgba(255, 255, 255, 0.8);
}

.dice.rolling {
  animation: shake 0.15s infinite;
}

@keyframes shake {
  0%, 100% { transform: rotate(-5deg); }
  50% { transform: rotate(5deg); }
}

.dice-vs {
  font-family: 'Noto Serif TC', serif;
  font-size: 1rem;
  color: var(--rose);
  font-weight: 600;
}

.dice-result {
  text-align: center;
  margin: 1.5rem 0;
  padding: 1.25rem;
  background: var(--bg-card);
  border-radius: var(--radius);
}

.dice-result.hidden { display: none; }

.result-win {
  font-size: 1.1rem;
  color: var(--success);
  margin-bottom: 0.5rem;
}

.result-lose {
  font-size: 1rem;
  color: var(--rose-light);
  margin-bottom: 1rem;
}

.result-tie {
  font-size: 1.1rem;
  color: var(--gold-light);
  margin-bottom: 0.5rem;
}

.result-hint {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.result-dice-summary {
  font-size: 1.05rem;
  color: var(--cream);
  margin-bottom: 0.75rem;
  font-weight: 500;
}

.choice-dice-winner {
  font-size: 0.95rem;
  color: var(--rose-light);
  margin-bottom: 0.75rem;
}

/* 落敗方選擇 */
.loser-info {
  text-align: center;
  margin-bottom: 1.5rem;
}

.loser-badge {
  font-size: 1.15rem;
  color: var(--cream);
  margin-bottom: 0.75rem;
}

.choice-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.875rem;
}

.choice-card {
  background: var(--bg-card);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius);
  padding: 1.5rem 1rem;
  text-align: center;
  cursor: pointer;
  color: inherit;
  font-family: inherit;
  transition: transform 0.15s;
}

.choice-card:active { transform: scale(0.96); }
.choice-card.draw { border-color: rgba(232, 160, 180, 0.4); }
.choice-card.skip { border-color: rgba(232, 120, 120, 0.4); }

.choice-icon {
  display: block;
  font-size: 2rem;
  margin-bottom: 0.5rem;
}

.choice-title {
  display: block;
  font-weight: 600;
  margin-bottom: 0.35rem;
}

.choice-desc {
  display: block;
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* 動作顯示 */
.action-header {
  text-align: center;
  margin-bottom: 1.25rem;
}

.action-player {
  display: block;
  font-size: 1rem;
  color: var(--text-muted);
  margin-top: 0.5rem;
}

.action-card {
  background: linear-gradient(160deg, rgba(232, 160, 180, 0.15), rgba(212, 165, 116, 0.1));
  border: 1px solid rgba(232, 160, 180, 0.25);
  border-radius: var(--radius);
  padding: 2rem 1.5rem;
  margin-bottom: 1.25rem;
  text-align: center;
  box-shadow: var(--shadow);
}

.action-quote {
  font-family: 'Noto Serif TC', serif;
  font-size: 2rem;
  color: var(--rose);
  line-height: 1;
}

.action-quote.end {
  text-align: right;
  margin-top: 0.5rem;
}

.action-text {
  font-family: 'Noto Serif TC', serif;
  font-size: 1.2rem;
  line-height: 1.8;
  color: var(--cream);
  padding: 0.5rem 0;
}

.action-points {
  text-align: center;
  color: var(--gold-light);
  font-size: 0.9rem;
  margin-bottom: 1.5rem;
}

/* 回合結果 */
.result-card {
  text-align: center;
  padding: 2rem 1.5rem;
  border-radius: var(--radius);
  margin-bottom: 1.5rem;
}

.result-card.success {
  background: rgba(126, 200, 160, 0.15);
  border: 1px solid rgba(126, 200, 160, 0.3);
}

.result-card.skip {
  background: rgba(232, 120, 120, 0.15);
  border: 1px solid rgba(232, 120, 120, 0.3);
}

.result-title {
  font-family: 'Noto Serif TC', serif;
  font-size: 1.35rem;
  margin-bottom: 0.75rem;
}

.result-scores {
  margin-top: 0.75rem;
  font-size: 0.9rem;
  color: var(--text-muted);
}

/* 歷史紀錄 */
.history-list {
  display: flex;
  flex-direction: column;
  gap: 0.875rem;
  margin-bottom: 1rem;
  max-height: 60dvh;
  overflow-y: auto;
}

.history-card {
  background: var(--bg-card);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius);
  padding: 1rem 1.125rem;
}

.history-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
}

.history-round {
  font-weight: 600;
  color: var(--gold-light);
  font-size: 0.9rem;
}

.history-time {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.history-meta {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 0.5rem;
}

.tag {
  font-size: 0.7rem;
  padding: 0.15rem 0.5rem;
  border-radius: 10px;
}

.tag-done { background: rgba(126, 200, 160, 0.2); color: var(--success); }
.tag-skip { background: rgba(232, 120, 120, 0.2); color: var(--danger); }

.history-dice {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}

.history-action {
  font-size: 0.9rem;
  color: var(--cream);
  line-height: 1.5;
  padding: 0.5rem 0;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.history-action.muted {
  color: var(--text-muted);
  font-style: italic;
}

.history-footer {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.5rem;
}

.app-footer {
  text-align: center;
  padding: 1rem;
  font-size: 0.7rem;
  color: var(--text-muted);
  opacity: 0.6;
}

@media (min-width: 480px) {
  .app { padding-top: 2.5rem; }
  .choice-grid { gap: 1.25rem; }
}