/* ============================================================
   PandaLotto · Modern Classic White Theme
   ============================================================ */

/* ---------- design tokens ---------- */
:root {
  --t1: #c9a96e;
  --t2: #9b8ec4;
  --t3: #e8a87c;
  --t4: #d4a5a5;
  --t5: #85b79d;
  --t0: #b0b0b0;

  --bg: #faf8f5;
  --bg-card: #ffffff;
  --bg-subtle: #f5f2ed;

  --text: #1a1a2e;
  --muted: #6b7280;
  --text-light: #9ca3af;

  --accent: #8b6f47;
  --accent-light: #c9a96e;
  --accent-dark: #6b5536;
  --accent-soft: rgba(139, 111, 71, 0.08);

  --border: #e8e4dd;
  --border-h: #d1ccc2;

  --shadow-sm: 0 1px 3px rgba(26, 26, 46, 0.06);
  --shadow-md: 0 4px 12px rgba(26, 26, 46, 0.08);
  --shadow-lg: 0 8px 24px rgba(26, 26, 46, 0.12);

  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 20px;
  --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);

  --font: 'Inter', 'Noto Sans KR', 'Apple SD Gothic Neo', 'Malgun Gothic', sans-serif;
  --font-serif: 'Cormorant Garamond', 'Noto Serif KR', Georgia, serif;
}

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

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

a {
  color: var(--accent);
  text-decoration: none;
  transition: color var(--transition);
}
a:hover {
  color: var(--accent-dark);
}

img {
  max-width: 100%;
  display: block;
}

.hidden,
[hidden] {
  display: none !important;
}

/* ---------- layout ---------- */
.wrap {
  max-width: 720px;
  margin: 0 auto;
  padding: 40px 20px 80px;
}

/* ---------- header ---------- */
header.site {
  text-align: center;
  margin-bottom: 32px;
}

.logo-link {
  color: inherit;
}

.site-title {
  font-family: var(--font-serif);
  font-size: clamp(2rem, 6vw, 3rem);
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.02em;
}

.site-subtitle {
  color: var(--muted);
  font-size: 0.95rem;
  margin-top: 4px;
  letter-spacing: 0.05em;
}

/* ---------- panels ---------- */
.panel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--transition);
}
.panel:hover {
  box-shadow: var(--shadow-md);
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}
.panel h3 {
  font-family: var(--font-serif);
  font-size: 1.3rem;
  font-weight: 600;
  color: var(--text);
}

/* ---------- buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 20px;
  border: 1px solid var(--border-h);
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  color: var(--text);
  font-family: var(--font);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
}
.btn:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.btn-primary:hover {
  background: var(--accent-dark);
  border-color: var(--accent-dark);
  color: #fff;
}

.btn-ghost {
  background: transparent;
  border-color: var(--border);
  color: var(--muted);
}
.btn-ghost:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.btn-sm {
  padding: 6px 14px;
  font-size: 0.825rem;
}

.btn-block {
  width: 100%;
  margin-top: 12px;
}

/* ---------- form fields ---------- */
.field {
  margin-bottom: 16px;
}
.field label {
  display: block;
  font-size: 0.85rem;
  font-weight: 500;
  margin-bottom: 6px;
  color: var(--text);
}
.field .hint {
  color: var(--text-light);
  font-weight: 400;
}
.field-hint {
  font-size: 0.75rem;
  color: var(--text-light);
  margin-top: 4px;
}

input[type='text'],
input[type='password'],
input[type='number'],
textarea {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border-h);
  border-radius: var(--radius-sm);
  background: var(--bg-subtle);
  color: var(--text);
  font-family: var(--font);
  font-size: 0.9rem;
  transition: all var(--transition);
}
input:focus,
textarea:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--bg-card);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

/* ---------- messages ---------- */
.error-msg {
  color: #c0524f;
  font-size: 0.85rem;
  margin-top: 8px;
}
.success-msg {
  color: var(--t5);
  font-size: 0.85rem;
  margin-top: 8px;
}
.muted {
  color: var(--muted);
  font-size: 0.85rem;
}

/* ---------- auth ---------- */
.auth-tabs {
  display: flex;
  gap: 0;
  margin-bottom: 24px;
  border-bottom: 2px solid var(--border);
}
.auth-tab {
  flex: 1;
  padding: 12px;
  border: none;
  background: transparent;
  color: var(--muted);
  font-family: var(--font);
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
}
.auth-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

