:root {
  --bg: #020617;
  --bg-card: #020617;
  --border-subtle: #111827;
  --border-strong: #1f2933;
  --accent: #3b82f6;
  --accent-soft: rgba(59, 130, 246, 0.16);
  --text-main: #e5e7eb;
  --text-muted: #9ca3af;
  --danger: #f87171;
  --success: #4ade80;
  --warn: #f97316;
  --shadow-soft: 0 18px 45px rgba(15, 23, 42, 0.7);
  --radius-card: 18px;
  --radius-pill: 999px;
  --transition-fast: 0.16s ease-out;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100vh;
  font-family: "Inter", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  background: radial-gradient(circle at top, #0b1120 0, #020617 60%, #000 100%);
  color: var(--text-main);
}

/* PAGE SHELL – stretch full width */

.page {
  width: 100%;
  max-width: none;             /* no centered “box” */
  padding: 18px 14px 28px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* TOP BAR */

.top-bar {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.92);
  border: 1px solid rgba(15, 23, 42, 0.8);
  box-shadow: 0 18px 40px rgba(15, 23, 42, 0.9);
  backdrop-filter: blur(16px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-mark {
  width: 36px;
  height: 36px;
  border-radius: 14px;
  background: radial-gradient(circle at 0% 0%, #22c55e 0%, #0ea5e9 65%, #1e3a8a 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 22px rgba(34, 197, 94, 0.45);
}

.brand-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: #ecfeff;
}

.brand-text h1 {
  margin: 0;
  font-size: 1.15rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.brand-text p {
  margin: 0;
  font-size: 0.82rem;
  color: var(--text-muted);
}

.top-meta {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* PILLS */

.pill {
  padding: 6px 10px;
  border-radius: var(--radius-pill);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.74rem;
}

.pill-soft {
  background: rgba(15, 23, 42, 0.9);
  border: 1px solid rgba(148, 163, 184, 0.3);
  color: var(--text-muted);
}

.pill-label {
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-size: 0.7rem;
}

.pill-value {
  color: var(--text-main);
  font-weight: 500;
}

.theme-toggle {
  cursor: pointer;
}

/* LAYOUT */

.layout {
  max-width: 1200px;
  margin: 4px auto 0;
  display: grid;
  grid-template-columns: minmax(0, 3fr) minmax(260px, 1.8fr);
  gap: 14px;
}

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

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

/* CARDS */

.card {
  background: radial-gradient(circle at top left, #020617 0, #020617 55%, #000 100%);
  border-radius: var(--radius-card);
  border: 1px solid var(--border-subtle);
  box-shadow: var(--shadow-soft);
  padding: 12px 14px 14px;
}

.card-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.card-header h2 {
  margin: 0;
  font-size: 0.98rem;
  font-weight: 600;
}

.subtle-text {
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* INPUT AREA */

.input-card {
  position: sticky;
  top: 12px;
  z-index: 1;
  background: linear-gradient(
    145deg,
    rgba(15, 23, 42, 0.98),
    rgba(17, 24, 39, 0.98)
  );
}

.field-label {
  display: block;
  margin-bottom: 6px;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.input-row {
  display: flex;
  gap: 8px;
  align-items: stretch;
}

.input-wrapper {
  flex: 1;
  position: relative;
}

#guess-input {
  width: 100%;
  padding: 11px 12px;
  border-radius: var(--radius-pill);
  border: 1px solid #1f2937;
  background: #020617;
  color: var(--text-main);
  font-size: 0.95rem;
  outline: none;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast),
    background var(--transition-fast), transform var(--transition-fast);
}

#guess-input::placeholder {
  color: #6b7280;
}

#guess-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent-soft);
  background: #020617;
  transform: translateY(-0.5px);
}

.primary-btn {
  padding: 0 18px;
  border-radius: var(--radius-pill);
  border: none;
  background: var(--accent);
  color: #f9fafb;
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: transform var(--transition-fast), box-shadow var(--transition-fast),
    background var(--transition-fast), opacity var(--transition-fast);
  box-shadow: 0 10px 25px rgba(37, 99, 235, 0.5);
}

.primary-btn:hover:not(:disabled) {
  background: #2563eb;
  transform: translateY(-1px);
  box-shadow: 0 14px 32px rgba(37, 99, 235, 0.6);
}

.primary-btn:disabled {
  opacity: 0.5;
  cursor: default;
  box-shadow: none;
}

.status-message {
  margin: 8px 2px 0;
  min-height: 1.2em;
  font-size: 0.82rem;
  color: var(--warn);
}

/* TABLE */

.table-card {
  padding-top: 10px;
}

.table-wrapper {
  width: 100%;
  border-radius: 12px;
  border: 1px solid #0b1220;
  background: radial-gradient(circle at top, #020617 0%, #020617 70%, #000 100%);
  overflow-x: hidden;   /* desktop: no horizontal scroll */
}
/* Tablet & phone: allow horizontal scroll so all 7 columns fit nicely */
@media (max-width: 880px) {
  .table-wrapper {
    overflow-x: auto;               /* enable sideways scroll */
    -webkit-overflow-scrolling: touch; /* smooth scroll on iOS */
  }

  .guesses-table {
    min-width: 900px;               /* table can be wider than screen */
  }
}

.guesses-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.78rem;
  table-layout: fixed;      /* stable width, no jitter */
}

/* column widths tuned for breathing room */
.col-stock  { width: 17%; }
.col-sector { width: 14%; }
.col-price  { width: 15%; }
.col-cap    { width: 16%; }
.col-ipo    { width: 12%; }
.col-return { width: 15%; }
.col-div    { width: 11%; }

.guesses-table th,
.guesses-table td {
  padding: 7px 9px;
  text-align: left;
  border-bottom: 1px solid rgba(15, 23, 42, 0.9);
}

/* only body cells can ellipsis, not headers */
.guesses-table td {
  overflow: hidden;
  text-overflow: ellipsis;
}

.guesses-table th {
  font-weight: 500;
  font-size: 0.72rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  white-space: nowrap;
}

.guesses-table tbody tr:hover {
  background: rgba(15, 23, 42, 0.6);
}

/* HINT CELLS */
/* STOCK cell: ticker on top, name below */

.stock-cell {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.stock-ticker {
  font-weight: 600;
  letter-spacing: 0.06em;
}

.stock-name {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.cell {
  border-radius: 999px;
  border: 1px solid #4b5563;
  padding: 1px 6px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.74rem;
  line-height: 1.3;
}

.cell .value {
  white-space: nowrap;
}

.match {
  background: rgba(34, 197, 94, 0.16);
  border-color: rgba(34, 197, 94, 0.8);
}

.near {
  background: rgba(234, 179, 8, 0.16);
  border-color: rgba(234, 179, 8, 0.8);
}

.miss {
  background: rgba(15, 23, 42, 0.9);
  border-color: #4b5563;
  color: var(--text-muted);
}

/* LEGEND & REVEAL */

.legend-card {
  padding-top: 10px;
}

.legend-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
}

.legend-copy {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.legend-copy strong {
  font-size: 0.8rem;
}

.legend-copy span {
  font-size: 0.76rem;
  color: var(--text-muted);
}

.legend-swatch {
  width: 16px;
  height: 16px;
  border-radius: 999px;
  border: 1px solid transparent;
}

.legend-swatch.match {
  background: rgba(34, 197, 94, 0.4);
  border-color: rgba(34, 197, 94, 0.9);
}

.legend-swatch.near {
  background: rgba(234, 179, 8, 0.4);
  border-color: rgba(234, 179, 8, 0.9);
}

.legend-swatch.miss {
  background: rgba(31, 41, 55, 1);
  border-color: #4b5563;
}

.legend-swatch.neutral {
  background: rgba(148, 163, 184, 0.25);
  border-color: rgba(148, 163, 184, 0.8);
}

.answer-box {
  margin: 0;
  padding: 10px 10px 12px;
  border-radius: 12px;
  background: #020617;
  border: 1px dashed rgba(55, 65, 81, 0.8);
  font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Monaco,
    Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 0.78rem;
  color: var(--text-muted);
  white-space: pre-wrap;
}

/* FOOTER */

.footer {
  max-width: 1200px;
  margin: 10px auto 0;
  font-size: 0.75rem;
  color: var(--text-muted);
  text-align: center;
}

/* LIGHT THEME (slight pink) */

body.theme-light {
  --bg: #fdf2f8;
  --bg-card: #ffffff;
  --border-subtle: #f9a8d4;
  --border-strong: #f472b6;
  --accent: #ec4899;
  --accent-soft: rgba(236, 72, 153, 0.18);
  --text-main: #111827;
  --text-muted: #6b7280;
  --danger: #dc2626;
  --success: #16a34a;
  --warn: #ea580c;
  --shadow-soft: 0 14px 30px rgba(248, 113, 165, 0.22);
}

body.theme-light {
  background: radial-gradient(circle at top, #ffe4e6 0, #fdf2f8 55%, #f9fafb 100%);
}

body.theme-light .top-bar {
  background: rgba(255, 241, 242, 0.94);
  border-color: rgba(251, 207, 232, 0.9);
  box-shadow: 0 14px 30px rgba(244, 114, 182, 0.35);
}

body.theme-light .brand-mark {
  background: radial-gradient(circle at 0% 0%, #fb7185 0%, #f97316 40%, #ec4899 100%);
  box-shadow: 0 8px 22px rgba(244, 114, 182, 0.55);
}

body.theme-light .card {
  background: #ffffff;
  border-color: #f9a8d4;
}

body.theme-light .input-card {
  background: linear-gradient(145deg, #fff1f2, #ffe4e6);
}

body.theme-light .table-wrapper {
  background: #fdf2ff;
  border-color: #fbcfe8;
}

body.theme-light .guesses-table thead {
  background: #ffe4e6;
}

body.theme-light .guesses-table th {
  color: #9f1239;
}

body.theme-light .guesses-table tbody tr:hover {
  background: rgba(255, 228, 230, 0.85);
}

body.theme-light .answer-box {
  background: #fdf2f8;
  border-color: #f9a8d4;
}

body.theme-light .pill-soft {
  background: rgba(255, 241, 242, 0.9);
  border-color: rgba(251, 207, 232, 0.9);
}

body.theme-light #guess-input {
  background: #fdf2f8;
  border-color: #fecdd3;
}

body.theme-light .primary-btn {
  box-shadow: 0 10px 26px rgba(236, 72, 153, 0.45);
}

/* make hint pills pink-theme too */
body.theme-light .match {
  background: rgba(34, 197, 94, 0.16);
  border-color: #16a34a;
}

body.theme-light .near {
  background: rgba(251, 191, 36, 0.22);
  border-color: #d97706;
}

body.theme-light .miss {
  background: rgba(248, 250, 252, 0.9);
  border-color: #e5e7eb;
  color: #6b7280;
}

/* STATUS COLORS */

#status-message {
  color: var(--warn);
}

/* RESPONSIVE */

@media (max-width: 880px) {
  .layout {
    grid-template-columns: minmax(0, 1fr);
  }

  .input-card {
    position: static;
  }
}

@media (max-width: 640px) {
  .page {
    padding: 14px 10px 22px;
  }

  .top-bar {
    flex-direction: column;
    align-items: flex-start;
    border-radius: 16px;
  }

  .input-row {
    flex-direction: column;
  }

  .primary-btn {
    width: 100%;
  }

  .guesses-table {
    font-size: 0.75rem;
  }

  .guesses-table th,
  .guesses-table td {
    padding: 6px 7px;
  }
}
