:root {
  --primary: #f39c12;
  --primary-dark: #d35400;
  --primary-light: #fef5e7;
  --bg-gradient: linear-gradient(135deg, #181c24 0%, #10131a 100%);
  --card-bg: rgba(26, 32, 44, 0.85);
  --card-border: rgba(255, 255, 255, 0.08);
  --text-main: #f5f6fa;
  --text-sub: #8a9ba8;
  --accent-gold: #f1c40f;
  --success: #2ecc71;
  --danger: #e74c3c;
  --warning: #f39c12;
  --shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.45);
  --radius: 14px;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Pretendard", "Segoe UI", Roboto, sans-serif;
  background: var(--bg-gradient);
  color: var(--text-main);
  min-height: 100vh;
  padding: 24px 16px 60px;
  position: relative;
  overflow-x: hidden;
  word-break: keep-all;
}

.container {
  max-width: 1140px;
  margin: 0 auto;
}

/* Header */
header {
  text-align: center;
  margin-bottom: 24px;
}

.title-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(243, 156, 18, 0.15);
  color: #ffaa2b;
  border: 1px solid rgba(243, 156, 18, 0.3);
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 0.88rem;
  font-weight: 600;
  margin-bottom: 10px;
}

h1 {
  font-size: 2.2rem;
  font-weight: 800;
  background: linear-gradient(135deg, #ffffff 40%, #ffc87a 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 8px;
  letter-spacing: -0.5px;
}

.subtitle {
  color: var(--text-sub);
  font-size: 0.98rem;
}

/* Dashboard Panel */
.dashboard-panel {
  background: var(--card-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 20px 24px;
  margin-bottom: 24px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.stats-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
}

.stat-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.stat-label {
  font-size: 0.82rem;
  color: var(--text-sub);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.stat-value {
  font-size: 1.6rem;
  font-weight: 800;
  color: #fff;
  display: flex;
  align-items: baseline;
  gap: 4px;
}

.stat-value .total {
  font-size: 1rem;
  color: var(--text-sub);
  font-weight: 500;
}

/* Stopwatch Timer */
.timer-box {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(0, 0, 0, 0.4);
  padding: 10px 18px;
  border-radius: 12px;
  border: 1px solid rgba(243, 156, 18, 0.25);
  box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.4);
}

.timer-icon {
  font-size: 1.25rem;
}

#timerDisplay {
  font-variant-numeric: tabular-nums;
  font-weight: 800;
  font-size: 1.45rem;
  color: #f1c40f;
  letter-spacing: 1px;
}

.timer-sec-badge {
  font-size: 0.9rem;
  color: var(--text-sub);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.controls-group {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.btn {
  border: none;
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  padding: 9px 15px;
  border-radius: 8px;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s ease;
}

.btn:hover {
  background: rgba(255, 255, 255, 0.16);
  transform: translateY(-1px);
}

.btn-start {
  background: linear-gradient(135deg, #2ecc71, #27ae60);
  color: #ffffff;
  border: 1px solid rgba(46, 204, 113, 0.4);
  box-shadow: 0 4px 14px rgba(46, 204, 113, 0.4);
  animation: pulseStart 2.2s infinite;
}

.btn-start:hover {
  background: linear-gradient(135deg, #27ae60, #219653);
  transform: translateY(-2px);
  box-shadow: 0 6px 18px rgba(46, 204, 113, 0.6);
}

@keyframes pulseStart {
  0%, 100% {
    box-shadow: 0 4px 14px rgba(46, 204, 113, 0.4);
  }
  50% {
    box-shadow: 0 0 0 6px rgba(46, 204, 113, 0.2), 0 4px 14px rgba(46, 204, 113, 0.4);
  }
}

.btn-danger {
  background: rgba(231, 76, 60, 0.16);
  color: #ff7675;
  border: 1px solid rgba(231, 76, 60, 0.35);
}

.btn-danger:hover {
  background: rgba(231, 76, 60, 0.3);
  color: #fff;
}

/* Progress bar */
.progress-container {
  width: 100%;
  background: rgba(0, 0, 0, 0.35);
  height: 12px;
  border-radius: 999px;
  overflow: hidden;
  position: relative;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #f39c12, #e67e22, #2ecc71);
  border-radius: 999px;
  transition: width 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 0 12px rgba(243, 156, 18, 0.5);
}

/* Input Section */
.input-section {
  position: sticky;
  top: 16px;
  z-index: 100;
  margin-bottom: 24px;
}

.input-wrapper {
  position: relative;
  max-width: 660px;
  margin: 0 auto;
}

.quiz-input {
  width: 100%;
  padding: 16px 20px;
  background: #232a37;
  border: 2px solid rgba(243, 156, 18, 0.4);
  border-radius: 14px;
  font-size: 1.15rem;
  color: #ffffff;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
  transition: all 0.2s ease;
  outline: none;
}

.quiz-input:focus {
  border-color: #f39c12;
  box-shadow: 0 0 0 4px rgba(243, 156, 18, 0.25), 0 12px 32px rgba(0, 0, 0, 0.55);
}

.quiz-input::placeholder {
  color: #718093;
  font-size: 1rem;
}

/* Toast Message */
.toast-container {
  min-height: 28px;
  display: flex;
  justify-content: center;
  align-items: center;
  margin-top: 8px;
}

.toast {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 16px;
  border-radius: 999px;
  font-size: 0.88rem;
  font-weight: 500;
  opacity: 0;
  transform: translateY(-6px);
  transition: all 0.25s ease;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.toast.success {
  background: rgba(46, 204, 113, 0.2);
  color: #2ecc71;
  border: 1px solid rgba(46, 204, 113, 0.4);
}

.toast.warning {
  background: rgba(243, 156, 18, 0.2);
  color: #f39c12;
  border: 1px solid rgba(243, 156, 18, 0.4);
}

.toast.info {
  background: rgba(52, 152, 219, 0.2);
  color: #74b9ff;
  border: 1px solid rgba(52, 152, 219, 0.4);
}

/* Mystery Grid Section (No Categories) */
.grid-section {
  background: rgba(24, 29, 39, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
  transition: background 0.3s ease, border-color 0.3s ease;
}

.mystery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(88px, 1fr));
  gap: 8px;
}

/* Job Card (Compact Size) */
.job-card {
  min-height: 104px;
  background: rgba(33, 40, 54, 0.8);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 9px;
  padding: 5px 4px 6px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: center;
  position: relative;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  user-select: none;
}

.job-card .job-num {
  align-self: flex-start;
  font-size: 0.62rem;
  font-weight: 700;
  color: #576574;
  letter-spacing: 0.3px;
  line-height: 1;
}

/* Locked Card & Mystery Icon */
.job-card.locked {
  border-style: dashed;
  border-color: rgba(255, 255, 255, 0.12);
  background: rgba(18, 22, 30, 0.5);
}

.job-card .mystery-icon {
  width: 52px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.35rem;
  font-weight: 800;
  color: #485460;
  background: rgba(0, 0, 0, 0.25);
  border-radius: 7px;
  border: 1px dashed rgba(255, 255, 255, 0.08);
  margin: 2px 0;
}

.job-card.locked .job-name {
  color: #485460;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.5px;
}

/* Character Image */
.job-card .job-img {
  width: 58px;
  height: 48px;
  object-fit: contain;
  margin: 2px 0;
  filter: drop-shadow(0 3px 6px rgba(0, 0, 0, 0.35));
  transition: transform 0.2s ease;
}

.job-card.revealed:hover .job-img {
  transform: scale(1.1);
}

/* Revealed Card */
.job-card.revealed {
  background: rgba(38, 48, 66, 0.95);
  border: 1px solid rgba(46, 204, 113, 0.45);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
  animation: popReveal 0.35s ease-out;
}

@keyframes popReveal {
  0% { transform: scale(0.85); opacity: 0.5; }
  50% { transform: scale(1.08); }
  100% { transform: scale(1); opacity: 1; }
}

.job-card.revealed .job-num {
  color: #2ecc71;
}

.job-card.revealed .job-name {
  font-size: 0.78rem;
  font-weight: 700;
  color: #ffffff;
  text-align: center;
  word-break: keep-all;
  line-height: 1.15;
  letter-spacing: -0.2px;
}

/* Surrendered / Missed Card */
.job-card.missed {
  background: rgba(231, 76, 60, 0.15);
  border: 1px solid rgba(231, 76, 60, 0.45);
  animation: fadeIn 0.4s ease;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.job-card.missed .job-img {
  filter: grayscale(35%) drop-shadow(0 2px 4px rgba(231, 76, 60, 0.25));
}

.job-card.missed .job-num {
  color: #ff7675;
}

.job-card.missed .job-name {
  font-size: 0.76rem;
  font-weight: 700;
  color: #ff7675;
  text-align: center;
  word-break: keep-all;
  line-height: 1.15;
  letter-spacing: -0.2px;
}

/* Modal Overlay & Card */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.82);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
  padding: 16px;
}

.modal-overlay.show {
  opacity: 1;
  pointer-events: auto;
}

.modal-card {
  position: relative;
  background: #232a37;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 20px;
  padding: 34px 28px 28px;
  max-width: 520px;
  width: 100%;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
  transform: translateY(20px);
  transition: transform 0.3s ease;
}

.modal-close-btn {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.14);
  color: #a4b0be;
  font-size: 1.05rem;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 10;
}

.modal-close-btn:hover {
  background: rgba(231, 76, 60, 0.25);
  color: #ff7675;
  border-color: rgba(231, 76, 60, 0.5);
  transform: rotate(90deg) scale(1.08);
}

.modal-overlay.show .modal-card {
  transform: translateY(0);
}

.modal-icon {
  font-size: 3.5rem;
  margin-bottom: 12px;
}

.modal-title {
  font-size: 1.7rem;
  font-weight: 800;
  color: #fff;
  margin-bottom: 8px;
}

.modal-desc {
  color: var(--text-sub);
  font-size: 0.95rem;
  margin-bottom: 24px;
  word-break: keep-all;
  line-height: 1.5;
}

.modal-rank-box {
  background: rgba(243, 156, 18, 0.12);
  border: 1px solid rgba(243, 156, 18, 0.3);
  border-radius: 12px;
  padding: 14px;
  margin-bottom: 20px;
}

.modal-rank-title {
  font-size: 0.8rem;
  color: #ffc87a;
  text-transform: uppercase;
  margin-bottom: 4px;
}

.modal-rank-name {
  font-size: 1.35rem;
  font-weight: 800;
  color: #f1c40f;
  word-break: keep-all;
}

.modal-stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 24px;
}

.modal-stat-box {
  background: rgba(0, 0, 0, 0.25);
  border-radius: 10px;
  padding: 12px;
}

.modal-stat-val {
  font-size: 1.35rem;
  font-weight: 700;
  color: #fff;
  white-space: nowrap;
}

.modal-stat-sub {
  font-size: 0.8rem;
  color: var(--text-sub);
}

/* Modal Nickname Input */
.modal-nickname-wrap {
  margin-bottom: 20px;
  text-align: left;
}

.modal-nickname-label {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-sub);
  margin-bottom: 6px;
  letter-spacing: 0.3px;
}

.modal-nickname-input {
  width: 100%;
  padding: 10px 14px;
  background: rgba(0, 0, 0, 0.28);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 8px;
  font-size: 0.95rem;
  color: #ffffff;
  outline: none;
  transition: all 0.2s ease;
}

.modal-nickname-input:focus {
  border-color: #f39c12;
  background: rgba(0, 0, 0, 0.4);
  box-shadow: 0 0 0 3px rgba(243, 156, 18, 0.2);
}

.modal-nickname-input::placeholder {
  color: #636e72;
  font-size: 0.88rem;
}

.modal-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
  align-items: stretch;
}

