/* Goldwin public site — shared theme, layout and component styles. */

:root,
:root[data-theme="dark"] {
	--bg: #0b0c14;
	--bg-glow: radial-gradient(circle at 15% -10%, #241f45 0%, #0b0c14 45%);
	--surface: #12141d;
	--surface-2: #171a24;
	--border: rgba(255,255,255,.08);
	--border-soft: rgba(255,255,255,.05);
	--text: #f2f3f7;
	--text-muted: #9aa0b4;
	--text-faint: #6b7085;
	--head-cell-bg: rgba(255,255,255,.04);
	--row-alt: rgba(255,255,255,.02);
	--shadow: 0 12px 30px -14px rgba(0,0,0,.65);
}

:root[data-theme="light"] {
	--bg: #f4f5fb;
	--bg-glow: radial-gradient(circle at 15% -10%, #e7e4ff 0%, #f4f5fb 45%);
	--surface: #ffffff;
	--surface-2: #f0f1f8;
	--border: rgba(20,20,40,.10);
	--border-soft: rgba(20,20,40,.06);
	--text: #1c1d2b;
	--text-muted: #5c6178;
	--text-faint: #8b90a3;
	--head-cell-bg: rgba(20,20,40,.035);
	--row-alt: rgba(20,20,40,.02);
	--shadow: 0 12px 30px -16px rgba(30,30,60,.25);
}

* { box-sizing: border-box; }

body {
	font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
	background: var(--bg-glow), var(--bg);
	color: var(--text);
	margin: 0;
	min-height: 100vh;
	transition: background-color .2s ease, color .2s ease;
}

a { color: inherit; }

/* ---------- top bar: brand + nav + theme toggle ----------
   Deliberately always dark (independent of the light/dark toggle, which
   only affects the page content below) so the header reads as a fixed
   brand bar rather than blending with whichever theme is active. */

.topbar {
	position: sticky; top: 0; z-index: 20;
	background: linear-gradient(135deg, #14161f, #1c1f2c);
	border-bottom: 1px solid rgba(255,255,255,.08);
	box-shadow: 0 4px 16px rgba(0,0,0,.35);
	padding: .6rem .9rem;
	display: flex; align-items: center; gap: .6rem; flex-wrap: nowrap;
}

.topbar .brand {
	font-weight: 800; font-size: 1.05rem; letter-spacing: -.01em;
	background: linear-gradient(120deg, #a78bfa, #34d1c4);
	-webkit-background-clip: text; background-clip: text; color: transparent;
	text-decoration: none; white-space: nowrap; flex: 0 0 auto;
}

.topbar .nav {
	display: flex; align-items: center; gap: .2rem; flex: 1 1 auto; min-width: 0;
	overflow-x: auto; white-space: nowrap; scrollbar-width: thin;
}

.topbar .nav::-webkit-scrollbar { height: 3px; }

.topbar .nav a {
	color: #b8bcd0; text-decoration: none; font-size: .82rem; font-weight: 600;
	padding: .4rem .6rem; border-radius: 8px; flex: 0 0 auto;
}

.topbar .nav a:hover { color: #fff; background: rgba(255,255,255,.06); }

.topbar .nav a.active {
	color: #0b0c14; background: linear-gradient(120deg, var(--accent-a, #6a5cff), var(--accent-b, #00d4c8));
}

.theme-toggle {
	display: inline-flex; align-items: center; gap: .35rem;
	background: rgba(255,255,255,.06); border: 1px solid rgba(255,255,255,.12);
	color: #eee; border-radius: 999px; padding: .35rem .65rem;
	font-size: .78rem; font-weight: 600; cursor: pointer; flex: 0 0 auto; white-space: nowrap;
}

/* Charts dropdown — a sibling of .nav (not nested inside it) so its panel
   isn't clipped by .nav's own horizontal-scroll overflow container. */
.nav-dropdown { position: relative; flex: 0 0 auto; }

.nav-dropdown-toggle {
	color: #b8bcd0; background: none; border: none; cursor: pointer;
	font-size: .82rem; font-weight: 600; font-family: inherit;
	padding: .4rem .6rem; border-radius: 8px; white-space: nowrap;
}

.nav-dropdown-toggle:hover, .nav-dropdown.open .nav-dropdown-toggle { color: #fff; background: rgba(255,255,255,.06); }

.nav-dropdown-menu {
	display: none; position: absolute; top: calc(100% + .5rem); right: 0; z-index: 30;
	background: #191c28; border: 1px solid rgba(255,255,255,.1); border-radius: 12px;
	padding: .4rem; min-width: 10rem; box-shadow: 0 12px 30px rgba(0,0,0,.4);
}

.nav-dropdown.open .nav-dropdown-menu { display: block; }

.nav-dropdown-menu a {
	display: block; color: #cfd2e0; text-decoration: none; font-size: .82rem; font-weight: 600;
	padding: .5rem .6rem; border-radius: 8px; white-space: nowrap;
}

.nav-dropdown-menu a:hover { color: #fff; background: rgba(255,255,255,.08); }

.theme-toggle:hover { border-color: var(--accent-a, #6a5cff); background: rgba(255,255,255,.1); }

/* Mobile hamburger — hidden by default; below ~640px it replaces the
   inline nav + Charts dropdown entirely (rather than letting them
   horizontally scroll) so the header never needs scrolling on a real
   phone: too many links to fit legibly in one row at any font size. */
.menu-toggle {
	display: none; background: rgba(255,255,255,.06); border: 1px solid rgba(255,255,255,.12);
	color: #fff; border-radius: 8px; width: 2.2rem; height: 2.2rem; font-size: 1.1rem;
	cursor: pointer; flex: 0 0 auto; align-items: center; justify-content: center;
}

.mobile-panel {
	display: none; position: absolute; top: 100%; left: 0; right: 0; z-index: 30;
	background: #14161f; border-bottom: 1px solid rgba(255,255,255,.08);
	box-shadow: 0 12px 24px rgba(0,0,0,.4); padding: .5rem; flex-direction: column;
}

.mobile-panel a {
	color: #cfd2e0; text-decoration: none; font-size: .92rem; font-weight: 600;
	padding: .7rem .8rem; border-radius: 8px;
}

.mobile-panel a:hover { background: rgba(255,255,255,.06); }
.mobile-panel a.active { color: #0b0c14; background: linear-gradient(120deg, var(--accent-a, #6a5cff), var(--accent-b, #00d4c8)); }
.mobile-panel-divider { color: #6b7085; font-size: .7rem; text-transform: uppercase; letter-spacing: .05em; font-weight: 700; padding: .8rem .8rem .3rem; }

@media (max-width: 640px) {
	.nav-desktop { display: none !important; }
	.menu-toggle { display: flex; }
	.topbar { position: relative; padding: .5rem .6rem; gap: .35rem; }
	.topbar .brand { font-size: .95rem; }
	.mobile-panel.open { display: flex; }
}

/* ---------- notice ticker ---------- */

.notice-ticker {
	overflow: hidden; white-space: nowrap; position: relative;
	background: linear-gradient(90deg, var(--accent-a, #6a5cff), var(--accent-b, #00d4c8));
	color: #0b0c14; font-weight: 700; font-size: .85rem;
	padding: .55rem 0;
}

.notice-ticker .track {
	display: inline-block; padding-left: 100%;
	animation: ticker 22s linear infinite;
}

.notice-ticker .track span { margin-right: 3.5rem; }

@keyframes ticker {
	0% { transform: translateX(0); }
	100% { transform: translateX(-100%); }
}

@media (prefers-reduced-motion: reduce) {
	.notice-ticker .track { animation: none; padding-left: 1.25rem; }
}

/* ---------- countdown ---------- */

.countdown {
	display: inline-flex; align-items: center; gap: .6rem;
	background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
	padding: .6rem 1rem; box-shadow: var(--shadow);
}

.countdown .label { font-size: .72rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: .05em; }

.countdown .clock {
	font-variant-numeric: tabular-nums; font-weight: 800; font-size: 1.25rem;
	background: linear-gradient(120deg, var(--accent-a, #6a5cff), var(--accent-b, #00d4c8));
	-webkit-background-clip: text; background-clip: text; color: transparent;
}

.countdown.done .clock { color: var(--text-muted); background: none; -webkit-text-fill-color: currentColor; }

/* ---------- header / hero ---------- */

.page-main { padding: 1.5rem 1.25rem 3rem; max-width: 900px; margin: 0 auto; }

.title-row { display: flex; align-items: center; justify-content: space-between; flex-wrap: nowrap; gap: .6rem; margin: 1.3rem 0; }

.title-row h1 {
	font-size: clamp(1.1rem, 4vw, 1.8rem); margin: 0; font-weight: 800; letter-spacing: -.01em;
	background: linear-gradient(120deg, var(--accent-a, #6a5cff), var(--accent-b, #00d4c8));
	-webkit-background-clip: text; background-clip: text; color: transparent;
	flex: 0 1 auto; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.title-row .countdown { flex: 0 0 auto; }
.title-row input[type=date] { flex: 0 1 auto; min-width: 0; }

input[type=date] {
	padding: .55rem .8rem; border-radius: 10px; border: 1px solid var(--border);
	background: var(--surface-2); color: var(--text); font-size: .9rem;
}

@media (max-width: 480px) {
	.title-row { gap: .4rem; }
	.title-row h1 { font-size: 1.05rem; }
	.countdown { padding: .4rem .6rem; gap: .35rem; }
	.countdown .label { display: none; }
	.countdown .clock { font-size: 1rem; }
	.title-row input[type=date] { padding: .4rem .3rem; font-size: .78rem; }
}

/* ---------- slot cards + grid ---------- */

.slot-card {
	background: var(--surface); border: 1px solid var(--border); border-radius: 18px;
	margin-bottom: 1.4rem; overflow: hidden; box-shadow: var(--shadow);
}

.slot-head {
	padding: .85rem 1.15rem; color: #0b0c14;
	background: linear-gradient(120deg, var(--accent-a, #6a5cff), var(--accent-b, #00d4c8));
	display: flex; justify-content: space-between; align-items: center; font-weight: 800;
}

.slot-head .time { font-size: 1.02rem; display: flex; align-items: center; gap: .5rem; }
.slot-head .live-dot { width: .5rem; height: .5rem; border-radius: 50%; background: #0b0c14; animation: pulse 1.4s ease infinite; }
.slot-head .janwar { font-size: .8rem; font-weight: 700; opacity: .85; }

@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .25; } }

.grid-scroll { overflow-x: auto; padding: .9rem; }

table.grid { border-collapse: separate; border-spacing: 3px; width: 100%; min-width: 600px; }

table.grid th, table.grid td { text-align: center; font-variant-numeric: tabular-nums; font-size: .8rem; }

table.grid thead th {
	background: var(--head-cell-bg); color: var(--text-muted); font-size: .68rem;
	text-transform: uppercase; letter-spacing: .05em; padding: .4rem .2rem; border-radius: 6px;
}

table.grid tbody th {
	background: var(--head-cell-bg); color: var(--text-muted); font-weight: 700; border-radius: 6px; padding: .3rem;
}

/* the gradient-filled "box" each number sits in */
.cell-box {
	display: block; border-radius: 8px; padding: .42rem .2rem;
	color: #0b0c14; font-weight: 700; border: none;
	background: linear-gradient(120deg, var(--accent-a, #6a5cff), var(--accent-b, #00d4c8), var(--accent-a, #6a5cff));
}

.cell-box.animated {
	background-size: 240% 240%;
	animation: cellGradient 3.2s ease infinite;
}

@keyframes cellGradient {
	0% { background-position: 0% 50%; }
	50% { background-position: 100% 50%; }
	100% { background-position: 0% 50%; }
}

@media (prefers-reduced-motion: reduce) {
	.cell-box.animated { animation: none; }
}

/* Below 640px, a rigid 10-column table (Single/Double, 100 cells) can't fit
   without either scrolling or shrinking cells past readability. Convert the
   table to a flex-wrap layout instead — same markup, cells just wrap onto
   more lines rather than forcing horizontal scroll. The column-index header
   (0-9) is hidden since it no longer lines up with anything once wrapped;
   the row label (00/10/.../90) stays as the first item in each wrapped row. */
@media (max-width: 640px) {
	.page-main { padding-left: .75rem; padding-right: .75rem; }
	.grid-scroll { overflow-x: auto; padding: .5rem .35rem; }

	/* :not(.matrix-table) — the chart page's jodi x day matrix (grouped
	   colspan headers, 40+ columns) shares the .grid class but its structure
	   can't survive a display:flex override (colspan doesn't mean anything
	   once the table stops being a table); it keeps its original
	   horizontal-scroll behavior instead, which is the only sane option for
	   that much data density. This rule block is only for the simple single-
	   header 10-column game-page grid. */
	table.grid:not(.matrix-table) { min-width: 0; display: block; }
	table.grid:not(.matrix-table) thead { display: none; }
	table.grid:not(.matrix-table) tbody { display: block; }
	/* nowrap: all 10 values stay on one line per row-group, shrinking to
	   fit instead of wrapping onto a second line. */
	table.grid:not(.matrix-table) tr { display: flex; flex-wrap: nowrap; align-items: center; gap: 2px; margin-bottom: 4px; }
	table.grid:not(.matrix-table) tbody th {
		flex: 0 0 auto; width: 1.5rem; font-size: .68rem; padding: .25rem .1rem; margin-right: 2px;
	}
	table.grid:not(.matrix-table) td { display: block; flex: 1 1 0; min-width: 0; padding: 0; }
	table.grid:not(.matrix-table) .cell-box { font-size: .56rem; padding: .32rem .05rem; letter-spacing: -.02em; }
}

.empty { padding: 2.5rem 1rem; text-align: center; color: var(--text-faint); }

/* ---------- 3D segment table (A/B/C, one row per slot) ---------- */

/* No fixed min-width here (unlike table.grid/table.matrix-table, which
   genuinely need it for 10+ columns) — a 2-column table (SL/GL Green) should
   shrink to fit any phone width without forcing scroll; a 4-column one (3D)
   sizes itself from its cells and only scrolls if it truly doesn't fit. */
table.seg-table { border-spacing: 6px; width: 100%; min-width: auto; }
table.seg-table th { background: var(--head-cell-bg); color: var(--text-muted); font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; padding: .5rem; border-radius: 8px; }
table.seg-table td { padding: 0; }
.seg-time { font-weight: 700; color: var(--text); white-space: nowrap; padding: 0 .6rem !important; font-size: .95rem; display: flex; align-items: center; gap: .4rem; height: 100%; }
.cell-box.seg { display: block; padding: .65rem .5rem; font-size: 1.15rem; font-weight: 800; text-align: center; min-width: 3.5rem; }

@media (max-width: 400px) {
	.cell-box.seg { font-size: .95rem; padding: .55rem .3rem; min-width: 2.6rem; }
	.seg-time { font-size: .82rem; padding: 0 .4rem !important; }
}

/* ---------- home ---------- */

.hero { padding: 2.2rem 1.25rem 1rem; text-align: center; }
.hero h1 {
	margin: 0; font-size: clamp(1.9rem, 5vw, 2.7rem); font-weight: 800; letter-spacing: -.02em;
	background: linear-gradient(120deg, #a78bfa, #34d1c4);
	-webkit-background-clip: text; background-clip: text; color: transparent;
}
.hero p { margin: .5rem 0 0; color: var(--text-muted); font-size: .95rem; }
.hero-countdown { margin: 1.1rem auto 0; --accent-a: #a78bfa; --accent-b: #34d1c4; }

.home-grid {
	padding: 1rem 1.25rem 3rem; max-width: 980px; margin: 0 auto;
	display: grid; gap: 1.1rem; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
}

.charts-section { padding: 0 1.25rem 3.5rem; max-width: 980px; margin: 0 auto; text-align: center; }
.charts-section h2 { margin: 0 0 .3rem; font-size: 1.3rem; font-weight: 800; }
.charts-section .hint { margin: 0 0 1.2rem; }
.charts-links { display: flex; flex-wrap: wrap; justify-content: center; gap: .7rem; }
.chart-link {
	display: inline-block; padding: .7rem 1.2rem; border-radius: 12px; font-weight: 700; font-size: .88rem;
	text-decoration: none; color: var(--text); background: var(--surface); border: 1px solid var(--border);
	transition: transform .15s ease, box-shadow .15s ease;
}
.chart-link:hover {
	transform: translateY(-2px); box-shadow: var(--shadow);
	background: linear-gradient(120deg, var(--accent-a, #6a5cff), var(--accent-b, #00d4c8)); color: #0b0c14; border-color: transparent;
}

.game-card {
	position: relative; border-radius: 18px; padding: 1.4rem 1.4rem 1.2rem;
	background: var(--surface); border: 1px solid var(--border); overflow: hidden;
	transition: transform .15s ease, box-shadow .15s ease;
}
.game-card:hover { transform: translateY(-3px); box-shadow: var(--shadow); }
.game-card .card-cover { position: absolute; inset: 0; z-index: 1; }
.game-card .glow {
	position: absolute; inset: -40% -40% auto auto; width: 12rem; height: 12rem;
	border-radius: 50%; filter: blur(40px); opacity: .35; pointer-events: none;
}
.game-card h2 { margin: 0 0 .8rem; font-size: 1.05rem; font-weight: 700; position: relative; pointer-events: none; }
.badge {
	display: inline-block; font-size: .68rem; font-weight: 700; letter-spacing: .04em;
	text-transform: uppercase; padding: .2rem .55rem; border-radius: 999px; margin-bottom: .7rem; color: #0b0c14;
	position: relative; pointer-events: none;
}
.game-card .value { font-size: 1.9rem; font-weight: 800; letter-spacing: .04em; font-variant-numeric: tabular-nums; position: relative; pointer-events: none; }
.game-card .value.seg-preview { font-size: 1.25rem; }
.game-card .meta { color: var(--text-muted); font-size: .8rem; margin-top: .3rem; position: relative; pointer-events: none; }
.game-card .pending { color: var(--text-faint); font-size: .9rem; position: relative; pointer-events: none; }
.game-card .cta {
	display: inline-block; margin-top: 1rem; font-size: .8rem; font-weight: 700;
	color: var(--accent-a, #a78bfa); position: relative; z-index: 2; text-decoration: none;
}
.game-card .cta:hover { text-decoration: underline; }

/* ---------- chart ---------- */

.hint { color: var(--text-faint); font-size: .8rem; margin: 0 0 1rem; }

.row-group-picker { display: flex; flex-wrap: wrap; gap: .5rem; margin-bottom: 1.2rem; }
.row-group-picker a {
	display: inline-block; min-width: 2.6rem; text-align: center; padding: .5rem .7rem;
	border-radius: 10px; text-decoration: none; font-weight: 700; font-size: .85rem;
	background: var(--surface); border: 1px solid var(--border); color: var(--text-muted);
}
.row-group-picker a.active {
	color: #0b0c14; border-color: transparent;
	background: linear-gradient(120deg, var(--accent-a, #6a5cff), var(--accent-b, #00d4c8));
}

/* Digit-view toggle: same underlying panna value, 4 different formats
   (3rd-digit only / last-2-digits / full 4-digit / same as last-2-digits
   again — "2D Chart" is a duplicate of Double on the reference site, kept
   for fidelity rather than merged away). Each mode gets its own fixed
   color regardless of the active game's accent, matching the reference. */
.view-mode-picker { display: flex; flex-wrap: wrap; gap: .5rem; margin-bottom: 1rem; }
.view-mode-picker a {
	display: inline-block; padding: .5rem 1rem; border-radius: 10px; text-decoration: none;
	font-weight: 700; font-size: .85rem; color: #fff; opacity: .55;
}
.view-mode-picker a.active { opacity: 1; box-shadow: 0 4px 14px -4px rgba(0,0,0,.5); }
.view-mode-picker a.view-mode-fours { background: #1fa971; }
.view-mode-picker a.view-mode-single { background: #3f7fe0; }
.view-mode-picker a.view-mode-double { background: #e0455a; }
.view-mode-picker a.view-mode-2d { background: #d9a520; color: #0b0c14; }

table.chart-table { border-spacing: 3px; min-width: 480px; }
table.chart-table th {
	background: var(--head-cell-bg); color: var(--text-muted); font-size: .72rem;
	text-transform: uppercase; letter-spacing: .05em; padding: .5rem .7rem; border-radius: 8px; text-align: left;
}
table.chart-table td { padding: .25rem .3rem; }
.chart-cell { display: inline-block; padding: .4rem .7rem; font-size: .9rem; font-weight: 700; }

/* ---------- grid-game chart matrix (jodi x day) ---------- */

table.matrix-table { border-collapse: separate; border-spacing: 1px; font-size: .8rem; min-width: 900px; }
table.matrix-table th, table.matrix-table td { text-align: center; padding: .35rem .4rem; white-space: nowrap; }
table.matrix-table thead th {
	background: var(--head-cell-bg); color: var(--text-muted); font-size: .72rem;
	text-transform: uppercase; letter-spacing: .04em; position: sticky; top: 0;
}
table.matrix-table thead tr:first-child th {
	background: linear-gradient(120deg, var(--accent-a, #6a5cff), var(--accent-b, #00d4c8));
	color: #0b0c14; font-weight: 800; font-size: .8rem;
}
.matrix-time-head { background: var(--surface-2) !important; color: var(--text) !important; }
table.matrix-table tbody .seg-time { background: var(--surface-2); font-weight: 700; color: var(--text); padding: .35rem .6rem !important; }
table.matrix-table tbody td { background: var(--row-alt); font-variant-numeric: tabular-nums; color: var(--text); }
table.matrix-table td.today-col, table.matrix-table th.today-col {
	background: color-mix(in srgb, var(--accent-b, #00d4c8) 18%, var(--surface));
	color: var(--accent-b, #00d4c8); font-weight: 700;
}
table.matrix-table thead tr:last-child th.today-col { background: var(--accent-b, #00d4c8); color: #0b0c14; }
