@charset "UTF-8";

@font-face {
	font-family: 'Anton';
	font-style: normal;
	font-weight: 400;
	font-display: swap;
	src: url('fonts/Anton-Regular.ttf') format('truetype');
}
@font-face {
	font-family: 'Roboto';
	font-style: normal;
	font-weight: 400;
	font-display: swap;
	src: url('fonts/Roboto-Regular.ttf') format('truetype');
}
@font-face {
	font-family: 'Azeret Mono';
	font-style: normal;
	font-weight: 800;
	font-display: swap;
	src: url('fonts/AzeretMono-ExtraBold.ttf') format('truetype');
}

:root {
	color-scheme: light;
}
html {
	background-color: black;
}
#bg-fixed {
	position: fixed;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
	background-image: url("images/background.jpg");
	background-size: cover;
	background-repeat: no-repeat;
	background-position: center;
	z-index: -1;
}
body {
	-webkit-font-smoothing: antialiased !important;
	-moz-osx-font-smoothing: grayscale !important;
	font-family: "Roboto", Arial, sans-serif;
	line-height: 1;
}
html, body {
	margin: 0;
	padding: 0;
	width: 100%;
	height: 100%;
}
img {
	margin-top: 2px;
	filter: drop-shadow(0px 0px 6px rgba(0, 0, 0, 0.5));
}
#countdown {
	font-variant-numeric: tabular-nums;
}
.flash {
	animation: flash 1s linear infinite;
	color: #b21f27;
}
@keyframes flash {
	50% {
		opacity: 1;
		color: #f8d904;
	}
}
.main {
	max-height: 100vh;
	align-content: center;
	height: 100vh;
	width: 100%;
	margin: 0 auto;
	display: grid;
	gap: 1rem;
	grid-template-columns: 1fr;
}
.buttons.justify-center {
	display: grid;
	align-content: center;
	width: 100%;
	min-width: 0;
}
.buttonrow {
	display: grid;
	gap: 1rem;
	grid-template-columns: repeat(2, 1fr);
	align-content: space-evenly;
}
.buttonrowsingle {
	display: grid;
	gap: 1rem;
	grid-template-columns: 1fr;
	align-content: space-evenly;
}
.button {
	height: 8vh;
	font-size: 6vw;
	margin: 2vh;
	display: block;
	padding: 12px;
	border-radius: 24px;
	border: 3px solid white;
	color: white;
	font-family: inherit;
	font-weight: 600;
	white-space: nowrap;
	font-family: inherit;
}
.button:disabled {
	background-color: silver !important;
	color: dimgray !important;
}
.drop-shadow {
	filter: drop-shadow(0px 0px 6px rgba(0, 0, 0, 0.5));
}
.timer {
	display: grid;
	align-content: center;
	font-size: 80vw;
	font-family: "Anton", Arial, sans-serif;
	font-weight: 500;
	color: #f8d904;
	margin: 0;
	text-align: center;
	height: 100%;
	width: auto;
	min-width: 0;
	background: url(images/logo.svg);
	background-size: contain;
	background-repeat: no-repeat;
	background-position: center;
	-webkit-text-stroke: 0.02em #222;
	letter-spacing: 0.04em;
}
.countdown {
	visibility: hidden;
	width: 100%;
	height: 100%;
	opacity: 1;
}
.settings {
	position: fixed;
	top: 8px;
	left: 50%;
	transform: translateX(-50%);
	background-color: rgba(0, 0, 0, 0.5);
	color: white;
	font-size: 14px;
	text-align: center;
	padding: 1rem;
	z-index: 5;
	border-radius: 8px;
	white-space: nowrap;
	cursor: pointer;
	line-height: 1.5;
}
.settingsOverlay {
	position: fixed;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
	background-color: rgba(0, 0, 0, 0.8);
	z-index: 15;
	display: flex;
	justify-content: center;
	align-items: center;
}
.settingsButton {
	width: 100%;
	background-color: green;
	color: white;
	border: 2px solid white;
	padding: 12px 0;
	font-size: 24px;
	border-radius: 8px;
	text-align: center;
	font-weight: 600;
	font-family: inherit;
}
.settingsInput {
	font-size: 22px;
	text-indent: 0.1em;
	border-radius: 6px;
	font-family: inherit;
}
.settingsRow {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 1rem;
	margin-bottom: 1rem;
}
.settingsCaption {
	color: white;
	font-size: 18px;
	font-family: inherit;
	width: 75%;
}
.settingsControl {
	width: 74px;
	height: 36px;
}
.settingsInput,
.settingsToggle {
	width: 100%;
	height: 100%;
	box-sizing: border-box;
	display: block;
	text-align: center;
	object-fit: contain;
	padding: 0;
	margin: 0;
	font-family: inherit;
}
.settingsForm {
	padding: 1.25rem;
	text-align: left;
	background-color: rgba(0, 0, 0, 0.6);
	border-radius: 20px;
	width: 280px;
	max-width: 90%;
}
.hidden {
	display: none !important;
}
#flash-overlay {
	position: fixed;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
	background-color: white;
	opacity: 0;
	pointer-events: none;
	z-index: 100;
	transition: opacity 0.05s ease-in-out;
}
.input-error {
	border: 2px solid red !important;
	background-color: red;
	color: white;
}