.modal-actions .btn {
  white-space: nowrap;
  padding: 12px 14px;
  font-size: 0.93rem;
  flex: 1 1 0;
  justify-content: center;
}

.btn-primary {
  background: linear-gradient(135deg, #f39c12, #e67e22);
  color: #fff;
  padding: 12px 24px;
  border-radius: 10px;
  font-size: 1rem;
  font-weight: 700;
  box-shadow: 0 4px 15px rgba(243, 156, 18, 0.4);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(243, 156, 18, 0.6);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  padding: 12px 20px;
  border-radius: 10px;
  font-size: 1rem;
  font-weight: 600;
}

/* Confetti Canvas */
#confettiCanvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
  z-index: 999;
}

/* Footer */
footer {
  text-align: center;
  margin-top: 44px;
  color: #718093;
  font-size: 0.92rem;
  font-weight: 600;
  letter-spacing: 0.5px;
}

@media (max-width: 640px) {
  h1 {
    font-size: 1.6rem;
  }
  .mystery-grid {
    grid-template-columns: repeat(auto-fill, minmax(78px, 1fr));
    gap: 6px;
  }
  .job-card {
    min-height: 96px;
    padding: 4px 3px 6px;
  }
  .job-card .mystery-icon {
    width: 46px;
    height: 44px;
    font-size: 1.2rem;
  }
  .job-card .job-img {
    width: 52px;
    height: 44px;
  }
  .job-card .job-name {
    font-size: 0.72rem;
  }
  .stats-row {
    flex-direction: column;
    align-items: stretch;
  }
  .controls-group {
    justify-content: space-between;
  }
}

