:root {
  --bg: #f8f9fa;
  --panel: #ffffff;
  --panel-solid: #ffffff;
  --text: #1a1d23;
  --muted: #64748b;
  --line: #e2e8f0;
  --accent: #3b82f6;
  --accent-strong: #2563eb;
  --shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  --button-ghost: #f1f5f9;
}

:root[data-theme='dark'] {
  --bg: #0f172a;
  --panel: #1e293b;
  --panel-solid: #1e293b;
  --text: #f8fafc;
  --muted: #94a3b8;
  --line: #334155;
  --accent: #60a5fa;
  --accent-strong: #3b82f6;
  --shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.3), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
  --button-ghost: #334155;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--text);
  background-color: var(--bg);
  transition: background-color 0.3s ease, color 0.3s ease;
  line-height: 1.5;
}

.app-shell {
  width: min(800px, calc(100% - 40px));
  margin: 0 auto;
  padding: 60px 0 100px;
}

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

.hero-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 32px;
}

.eyebrow {
  margin: 0;
  letter-spacing: 0.1em;
  font-size: 0.75rem;
  font-weight: 800;
  text-transform: uppercase;
  color: var(--accent);
}

.theme-toggle {
  font-size: 0.85rem;
  padding: 8px 16px;
  background: var(--button-ghost);
  border: 1px solid var(--line);
  color: var(--text);
}

h1 {
  font-size: clamp(2rem, 5vw, 3.5rem);
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.1;
  margin-bottom: 20px;
}

.hero-copy {
  font-size: 1.125rem;
  color: var(--muted);
  max-width: 600px;
  margin: 0 auto;
}

/* Tab Navigation */
.tab-nav {
  display: flex;
  gap: 8px;
  margin-bottom: 32px;
  padding: 6px;
  background: var(--button-ghost);
  border-radius: 16px;
}

.tab-button {
  flex: 1;
  padding: 12px;
  border: none;
  border-radius: 12px;
  background: transparent;
  color: var(--muted);
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.tab-button.active {
  background: var(--panel);
  color: var(--accent);
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
  animation: fadeIn 0.4s ease;
}

#disqus_thread {
  min-height: 400px;
  color: var(--text);
}

/* Text Content Styles */
.text-content {
  line-height: 1.8;
  color: var(--text);
}

.text-content h2 {
  margin-top: 0;
  margin-bottom: 24px;
  color: var(--accent);
  font-size: 1.75rem;
}

.text-content h3 {
  margin-top: 32px;
  margin-bottom: 12px;
  font-size: 1.25rem;
  color: var(--text);
  border-left: 4px solid var(--accent);
  padding-left: 12px;
}

.text-content p {
  margin-bottom: 20px;
  color: var(--muted);
}

.text-content ul {
  padding-left: 20px;
  margin-bottom: 24px;
}

.text-content li {
  margin-bottom: 8px;
  color: var(--muted);
}

/* Footer */
.app-footer {
  margin-top: 80px;
  padding: 64px 0 48px;
  border-top: 1px solid var(--line);
}

.footer-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 48px;
  margin-bottom: 64px;
}

.footer-section h4 {
  color: var(--text);
  margin-bottom: 20px;
  font-size: 1rem;
  font-weight: 700;
}

.footer-section ul {
  list-style: none;
  padding: 0;
}

.footer-section li {
  margin-bottom: 12px;
}

.footer-section a {
  color: var(--muted);
  text-decoration: none;
  font-size: 0.9rem;
  transition: color 0.2s;
}

.footer-section a:hover {
  color: var(--accent);
}

.footer-bottom {
  text-align: center;
  font-size: 0.85rem;
  color: var(--muted);
  border-top: 1px solid var(--line);
  padding-top: 32px;
}

/* Modal */
.modal {
  display: none;
  position: fixed;
  z-index: 1000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(15, 23, 42, 0.7);
  backdrop-filter: blur(8px);
}

.modal-content {
  position: relative;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: min(700px, 92%);
  max-height: 85vh;
  overflow-y: auto;
  padding: 48px;
}

.close-modal {
  position: absolute;
  right: 24px;
  top: 24px;
  font-size: 32px;
  font-weight: 300;
  cursor: pointer;
  color: var(--muted);
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: background 0.2s;
}

.close-modal:hover {
  background: var(--button-ghost);
  color: var(--text);
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Panels */
.panel {
  margin-bottom: 24px;
  padding: 32px;
  border-radius: 24px;
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.section-head {
  margin-bottom: 24px;
}

h2 {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 8px;
}

.controls {
  display: grid;
  gap: 24px;
}

.control-row {
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
}

.control-group {
  flex: 1;
  min-width: 200px;
}

label {
  display: block;
  margin-bottom: 8px;
  font-size: 0.875rem;
  font-weight: 600;
}

input, textarea {
  width: 100%;
  padding: 12px 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  font: inherit;
  color: inherit;
  background: var(--bg);
  transition: border-color 0.2s ease;
}

input:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
}

.button-row {
  display: flex;
  gap: 12px;
  margin-top: 8px;
}

button {
  padding: 14px 28px;
  border-radius: 12px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all 0.2s ease;
}

.primary {
  background: var(--accent);
  color: white;
}

.primary:hover {
  background: var(--accent-strong);
  transform: translateY(-1px);
}

.secondary {
  background: var(--button-ghost);
  color: var(--text);
}

.hint, .subtle {
  font-size: 0.875rem;
  color: var(--muted);
  margin-top: 6px;
}

/* Tickets */
.ticket-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 16px;
}

.ticket-card {
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--bg);
}

.ticket-title {
  font-weight: 700;
  margin-bottom: 12px;
  font-size: 0.875rem;
  color: var(--muted);
}

.ball-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.ball {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  color: white;
  font-weight: 700;
  font-size: 0.9rem;
}

.band-0 { background: #facc15; }
.band-1 { background: #60a5fa; }
.band-2 { background: #f87171; }
.band-3 { background: #94a3b8; }
.band-4 { background: #4ade80; }

/* Simulation */
.simulation-card {
  padding: 24px;
  border-radius: 16px;
  background: var(--bg);
  border: 1px solid var(--line);
}

.result-head {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--accent);
  margin-bottom: 16px;
}

.simulation-card p {
  margin-bottom: 8px;
}

.empty {
  text-align: center;
  color: var(--muted);
  padding: 40px;
}

.error {
  background: #fef2f2;
  border-color: #fee2e2;
  color: #991b1b;
}

[data-theme='dark'] .error {
  background: #450a0a;
  border-color: #7f1d1d;
  color: #fecaca;
}

@media (max-width: 600px) {
  .app-shell { padding-top: 40px; }
  .panel { padding: 20px; }
  .control-row { flex-direction: column; }
  .button-row { flex-direction: column; }
  .tab-nav { padding: 4px; }
  .tab-button { padding: 10px 4px; font-size: 0.85rem; }
}
