/* BombPoint — dark arcade theme. Board drawn on canvas (js/render.js), everything else here. */
:root {
	--bg: #0f1420;
	--bg-2: #131a29;
	--panel: #171e2e;
	--panel-2: #1d2638;
	--line: #263149;
	--grid: #1d2638;
	--text: #e8ecf4;
	--muted: #8a94a8;
	--accent: #ff5a36;
	--accent-2: #ff7a5c;
	--point: #3ddc6a;
	--bomb: #ff5a36;
	--warn: #ffb547;
	--radius: 14px;
	--radius-s: 10px;
	--shadow: 0 10px 30px rgba(0, 0, 0, .35);
	--font: system-ui, -apple-system, "Segoe UI", Roboto, Ubuntu, "Helvetica Neue", Arial, sans-serif;
	--safe-b: env(safe-area-inset-bottom, 0px);
	color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
	background: radial-gradient(1200px 600px at 50% -10%, #1a2340 0%, var(--bg) 60%) fixed, var(--bg);
	color: var(--text);
	font: 15px/1.45 var(--font);
	overflow: hidden;
	-webkit-tap-highlight-color: transparent;
	-webkit-text-size-adjust: 100%;
}
button, select { font: inherit; color: inherit; }
a { color: var(--accent-2); }
kbd { font: 600 11px/1 var(--font); padding: 3px 5px; border-radius: 5px; border: 1px solid rgba(255,255,255,.25); opacity: .8; }
[hidden] { display: none !important; }

.icon-sprite { position: absolute; }
.icon { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.icon .dot { fill: currentColor; }
.noscript { margin: 40px auto; max-width: 480px; text-align: center; }

/* ---------- layout ---------- */
#app { height: 100%; display: flex; flex-direction: column; }
#topbar {
	display: flex; align-items: center; justify-content: space-between; gap: 12px;
	padding: 10px clamp(12px, 3vw, 28px); padding-top: max(10px, env(safe-area-inset-top));
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; }
.brand-name { font-weight: 800; font-size: 19px; letter-spacing: .3px; }
.topbar-actions { display: flex; gap: 8px; }

.icon-button {
	display: inline-flex; align-items: center; gap: 8px; height: 40px; padding: 0 14px;
	background: var(--panel); border: 1px solid var(--line); border-radius: 999px; cursor: pointer;
	transition: background .15s, border-color .15s, transform .1s;
}
.icon-button:hover { background: var(--panel-2); border-color: #34415f; }
.icon-button:active { transform: scale(.96); }
.icon-button.round { width: 40px; padding: 0; justify-content: center; }
.icon-button .label { font-weight: 600; font-size: 14px; }
:focus-visible { outline: 2px solid var(--accent-2); outline-offset: 2px; }

#offline-bar {
	margin: 0 clamp(12px, 3vw, 28px) 8px; padding: 8px 14px; border-radius: var(--radius-s);
	background: rgba(255, 181, 71, .12); border: 1px solid rgba(255, 181, 71, .35); color: var(--warn); font-size: 13.5px;
}

/* TOP 10 deadline: a calm state, not an error (reminder under 24 h, then "not ranked") */
.notice-bar {
	display: flex; align-items: center; gap: 10px;
	margin: 0 clamp(12px, 3vw, 28px) 8px; padding: 6px 6px 6px 14px; border-radius: var(--radius-s);
	background: var(--panel); border: 1px solid var(--line); color: var(--muted); font-size: 13.5px;
}
.notice-bar[hidden] { display: none; }
.notice-text { flex: 1; min-width: 0; }
.notice-close {
	flex: none; width: 30px; height: 30px; border: 0; border-radius: 8px; background: transparent; color: var(--muted);
	font: inherit; font-size: 20px; line-height: 1; cursor: pointer;
}
.notice-close:hover { background: var(--panel-2); color: var(--text); }
.hud-badge {
	align-self: flex-start; margin-top: 4px; padding: 1px 7px; border: 1px solid var(--line); border-radius: 999px;
	color: var(--muted); font-size: 11px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%;
}
.hud-badge[hidden] { display: none; }
body.is-portrait .hud-badge { align-self: center; margin-top: 2px; padding: 0 5px; font-size: 9.5px; }

#stage {
	flex: 1; min-height: 0; display: grid; gap: 18px;
	grid-template-columns: minmax(0, 1fr) 230px; grid-template-rows: auto 1fr;
	grid-template-areas: "board hud" "board actions";
	padding: 4px clamp(12px, 3vw, 28px) calc(18px + var(--safe-b));
}
#board-wrap { grid-area: board; position: relative; min-width: 0; min-height: 0; display: flex; align-items: center; justify-content: center; }
#hud { grid-area: hud; display: grid; gap: 10px; align-content: start; }
#actions { grid-area: actions; display: flex; flex-direction: column; gap: 10px; align-self: start; }