@media (max-width: 480px) {
  .modal-card {
    padding: 28px 18px 20px;
  }
  .modal-actions {
    flex-direction: column;
  }
  .modal-actions .btn {
    width: 100%;
  }
}

/* ==================== 화이트 (라이트) 모드 테마 ==================== */
body.light-mode {
  background: linear-gradient(135deg, #f4f6fb 0%, #e7ecf5 100%);
  color: #2d3436;
}

body.light-mode h1 {
  background: linear-gradient(135deg, #2d3436 40%, #e67e22 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

body.light-mode .title-badge {
  background: rgba(243, 156, 18, 0.14);
  color: #d35400;
  border-color: rgba(243, 156, 18, 0.35);
}

body.light-mode .dashboard-panel {
  background: rgba(255, 255, 255, 0.88);
  border-color: rgba(0, 0, 0, 0.08);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.07);
}

body.light-mode .stat-value {
  color: #1e272e;
}

body.light-mode .stat-label {
  color: #636e72;
}

body.light-mode .stat-value .total {
  color: #8395a7;
}

body.light-mode .timer-box {
  background: #f1f3f8;
  border-color: rgba(243, 156, 18, 0.35);
  box-shadow: inset 0 1px 4px rgba(0, 0, 0, 0.05);
}

body.light-mode #timerDisplay {
  color: #d35400;
}

body.light-mode .timer-sec-badge {
  color: #718093;
}

body.light-mode .btn {
  background: #ffffff;
  color: #2f3640;
  border: 1px solid rgba(0, 0, 0, 0.14);
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.04);
}

