/* ============================
   你说我猜 — 极简派对游戏
   移动端优先 · 响应式设计
   ============================ */

/* --- Reset & Base --- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: #1a1a2e;
  min-height: 100vh;
  min-height: 100dvh;
  overflow: hidden;
}

/* --- Views --- */
.view {
  display: none;
  min-height: 100vh;
  min-height: 100dvh;
}

.view.active {
  display: flex;
  align-items: center;
  justify-content: center;
}

.container {
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  padding: 24px 20px;
}

/* --- Buttons --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 16px;
  cursor: pointer;
  touch-action: manipulation;
  font-size: 1rem;
  font-weight: 600;
  transition: transform 0.1s ease, background 0.1s ease, border-color 0.1s ease;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

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

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
}

.btn-primary {
  background: #fff;
  color: #667eea;
  padding: 16px 48px;
  font-size: 1.2rem;
  box-shadow: 0 4px 15px rgba(0,0,0,0.15);
}

.btn-primary:active:not(:disabled) {
  background: #f0f0f5;
}

.btn-lg {
  width: 100%;
  min-height: 56px;
  border-radius: 16px;
}

.btn-ghost {
  background: transparent;
  color: rgba(255,255,255,0.8);
  padding: 12px 24px;
  font-size: 0.9rem;
}

.btn-ghost:active {
  color: #fff;
}

.btn-sm {
  font-size: 0.85rem;
  padding: 8px 16px;
}

.btn-icon {
  background: rgba(255,255,255,0.2);
  color: #fff;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  font-size: 1.2rem;
}

/* --- Home View --- */
.home-content {
  text-align: center;
}

.title {
  font-size: clamp(2.5rem, 10vw, 4rem);
  font-weight: 800;
  color: #fff;
  margin-bottom: 12px;
  text-shadow: 0 2px 10px rgba(0,0,0,0.15);
}

.subtitle {
  color: rgba(255,255,255,0.85);
  font-size: 1.1rem;
  margin-bottom: 48px;
  letter-spacing: 0.1em;
}

.home-footer {
  margin-top: 40px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.info-text {
  color: rgba(255,255,255,0.6);
  font-size: 0.85rem;
}

/* --- Page Header --- */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.page-header h2 {
  color: #fff;
  font-size: 1.4rem;
  font-weight: 700;
}

.hint {
  color: rgba(255,255,255,0.7);
  font-size: 0.9rem;
  margin-bottom: 20px;
  text-align: center;
}

.page-footer {
  margin-top: 24px;
}

/* --- Category Grid --- */
.cat-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.cat-card {
  background: rgba(255,255,255,0.15);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 2px solid rgba(255,255,255,0.2);
  border-radius: 12px;
  padding: 10px 4px;
  text-align: center;
  cursor: pointer;
  touch-action: manipulation;
  transition: transform 0.05s ease, background 0.05s ease, border-color 0.05s ease;
  -webkit-tap-highlight-color: transparent;
}

.cat-card:active {
  transform: scale(0.95);
}

.cat-card.selected {
  background: rgba(255,255,255,0.95);
  border-color: #fff;
}

.cat-card.selected .cat-name,
.cat-card.selected .cat-count {
  color: #667eea;
}

.cat-card.exhausted {
  opacity: 0.35;
  cursor: not-allowed;
}

.cat-icon {
  display: block;
  font-size: 1.5rem;
  margin-bottom: 4px;
}

.cat-name {
  display: block;
  color: #fff;
  font-size: 0.8rem;
  font-weight: 600;
  margin-bottom: 2px;
}

.cat-count {
  display: block;
  color: rgba(255,255,255,0.6);
  font-size: 0.65rem;
}

/* --- Duration Grid --- */
.dur-grid {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.dur-card {
  background: rgba(255,255,255,0.15);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 2px solid rgba(255,255,255,0.2);
  border-radius: 16px;
  padding: 24px;
  text-align: center;
  cursor: pointer;
  touch-action: manipulation;
  transition: transform 0.1s ease, background 0.1s ease, border-color 0.1s ease;
  -webkit-tap-highlight-color: transparent;
}

.dur-card:active {
  transform: scale(0.97);
  background: rgba(255,255,255,0.9);
}

.dur-card:active .dur-time,
.dur-card:active .dur-detail {
  color: #667eea;
}

.dur-time {
  display: block;
  color: #fff;
  font-size: 1.5rem;
  font-weight: 800;
  margin-bottom: 6px;
}

.dur-detail {
  display: block;
  color: rgba(255,255,255,0.7);
  font-size: 0.85rem;
}

/* --- Game View --- */
.game-container {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  padding-top: env(safe-area-inset-top, 20px);
  padding-bottom: env(safe-area-inset-bottom, 20px);
}

.game-top {
  flex-shrink: 0;
  margin-bottom: 16px;
}

.timer-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
}

.timer-bar-bg {
  flex: 1;
  height: 8px;
  background: rgba(255,255,255,0.2);
  border-radius: 4px;
  overflow: hidden;
}

.timer-bar {
  height: 100%;
  background: #4ade80;
  border-radius: 4px;
  transition: width 1s linear;
  width: 100%;
}

.timer-bar.warning {
  background: #fbbf24;
}

.timer-bar.danger {
  background: #f87171;
  animation: pulse 0.5s ease-in-out infinite alternate;
}

@keyframes pulse {
  from { opacity: 1; }
  to { opacity: 0.6; }
}

.timer-text {
  color: #fff;
  font-size: 1.3rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  min-width: 52px;
  text-align: right;
}

.game-stats {
  display: flex;
  justify-content: center;
}

.stat {
  color: rgba(255,255,255,0.9);
  font-size: 1.1rem;
  font-weight: 600;
}

/* --- Word Display --- */
.word-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.word-category-label {
  color: rgba(255,255,255,0.7);
  font-size: 0.9rem;
  margin-bottom: 16px;
}

.current-word {
  font-size: clamp(2.5rem, 12vw, 5rem);
  font-weight: 800;
  color: #fff;
  text-align: center;
  text-shadow: 0 2px 15px rgba(0,0,0,0.2);
  line-height: 1.3;
  padding: 0 16px;
  word-break: keep-all;
}

/* --- Game Actions --- */
.game-actions {
  flex-shrink: 0;
  display: grid;
  grid-template-columns: 1fr 1.5fr;
  gap: 12px;
  padding-bottom: 16px;
}

.btn-skip {
  background: rgba(255,255,255,0.2);
  color: #fff;
  padding: 20px 16px;
  font-size: 1rem;
  border-radius: 16px;
}

.btn-skip:disabled {
  opacity: 0.3;
}

.btn-correct {
  background: #4ade80;
  color: #065f46;
  padding: 20px 16px;
  font-size: 1.15rem;
  font-weight: 700;
  border-radius: 16px;
  box-shadow: 0 4px 15px rgba(74, 222, 128, 0.3);
}

.btn-correct:active {
  background: #22c55e;
}

/* --- Result View --- */
#view-result .container {
  padding-top: 48px;
}