/* Responsive hide utilities
   Each class only activates inside its own screen-size range,
   so combining them on the same element never causes conflicts.
   Small  : < 480px
   Medium : 480px – 767px
   Large  : 768px +                                              */
@media (max-width: 479px) {
	.hide-small { display: none !important; }
}
@media (min-width: 480px) and (max-width: 767px) {
	.hide-medium { display: none !important; }
}
@media (min-width: 768px) {
	.hide-large { display: none !important; }
}

/* Timer selector — display:contents makes all 6 items direct flex
   children of .help-buttons for even space-between in both orientations */
.timer-selector {
	display: contents;
}
.timer-option {
	cursor: pointer;
}
.timer-option input[type="radio"] {
	display: none;
}
.timer-option > span {
	display: inline-flex;
	align-items: center;
	padding: 4px 8px;
	border-radius: 10px;
	font-size: 14px;
	font-weight: 700;
	height: 18px;
	color: rgba(255, 255, 255, 0.8);
	background-color: rgba(0, 0, 0, 0.8);
	border: 2px solid rgba(255, 255, 255, 0.25);
	line-height: 1;
	-webkit-user-select: none;
	user-select: none;
	transition: color 0.15s, background-color 0.15s, border-color 0.15s;
}
.timer-option > span > span {
	margin-left: 4px;
}
.timer-option input[type="radio"]:checked + span {
	color: #f8d904;
	background-color: rgba(0, 0, 0, 0.8);
	border-color: #f8d904;
}
.help-buttons {
	position: fixed;
	top: calc(16px + env(safe-area-inset-top));
	left: 0;
	width: calc(100vw - 32px);
	display: flex;
	justify-content: space-between;
	align-items: center;
	z-index: 10;
	background-color: transparent;
	padding: 6px 10px;
	border-radius: 12px;
}
.help-buttons img {
	width: 32px;
	height: 32px;
	cursor: pointer;
	transition: transform 0.2s ease-in-out;
	z-index: 4;
	display: block;
}
.help-buttons img:hover {
	transform: scale(1.2);
}
/* Ensure the info <a> wrapper doesn't add extra baseline space */
.help-buttons > a {
	display: flex;
	align-items: center;
	line-height: 0;
}

@media (orientation: portrait) and (display-mode: standalone) {
	.main {
		margin-top: 80px;
		height: calc(100vh - 80px);
		max-height: calc(100vh - 80px);
		gap: 0.5rem;
	}
	.timer { height: auto; }
}
@media (orientation: portrait) and (display-mode: browser) {
	.main {
		height: 100dvh;
		max-height: 100dvh;
		margin-top: 0;
		box-sizing: border-box;
		padding-top: calc(env(safe-area-inset-top, 0px) + 84px);
		gap: 0.5rem;
	}
	.timer { height: auto; }
	.button {
		height: 8dvh;
		margin: 1.8dvh;
		display: flex;
		align-items: center;
		justify-content: center;
	}
}

