:root {
  --bg-color: #f9fbff;
  --app-bg: #ffffff;
  --text-main: #1f2937;
  --text-muted: #4b5563;
  --card-bg: linear-gradient(180deg, #eef4ff 0%, #ffffff 100%);
  --card-border: #dae2f2;
  --btn-secondary-bg: #e2e8f0;
  --btn-secondary-text: #1f2937;
  --info-text: #475569;
  --ball-shadow: rgba(29, 78, 216, 0.24);
  --shell-shadow: rgba(15, 23, 42, 0.12);
  --input-bg: #ffffff;
  --input-border: #dae2f2;
  --input-text: #1f2937;
  
  color-scheme: light;
  font-family: 'Pretendard', system-ui, sans-serif;
  background: var(--bg-color);
  color: var(--text-main);
  line-height: 1.5;
}

[data-theme="dark"] {
  --bg-color: #0f172a;
  --app-bg: #1e293b;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --card-bg: linear-gradient(180deg, #334155 0%, #1e293b 100%);
  --card-border: #334155;
  --btn-secondary-bg: #334155;
  --btn-secondary-text: #f8fafc;
  --info-text: #94a3b8;
  --ball-shadow: rgba(0, 0, 0, 0.4);
  --shell-shadow: rgba(0, 0, 0, 0.3);
  --input-bg: #334155;
  --input-border: #475569;
  --input-text: #f8fafc;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  transition: background-color 0.3s ease, color 0.3s ease;
}

body {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 40px 24px;
}

.top-nav {
  position: fixed;
  top: 20px;
  right: 80px; /* Space for theme toggle */
  display: flex;
  gap: 12px;
  z-index: 100;
}

.small-link {
  padding: 8px 16px;
  border-radius: 999px;
  background: var(--app-bg);
  border: 1px solid var(--card-border);
  color: #2563eb;
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 600;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
  transition: all 0.2s ease;
}

.small-link:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.1);
  background: var(--card-bg);
}

.theme-toggle {
  position: fixed;
  top: 20px;
  right: 20px;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 1px solid var(--card-border);
  background: var(--app-bg);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  z-index: 100;
  padding: 0;
  transition: all 0.3s ease;
}

.theme-toggle .moon-icon { display: none; }
[data-theme="dark"] .theme-toggle .sun-icon { display: none; }
[data-theme="dark"] .theme-toggle .moon-icon { display: block; }

.app-shell {
  width: min(100%, 720px);
  background: var(--app-bg);
  border-radius: 32px;
  box-shadow: 0 30px 80px var(--shell-shadow);
  padding: 40px;
  transition: background-color 0.3s ease, box-shadow 0.3s ease;
}

.app-header {
  display: none; /* Hide old back link header */
}

.hero {
  text-align: center;
  margin-bottom: 32px;
}

.hero h1 { margin: 0; font-size: 2.5rem; }
.hero p { color: var(--text-muted); margin-top: 8px; }

/* Portal Styles */
.portal-nav {
  display: grid;
  gap: 20px;
  margin-bottom: 40px;
}

.portal-card {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 24px;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 20px;
  text-decoration: none;
  color: inherit;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.portal-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 30px var(--shell-shadow);
}

.card-icon { font-size: 3rem; }
.card-content h3 { margin: 0 0 4px; color: #2563eb; }
.card-content p { margin: 0; font-size: 0.95rem; color: var(--text-muted); }

/* Feature Specifics */
.lotto-card, .classifier-container {
  padding: 32px;
  border-radius: 24px;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  margin-bottom: 32px;
}

.primary-btn, .secondary-btn {
  border: none;
  border-radius: 999px;
  padding: 14px 28px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all .2s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: inherit;
}

.primary-btn { background: #2563eb; color: white; box-shadow: 0 10px 25px rgba(37, 99, 235, 0.2); }
.secondary-btn { background: var(--btn-secondary-bg); color: var(--btn-secondary-text); }
.primary-btn:hover { transform: translateY(-2px); box-shadow: 0 15px 35px rgba(37, 99, 235, 0.3); }

.controls, .classifier-controls { display: flex; gap: 16px; justify-content: center; margin-bottom: 24px; }

.balls { display: flex; flex-wrap: wrap; justify-content: center; gap: 14px; min-height: 80px; }
.ball {
  width: 60px; height: 60px; display: grid; place-items: center; border-radius: 50%;
  font-weight: 700; color: white; box-shadow: 0 8px 20px var(--ball-shadow);
}
.ball.yellow { background: #fbbf24; color: #1f2937; }
.ball.green { background: #10b981; }
.ball.blue { background: #3b82f6; }
.ball.red { background: #ef4444; }
.ball.gray { background: #6b7280; }

.video-container {
  width: 100%; aspect-ratio: 16/9; background: #000; border-radius: 16px;
  overflow: hidden; display: flex; align-items: center; justify-content: center; margin-bottom: 24px;
}
.placeholder-text { color: #94a3b8; text-align: center; }

.label-container { display: flex; flex-direction: column; gap: 16px; }
.prediction-bar { display: flex; flex-direction: column; gap: 6px; }
.bar-header { display: flex; justify-content: space-between; font-weight: 600; font-size: 0.9rem; }
.bar-outer { width: 100%; height: 12px; background: var(--btn-secondary-bg); border-radius: 6px; overflow: hidden; }
.bar-inner { height: 100%; background: #2563eb; transition: width 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275); }

/* Common UI */
.contact-section, .comments-section { border-top: 1px solid var(--card-border); padding-top: 40px; margin-top: 40px; }
.contact-form { display: grid; gap: 20px; max-width: 500px; margin: 0 auto; }
.form-group { display: grid; gap: 8px; }
input, textarea {
  width: 100%; padding: 14px 18px; border-radius: 14px; border: 1px solid var(--input-border);
  background: var(--input-bg); color: var(--input-text); font-family: inherit; transition: all 0.2s ease;
}
input:focus, textarea:focus { outline: none; border-color: #2563eb; box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.1); }
.full-width { width: 100%; }

.info { margin-top: 40px; padding-top: 32px; border-top: 1px solid var(--card-border); color: var(--info-text); }
.info ol { padding-left: 20px; }

@media (max-width: 600px) {
  .app-shell { padding: 24px; }
  .hero h1 { font-size: 2rem; }
  .portal-card { flex-direction: column; text-align: center; }
  .top-nav { right: 70px; gap: 8px; }
  .small-link { padding: 6px 12px; font-size: 0.75rem; }
}