#board {
	display: block; border-radius: var(--radius); background: var(--bg-2);
	box-shadow: 0 0 0 1px var(--line), var(--shadow), 0 0 60px rgba(61, 220, 106, .05);
	touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
}

.stat {
	display: flex; flex-direction: column; gap: 2px; padding: 12px 16px; position: relative;
	background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
}
.stat-label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .8px; font-weight: 600; }
.stat-value { font-size: 26px; font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1.1; }
.stat-score .stat-value { color: var(--point); }
.stat-vanishers .stat-value { color: var(--warn); }
.bonus-meter { height: 4px; border-radius: 4px; background: var(--line); margin-top: 8px; overflow: hidden; }
.bonus-meter span { display: block; height: 100%; width: 0; background: var(--warn); transition: width .25s; }
.stat-value.bump { animation: bump .35s ease-out; }
@keyframes bump { 40% { transform: scale(1.18); } }

.action-button {
	display: flex; align-items: center; justify-content: center; gap: 10px; min-height: 50px; padding: 0 16px;
	border-radius: var(--radius); border: 1px solid var(--line); background: var(--panel); cursor: pointer;
	font-weight: 700; position: relative; transition: background .15s, border-color .15s, box-shadow .15s, transform .1s, opacity .15s;
}
.action-button:active { transform: scale(.97); }
.action-button.vanish { color: var(--warn); }
.action-button.vanish.ready { background: rgba(255, 181, 71, .14); border-color: var(--warn); box-shadow: 0 0 0 3px rgba(255, 181, 71, .15), 0 0 24px rgba(255, 181, 71, .25); }
.action-button.vanish:disabled { opacity: .45; cursor: default; }
.action-button.ghost { color: var(--muted); }
.action-button .badge {
	min-width: 22px; height: 22px; padding: 0 6px; border-radius: 11px; background: var(--warn); color: #1b1408;
	font-size: 12px; display: inline-flex; align-items: center; justify-content: center;
}
.action-button.shake { animation: shake .3s; }
@keyframes shake { 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }

.board-overlay { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; pointer-events: none; }
.overlay-card {
	max-width: min(360px, 86%); padding: 18px 22px; text-align: center; border-radius: var(--radius);
	background: rgba(15, 20, 32, .82); border: 1px solid var(--line); backdrop-filter: blur(6px); box-shadow: var(--shadow);
}
.overlay-title { margin: 0 0 6px; font-size: 20px; font-weight: 800; }
.overlay-go { margin: 10px 0 6px; }
.overlay-card { pointer-events: none; }
.mode-tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 10px; }
.mode-tile {
	pointer-events: auto; display: flex; flex-direction: column; align-items: flex-start; gap: 4px; padding: 14px 14px; text-align: left;
	border-radius: var(--radius); border: 1px solid var(--line); background: var(--panel-2); cursor: pointer; transition: border-color .15s, background .15s, transform .1s;
}
.mode-tile:hover { border-color: #3a4868; }
.mode-tile:active { transform: scale(.98); }
.mode-tile[aria-pressed="true"], .mode-tile[aria-current="true"] { border-color: var(--point); background: rgba(61, 220, 106, .08); box-shadow: 0 0 0 3px rgba(61, 220, 106, .12); }
.mode-name { font-weight: 800; font-size: 17px; }
.mode-tile[data-mode="sprint"] .mode-name::after { content: " ⚡"; }
.mode-desc { color: var(--muted); font-size: 13px; line-height: 1.35; }
.mode-tile[aria-pressed="true"] .mode-desc, .mode-tile[aria-current="true"] .mode-desc { color: var(--text); }
.mode-tiles.again { margin-top: 14px; }
.top-tabs { display: flex; gap: 6px; margin: 4px 0 10px; }
.top-tab { flex: 1; height: 38px; border-radius: 999px; border: 1px solid var(--line); background: transparent; cursor: pointer; font-weight: 600; color: var(--muted); }
.top-tab[aria-selected="true"] { color: var(--text); background: var(--panel-2); border-color: #3a4868; }
.overlay-hint { margin: 0; color: var(--muted); }
.board-overlay.hide { opacity: 0; visibility: hidden; transition: opacity .25s, visibility 0s .25s; } /* hidden tiles must not catch taps */
.board-overlay.hide .mode-tile { pointer-events: none; } /* at once, not after the fade */

.toast {
	position: absolute; left: 50%; top: 14px; transform: translate(-50%, -8px); opacity: 0; pointer-events: none;
	padding: 8px 16px; border-radius: 999px; background: rgba(23, 30, 46, .92); border: 1px solid var(--line);
	font-weight: 700; transition: opacity .2s, transform .2s; white-space: nowrap;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.level { color: var(--point); border-color: rgba(61, 220, 106, .5); }
.toast.warn { color: var(--warn); }

/* ---------- portrait: HUD strip above, actions below ---------- */
body.is-portrait #stage {
	grid-template-columns: 1fr; grid-template-rows: auto 1fr auto;
	grid-template-areas: "hud" "board" "actions"; gap: 10px; padding-top: 0;
}
body.is-portrait #hud { grid-template-columns: repeat(4, 1fr); gap: 6px; }
body.is-portrait .stat { padding: 7px 8px; border-radius: var(--radius-s); align-items: center; text-align: center; }
body.is-portrait .stat-label { font-size: 9.5px; letter-spacing: .4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
body.is-portrait .stat-value { font-size: 19px; }
body.is-portrait .bonus-meter { width: 100%; margin-top: 4px; height: 3px; }
body.is-portrait #actions { flex-direction: row; }
body.is-portrait #btn-vanish { flex: 1; min-height: 54px; }
body.is-portrait #btn-vanish kbd { display: none; }
body.is-portrait #btn-end { flex: none; min-height: 54px; }
body.is-portrait #btn-end span { display: none; }
body.is-portrait .brand-name { font-size: 17px; }
@media (max-width: 380px) { .icon-button .label { display: none; } #btn-top { width: 40px; padding: 0; justify-content: center; } }

/* ---------- low landscape screens (phones turned sideways): compact side panel ---------- */
@media (min-aspect-ratio: 1/1) and (max-height: 560px) { /* landscape or square, like rotated() === false */
	#topbar { padding-top: max(4px, env(safe-area-inset-top)); padding-bottom: 4px; }
	.brand-name { font-size: 16px; }
	.icon-button { height: 34px; padding: 0 10px; }
	.icon-button.round { width: 34px; }
	#stage { grid-template-columns: minmax(0, 1fr) 210px; gap: 10px; padding: 0 max(10px, env(safe-area-inset-right)) calc(8px + var(--safe-b)) max(10px, env(safe-area-inset-left)); }
	#hud { grid-template-columns: 1fr 1fr; gap: 6px; }
	.stat { padding: 6px 10px; border-radius: var(--radius-s); }
	.stat-label { font-size: 10px; letter-spacing: .4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
	.stat-value { font-size: 18px; }
	.bonus-meter { margin-top: 4px; height: 3px; }
	#actions { flex-direction: row; gap: 6px; }
	.action-button { min-height: 42px; padding: 0 10px; border-radius: var(--radius-s); }
	#btn-vanish { flex: 1; }
	#btn-vanish kbd, #btn-end span { display: none; }
	#offline-bar { margin-bottom: 4px; padding: 5px 10px; font-size: 12.5px; }
	.notice-bar { margin-bottom: 4px; padding: 2px 2px 2px 10px; font-size: 12.5px; }
	.notice-close { width: 26px; height: 26px; }
	.hud-badge { margin-top: 2px; font-size: 9.5px; }
}

/* ---------- dialogs ---------- */
dialog.sheet {
	width: min(520px, calc(100vw - 24px)); max-height: calc(100dvh - 32px); padding: 0; overflow: auto;
	color: var(--text); background: var(--panel); border: 1px solid var(--line); border-radius: 20px; box-shadow: 0 30px 80px rgba(0,0,0,.55);
}
dialog.sheet:focus { outline: none; }
dialog.sheet::backdrop { background: rgba(5, 8, 14, .62); backdrop-filter: blur(3px); }
dialog.sheet[open] { animation: rise .22s ease-out; }
@keyframes rise { from { transform: translateY(14px); opacity: 0; } }
.sheet-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 12px 12px 22px; position: sticky; top: 0; z-index: 2; background: var(--panel); border-bottom: 1px solid transparent; transition: border-color .15s, box-shadow .15s; } /* above scrolled content, also dimmed (opacity) items */
.sheet-head.scrolled { border-bottom-color: var(--line); box-shadow: 0 6px 14px rgba(0, 0, 0, .25); }
.sheet-head h2 { display: flex; align-items: center; gap: 10px; margin: 0; font-size: 20px; }
.sheet-head h2 img { border-radius: 7px; }
.sheet-head .close { width: 38px; height: 38px; padding: 0; justify-content: center; }
.sheet-body { padding: 4px 22px 22px; }
.sheet-body h3 { margin: 18px 0 6px; font-size: 15px; color: var(--muted); text-transform: uppercase; letter-spacing: .8px; }
.lead { font-size: 16px; margin: 4px 0 10px; }
.rules, .controls { margin: 0; padding-left: 20px; display: grid; gap: 6px; }
.controls li.dim { opacity: .45; }
.muted { color: var(--muted); font-size: 13.5px; }
.notice { font-size: 13.5px; padding: 10px 12px; border-radius: var(--radius-s); background: rgba(255, 181, 71, .1); border: 1px solid rgba(255, 181, 71, .3); }
.info-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 16px 0 8px; }
.info-row select { background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--radius-s); padding: 8px 10px; }
.footer-line { margin: 10px 0 0; font-size: 13.5px; }
.sheet-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 16px; flex-wrap: wrap; }

.primary-button {
	display: inline-flex; align-items: center; gap: 8px; height: 44px; padding: 0 20px; border: 0; border-radius: 999px; cursor: pointer;
	background: linear-gradient(180deg, var(--accent-2), var(--accent)); color: #fff; font-weight: 700; box-shadow: 0 8px 20px rgba(255, 90, 54, .3);
}
.primary-button:active { transform: scale(.97); }
.text-button { height: 44px; padding: 0 16px; border-radius: 999px; border: 1px solid var(--line); background: transparent; cursor: pointer; font-weight: 600; }
.text-button:hover { background: var(--panel-2); }

.over-title { margin: 6px 0 14px; font-size: 26px; text-align: center; }
.over-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.over-stats .stat-time { grid-column: 1 / -1; }
.over-stats .stat-time .stat-value { font-size: 20px; }
dialog.sheet.small { width: min(420px, calc(100vw - 24px)); }
.end-title { margin: 6px 0 8px; font-size: 22px; }
.over-stats .stat { align-items: center; }
.over-stats .stat:first-child .stat-value { color: var(--point); font-size: 34px; }
.over-stats .stat:last-child .stat-value { font-size: 34px; }
.over-status { text-align: center; font-weight: 600; margin: 14px 0 4px; min-height: 1.45em; }
.over-status.ok { color: var(--point); }
.over-status.bad { color: var(--warn); }
#over-best { text-align: center; margin: 0 0 8px; }

.top-list table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.top-list { overflow-x: auto; }
.top-list th { text-align: left; white-space: nowrap; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .6px; font-weight: 600; padding: 6px 8px; }
.top-list td { padding: 8px; border-top: 1px solid var(--line); }
.top-list td.num, .top-list th.num { text-align: right; }
.top-list tr.medal-1 td:first-child { color: #ffd166; font-weight: 800; }
.top-list tr.medal-2 td:first-child { color: #d6dde8; font-weight: 800; }
.top-list tr.medal-3 td:first-child { color: #e0a370; font-weight: 800; }
.top-list tr.you td { background: rgba(61, 220, 106, .1); }
.top-list tr.you td:first-child { box-shadow: inset 3px 0 var(--point); }
.top-list .state { color: var(--muted); text-align: center; padding: 18px 0; }

/* ---------- cookie and update cards ---------- */
.card {
	position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(16px + var(--safe-b)); z-index: 10;
	width: min(560px, calc(100vw - 24px)); display: flex; align-items: center; gap: 14px; padding: 14px 16px;
	background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); font-size: 14px;
}
.card p { margin: 0; flex: 1; }
.card .primary-button { height: 40px; flex: none; }
.card-buttons { display: flex; gap: 8px; flex: none; }
/* Accept and decline look the same: neither is pushed on the visitor */
.consent-button {
	height: 40px; padding: 0 16px; border-radius: 999px; border: 1px solid var(--line); background: var(--panel);
	color: var(--text); font: inherit; font-weight: 700; cursor: pointer; white-space: nowrap;
}
.consent-button:hover { background: var(--bg-2); }
@media (max-width: 520px) { #cookie-notice { flex-wrap: wrap; } #cookie-notice .card-buttons { width: 100%; } #cookie-notice .consent-button { flex: 1; } }
.info-storage { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin: 10px 0; }
.info-storage p { margin: 0; flex: 1 1 220px; }
#update-card { bottom: auto; top: calc(12px + env(safe-area-inset-top, 0px)); }

@media (prefers-reduced-motion: reduce) {
	*, *::before, *::after { animation: none !important; transition: none !important; }
}