.result-badge {
  text-align: center;
  font-size: 2rem;
  font-weight: 800;
  margin-bottom: 32px;
}

.result-badge.pass {
  color: #4ade80;
}

.result-badge.fail {
  color: #fbbf24;
}

.result-stats {
  display: flex;
  justify-content: center;
  gap: 32px;
  margin-bottom: 32px;
}

.result-stat {
  text-align: center;
}

.stat-num {
  font-size: 2.5rem;
  font-weight: 800;
  color: #fff;
}

.stat-label {
  color: rgba(255,255,255,0.7);
  font-size: 0.85rem;
  margin-top: 4px;
}

.result-section {
  margin-bottom: 24px;
}

.result-section h3 {
  color: rgba(255,255,255,0.9);
  font-size: 1rem;
  margin-bottom: 12px;
}

.result-word-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.result-word-tag {
  background: rgba(255,255,255,0.2);
  color: #fff;
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 0.85rem;
}

.result-word-tag.skipped {
  background: rgba(251,191,36,0.3);
  color: #fde68a;
}

.result-actions {
  margin-top: 32px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* --- Responsive --- */
@media (min-width: 768px) {
  .cat-grid {
    grid-template-columns: repeat(4, 1fr);
  }

  .container {
    max-width: 520px;
  }

  .game-actions {
    gap: 16px;
  }
}

@media (min-width: 1024px) {
  .container {
    max-width: 560px;
  }
}

/* --- Safe area for notch phones --- */
@supports (padding: env(safe-area-inset-bottom)) {
  .game-actions {
    padding-bottom: calc(16px + env(safe-area-inset-bottom));
  }

  #view-home .container,
  #view-result .container {
    padding-bottom: calc(24px + env(safe-area-inset-bottom));
  }
}

/* --- Setup View --- */
.setup-container {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
}
.setup-scroll-area {
  flex: 1;
  overflow-y: auto;
  padding-bottom: 24px;
}
.setup-title {
  color: #fff;
  font-size: 1rem;
  margin: 20px 0 12px;
  opacity: 0.9;
}
.pill-group {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
.pill-btn {
  background: rgba(255,255,255,0.15);
  touch-action: manipulation;
  border: 2px solid rgba(255,255,255,0.2);
  color: #fff;
  padding: 10px 16px;
  border-radius: 20px;
  font-size: 0.95rem;
  flex: 1;
  min-width: 60px;
  text-align: center;
  cursor: pointer;
  touch-action: manipulation;
  transition: transform 0.05s, background 0.05s, border-color 0.05s, color 0.05s;
  -webkit-tap-highlight-color: transparent;
}
.pill-btn.selected {
  background: #fff;
  color: #667eea;
  border-color: #fff;
  font-weight: bold;
}
.game-header-top {
  margin-bottom: 12px;
}
#btn-exit {
  width: auto;
  padding: 0 12px;
  height: 36px;
  font-size: 0.85rem;
}