@media (orientation: landscape) {
	.main {
		grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
		box-sizing: border-box;
		padding-left: calc(env(safe-area-inset-left, 0px) + 120px);
		padding-right: calc(env(safe-area-inset-right, 0px) + 16px);
	}
	.timer {
		font-size: 35vw;
	}
	.button {
		height: 8vw;
		font-size: clamp(14px, 2vw, 60px);
		margin: 5vh 4vh;
		display: flex;
		align-items: center;
		justify-content: center;
		padding: 12px;
		border-radius: 24px;
		border: 3px solid white;
		color: white;
		transform: translate(4px);
	}
	/* Help-buttons: vertical column on left, all 6 items evenly spaced */
	.help-buttons {
		top: 0;
		left: 0;
		width: calc(env(safe-area-inset-left, 0px) + 120px);
		height: 100dvh;
		box-sizing: border-box;
		flex-direction: column;
		justify-content: space-between;
		align-items: flex-start;
		padding: calc(env(safe-area-inset-top, 0px) + 16px)
		         16px
		         calc(env(safe-area-inset-bottom, 0px) + 16px)
		         max(env(safe-area-inset-left, 0px), 16px);
	}
	/* Order: settings(1), 15(2), 30(3), 45(4), 60(5), 6Red(6), info(7) */
	#settings-icon { order: 1; }
	.timer-selector > .timer-option:nth-child(1) { order: 2; }
	.timer-selector > .timer-option:nth-child(2) { order: 3; }
	.timer-selector > .timer-option:nth-child(3) { order: 4; }
	.timer-selector > .timer-option:nth-child(4) { order: 5; }
	#red6-btn { order: 6; }
	.help-buttons > a { order: 7; }
}

/* Phone landscape (<1024px): numbers only, no text */
@media (orientation: landscape) and (max-width: 1023px) {
	.timer-option > span > span {
		display: none !important;
	}
}
/* Tablet landscape (1024-1365px): show "Secs" */
@media (orientation: landscape) and (min-width: 1024px) and (max-width: 1365px) {
	.timer-option > span > span.hide-small.hide-large {
		display: inline-flex !important;
	}
	.timer-option > span > span.hide-small.hide-medium {
		display: none !important;
	}
}
/* Laptop landscape (1366px+): wider column to fit "Seconds" */
@media (orientation: landscape) and (min-width: 1366px) {
	.main {
		padding-left: calc(env(safe-area-inset-left, 0px) + 150px);
	}
	.help-buttons {
		width: calc(env(safe-area-inset-left, 0px) + 150px);
	}
}

@media (orientation: landscape) and (display-mode: browser) {
	.main {
		height: 100dvh;
		max-height: 100dvh;
	}
}