body.light-mode .btn:hover {
  background: #f8f9fa;
  border-color: rgba(0, 0, 0, 0.25);
}

body.light-mode .btn-danger {
  background: #fff5f5;
  color: #e74c3c;
  border-color: rgba(231, 76, 60, 0.35);
}

body.light-mode .btn-danger:hover {
  background: #fee2e2;
  color: #c0392b;
}

body.light-mode .btn-secondary {
  background: #edf2f7;
  color: #2d3436;
  border-color: rgba(0, 0, 0, 0.1);
}

body.light-mode .progress-container {
  background: #e2e8f0;
  border-color: rgba(0, 0, 0, 0.08);
}

body.light-mode .quiz-input {
  background: #ffffff;
  color: #1e272e;
  border-color: rgba(243, 156, 18, 0.55);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.07);
}

body.light-mode .quiz-input:focus {
  border-color: #e67e22;
  box-shadow: 0 0 0 4px rgba(243, 156, 18, 0.25), 0 10px 28px rgba(0, 0, 0, 0.1);
}

body.light-mode .quiz-input::placeholder {
  color: #a4b0be;
}

body.light-mode .grid-section {
  background: rgba(255, 255, 255, 0.75);
  border-color: rgba(0, 0, 0, 0.07);
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.05);
}

body.light-mode .job-card.locked {
  background: #ffffff;
  border-color: #dcdde1;
}

body.light-mode .job-card .mystery-icon {
  background: #f1f2f6;
  color: #95a5a6;
  border-color: #dcdde1;
}

body.light-mode .job-card.locked .job-num {
  color: #95a5a6;
}

body.light-mode .job-card.locked .job-name {
  color: #95a5a6;
}

body.light-mode .job-card.revealed {
  background: #ffffff;
  border-color: #2ecc71;
  box-shadow: 0 4px 14px rgba(46, 204, 113, 0.25);
}

body.light-mode .job-card.revealed .job-name {
  color: #1e272e;
}

body.light-mode .job-card.missed {
  background: #fff5f5;
  border-color: #e74c3c;
  box-shadow: 0 4px 12px rgba(231, 76, 60, 0.2);
}

body.light-mode .job-card.missed .job-name {
  color: #e74c3c;
}

body.light-mode .modal-card {
  background: #ffffff;
  color: #2d3436;
  border-color: rgba(0, 0, 0, 0.1);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
}

body.light-mode .modal-title {
  color: #1e272e;
}

body.light-mode .modal-desc {
  color: #57606f;
}

body.light-mode .modal-rank-box {
  background: #fff9ed;
  border-color: rgba(243, 156, 18, 0.45);
}

body.light-mode .modal-rank-title {
  color: #d35400;
}

body.light-mode .modal-rank-name {
  color: #e67e22;
}

body.light-mode .modal-stat-box {
  background: #f4f6fa;
}

body.light-mode .modal-stat-val {
  color: #1e272e;
}

body.light-mode .modal-stat-sub {
  color: #636e72;
}

body.light-mode .modal-close-btn {
  background: #f1f2f6;
  color: #57606f;
  border-color: #dcdde1;
}

body.light-mode .modal-nickname-label {
  color: #636e72;
}

body.light-mode .modal-nickname-input {
  background: #f1f3f8;
  border-color: #dcdde1;
  color: #2d3436;
}

body.light-mode .modal-nickname-input:focus {
  border-color: #f39c12;
  background: #ffffff;
  box-shadow: 0 0 0 3px rgba(243, 156, 18, 0.2);
}

body.light-mode .modal-nickname-input::placeholder {
  color: #a4b0be;
}

body.light-mode footer {
  color: #8395a7;
}