/* ---------- page tabs (lotto / upload) ---------- */
.page-tabs {
  display: flex;
  gap: 0;
  margin-bottom: 24px;
  border-bottom: 2px solid var(--border);
}
.page-tab {
  flex: 1;
  padding: 14px 20px;
  border: none;
  background: transparent;
  color: var(--muted);
  font-family: var(--font);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  border-bottom: 3px solid transparent;
  margin-bottom: -2px;
}
.page-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}
.page-tab:hover:not(.active) {
  color: var(--accent-dark);
}
.auth-form {
  display: flex;
  flex-direction: column;
}

/* ---------- dashboard ---------- */
.dash-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 20px;
}
.dash-header h2 {
  font-family: var(--font-serif);
  font-size: 1.5rem;
  font-weight: 600;
}
.profile-grid {
  display: grid;
  gap: 12px;
  margin-bottom: 16px;
}
.profile-item {
  display: flex;
  gap: 12px;
  align-items: baseline;
}
.profile-label {
  font-size: 0.8rem;
  color: var(--muted);
  min-width: 80px;
}
.profile-value {
  font-weight: 500;
}

/* ---------- badges ---------- */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 100px;
  font-size: 0.75rem;
  font-weight: 600;
}
.badge-live {
  background: #fee2e2;
  color: #b91c1c;
}
.badge-offline {
  background: var(--bg-subtle);
  color: var(--muted);
}

/* ---------- stream card ---------- */
.stream-card {
  display: flex;
  gap: 16px;
  align-items: flex-start;
}
.stream-thumb {
  width: 120px;
  height: 68px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}
.stream-info-text {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.stream-title {
  font-weight: 500;
  font-size: 0.9rem;
}

/* ---------- quick links ---------- */
.quick-links {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
}
.link-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 20px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  text-align: center;
  font-size: 0.85rem;
  transition: all var(--transition);
}
.link-card:hover {
  border-color: var(--accent);
  box-shadow: var(--shadow-sm);
  transform: translateY(-2px);
}
.link-icon {
  font-size: 1.8rem;
}

/* ---------- gallery ---------- */
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
  margin: 16px 0;
}
.gallery-item {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--bg-card);
}
.gallery-item img {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
}
.gallery-meta {
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.gallery-name {
  font-size: 0.8rem;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ---------- nickname form ---------- */
.nick-row {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 10px;
}
.nick-row .nickname-input {
  flex: 1 1 auto;
  min-width: 0;
  width: auto;
}
.nick-row .quantity-input {
  flex: 0 0 64px;
  width: 64px;
}
.nick-row .remove-nick-btn {
  flex: 0 0 36px;
  width: 36px;
  height: 36px;
  padding: 0;
}

/* ---------- card section ---------- */
.card-section {
  margin-top: 24px;
}
#dailyInfo {
  text-align: center;
  color: var(--muted);
  margin-bottom: 20px;
  font-size: 0.85rem;
}

/* ---------- scratch card ---------- */
.cards-container {
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
  justify-content: center;
}
.card-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}
.card-owner {
  font-size: 0.8rem;
  color: var(--muted);
}
.card {
  position: relative;
  width: min(90vw, 280px);
  aspect-ratio: 1 / 1;
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-md);
  background: var(--bg-card);
}
.card-grid {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  background: linear-gradient(135deg, #fdfcfa, #f0ebe3);
}
.card-cell {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: clamp(28px, 9vw, 48px);
  border: 0.5px solid rgba(0, 0, 0, 0.04);
}
.card-cell.win-cell {
  animation: pop 0.4s ease;
  background: linear-gradient(135deg, rgba(201, 169, 110, 0.15), rgba(201, 169, 110, 0.05));
}
@keyframes pop {
  0% { transform: scale(0.5); }
  60% { transform: scale(1.15); }
  100% { transform: scale(1); }
}
.scratch-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  cursor: crosshair;
  touch-action: none;
  z-index: 5;
}
.card-overlay-result {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(4px);
  border-radius: var(--radius-lg);
}
.card-overlay-result.show {
  opacity: 1;
}
.card-overlay-result .result-badge {
  font-size: 1.4rem;
  font-weight: 700;
  margin-bottom: 4px;
}
.card-overlay-result .result-label {
  font-size: 0.9rem;
  color: var(--muted);
  padding: 0 16px;
}
.card-overlay-result.is-win {
  border: 2px solid var(--accent-light);
}
.card-overlay-result.is-win .result-badge {
  color: var(--accent);
}

/* ---------- buttons row ---------- */
.card-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  margin-top: 24px;
}

/* ---------- board ---------- */
.board-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}
.board-head h2 {
  font-family: var(--font-serif);
  font-size: 1.5rem;
}
#winnersCount {
  font-size: 0.85rem;
  color: var(--muted);
}

