/* ===== LogicPuzzleDaily - Style ===== */
:root {
  --bg: #F8F9FA;
  --card: #FFFFFF;
  --text: #1A1A2E;
  --primary: #6C63FF;
  --primary-hover: #5A52E0;
  --success: #38B000;
  --danger: #E63946;
  --unknown: #CED4DA;
  --gray-light: #E9ECEF;
  --gray-text: #6C757D;
  --radius: 12px;
  --radius-sm: 8px;
}

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

html { font-size: 16px; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
  padding-bottom: 80px;
}

/* ===== Layout ===== */
.container { max-width: 600px; margin: 0 auto; padding: 20px 16px; }
.page { display: none; }
.page.active { display: block; }

/* ===== Header ===== */
.app-header {
  text-align: center;
  padding: 24px 0 16px;
}
.app-header h1 {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--primary);
}
.app-header .subtitle {
  font-size: 0.85rem;
  color: var(--gray-text);
  margin-top: 4px;
}

/* ===== Cards ===== */
.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}
.card-title {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 12px;
}

/* ===== Buttons ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 12px 24px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  text-decoration: none;
  gap: 8px;
}
.btn:active { transform: scale(0.97); }
.btn-primary {
  background: var(--primary);
  color: #fff;
}
.btn-primary:hover { background: var(--primary-hover); }
.btn-primary:disabled {
  background: var(--unknown);
  cursor: not-allowed;
}
.btn-outline {
  background: transparent;
  border: 2px solid var(--primary);
  color: var(--primary);
}
.btn-outline:hover { background: var(--primary); color: #fff; }
.btn-block { width: 100%; }
.btn-sm { padding: 8px 16px; font-size: 0.85rem; }
.btn-ghost {
  background: transparent;
  color: var(--gray-text);
  padding: 8px 12px;
}
.btn-ghost:hover { background: var(--gray-light); }

/* ===== Form ===== */
.form-group { margin-bottom: 16px; }
.form-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--gray-text);
}
.form-input {
  width: 100%;
  padding: 12px 14px;
  border: 2px solid var(--gray-light);
  border-radius: var(--radius-sm);
  font-size: 1rem;
  outline: none;
  transition: border-color 0.15s;
}
.form-input:focus { border-color: var(--primary); }
.form-error {
  color: var(--danger);
  font-size: 0.8rem;
  margin-top: 4px;
}

/* ===== Nav ===== */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--card);
  display: flex;
  border-top: 1px solid var(--gray-light);
  z-index: 100;
  max-width: 600px;
  margin: 0 auto;
}
.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 8px 0 6px;
  cursor: pointer;
  color: var(--gray-text);
  font-size: 0.7rem;
  transition: color 0.15s;
  border: none;
  background: none;
}
.nav-item svg {
  width: 24px;
  height: 24px;
  margin-bottom: 2px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
}
.nav-item.active { color: var(--primary); }

/* ===== Game Grid ===== */
.puzzle-grid {
  display: grid;
  gap: 8px;
  margin: 16px 0;
}
.grid-cell {
  background: var(--unknown);
  border-radius: var(--radius);
  padding: 12px 8px;
  text-align: center;
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
  min-height: 60px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.grid-cell .cell-name {
  font-weight: 700;
  font-size: 0.9rem;
}
.grid-cell .cell-job {
  font-size: 0.7rem;
  color: rgba(0,0,0,0.5);
  margin-top: 2px;
}
.grid-cell.cell-innocent {
  background: var(--success);
  color: #fff;
}
.grid-cell.cell-innocent .cell-job { color: rgba(255,255,255,0.7); }
.grid-cell.cell-criminal {
  background: var(--danger);
  color: #fff;
}
.grid-cell.cell-criminal .cell-job { color: rgba(255,255,255,0.7); }
.grid-cell:active { transform: scale(0.95); }

/* ===== Clues ===== */
.clue-card {
  background: var(--gray-light);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  margin-bottom: 8px;
  font-size: 0.9rem;
  line-height: 1.4;
}
.clue-num {
  display: inline-block;
  width: 22px;
  height: 22px;
  background: var(--primary);
  color: #fff;
  border-radius: 50%;
  text-align: center;
  line-height: 22px;
  font-size: 0.7rem;
  font-weight: 700;
  margin-right: 8px;
}

/* ===== Stats ===== */
.stat-row {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid var(--gray-light);
  font-size: 0.9rem;
}
.stat-row:last-child { border-bottom: none; }
.stat-label { color: var(--gray-text); }
.stat-value { font-weight: 600; }

/* ===== History ===== */
.history-item {
  padding: 12px 16px;
  border-bottom: 1px solid var(--gray-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.history-item:last-child { border-bottom: none; }
.history-date { font-size: 0.85rem; color: var(--gray-text); }
.history-result { font-size: 0.85rem; font-weight: 600; }
.history-result .correct { color: var(--success); }
.history-result .wrong { color: var(--danger); }

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 600;
}
.badge-easy { background: #D3F9D8; color: #2B8A3E; }
.badge-medium { background: #FFF3BF; color: #995E00; }
.badge-hard { background: #FFD8D8; color: #C92A2A; }

/* ===== Level Card ===== */
.level-card {
  text-align: center;
  padding: 32px 20px;
}
.level-icon {
  width: 64px;
  height: 64px;
  background: var(--primary);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 12px;
  color: #fff;
  font-size: 1.5rem;
}
.level-name {
  font-size: 1.2rem;
  font-weight: 700;
}

/* ===== Streak ===== */
.streak-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: #FFF3CD;
  color: #856404;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
}

/* ===== Result Page ===== */
.result-summary {
  text-align: center;
  padding: 32px 20px;
}
.result-score {
  font-size: 3rem;
  font-weight: 800;
  color: var(--primary);
}
.result-label {
  color: var(--gray-text);
  font-size: 0.9rem;
  margin-top: 4px;
}

/* ===== Toast ===== */
.toast {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--text);
  color: #fff;
  padding: 12px 24px;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  z-index: 999;
  opacity: 0;
  transition: opacity 0.3s;
  pointer-events: none;
}
.toast.show { opacity: 1; }

/* ===== Loading ===== */
.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--gray-light);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  margin: 40px auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== Result Grid ===== */
.result-grid {
  display: grid;
  gap: 6px;
  margin: 16px 0;
}
.result-cell {
  padding: 8px 4px;
  border-radius: var(--radius-sm);
  text-align: center;
  font-size: 0.75rem;
  min-height: 48px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.result-cell .cell-name { font-weight: 700; }
.result-cell.correct { background: rgba(56, 176, 0, 0.15); color: var(--success); }
.result-cell.wrong { background: rgba(230, 57, 70, 0.15); color: var(--danger); }
.result-cell.unanswered { background: var(--gray-light); color: var(--gray-text); }

/* ===== Responsive ===== */
@media (max-width: 400px) {
  .container { padding: 12px; }
  .grid-cell { min-height: 50px; padding: 8px 4px; }
  .grid-cell .cell-name { font-size: 0.8rem; }
  .grid-cell .cell-job { font-size: 0.6rem; }
}
