:root {
	color-scheme: light dark;
	--bg: #ffffff;
	--fg: #0b0d12;
	--muted: #5b6472;
	--accent: #2f6df6;
	--border: #e4e7ec;
	--danger: #b42318;
	--radius: 10px;
	--space: 1rem;
	--font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

@media (prefers-color-scheme: dark) {
	:root {
		--bg: #0b0d12;
		--fg: #f4f6fa;
		--muted: #9aa4b2;
		--accent: #6f9bff;
		--border: #232833;
		--danger: #ff9a8f;
	}
}

:root{--bg:#0d0f14;--fg:#ece8e1;--muted:#8b93a1;--accent:#ff4655;--border:#252a35}
* {
	box-sizing: border-box;
}
.card{background:#151922;border:1px solid var(--border);border-radius:10px;padding:1rem}
.btn-primary{background:var(--accent);color:#fff;border:0}
.topbar{display:flex;justify-content:space-between;align-items:center;padding:.8rem 1rem;border-bottom:1px solid var(--border);flex-wrap:wrap;gap:.5rem}
.brand,.brand-big{display:flex;align-items:center;gap:.6rem;font-weight:800;letter-spacing:.15em}
.brand-mark{background:var(--accent);color:#fff;width:2rem;height:2rem;display:grid;place-items:center;clip-path:polygon(0 0,100% 0,100% 75%,75% 100%,0 100%)}
.brand-big h1{margin:0}.brand-big p{margin:0;color:var(--muted);letter-spacing:0;font-weight:400}
.auth-wrap{max-width:26rem;margin:3rem auto;padding:1rem;display:grid;gap:1.5rem}
.tabs{display:flex;gap:.3rem;padding:.5rem 1rem;overflow-x:auto;border-bottom:1px solid var(--border)}
.tab{background:none;border:0;color:var(--muted);padding:.5rem .9rem;font-weight:700;cursor:pointer;border-bottom:2px solid transparent}
.tab.active{color:var(--fg);border-color:var(--accent)}
.pts-pill{color:var(--accent);font-weight:800}.btn-ghost{background:transparent;border:1px solid var(--border);color:var(--fg)}
.btn-sm{padding:.3rem .7rem}.muted{color:var(--muted)}.small{font-size:.8rem}.between{justify-content:space-between;flex-wrap:wrap}
.match-head{display:flex;justify-content:space-between;flex-wrap:wrap;gap:.5rem}.match h3{margin:.4rem 0}
.chips{display:flex;flex-wrap:wrap;gap:.35rem;margin:.6rem 0}.chip{background:#1e2430;padding:.2rem .6rem;border-radius:4px;font-size:.85rem}
.chip.team-A{border-left:3px solid #3fd1c2}.chip.team-B{border-left:3px solid var(--accent)}.chip.mvp{color:#ffd166}
.st-open{color:#3fd1c2}.st-done{color:var(--muted)}.result{font-weight:700}
.rank-list{display:grid;gap:.4rem}.rank-row{display:flex;align-items:center;gap:.8rem;background:#151922;border:1px solid var(--border);padding:.7rem 1rem;border-radius:8px}
.rank-no{font-weight:800;width:1.6rem}.rank-name{flex:1;display:grid}.rank-pts{font-weight:800;color:var(--accent)}
.top1{border-color:#ffd166}.top2{border-color:#c0c7d2}.top3{border-color:#cd7f32}
.stats{display:grid;grid-template-columns:repeat(auto-fit,minmax(70px,1fr));gap:.5rem;margin-top:1rem}
.stats div{display:grid;text-align:center;background:#1e2430;padding:.6rem;border-radius:6px}.stats b{font-size:1.3rem}.stats span{color:var(--muted);font-size:.8rem}
.plus{color:#3fd1c2;font-weight:700}.minus{color:var(--accent);font-weight:700}.sel{width:auto}

/* Bright theme */
:root{color-scheme:light;--bg:#f5f6f9;--fg:#0f1420;--muted:#6a7383;--accent:#ff4655;--border:#e3e6ed;--teal:#0fa89a;
  --font:"Pretendard","Apple SD Gothic Neo","Noto Sans KR",ui-sans-serif,system-ui,sans-serif}
body{background:radial-gradient(1200px 400px at 50% -200px,#ffe3e6 0,transparent 70%),var(--bg)}
.card,.rank-row{background:#fff;border:1px solid var(--border);border-radius:14px;box-shadow:0 1px 2px rgba(15,20,32,.04),0 8px 24px -12px rgba(15,20,32,.12)}
.shell{max-width:64rem;padding:1.5rem 1rem 3rem}
.topbar{background:rgba(255,255,255,.85);backdrop-filter:blur(10px);position:sticky;top:0;z-index:5}
.tabs{background:#fff}
.tab{border-radius:0}.tab.active{color:var(--accent)}
.chip{background:#f0f2f6;color:var(--fg)}.chip.mvp{color:#b7791f;background:#fff6e0}
.chip-kda{font-style:normal;color:var(--muted);font-size:.78rem}
.stats div{background:#f5f6f9}
.st-open{color:var(--teal)}.plus{color:var(--teal)}
.btn{border-radius:10px;font-weight:700}
.btn-primary{box-shadow:0 6px 16px -8px rgba(255,70,85,.7)}
.input{background:#fff;color:var(--fg)}
.rank-row{border-radius:12px}.top1{border-color:#f2c14e}.top2{border-color:#b9c1cc}.top3{border-color:#d49a5f}
.sort-bar{display:flex;flex-wrap:wrap;gap:.4rem}
.sort-btn{border:1px solid var(--border);background:#fff;color:var(--fg);padding:.4rem .85rem;border-radius:999px;font-weight:700;cursor:pointer}
.sort-btn.on{background:var(--fg);color:#fff;border-color:var(--fg)}
.table-scroll{overflow-x:auto;background:#fff;border:1px solid var(--border);border-radius:14px}
.rec-table{width:100%;border-collapse:collapse;font-size:.9rem;white-space:nowrap}
.rec-table th{text-align:left;font-size:.75rem;color:var(--muted);font-weight:700;padding:.7rem .8rem;background:#fafbfc;border-bottom:1px solid var(--border)}
.rec-table td{padding:.7rem .8rem;border-bottom:1px solid #f0f2f5;vertical-align:middle}
.rec-table tr:last-child td{border-bottom:0}
.rec-table td:nth-child(2){position:sticky;left:0;background:#fff}
.rec-no{font-weight:800;color:var(--muted)}
.kd-good{color:var(--teal);font-weight:800}.kd-low{color:var(--muted);font-weight:700}
.bar{height:4px;width:56px;background:#eef0f4;border-radius:4px;margin-bottom:3px}
.bar i{display:block;height:100%;background:var(--accent);border-radius:4px}
.kda-row{display:grid;grid-template-columns:1fr auto;gap:.4rem .5rem;align-items:center;padding:.6rem 0;border-bottom:1px solid #f0f2f5}
.kda-name{grid-column:1/-1}
.kda-in{display:flex;align-items:center;gap:.3rem;font-size:.75rem;font-weight:800;color:var(--muted)}
.kda-in .input{width:100%;min-width:0;padding:.35rem .4rem}
.kda-calc{font-size:.8rem;font-weight:800;color:var(--teal)}
@media (min-width:600px){.kda-row{grid-template-columns:1fr auto 70px 70px 70px auto}.kda-name{grid-column:auto}}
@media (max-width:599px){.kda-row{grid-template-columns:repeat(3,1fr)}.kda-row .sel{grid-column:1/-1;width:100%}.kda-calc{grid-column:1/-1}}

body {
	margin: 0;
	background: var(--bg);
	color: var(--fg);
	font-family: var(--font);
	line-height: 1.55;
	-webkit-font-smoothing: antialiased;
}

.shell {
	max-width: 42rem;
	margin: 0 auto;
	padding: calc(var(--space) * 3) var(--space);
}

h1 {
	margin: 0 0 0.5rem;
	font-size: clamp(1.6rem, 4vw, 2.25rem);
	letter-spacing: -0.02em;
}

.lede {
	margin: 0 0 0.75rem;
	font-size: 1.05rem;
}

.hint {
	margin: 0;
	color: var(--muted);
}

.btn {
	display: inline-flex;
	align-items: center;
	gap: 0.5rem;
	padding: 0.55rem 0.9rem;
	border: 1px solid transparent;
	border-radius: var(--radius);
	background: var(--accent);
	color: #fff;
	font: inherit;
	font-weight: 500;
	cursor: pointer;
}

.btn:hover {
	filter: brightness(1.05);
}

.btn-secondary {
	background: transparent;
	color: var(--fg);
	border-color: var(--border);
}

.card {
	padding: var(--space);
	border: 1px solid var(--border);
	border-radius: var(--radius);
	background: var(--bg);
}

.input,
.select,
.textarea {
	width: 100%;
	padding: 0.55rem 0.7rem;
	border: 1px solid var(--border);
	border-radius: var(--radius);
	background: var(--bg);
	color: var(--fg);
	font: inherit;
}

.field {
	display: grid;
	grid-template-columns: minmax(0, 1fr);
	gap: 0.35rem;
	margin-bottom: var(--space);
}

.field > label {
	font-size: 0.875rem;
	color: var(--muted);
}

/*
 * 390px-safe, like .grid below. A grid with no column list gets one implicit
 * auto column, and an auto column is never narrower than its widest item's
 * min-content width. One nowrap scrolling strip (days, time slots) anywhere
 * inside an item therefore widened the whole column past the screen: the page
 * scrolled sideways instead of the strip scrolling on its own. minmax(0, 1fr)
 * caps the column at the container; the min-width rule keeps a child from
 * bringing the same floor back if an app redefines the columns. :where() adds
 * no specificity, so a min-width the app sets on a child still wins.
 */
.stack {
	display: grid;
	grid-template-columns: minmax(0, 1fr);
	gap: var(--space);
}

:where(.field, .stack, .list) > * {
	min-width: 0;
}

.row {
	display: flex;
	align-items: center;
	gap: 0.75rem;
	flex-wrap: wrap;
}

/*
 * 390px-safe. An unclamped minmax track overflows a 390px viewport once the
 * shell padding is subtracted, and nothing in the pipeline ever looked at a
 * phone-width layout, so every generated app inherited the horizontal scroll.
 * min() clamps the track to the container instead.
 */
.grid {
	display: grid;
	gap: var(--space);
	grid-template-columns: repeat(auto-fit, minmax(min(15rem, 100%), 1fr));
}

.list {
	display: grid;
	grid-template-columns: minmax(0, 1fr);
	gap: 0.5rem;
	margin: 0;
	padding: 0;
	list-style: none;
}

.list-item {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 0.75rem;
	flex-wrap: wrap;
	padding: 0.7rem 0.85rem;
	border: 1px solid var(--border);
	border-radius: var(--radius);
}

.table {
	width: 100%;
	border-collapse: collapse;
}

.table th,
.table td {
	padding: 0.6rem 0.5rem;
	text-align: left;
	border-bottom: 1px solid var(--border);
}

.table th {
	font-size: 0.8125rem;
	color: var(--muted);
	font-weight: 600;
}

.empty {
	padding: calc(var(--space) * 2);
	text-align: center;
	color: var(--muted);
}

.empty-title {
	margin: 0 0 0.25rem;
	color: var(--fg);
	font-weight: 600;
}

/* Loading. Every fetch has one; without a primitive each app invented its own. */
.loading {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 0.6rem;
	padding: calc(var(--space) * 1.5);
	color: var(--muted);
}

.spinner {
	flex: none;
	width: 1.15rem;
	height: 1.15rem;
	border: 2px solid var(--border);
	border-top-color: var(--accent);
	border-radius: 50%;
	animation: fab-spin 0.7s linear infinite;
}

@keyframes fab-spin {
	to {
		transform: rotate(360deg);
	}
}

/* Placeholder for content whose shape is known before its data arrives. */
.skeleton {
	display: block;
	height: 1rem;
	border-radius: calc(var(--radius) / 2);
	background: linear-gradient(90deg, var(--border), transparent, var(--border));
	background-size: 200% 100%;
	animation: fab-shimmer 1.2s linear infinite;
}

@keyframes fab-shimmer {
	to {
		background-position: -200% 0;
	}
}

/* Error strip: a failure the user can see and retry, never a silent no-op. */
.alert {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 0.75rem;
	flex-wrap: wrap;
	padding: 0.7rem 0.85rem;
	border: 1px solid var(--border);
	border-left: 3px solid var(--muted);
	border-radius: var(--radius);
}

.alert-error {
	border-left-color: var(--danger);
	color: var(--danger);
}

.badge {
	display: inline-block;
	padding: 0.1rem 0.5rem;
	border: 1px solid var(--border);
	border-radius: 999px;
	font-size: 0.8125rem;
	color: var(--muted);
}

/*
 * The scaffold had exactly one @media rule (prefers-color-scheme) and no width
 * breakpoint at all, so the shell was a 42rem column at every size.
 * Mobile-first stays the default; these only widen it.
 */
@media (min-width: 48rem) {
	.shell {
		max-width: 52rem;
		padding: calc(var(--space) * 3) calc(var(--space) * 1.5);
	}
}

@media (min-width: 64rem) {
	.shell {
		max-width: 64rem;
	}
}

@media (prefers-reduced-motion: reduce) {
	.spinner,
	.skeleton {
		animation: none;
	}
}

:where(a, button, input, select, textarea):focus-visible {
	outline: 2px solid var(--accent);
	outline-offset: 2px;
}