/* ── Match clock panel ── */
#match-clock-panel {
	/* In-flow: never overlaps buttons regardless of screen size or browser chrome */
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 6px;
	background: rgba(0,0,0,0.75);
	border: 3px solid #aaaaaa;
	border-radius: 20px;
	padding: 6px 14px;
	backdrop-filter: blur(6px);
	-webkit-backdrop-filter: blur(6px);
	white-space: nowrap;
	/* Portrait: centred below buttons with safe-area breathing room */
	margin: 6px auto calc(8px + env(safe-area-inset-bottom, 0px));
}
.mc-label {
	font-size: clamp(0.55rem, 1.1vw, 0.7rem);
	font-weight: 700;
	color: rgba(255,255,255,0.55);
	text-transform: uppercase;
	letter-spacing: 0.12em;
	line-height: 1;
	width: 100%;
	text-align: center;
}
#mc-timer {
	font-family: 'Azeret Mono', monospace;
	font-weight: 800;
	font-size: clamp(43px, 7.8vw, 58px);
	color: lightblue;
	line-height: 1;
	letter-spacing: 0.04em;
	min-width: 4.2ch;
	text-align: center;
}
#mc-timer.mc-stage2  { color: orange; }
.mc-btn {
	display: flex;
	align-items: center;
	justify-content: center;
	width: clamp(36px, 6.5vw, 48px);
	height: clamp(36px, 6.5vw, 48px);
	border-radius: 50%;
	border: 2px solid rgba(255,255,255,0.55);
	background: rgba(0,0,0,0.4);
	cursor: pointer;
	touch-action: manipulation;
	padding: 0;
	flex-shrink: 0;
}
.mc-btn img {
	width: 50%;
	height: 50%;
	object-fit: contain;
	filter: brightness(0) invert(1);
	pointer-events: none;
	margin: 0;
}
#mc-startButton { background-color: rgba(0,120,0,0.8); }
#mc-resetButton { background-color: rgba(140,0,0,0.7); }
#mc-resetButton:disabled {
	background-color: rgba(80,80,80,0.5);
	border-color: rgba(255,255,255,0.2);
}

/* Full-reset button – hidden but kept in DOM */
#full-reset-btn { display: none; }

/* Fullscreen/zoom button */
#zoom {
	width: 28px;
	height: 28px;
	cursor: pointer;
	transition: transform 0.2s;
}
#zoom:hover { transform: scale(1.2); }

/* 6-Red button */
#red6-btn {
	width: 32px;
	height: 32px;
	cursor: pointer;
	transition: transform 0.2s, opacity 0.2s;
}
#red6-btn:hover:not(.disabled) { transform: scale(1.2); }
#red6-btn.disabled {
	opacity: 0.3;
	cursor: default;
	pointer-events: none;
}

/* ── Stopwatch overlay ── */
#stopwatch-overlay {
	display: none;
	position: fixed;
	inset: 0;
	z-index: 200;
	background: transparent;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 28px;
	box-sizing: border-box;
	padding: calc(env(safe-area-inset-top,0px) + 16px)
	         calc(env(safe-area-inset-right,0px) + 16px)
	         calc(env(safe-area-inset-bottom,0px) + 16px)
	         calc(env(safe-area-inset-left,0px) + 16px);
}
#stopwatch-overlay.active { display: flex; }
#sw-display {
	font-family: 'Azeret Mono', monospace;
	font-weight: 800;
	font-size: clamp(56px, 16vmin, 190px);
	color: #fff;
	letter-spacing: -0.02em;
	line-height: 1;
	text-align: center;
	text-shadow: 0 2px 14px rgba(0,0,0,0.9);
}
.sw-buttons {
	display: flex;
	flex-direction: column;
	gap: 12px;
	align-items: center;
	width: 100%;
}
.sw-action-btn {
	width: min(82vw, 360px);
	height: clamp(50px, 7.5vh, 68px);
	border-radius: 20px;
	border: 3px solid #aaaaaa;
	font-size: clamp(16px, 2.2vw, 20px);
	font-weight: 700;
	color: #fff;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 10px;
	font-family: inherit;
	letter-spacing: 0.04em;
	transition: filter 0.12s, transform 0.1s;
}
.sw-action-btn:active { transform: scale(0.97); filter: brightness(1.2); }
.sw-action-btn img { width: 26px; height: 26px; display: block; }
#sw-start-btn  { background: #2a6e2a; }
#sw-start-btn.running { background: #b21f27; }
#sw-foul-btn   { background: #7a4500; }
#sw-foul-btn:disabled { opacity: 0.35; cursor: default; }
#sw-back-btn   { background: #1a1a2e; }
#sw-laps {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 4px;
	max-height: 18vh;
	overflow-y: auto;
	width: min(82vw, 360px);
}
.sw-lap {
	font-family: 'Azeret Mono', monospace;
	font-weight: 800;
	font-size: clamp(14px, 2.5vmin, 22px);
	color: rgba(255,255,255,0.7);
	letter-spacing: 0.04em;
	cursor: pointer;
	border-radius: 6px;
	padding: 2px 6px;
	transition: color 0.1s;
	text-shadow: 0 1px 4px rgba(0,0,0,0.9), 0 0 12px rgba(0,0,0,0.8);
}
.sw-lap:hover { color: #fff; }
.sw-lap[contenteditable="true"] {
	outline: 1px solid rgba(255,255,255,0.45);
	color: #fff;
	cursor: text;
	min-width: 12ch;
}

/* sw-right: transparent in portrait, real column in landscape */
#sw-right { display: contents; }

@media (orientation: landscape) {
	#stopwatch-overlay {
		flex-direction: row;
		align-items: stretch;
		gap: 0;
		padding: 0;
	}
	#sw-display {
		flex: 0 0 70%;
		display: flex;
		align-items: center;
		justify-content: center;
		font-size: clamp(48px, 14vh, 160px);
		padding: calc(env(safe-area-inset-top,0px) + 12px)
		         12px
		         calc(env(safe-area-inset-bottom,0px) + 12px)
		         calc(env(safe-area-inset-left,0px) + 12px);
		box-sizing: border-box;
	}
	#sw-right {
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
		gap: 8px;
		flex: 0 0 30%;
		overflow-y: auto;
		box-sizing: border-box;
		padding: calc(env(safe-area-inset-top,0px) + 12px)
		         calc(env(safe-area-inset-right,0px) + 16px)
		         calc(env(safe-area-inset-bottom,0px) + 12px)
		         12px;
	}
	.sw-buttons { width: 100%; max-width: 220px; gap: 8px; }
	.sw-action-btn {
		width: 100%;
		height: clamp(40px, 8vh, 56px);
		font-size: clamp(13px, 1.8vh, 17px);
	}
	#sw-laps {
		max-height: none;
		width: 100%;
		overflow-y: auto;
	}
}

