:root {
  --bg-top: #0b1e3b;
  --bg-bottom: #183a61;
  --card-bg: rgba(255, 255, 255, 0.12);
  --card-border: rgba(255, 255, 255, 0.22);
  --gold: #ffd166;
  --red: #e63946;
  --green: #2a9d8f;
  --text: #ffffff;
  --muted: #cbd5e1;
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang HK", "Microsoft JhengHei", sans-serif;
  background: linear-gradient(180deg, var(--bg-top) 0%, var(--bg-bottom) 100%);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
  position: relative;
}

/* 飄雪背景 */
#snow-canvas {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  pointer-events: none;
  z-index: 0;
}

.container {
  position: relative;
  z-index: 1;
  max-width: 560px;
  margin: 0 auto;
  padding: 16px;
}

.card {
  background: var(--card-bg);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--card-border);
  border-radius: 18px;
  padding: 20px;
  margin-bottom: 16px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.25);
}

h1, h2, h3 { text-align: center; margin-bottom: 10px; }
.title-gold { color: var(--gold); text-shadow: 0 2px 10px rgba(255, 209, 102, 0.4); }
.subtitle { text-align: center; color: var(--muted); font-size: 0.9rem; margin-bottom: 16px; }

/* 按鈕與輸入框 */
input[type="text"], input[type="password"] {
  width: 100%;
  padding: 14px 16px;
  border-radius: 12px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  background: rgba(0, 0, 0, 0.25);
  color: #fff;
  font-size: 1.05rem;
  outline: none;
  margin-bottom: 12px;
}
input:focus { border-color: var(--gold); }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 14px 18px;
  border: none;
  border-radius: 12px;
  font-size: 1.05rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.1s, opacity 0.2s;
  color: #fff;
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: linear-gradient(135deg, #e63946, #c1121f); box-shadow: 0 4px 14px rgba(230, 57, 70, 0.4); }
.btn-green { background: linear-gradient(135deg, #2a9d8f, #1d7a6e); }
.btn-gold { background: linear-gradient(135deg, #f4a261, #e76f51); }
.btn-outline { background: rgba(255,255,255,0.12); border: 1px solid rgba(255,255,255,0.35); }
.btn-sm { padding: 8px 12px; font-size: 0.85rem; width: auto; }

/* 遊戲棋盤 */
.board {
  display: grid;
  gap: 6px;
  background: rgba(255, 255, 255, 0.15);
  padding: 12px 8px;
  border-radius: 16px;
  border: 2px solid rgba(255, 255, 255, 0.25);
  margin: 16px 0;
  align-items: center;
}
.board-7 { grid-template-columns: repeat(7, 1fr); }
.board-11 { grid-template-columns: repeat(11, 1fr); gap: 3px; padding: 8px 4px; }

.slot {
  aspect-ratio: 1 / 1.15;
  background: rgba(255, 255, 255, 0.88);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: clamp(20px, 6.5vw, 38px);
  cursor: pointer;
  user-select: none;
  box-shadow: 0 4px 0 rgba(148, 163, 184, 0.8);
  transition: transform 0.12s, background 0.15s;
  position: relative;
}
.board-11 .slot {
  font-size: clamp(14px, 4.5vw, 28px);
  border-radius: 7px;
}
.slot.empty {
  background: rgba(255, 255, 255, 0.18);
  border: 2px dashed rgba(255, 255, 255, 0.45);
  box-shadow: none;
  cursor: default;
}
.slot.movable:hover { transform: translateY(-3px); }
.slot.movable:active { transform: scale(0.92); }
.slot.piece-L { border-bottom: 4px solid #e63946; }
.slot.piece-R { border-bottom: 4px solid #2a9d8f; }
.slot img { width: 82%; height: 82%; object-fit: contain; pointer-events: none; }

/* 狀態列 */
.stats-bar {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}
.stat-box {
  flex: 1;
  background: rgba(0,0,0,0.28);
  border-radius: 12px;
  padding: 10px;
  text-align: center;
}
.stat-label { font-size: 0.75rem; color: var(--muted); }
.stat-val { font-size: 1.3rem; font-weight: 800; color: var(--gold); font-variant-numeric: tabular-nums; }

.deadlock-alert {
  background: rgba(230, 57, 70, 0.9);
  color: #fff;
  text-align: center;
  padding: 10px;
  border-radius: 10px;
  font-weight: 700;
  margin-bottom: 10px;
  animation: pulse 1s infinite;
}
@keyframes pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.03); } }

.rules-box {
  background: rgba(0,0,0,0.22);
  border-radius: 12px;
  padding: 14px;
  font-size: 0.92rem;
  line-height: 1.6;
  margin-bottom: 14px;
}
.rules-box li { margin-left: 18px; margin-bottom: 4px; }

.badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 700;
}
.badge-gold { background: var(--gold); color: #1e293b; }
.badge-green { background: var(--green); color: #fff; }
.badge-red { background: var(--red); color: #fff; }

.hidden { display: none !important; }
.text-center { text-align: center; }
.mt-2 { margin-top: 10px; }
.mt-3 { margin-top: 16px; }