ul#winnersList {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.winner-row {
  display: grid;
  grid-template-columns: 70px 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 12px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-left: 4px solid var(--t0);
  border-radius: var(--radius-sm);
  animation: slidein 0.3s ease;
}
@keyframes slidein {
  from {
    opacity: 0;
    transform: translateX(-12px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}
.winner-row.rank-1 { border-left-color: var(--t1); }
.winner-row.rank-2 { border-left-color: var(--t2); }
.winner-row.rank-3 { border-left-color: var(--t3); }
.winner-row.rank-4 { border-left-color: var(--t4); }
.winner-row.rank-5 { border-left-color: var(--t5); }

.w-badge {
  font-size: 0.85rem;
  font-weight: 600;
}
.w-nick {
  font-weight: 500;
}
.w-label {
  font-size: 0.85rem;
  color: var(--muted);
}
.w-time {
  font-size: 0.75rem;
  color: var(--text-light);
}

/* ---------- overlay (OBS) ---------- */
body.overlay {
  background: transparent;
}
#overlayStage {
  position: relative;
  width: 100%;
  min-height: 100px;
}

.banner {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 24px;
  background: var(--bg-card);
  border: 2px solid var(--flash-color, var(--t5));
  border-radius: var(--radius);
  box-shadow: 0 0 24px color-mix(in srgb, var(--flash-color, var(--t5)) 30%, transparent),
    var(--shadow-lg);
  margin-bottom: 12px;
  opacity: 0;
  transform: translateY(20px) scale(0.97);
  transition: all 0.4s cubic-bezier(0.18, 0.9, 0.3, 1.35);
}
.banner.show {
  opacity: 1;
  transform: translateY(0) scale(1);
}
.banner .ov-rank {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--flash-color, var(--t5));
}
.banner .ov-nick {
  font-weight: 600;
  font-size: 1.1rem;
}
.banner .ov-label {
  color: var(--muted);
  font-size: 0.9rem;
}

/* overlay image display */
.overlay-image-wrap {
  display: flex;
  justify-content: center;
  align-items: center;
  margin-bottom: 12px;
  opacity: 0;
  transform: scale(0.95);
  transition: all 0.4s cubic-bezier(0.18, 0.9, 0.3, 1.35);
}
.overlay-image-wrap.show {
  opacity: 1;
  transform: scale(1);
}
.overlay-image-wrap img {
  max-width: 100%;
  max-height: 60vh;
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
}
.overlay-image-meta {
  text-align: center;
  color: #fff;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
  font-size: 0.85rem;
  margin-top: 8px;
}

/* ---------- upload zone ---------- */
.upload-zone {
  border: 2px dashed var(--border-h);
  border-radius: var(--radius);
  padding: 32px 20px;
  text-align: center;
  transition: all var(--transition);
  cursor: pointer;
}
.upload-zone:hover,
.upload-zone.dragover {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.upload-zone .upload-icon {
  font-size: 2.5rem;
  margin-bottom: 8px;
}
.upload-zone .upload-text {
  color: var(--muted);
  font-size: 0.9rem;
}

/* ---------- admin table ---------- */
table.tiers {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 20px;
}
table.tiers th {
  text-align: left;
  padding: 8px 10px;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--muted);
  border-bottom: 2px solid var(--border);
}
table.tiers td {
  padding: 10px;
  border-bottom: 1px solid var(--border);
}
.t-symbol {
  width: 60px;
  text-align: center;
  font-size: 1.2rem;
}
.t-prob-input {
  width: 80px;
}
.limit-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}
.limit-row label {
  min-width: 140px;
  font-size: 0.85rem;
}
.sum-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}
#sumIndicator {
  font-weight: 600;
  color: #c0524f;
}
#sumIndicator.ok {
  color: var(--t5);
}

/* BJ management list */
.bj-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.bj-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 12px;
  align-items: center;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.bj-row .bj-info {
  display: flex;
  flex-direction: column;
}
.bj-row .bj-name {
  font-weight: 500;
}
.bj-status {
  font-size: 0.75rem;
  padding: 2px 8px;
  border-radius: 100px;
  font-weight: 600;
}
.bj-status.pending { background: #fef3c7; color: #92400e; }
.bj-status.approved { background: #d1fae5; color: #065f46; }
.bj-status.rejected { background: #fee2e2; color: #991b1b; }
.bj-status.banned { background: #f3f4f6; color: #6b7280; }

/* ---------- responsive ---------- */
@media (max-width: 540px) {
  .wrap {
    padding: 24px 16px 60px;
  }
  .winner-row {
    grid-template-columns: 60px 1fr;
  }
  .winner-row .w-time {
    grid-column: 1 / -1;
  }
  .quick-links {
    grid-template-columns: repeat(2, 1fr);
  }
}