/* Settings additions */
.settingsSectionHeader {
	color: rgba(255,255,255,0.5);
	font-size: 10px;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: 0.12em;
	margin: 14px 0 8px;
	border-top: 1px solid rgba(255,255,255,0.15);
	padding-top: 12px;
}
.settingsInputText {
	font-size: 20px;
	border-radius: 6px;
	font-family: inherit;
	padding: 2px 6px;
	width: 100%;
	height: 36px;
	box-sizing: border-box;
	text-align: center;
}

/* ── Portrait layout: right-column is transparent to grid ── */
.right-column {
	display: contents; /* .buttons and #match-clock-panel become direct grid children */
}
/* Use dynamic viewport height so browser chrome never causes overflow */
.main {
	height: 100dvh;
	max-height: 100dvh;
	grid-template-rows: minmax(0, 1fr) auto auto;
}

/* ── Landscape layout: right-column is a real flex column ── */
@media (orientation: landscape) {
	.right-column {
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
		/* sits in grid column 2, row 1 automatically */
	}
	/* Match clock centred below Reset Frame, no overlap possible */
	#match-clock-panel {
		margin: 10px auto 0;
	}
	/* Reset the portrait grid-template-rows (landscape is 2-column, 1-row) */
	.main {
		grid-template-rows: auto;
	}
	#zoom           { order: 0; }
	#full-reset-btn { order: 8; }
}

/* Landscape on very short screens (e.g. phone in landscape ~390px tall) */
@media (orientation: landscape) and (max-height: 500px) {
	.button {
		margin: 1.5vh 4vh;
		height: 7vw;
	}
	#match-clock-panel {
		margin: 2px auto 0;
		padding: 4px 10px;
	}
	#mc-timer {
		font-size: clamp(1.2rem, 3.5vw, 1.8rem);
	}
	.mc-btn {
		width: clamp(26px, 4.5vw, 38px);
		height: clamp(26px, 4.5vw, 38px);
	}
}
