* { box-sizing: border-box; }

#theme-panel-body {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
#theme-controls .hint { margin-top: 6px; }
#theme-controls button { margin-top: 10px; }

#theme-preview-box {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 160px;
  background: repeating-conic-gradient(#251c38 0% 25%, #1c1528 0% 50%) 50% / 20px 20px;
  border-radius: 10px;
  overflow: hidden;
}
#theme-preview-box img {
  max-width: 70%;
  max-height: 70%;
  object-fit: contain;
  filter: drop-shadow(0 6px 16px rgba(0, 0, 0, 0.5));
}

.hidden { display: none !important; }

body {
  margin: 0;
  font-family: "Apple SD Gothic Neo", "Malgun Gothic", "Pretendard", sans-serif;
  background: #17131f;
  color: #eee7fb;
}

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  background: #241a35;
  border-bottom: 1px solid #3a2a55;
}

header h1 { font-size: 18px; margin: 0 16px; flex: 1; }

.back-link {
  flex: 0 0 auto;
  color: #cabde6;
  text-decoration: none;
  font-size: 13px;
  white-space: nowrap;
}
.back-link:hover { color: #fff; }

.badge {
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 13px;
  background: #3a2a55;
}

.badge.ok { background: #2f6f4f; }
.badge.error { background: #7a2f3a; }

main {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  padding: 20px;
  max-width: 1100px;
  margin: 0 auto;
}

.hub-main {
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding: 20px;
  max-width: 900px;
  margin: 0 auto;
}

.game-links {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.game-card {
  display: flex;
  align-items: center;
  gap: 16px;
  background: linear-gradient(145deg, #241a38, #1a1428);
  border: 1px solid #3a2a55;
  border-radius: 16px;
  padding: 18px 20px;
  text-decoration: none;
  color: #eee7fb;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.28);
  transition: border-color 150ms ease, transform 150ms ease, box-shadow 150ms ease;
}
.game-card:hover {
  border-color: #9a6fef;
  transform: translateY(-2px);
  box-shadow: 0 10px 28px rgba(154, 111, 239, 0.28);
}

.game-card-icon {
  flex: 0 0 auto;
  width: 52px;
  height: 52px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.12);
}
.game-card-icon svg { width: 28px; height: 28px; }
.game-card-icon.egg-icon { background: linear-gradient(160deg, #ffe9a8, #ffb020); }
.game-card-icon.quiz-icon { background: linear-gradient(160deg, #c9a8ff, #7f4fd6); }
.game-card-icon.updown-icon { background: linear-gradient(160deg, #a8d8ff, #4fa1e6); }
.game-card-icon.tower-race-icon { background: linear-gradient(160deg, #ffcf8a, #c97a3a); }

.game-card-body { flex: 1; min-width: 0; }
.game-card-title { font-size: 16px; font-weight: 800; color: #fff; margin-bottom: 6px; }
.new-badge {
  display: inline-block;
  vertical-align: middle;
  margin-left: 6px;
  padding: 2px 7px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0.5px;
  color: #2a1240;
  background: linear-gradient(160deg, #ffe9a8, #ff9ecf);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.4) inset, 0 0 10px rgba(255, 158, 207, 0.65);
  animation: newBadgePulse 1.6s ease-in-out infinite;
}
@keyframes newBadgePulse {
  0%, 100% { transform: scale(1); box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.4) inset, 0 0 6px rgba(255, 158, 207, 0.5); }
  50% { transform: scale(1.12); box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.5) inset, 0 0 14px rgba(255, 158, 207, 0.9); }
}
.game-card-desc {
  display: inline-block;
  font-size: 12px;
  color: #cabde6;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 999px;
  padding: 3px 10px;
}

.game-card-arrow {
  flex: 0 0 auto;
  width: 20px;
  height: 20px;
  color: #6a5c8a;
  transition: transform 150ms ease, color 150ms ease;
}
.game-card:hover .game-card-arrow { color: #eee7fb; transform: translateX(4px); }

.panel {
  background: #1f1830;
  border: 1px solid #3a2a55;
  border-radius: 12px;
  padding: 16px 20px;
}

.panel h2 {
  margin-top: 0;
  font-size: 15px;
  color: #ffd76a;
}

.hint { color: #9d8fc0; font-weight: normal; font-size: 12px; }

.hp-row { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }

.hp-bar-outer {
  flex: 1;
  height: 18px;
  background: #322346;
  border-radius: 999px;
  overflow: hidden;
}

.hp-bar-fill {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, #ff6a6a, #ffd76a);
  transition: width 200ms ease;
}

.hp-text { font-variant-numeric: tabular-nums; min-width: 80px; text-align: right; }

.status-grid {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 6px 12px;
  margin: 0;
  font-size: 14px;
}
.status-grid dt { color: #9d8fc0; }
.status-grid dd { margin: 0; }

.control-row { display: flex; gap: 8px; margin-bottom: 10px; flex-wrap: wrap; }

input[type="text"], input[type="number"] {
  background: #120e1c;
  border: 1px solid #3a2a55;
  color: #eee7fb;
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 14px;
}

#test-name { flex: 1; min-width: 140px; }

button {
  background: #3a2a55;
  color: #eee7fb;
  border: 1px solid #4a3670;
  border-radius: 8px;
  padding: 8px 14px;
  cursor: pointer;
  font-size: 14px;
}
button:hover { background: #4a3670; }
button.primary { background: #7f4fd6; border-color: #9a6fef; }
button.primary:hover { background: #9a6fef; }
button.danger { background: #7a2f3a; border-color: #9a3f4c; }
button.danger:hover { background: #9a3f4c; }

#settings-form fieldset {
  border: 1px solid #3a2a55;
  border-radius: 10px;
  margin-bottom: 12px;
}
#settings-form legend { color: #ffd76a; font-size: 13px; padding: 0 6px; }
#settings-form label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 13px;
  color: #cabde6;
  margin-bottom: 10px;
}

#save-status { margin-left: 10px; font-size: 13px; color: #8fdca0; }

#winners-panel, #log-panel, #quiz-panel, #updown-panel, #updown-log-panel, #updown-winners-panel { grid-column: 1 / -1; }

#updown-min, #updown-max, #updown-answer { flex: 0 0 140px; }
#updown-test-name { flex: 0 0 140px; }
#updown-test-text { flex: 1; min-width: 160px; }

#updown-overlay-url {
  color: #ffd76a;
  background: #120e1c;
  padding: 2px 6px;
  border-radius: 6px;
  word-break: break-all;
}

#updown-log-list {
  list-style: none;
  margin: 10px 0 0;
  padding: 0;
  max-height: 260px;
  overflow-y: auto;
  font-size: 13px;
}
#updown-log-list li {
  padding: 6px 4px;
  border-bottom: 1px solid #2a1f3e;
  display: flex;
  justify-content: space-between;
  gap: 10px;
}
#updown-log-list li.correct { color: #8fdca0; font-weight: 700; }

.radio-label { display: flex; align-items: center; gap: 6px; font-size: 14px; color: #cabde6; }

#quiz-answer, #quiz-test-text { flex: 1; min-width: 200px; }
#quiz-test-name { flex: 0 0 140px; }

#quiz-overlay-url {
  color: #ffd76a;
  background: #120e1c;
  padding: 2px 6px;
  border-radius: 6px;
  word-break: break-all;
}

#quiz-log-list {
  list-style: none;
  margin: 10px 0 0;
  padding: 0;
  max-height: 220px;
  overflow-y: auto;
  font-size: 13px;
}
#quiz-log-list li {
  padding: 6px 4px;
  border-bottom: 1px solid #2a1f3e;
  display: flex;
  justify-content: space-between;
  gap: 10px;
}
#quiz-log-list li.correct { color: #8fdca0; font-weight: 700; }

#winners-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  margin-top: 6px;
}
#winners-table th, #winners-table td {
  text-align: left;
  padding: 8px 10px;
  border-bottom: 1px solid #2a1f3e;
}
#winners-table th { color: #9d8fc0; font-weight: 600; font-size: 13px; }
#winners-table td.amount { color: #ffd76a; font-weight: 700; }
#winners-table tr.paid td { opacity: 0.5; }
#winners-table .empty-row td { text-align: center; color: #6a5c8a; padding: 16px; }
#log-list {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 260px;
  overflow-y: auto;
  font-size: 13px;
}
#log-list li {
  padding: 6px 4px;
  border-bottom: 1px solid #2a1f3e;
  display: flex;
  justify-content: space-between;
}
#log-list li.break { color: #ffd76a; font-weight: 700; }
#log-list li.reset { color: #9d8fc0; }

@media (max-width: 820px) {
  main { grid-template-columns: 1fr; }
}
