/* ========== 全局样式 ========== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html {
  font-size: 16px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  min-height: 100vh;
  color: #1f2937;
  overflow-x: hidden;
}

#app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  position: relative;
}

/* ========== 页面切换 ========== */
.page {
  display: none;
  padding: 20px 16px;
  min-height: 100vh;
}

.page.active {
  display: block;
  animation: fadeIn 0.3s ease;
}

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

/* ========== 首页 Hero ========== */
.hero {
  text-align: center;
  padding: 40px 0 30px;
  color: white;
}

.logo {
  font-size: 64px;
  margin-bottom: 12px;
  filter: drop-shadow(0 4px 8px rgba(0,0,0,0.2));
}

.hero h1 {
  font-size: 32px;
  font-weight: 700;
  margin-bottom: 6px;
  letter-spacing: 2px;
}

.subtitle {
  font-size: 15px;
  opacity: 0.9;
}

/* ========== 卡片 ========== */
.card {
  background: white;
  border-radius: 16px;
  padding: 16px;
  margin-bottom: 14px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.1);
}

.card-title {
  font-size: 16px;
  font-weight: 600;
  color: #374151;
  margin-bottom: 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.round-count {
  font-size: 13px;
  font-weight: 400;
  color: #9ca3af;
}

/* ========== 表单 ========== */
.form-group {
  margin-bottom: 14px;
}

.form-group label {
  display: block;
  font-size: 14px;
  color: #6b7280;
  margin-bottom: 6px;
}

.form-group input {
  width: 100%;
  height: 48px;
  padding: 0 14px;
  border: 2px solid #e5e7eb;
  border-radius: 12px;
  font-size: 17px;
  outline: none;
  transition: border-color 0.2s;
}

.form-group input:focus {
  border-color: #6366f1;
}

input[type="text"], input[type="number"] {
  width: 100%;
  height: 48px;
  padding: 0 14px;
  border: 2px solid #e5e7eb;
  border-radius: 12px;
  font-size: 17px;
  outline: none;
  transition: border-color 0.2s;
  font-family: inherit;
}

input:focus {
  border-color: #6366f1;
}

/* ========== 按钮 ========== */
.btn {
  border: none;
  border-radius: 12px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-family: inherit;
  padding: 0 18px;
  height: 48px;
}

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

.btn:disabled,
.btn-disabled {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

.btn-large {
  width: 100%;
  height: 56px;
  font-size: 18px;
  border-radius: 14px;
}

.btn-primary {
  background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
  color: white;
  box-shadow: 0 4px 15px rgba(99, 102, 241, 0.4);
}

.btn-primary:active {
  box-shadow: 0 2px 8px rgba(99, 102, 241, 0.4);
}

.btn-secondary {
  background: #f3f4f6;
  color: #374151;
}

.btn-success {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  color: white;
  box-shadow: 0 4px 15px rgba(16, 185, 129, 0.4);
}

.btn-warning {
  background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
  color: white;
}

.btn-danger {
  background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
  color: white;
}

.btn-icon {
  font-size: 20px;
}

/* ========== 操作按钮区 ========== */
.action-buttons {
  margin: 20px 0 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.divider-text {
  text-align: center;
  color: rgba(255,255,255,0.7);
  font-size: 14px;
  position: relative;
}

.divider-text::before,
.divider-text::after {
  content: '';
  position: absolute;
  top: 50%;
  width: 40%;
  height: 1px;
  background: rgba(255,255,255,0.3);
}

.divider-text::before { left: 0; }
.divider-text::after { right: 0; }

.join-row {
  display: flex;
  gap: 10px;
}

.join-row input {
  flex: 1;
  text-align: center;
  font-size: 20px;
  font-weight: 600;
  letter-spacing: 4px;
}

.join-row .btn {
  min-width: 100px;
}

/* ========== 底部提示 ========== */
.footer-tip {
  text-align: center;
  color: rgba(255,255,255,0.6);
  font-size: 12px;
  margin-top: 30px;
}

.bottom-space {
  height: 40px;
}

/* ========== 房间页头部 ========== */
.room-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: white;
  margin-bottom: 14px;
}

.room-code-box {
  display: flex;
  align-items: center;
  gap: 8px;
}

.room-code-label {
  font-size: 13px;
  opacity: 0.8;
}

.room-code {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 3px;
}

.copy-btn {
  background: rgba(255,255,255,0.2);
  border: none;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
}

.copy-btn:active {
  background: rgba(255,255,255,0.3);
}

.my-name {
  font-size: 14px;
  background: rgba(255,255,255,0.2);
  padding: 6px 12px;
  border-radius: 20px;
}

/* ========== 状态条 ========== */
.status-bar {
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 500;
  text-align: center;
  margin-bottom: 14px;
}

.status-normal {
  background: rgba(255,255,255,0.9);
  color: #4b5563;
}

.status-warning {
  background: #fef3c7;
  color: #92400e;
}

.status-success {
  background: #d1fae5;
  color: #065f46;
}

.status-info {
  background: #dbeafe;
  color: #1e40af;
}

/* ========== 输赢榜 ========== */
.scoreboard {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.score-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 12px;
  border-radius: 10px;
  background: #f9fafb;
}

.score-item.rank-1 {
  background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
}

.score-item.rank-2 {
  background: linear-gradient(135deg, #f3f4f6 0%, #e5e7eb 100%);
}

.score-item.rank-3 {
  background: linear-gradient(135deg, #fed7aa 0%, #fdba74 100%);
}

.score-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.rank-badge {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #d1d5db;
  color: white;
  font-size: 13px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

.score-item.rank-1 .rank-badge { background: #f59e0b; }
.score-item.rank-2 .rank-badge { background: #9ca3af; }
.score-item.rank-3 .rank-badge { background: #b45309; }

.player-name {
  font-size: 15px;
  font-weight: 500;
  color: #374151;
}

.player-name.me {
  color: #6366f1;
  font-weight: 600;
}

.score-amount {
  font-size: 17px;
  font-weight: 700;
}

.score-amount.positive {
  color: #059669;
}

.score-amount.negative {
  color: #dc2626;
}

.score-amount.zero {
  color: #9ca3af;
}

/* ========== 当前局内容 ========== */
#current-round-content {
  min-height: 60px;
}

.no-round-tip {
  text-align: center;
  color: #9ca3af;
  padding: 16px 0;
  font-size: 14px;
}

.round-info {
  margin-bottom: 12px;
}

.round-winner {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 15px;
  margin-bottom: 12px;
  padding: 10px 12px;
  background: #ecfdf5;
  border-radius: 10px;
}

.round-winner-name {
  font-weight: 600;
  color: #059669;
}

.losses-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 12px;
}

.loss-item {
  display: flex;
  justify-content: space-between;
  padding: 8px 12px;
  background: #f9fafb;
  border-radius: 8px;
  font-size: 14px;
}

.loss-item.submitted {
  background: #fef2f2;
}

.loss-item .loss-name {
  color: #6b7280;
}

.loss-item .loss-amount {
  font-weight: 600;
  color: #dc2626;
}

.loss-item .loss-status {
  color: #9ca3af;
  font-size: 13px;
}

.round-actions {
  display: flex;
  gap: 10px;
  margin-top: 10px;
}

.round-actions .btn {
  flex: 1;
  height: 44px;
  font-size: 15px;
}

.round-tip {
  text-align: center;
  font-size: 12px;
  color: #9ca3af;
  margin-top: 8px;
}

/* ========== 历史记录 ========== */
.toggle-btn {
  background: none;
  border: none;
  color: #6366f1;
  font-size: 13px;
  cursor: pointer;
  padding: 4px 8px;
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.history-list.hidden {
  display: none;
}

.history-item {
  padding: 10px 12px;
  background: #f9fafb;
  border-radius: 10px;
}

.history-item-header {
  display: flex;
  justify-content: space-between;
  margin-bottom: 6px;
}

.history-round-no {
  font-weight: 600;
  color: #374151;
  font-size: 14px;
}

.history-time {
  font-size: 12px;
  color: #9ca3af;
}

.history-winner {
  font-size: 13px;
  color: #059669;
  margin-bottom: 4px;
}

.history-losses {
  font-size: 13px;
  color: #6b7280;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.history-loss-tag {
  background: #fef2f2;
  color: #dc2626;
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 12px;
}

/* ========== 弹窗 ========== */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
}

.modal.hidden {
  display: none;
}

.modal-content {
  background: white;
  border-radius: 20px;
  width: 100%;
  max-width: 420px;
  max-height: 80vh;
  overflow-y: auto;
  animation: modalIn 0.3s ease;
}

@keyframes modalIn {
  from { opacity: 0; transform: scale(0.9) translateY(20px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-header {
  padding: 18px 20px 14px;
  border-bottom: 1px solid #f3f4f6;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-header h2 {
  font-size: 18px;
  font-weight: 600;
}

.close-btn {
  background: none;
  border: none;
  font-size: 18px;
  color: #9ca3af;
  cursor: pointer;
  width: 32px;
  height: 32px;
  border-radius: 8px;
}

.close-btn:active {
  background: #f3f4f6;
}

.modal-footer {
  padding: 16px 20px;
  border-top: 1px solid #f3f4f6;
}

/* ========== 赢家选择 ========== */
.winner-list {
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.winner-btn {
  padding: 14px 16px;
  border: 2px solid #e5e7eb;
  border-radius: 12px;
  background: white;
  font-size: 16px;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-family: inherit;
  transition: all 0.2s;
}

.winner-btn:active {
  background: #f3f4f6;
  border-color: #6366f1;
}

/* ========== 金额输入 ========== */
.amount-input-area {
  padding: 24px 20px;
  text-align: center;
}

.amount-label {
  font-size: 14px;
  color: #6b7280;
  margin-bottom: 12px;
}

#input-amount {
  width: 100%;
  height: 60px;
  font-size: 28px;
  font-weight: 700;
  text-align: center;
  border: 2px solid #e5e7eb;
  border-radius: 12px;
  outline: none;
  margin-bottom: 10px;
}

#input-amount:focus {
  border-color: #6366f1;
}

.amount-tip {
  font-size: 12px;
  color: #9ca3af;
}

/* ========== 结算弹窗内容 ========== */
#settle-content {
  padding: 16px 20px;
}

.settle-section {
  margin-bottom: 20px;
}

.settle-section-title {
  font-size: 14px;
  font-weight: 600;
  color: #6b7280;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.settle-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.settle-item {
  display: flex;
  justify-content: space-between;
  padding: 10px 12px;
  background: #f9fafb;
  border-radius: 10px;
  font-size: 15px;
}

.settle-item .amount.positive {
  color: #059669;
  font-weight: 600;
}

.settle-item .amount.negative {
  color: #dc2626;
  font-weight: 600;
}

.transfer-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px;
  background: #fef2f2;
  border-radius: 10px;
  margin-bottom: 8px;
}

.transfer-flow {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
}

.transfer-from {
  font-weight: 500;
  color: #dc2626;
}

.transfer-arrow {
  color: #9ca3af;
}

.transfer-to {
  font-weight: 500;
  color: #059669;
}

.transfer-amount {
  font-size: 16px;
  font-weight: 700;
  color: #dc2626;
}

.no-transfer-tip {
  text-align: center;
  color: #9ca3af;
  padding: 20px 0;
  font-size: 14px;
}

/* ========== 使用说明 ========== */
.help-content {
  padding: 4px 0 0 0;
}

.help-content.hidden {
  display: none;
}

.help-list {
  padding-left: 20px;
  font-size: 14px;
  color: #6b7280;
  line-height: 1.8;
}

.help-list li {
  margin-bottom: 2px;
}

/* ========== 结算提示 ========== */
.settle-tip {
  background: #f0f9ff;
  color: #0369a1;
  padding: 12px;
  border-radius: 10px;
  font-size: 13px;
  line-height: 1.6;
}

/* ========== 结束本局确认 ========== */
.finish-confirm-tip {
  padding: 20px;
  font-size: 15px;
  color: #6b7280;
  line-height: 1.8;
}

/* ========== 最终结算 ========== */
.final-banner {
  margin: 16px 20px;
  padding: 20px;
  background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
  border-radius: 16px;
  text-align: center;
  color: white;
}

.final-banner-icon {
  font-size: 40px;
  margin-bottom: 8px;
}

.final-banner-text {
  font-size: 18px;
  font-weight: 600;
}

.final-tip {
  text-align: center;
  font-size: 13px;
  color: #9ca3af;
  padding: 0 20px 16px;
}

/* ========== ghost 按钮 ========== */
.btn-ghost {
  background: transparent;
  color: white;
  border: 1px solid rgba(255,255,255,0.4);
  height: 44px;
  font-size: 14px;
  opacity: 0.8;
}

.btn-ghost:active {
  background: rgba(255,255,255,0.1);
  opacity: 1;
}

/* ========== Toast ========== */
.toast {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(0,0,0,0.8);
  color: white;
  padding: 12px 24px;
  border-radius: 10px;
  font-size: 14px;
  z-index: 200;
  animation: toastIn 0.3s ease;
  max-width: 80%;
  text-align: center;
}

.toast.hidden {
  display: none;
}

@keyframes toastIn {
  from { opacity: 0; transform: translate(-50%, -50%) scale(0.9); }
  to { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}

/* ========== 响应式适配 ========== */
@media (max-width: 360px) {
  .hero h1 { font-size: 28px; }
  .btn-large { font-size: 16px; height: 50px; }
  .card { padding: 14px; }
}

/* 隐藏数字输入框的上下箭头 */
input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
input[type="number"] {
  -moz-appearance: textfield;
}
