/* EG63 web app - theme matched to eg63_website (logo blue + gold accent) */
:root {
	--brand:         #00b4f8;   /* logo blue - accents, gradients            */
	--brand-light:   #4ed0ff;   /* highlights                                */
	--brand-dark:    #0083c4;   /* surfaces that carry white text            */
	--brand-text:    #0070a8;   /* blue text on white (AA contrast)          */
	--brand-darker:  #05426b;   /* header, keypad, deep surfaces             */
	--brand-deepest: #03263f;
	--gold:          #f5b301;   /* lucky accent - pairs with the blue        */
	--gold-dark:     #d99a00;
	--gold-soft:     #fff3c8;
	--ink:           #0f2233;
	--muted:         #5f7383;
	--paper:         #ffffff;
	--bg:            #f3f9fd;
	--line:          #d9eaf3;
	--red:           #f0303a;
	--red-dark:      #b3101c;
	--green:         #1f9d55;
	--lm:            #a9ecff;
	--so:            #ffd0d6;
	--radius:        14px;
	--shadow:        0 6px 24px rgba(5, 66, 107, .12);
	--topbar-h:      58px;
	--mono:          ui-monospace, "SFMono-Regular", Menlo, Consolas, "Liberation Mono", monospace;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
	margin: 0;
	background: var(--bg);
	color: var(--ink);
	font: 15px/1.5 "Poppins", "Segoe UI", system-ui, -apple-system, Arial, sans-serif;
	min-height: 100vh;
	-webkit-tap-highlight-color: transparent;
}
a { color: var(--brand-text); text-decoration: none; }
code { font-family: var(--mono); background: #eaf6fc; color: var(--brand-text); padding: 1px 6px; border-radius: 5px; font-size: .92em; }
.muted { color: var(--muted); font-size: 13px; }
.mono { font-family: var(--mono); }
.sr-only { position: absolute !important; left: -9999px; width: 1px; height: 1px; opacity: 0; }
[hidden] { display: none !important; }

/* ---------- top bar ---------- */
.topbar {
	position: fixed; top: 0; left: 0; right: 0; z-index: 50;
	height: var(--topbar-h);
	display: flex; align-items: center; justify-content: space-between;
	background: linear-gradient(135deg, var(--brand) 0%, var(--brand-dark) 40%, var(--brand-darker) 100%);
	color: #fff;
	box-shadow: 0 3px 14px rgba(5, 66, 107, .35);
	padding: 0 4px;
	padding-top: env(safe-area-inset-top);
}
.topbar__title { flex: 1; margin: 0; text-align: center; font-size: 17px; font-weight: 700; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; letter-spacing: .01em; }
.topbar__btn { width: 48px; height: 48px; display: inline-flex; align-items: center; justify-content: center; color: #fff; background: none; border: 0; border-radius: 50%; cursor: pointer; }
.topbar__btn:active { background: rgba(255, 255, 255, .18); }
.topbar__spacer { pointer-events: none; }

/* ---------- layout ---------- */
.app {
	max-width: 640px; margin: 0 auto;
	padding: calc(var(--topbar-h) + 16px) 16px 110px;
	padding-top: calc(var(--topbar-h) + 16px + env(safe-area-inset-top));
}
.section-title { font-size: 12px; text-transform: uppercase; letter-spacing: .1em; color: var(--brand-text); font-weight: 700; margin: 22px 0 10px; }
.card { background: var(--paper); color: var(--ink); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); margin-bottom: 14px; }
.card--dark { background: linear-gradient(135deg, var(--brand-dark) 0%, var(--brand-darker) 100%); color: #fff; border-color: transparent; }
.card__title { margin: 0 0 8px; font-size: 17px; font-weight: 700; color: var(--brand-darker); }
.card p { margin: 6px 0; }
.alert { border-radius: 10px; padding: 12px 14px; margin-bottom: 14px; font-size: 14px; }
.alert--warn { background: var(--gold-soft); border: 1px solid #ffe6a8; color: #7a5a00; }
.alert--error { background: #ffe3e5; border: 1px solid #ffb3b8; color: var(--red-dark); }
.empty { text-align: center; padding: 28px 10px; }

/* ---------- forms ---------- */
.form .field { margin-bottom: 14px; }
.field label { display: block; font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 5px; }
.card--dark .field label { color: #cfe9f7; }
.input {
	width: 100%; height: 46px; padding: 0 14px;
	border: 1.5px solid var(--line); border-radius: 12px;
	background: #fff; color: var(--ink); font-size: 16px; font-family: inherit;
	outline: none; transition: border-color .15s, box-shadow .15s;
}
.input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(0, 180, 248, .2); }
.input--sm { height: 40px; font-size: 15px; }
.input.is-error { border-color: var(--red); }
input[type="date"].input { min-width: 0; }
.field--inline { margin: 0; }
.field--grow { flex: 1; }
.filters { padding: 12px; }
.filters__row { display: flex; gap: 10px; align-items: flex-end; margin: 10px 0; }
.filters__row .btn { height: 40px; }
.radio-list { display: flex; flex-direction: column; gap: 8px; }
.radio, .check { display: flex; align-items: center; gap: 10px; font-size: 15px; cursor: pointer; }
.radio input, .check input { width: 18px; height: 18px; accent-color: var(--brand-dark); }

/* segmented toggle */
.seg { display: flex; background: rgba(3, 38, 63, .35); border-radius: 999px; padding: 4px; }
.seg__btn { flex: 1; height: 36px; border: 0; border-radius: 999px; background: transparent; color: #cfe9f7; font-weight: 700; font-family: inherit; cursor: pointer; }
.seg__btn.is-active { background: linear-gradient(180deg, var(--gold), var(--gold-dark)); color: var(--brand-darker); }

/* ---------- buttons ---------- */
.btn {
	display: inline-flex; align-items: center; justify-content: center;
	height: 46px; padding: 0 22px; border: 0; border-radius: 999px;
	font-size: 15px; font-weight: 700; font-family: inherit; cursor: pointer; text-decoration: none;
	transition: transform .08s ease, box-shadow .15s ease, filter .15s ease;
	user-select: none;
}
.btn:hover { transform: translateY(-1px); box-shadow: 0 8px 20px rgba(5, 66, 107, .2); }
.btn:active { transform: scale(.98); box-shadow: none; }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; box-shadow: none; }
.btn--primary { background: linear-gradient(180deg, var(--brand), var(--brand-dark)); color: #fff; }
.btn--gold { background: linear-gradient(180deg, var(--gold), var(--gold-dark)); color: var(--brand-darker); }
.btn--secondary { background: #fff; color: var(--brand-text); border: 1.5px solid var(--line); }
.card--dark .btn--secondary { background: rgba(255, 255, 255, .12); color: #fff; border-color: rgba(255, 255, 255, .5); }
.btn--danger { background: linear-gradient(180deg, var(--red), var(--red-dark)); color: #fff; }
.btn--ghost { background: transparent; color: var(--brand-text); }
.btn--block { width: 100%; }
.btn--sm { height: 36px; padding: 0 16px; font-size: 14px; }
.row-actions { margin: 14px 0; }

/* bottom sticky action bar */
.bottom-actions {
	position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
	display: flex; gap: 10px; padding: 10px 16px;
	padding-bottom: calc(10px + env(safe-area-inset-bottom));
	background: linear-gradient(to top, var(--bg) 75%, rgba(243, 249, 253, 0));
}
.bottom-actions > .btn { flex: 1; }
.bottom-actions--two-rows { flex-direction: column; }
.bottom-actions__row { display: flex; gap: 10px; }
.bottom-actions__row .btn { flex: 1; }
@media (min-width: 640px) {
	.bottom-actions { max-width: 640px; left: 50%; transform: translateX(-50%); }
}

/* ---------- login ---------- */
.page-login .app { padding-top: calc(var(--topbar-h) + 30px); }
.login__logo { text-align: center; margin: 10px 0 24px; }
.login__logo img { width: 130px; height: 130px; object-fit: contain; border-radius: 50%; background: #fff; padding: 8px; box-shadow: var(--shadow); border: 1px solid var(--line); }
.login__logo--sm img { width: 90px; height: 90px; }
.login__links { text-align: center; margin-top: 22px; font-size: 15px; font-weight: 600; }

/* ---------- dashboard ---------- */
.dashboard__hello { margin: 4px 0 18px; }
.dashboard__name { font-size: 20px; font-weight: 700; color: var(--brand-darker); }
.dashboard__uid { color: var(--muted); font-size: 13px; }
.tiles { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }
@media (min-width: 560px) { .tiles { grid-template-columns: repeat(4, 1fr); } }
.tile {
	display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
	aspect-ratio: 1 / .9; background: var(--paper); color: var(--ink);
	border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); text-decoration: none;
	transition: transform .08s ease, box-shadow .15s ease;
}
.tile:hover { transform: translateY(-2px); box-shadow: 0 10px 26px rgba(5, 66, 107, .18); }
.tile:active { transform: scale(.97); }
.tile__icon { width: 64px; height: 64px; display: flex; align-items: center; justify-content: center; border-radius: 50%; background: linear-gradient(135deg, var(--brand-light), var(--brand-dark)); color: #fff; box-shadow: 0 4px 12px rgba(0, 131, 196, .35); }
.tile__label { font-weight: 700; font-size: 14px; text-align: center; padding: 0 8px; color: var(--brand-darker); }

/* ---------- buy ---------- */
.page-buy .app { padding-bottom: 120px; }
.page-buy.keypad-open .app { padding-bottom: 360px; }
.buy__top { display: flex; align-items: center; gap: 12px; padding: 12px 14px; }
.buy__sum { display: flex; align-items: baseline; gap: 8px; }
.buy__sumlabel { font-size: 11px; color: #cfe9f7; letter-spacing: .1em; font-weight: 700; }
.buy__sumvalue { font-size: 22px; font-weight: 800; color: var(--gold); font-family: var(--mono); }
.buy__bal { flex: 1; text-align: right; font-size: 13px; color: #cfe9f7; }
.buy__hint { margin-top: 14px; line-height: 1.6; }
.entries { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.entry { display: flex; align-items: center; border-bottom: 1px solid #eaf3f9; }
.entry:last-child { border-bottom: 0; }
.entry__idx { width: 40px; text-align: center; font-size: 12px; color: var(--muted); font-family: var(--mono); }
.entry__input {
	flex: 1; height: 40px; border: 0; outline: none; padding: 0 10px;
	font: 17px var(--mono); letter-spacing: .04em; color: var(--ink); background: transparent;
}
.entry.is-focus { background: #eaf6fc; }
.entry.is-focus .entry__idx { color: var(--brand-text); font-weight: 700; }
.entry.is-invalid { background: #ffe3e5; }
.entry.is-invalid .entry__input { color: var(--red-dark); }

.keypad {
	position: fixed; left: 0; right: 0; bottom: 0; z-index: 45;
	background: var(--brand-darker); padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
	box-shadow: 0 -4px 16px rgba(5, 66, 107, .4);
}
@media (min-width: 640px) { .keypad { max-width: 640px; left: 50%; transform: translateX(-50%); border-radius: 14px 14px 0 0; } }
.keypad__row { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; margin-bottom: 6px; }
.keypad__row:last-child { margin-bottom: 0; }
.key {
	height: 50px; border: 0; border-radius: 10px;
	background: #0b5a8c; color: #fff; font-size: 20px; font-weight: 700; font-family: var(--mono);
	cursor: pointer; display: inline-flex; align-items: center; justify-content: center;
	user-select: none; touch-action: manipulation;
}
.key:active { background: var(--brand-dark); }
.key--code { background: var(--brand-dark); color: var(--gold); font-size: 16px; font-family: inherit; }
.key--alt { background: var(--brand-deepest); font-size: 15px; font-family: inherit; }
.key--buy { background: linear-gradient(180deg, var(--gold), var(--gold-dark)); color: var(--brand-darker); font-family: inherit; font-size: 15px; font-weight: 800; }

/* ---------- receipts ---------- */
.list { display: flex; flex-direction: column; gap: 12px; }
.receipt-item {
	display: block; background: var(--paper); color: var(--ink);
	border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; box-shadow: var(--shadow);
	text-decoration: none; position: relative; overflow: hidden;
}
.receipt-item:not(.receipt-item--static):hover { border-color: var(--brand); }
.receipt-item--void { background: #fff0f1; border-color: #ffb3b8; color: var(--red-dark); }
.receipt-item--static { cursor: default; }
.receipt-item__head { display: flex; justify-content: space-between; gap: 8px; font-weight: 700; margin-bottom: 4px; color: var(--brand-darker); }
.receipt-item--void .receipt-item__head { color: var(--red-dark); }
.receipt-item__gt { color: var(--brand-text); }
.receipt-item__meta { display: flex; justify-content: space-between; gap: 8px; font-size: 12px; color: var(--muted); flex-wrap: wrap; }
.receipt-item__ticket { margin-top: 8px; font-family: var(--mono); font-size: 13px; line-height: 1.7; word-break: break-word; }
.receipt-item__void { position: absolute; right: -28px; top: 10px; transform: rotate(35deg); background: var(--red); color: #fff; font-weight: 800; letter-spacing: .2em; padding: 2px 40px; font-size: 12px; }
.lm { background: var(--lm); color: #04425f; padding: 0 4px; border-radius: 4px; }
.so { background: var(--so); color: #7a0a12; padding: 0 4px; border-radius: 4px; }

/* receipt paper (detail / result / report) */
.paper {
	background: var(--paper); color: var(--ink); border: 1px solid var(--line); border-radius: var(--radius);
	padding: 18px 16px; box-shadow: var(--shadow); font-family: var(--mono); font-size: 15px; line-height: 1.7;
	position: relative; overflow: hidden; margin-bottom: 14px;
}
.paper--void { border: 2px solid var(--red); }
.paper__title { font-weight: 700; font-size: 17px; margin-bottom: 4px; color: var(--brand-darker); font-family: "Poppins", inherit; }
.paper__line { white-space: pre-wrap; word-break: break-word; }
.paper__gap { height: 12px; }
.paper__gt { font-weight: 700; font-size: 17px; color: var(--brand-text); }
.paper__voidstamp {
	position: absolute; top: 40%; left: 50%; transform: translate(-50%, -50%) rotate(-20deg);
	border: 5px solid var(--red); color: var(--red); font-size: 56px; font-weight: 900; letter-spacing: .3em;
	padding: 4px 24px; opacity: .5; pointer-events: none; border-radius: 10px;
}

/* ---------- results (mirrors the website result card) ---------- */
.draw { padding: 0; }
.draw__head { background: linear-gradient(135deg, var(--brand-dark) 0%, var(--brand-darker) 100%); color: #fff; padding: 14px 18px; text-align: center; font-family: "Poppins", inherit; }
.draw__brand { font-weight: 800; font-size: 18px; letter-spacing: .05em; }
.draw__date { font-size: 12px; opacity: .9; }
.draw__pending { text-align: center; background: var(--gold-soft); color: #7a5a00; padding: 8px; margin: 14px 16px 0; border-radius: 8px; font-family: inherit; font-size: 13px; }
.draw__prizes { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 16px 16px 14px; }
.draw__prize { background: #f7fcff; border: 2px solid var(--line); border-radius: 12px; padding: 8px 4px 10px; text-align: center; min-width: 0; }
.draw__prize:first-child { border-color: var(--gold); background: linear-gradient(180deg, #fff8e0, var(--gold-soft)); }
.draw__prizelabel { font-size: 10px; color: var(--brand-text); font-family: "Poppins", inherit; font-weight: 700; text-transform: uppercase; letter-spacing: 1px; }
.draw__prizenum { font-size: 24px; font-weight: 800; letter-spacing: .08em; color: var(--ink); }
.draw__prizenum sup { font-size: 11px; color: var(--brand-text); margin-left: 2px; }
.draw__section { font-family: "Poppins", inherit; font-weight: 700; font-size: 12px; color: var(--brand-text); text-transform: uppercase; letter-spacing: .1em; margin: 10px 16px 6px; text-align: center; }
.draw__grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px 4px; text-align: center; font-size: 17px; font-weight: 700; letter-spacing: .06em; margin: 0 16px 16px; }
.draw__grid span { background: #f7fcff; border: 1px solid var(--line); border-radius: 8px; padding: 4px 0; }
@media (max-width: 380px) { .draw__grid { font-size: 15px; } }

/* ---------- strike ---------- */
.strike-total { display: flex; justify-content: space-between; align-items: center; font-size: 15px; }
.strike-total strong { font-size: 20px; color: var(--brand-text); }
.strike-table { width: 100%; border-collapse: collapse; margin-top: 8px; font-size: 13px; }
.strike-table th { text-align: left; font-weight: 700; color: var(--muted); border-bottom: 1px solid var(--line); padding: 4px 2px; }
.strike-table td { padding: 5px 2px; border-bottom: 1px dashed var(--line); }
.strike-table .num { text-align: right; }

/* ---------- report ---------- */
.report-paper { font-family: inherit; }
.report-block { padding: 6px 0 10px; border-bottom: 1px dashed var(--line); margin-bottom: 10px; }
.report-block:last-of-type { border-bottom: 0; }
.report-block__title { font-weight: 700; margin-bottom: 4px; color: var(--brand-text); }
.report-row { display: flex; justify-content: space-between; padding: 3px 0; }
.report-row strong { font-family: var(--mono); }
.report-row--total { border-top: 1px solid var(--line); margin-top: 4px; padding-top: 6px; font-size: 17px; color: var(--brand-darker); }
.report-range { text-align: right; margin-top: 6px; }

/* ---------- help ---------- */
.pkg-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; }
.pkg { margin: 0; padding: 12px 14px; }
.pkg__name { font-weight: 800; color: var(--brand-text); margin-bottom: 6px; font-size: 16px; }
.pkg__lines { list-style: none; margin: 0; padding: 0; font-size: 13px; }
.pkg__lines li { display: flex; justify-content: space-between; gap: 8px; padding: 3px 0; border-bottom: 1px dashed var(--line); }
.pkg__lines li:last-child { border-bottom: 0; }
.help-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.help-table th { text-align: left; white-space: nowrap; vertical-align: top; padding: 6px 10px 6px 0; color: var(--brand-text); }
.help-table td { padding: 6px 0; border-bottom: 1px dashed var(--line); }

/* ---------- toast / overlay / sheet ---------- */
.toast-wrap { position: fixed; left: 0; right: 0; bottom: 90px; display: flex; flex-direction: column; align-items: center; gap: 8px; z-index: 100; pointer-events: none; padding: 0 16px; }
.toast {
	background: var(--brand-darker); color: #fff; padding: 10px 18px; border-radius: 999px;
	font-size: 14px; font-weight: 500; box-shadow: var(--shadow); max-width: 100%; text-align: center;
	animation: toast-in .2s ease;
}
.toast--error { background: var(--red-dark); }
.toast--success { background: var(--green); }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

.overlay { position: fixed; inset: 0; background: rgba(3, 38, 63, .5); z-index: 90; display: flex; align-items: center; justify-content: center; }
.overlay__box { background: #fff; color: var(--ink); border-radius: 14px; padding: 22px 28px; display: flex; flex-direction: column; align-items: center; gap: 12px; box-shadow: var(--shadow); font-weight: 600; }
.spinner { width: 34px; height: 34px; border: 4px solid var(--line); border-top-color: var(--brand); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.sheet { position: fixed; inset: 0; z-index: 95; }
.sheet__backdrop { position: absolute; inset: 0; background: rgba(3, 38, 63, .5); }
.sheet__panel {
	position: absolute; left: 0; right: 0; bottom: 0; background: #fff; color: var(--ink);
	border-radius: 18px 18px 0 0; padding: 18px 16px calc(18px + env(safe-area-inset-bottom));
	box-shadow: 0 -6px 24px rgba(5, 66, 107, .25); animation: sheet-in .2s ease;
	max-width: 640px; margin: 0 auto;
}
@keyframes sheet-in { from { transform: translateY(30px); opacity: 0; } to { transform: none; opacity: 1; } }
.sheet__title { font-size: 18px; font-weight: 700; margin-bottom: 6px; color: var(--brand-darker); }
.sheet__msg { color: var(--muted); margin-bottom: 16px; white-space: pre-wrap; }
.sheet__actions { display: flex; gap: 10px; flex-wrap: wrap; }
.sheet__actions .btn { flex: 1; min-width: 40%; }
.sheet__actions--grid .btn { flex: 1 1 30%; }

/* ---------- print ---------- */
@media print {
	body { background: #fff; color: #000; font-size: 12px; }
	.topbar, .bottom-actions, .keypad, .filters, .toast-wrap, .overlay, .sheet, .row-actions, .buy__hint, .section-title, .login__logo { display: none !important; }
	.app { padding: 0; max-width: none; }
	.paper, .card, .receipt-item { box-shadow: none; border-radius: 0; border: 0; margin: 0; padding: 0; color: #000; background: #fff; }
	.paper { font-size: 12px; line-height: 1.4; }
	.paper--void { outline: none; }
	.draw__head { background: none; color: #000; padding: 0 0 6px; }
	.draw__prizes, .draw__grid, .draw__section, .draw__pending { margin-left: 0; margin-right: 0; }
	.lm, .so { background: none; color: #000; font-weight: 700; }
	.lm::after { content: " [LM]"; }
	.so::after { content: " [SO]"; }
	.draw__prize, .draw__grid span { border: 1px solid #000; background: #fff; }
	.print-hide { display: none !important; }
	body[data-paper="58"] .app, body[data-paper="58"] .paper { width: 58mm; font-size: 11px; }
	body[data-paper="80"] .app, body[data-paper="80"] .paper { width: 80mm; font-size: 12px; }
	@page { margin: 4mm; }
}
