/*
 * style.css : look of every page (ported from the old app). Phone first.
 */

/* Local copies, so the page looks the same without internet. */
@font-face { font-family: Poppins; font-weight: 400; font-display: swap; src: url(fonts/poppins-400.woff2) format("woff2"); }
@font-face { font-family: Poppins; font-weight: 600; font-display: swap; src: url(fonts/poppins-600.woff2) format("woff2"); }
@font-face { font-family: Poppins; font-weight: 900; font-display: swap; src: url(fonts/poppins-900.woff2) format("woff2"); }

* { box-sizing: border-box; }
[hidden] { display: none; }

body {
    margin: 0;
    min-height: 100vh;
    padding: 20px 16px;
    font-family: Poppins, system-ui, sans-serif;
    font-weight: 600;
    color: #000;
    background: #1B5E20;
}

main { max-width: 600px; margin: 0 auto; position: relative; }
main:has(.columns) { max-width: 1100px; }

h1 {
    margin: 0 0 20px;
    padding-top: 36px;
    text-align: center;
    font-size: clamp(34px, 8vw, 64px);
    font-weight: 900;
    letter-spacing: 4px;
    color: #E53935;
    text-shadow: 4px 4px 0 #000;
}

h2 {
    margin: 0 0 16px;
    padding-bottom: 8px;
    font-size: 22px;
    font-weight: 900;
    letter-spacing: 2px;
    text-transform: uppercase;
    border-bottom: 4px solid #FFC107;
}

.card {
    margin-bottom: 24px;
    padding: 20px;
    background: #FFF;
    border: 5px solid #000;
    border-radius: 24px;
    box-shadow: 0 8px 0 #000;
}

input {
    width: 100%;
    margin-bottom: 14px;
    padding: 14px;
    font: inherit;
    font-size: 20px;
    text-align: center;
    border: 3px solid #000;
    border-radius: 12px;
}

button {
    width: 100%;
    padding: 16px;
    font: inherit;
    font-size: 22px;
    font-weight: 900;
    text-transform: uppercase;
    border: 4px solid #000;
    border-radius: 14px;
    box-shadow: 0 6px 0 #000;
    cursor: pointer;
}
button:active { transform: translateY(4px); box-shadow: 0 2px 0 #000; }
button.red { background: #E53935; color: #FFF; }
button.blue { background: #1976D2; color: #FFF; font-size: 18px; }
button.yellow { background: #FFC107; color: #000; }

.lang {
    position: absolute;
    top: 0;
    right: 0;
    padding: 5px 12px;
    font-size: 14px;
    font-weight: 900;
    color: #FFF;
    background: #1976D2;
    border: 3px solid #000;
    border-radius: 8px;
    text-decoration: none;
}

button.qr { position: absolute; top: 0; left: 0; width: auto; padding: 5px 12px; font-size: 14px; color: #FFF; background: transparent; border: 2px solid rgba(255, 255, 255, 0.5); border-radius: 8px; box-shadow: none; }
#qr-dialog { width: min(92vw, 400px); padding: 20px; text-align: center; border: 5px solid #000; border-radius: 24px; }
#qr-dialog::backdrop { background: rgba(0, 0, 0, 0.7); }
#qr-code { width: 100%; image-rendering: pixelated; }
#qr-address { margin: 0 0 14px; overflow-wrap: anywhere; }

.error { padding: 12px; color: #FFF; background: #C62828; border: 3px solid #000; border-radius: 12px; }

#players { margin: 0; padding: 0; list-style: none; }
#players li {
    margin-bottom: 8px;
    padding: 10px 14px;
    border: 3px solid #000;
    border-radius: 12px;
    overflow-wrap: anywhere;
}
#players li.me { background: #FFF9C4; }

/* Game page */
.banner { margin: 0 0 24px; text-align: center; }
.banner span {
    display: inline-block;
    padding: 8px 26px;
    font-size: 20px;
    font-weight: 900;
    text-transform: uppercase;
    background: #FFC107;
    border: 4px solid #000;
    border-radius: 999px;
}
.done { padding: 16px; text-align: center; font-size: 20px; color: #FFF; background: #2E7D32; border: 3px solid #000; border-radius: 12px; }
h3 { margin: 16px 0 10px; font-size: 16px; font-weight: 900; text-transform: uppercase; }

/* Radio buttons shown as big tiles */
.choices { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 16px; }
/* Stacked: the French labels are too long side by side. */
.choices.three { grid-template-columns: 1fr; }
.choices label { position: relative; }
.choices input { position: absolute; inset: 0; height: 100%; margin: 0; opacity: 0; }
.choices span { display: flex; flex-direction: column; justify-content: center; height: 100%; padding: 14px 6px; text-align: center; font-weight: 900; text-transform: uppercase; letter-spacing: 1px; border: 3px solid #000; border-radius: 14px; box-shadow: 0 4px 0 #999; }
.choices input:checked + span { background: #FFC107; box-shadow: 0 0 0 4px #E53935; }
.choices input[value="YES"]:checked + span { color: #FFF; background: #2E7D32; box-shadow: 0 0 0 4px #000; }
.choices input[value="NO"]:checked + span { color: #FFF; background: #E53935; box-shadow: 0 0 0 4px #000; }
.my-bet { display: grid; justify-items: center; gap: 10px; text-align: center; font-size: 24px; }
.my-bet img { width: 120px; height: 120px; border: 4px solid #000; border-radius: 50%; }
.my-bet .side-yes, .my-bet .side-no { padding: 6px 20px; color: #FFF; border-radius: 14px; }
.my-bet .side-yes { background: #2E7D32; }
.my-bet .side-no { background: #E53935; }
.my-bet span { font-size: 18px; font-weight: 600; }
.over { margin: 0; padding: 24px; color: #FFF; background: #333; border-radius: 14px; text-align: center; font-size: 24px; font-weight: 900; text-transform: uppercase; }
.choices input:focus-visible + span { outline: 3px solid #1976D2; outline-offset: 5px; }

.badge { display: block; width: 52px; height: 52px; margin: 0 auto 8px; line-height: 46px; font-size: 26px; font-weight: 900; color: #FFF; border: 3px solid #000; border-radius: 50%; }

#players li { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
#players li span { flex: 1 1 140px; }
button.small { width: auto; padding: 8px 10px; font-size: 14px; text-transform: none; border-width: 2px; box-shadow: none; }
button:disabled { opacity: 0.5; }

.columns { display: grid; gap: 0 24px; }
.columns > div { min-width: 0; }
/* Two columns only when there is room: phones keep one. */
@media (min-width: 720px) { .columns { grid-template-columns: 1fr 1fr; } }

.pots { padding: 4px 18px; background: #FFF9C4; border: 3px dashed #000; border-radius: 14px; }
.pots h3 { text-align: center; }

/* Results and leaderboard */
button.green { background: #4CAF50; color: #FFF; }
select { width: 100%; margin: 4px 0 12px; padding: 10px; font: inherit; background: #FFF; border: 3px solid #000; border-radius: 10px; }
#result-form { margin-top: 20px; }
#result-form button { margin-bottom: 12px; }
#results { margin: 16px 0; padding: 0; list-style: none; }
#results li { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 8px; }
#results span { flex: 1 1 200px; font-size: 14px; }
.buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 20px; }
.buttons button { padding: 12px 4px; font-size: 16px; }
details button.small { margin-top: 10px; }
#players li.rank1 { background: #FFD700; }
#players li.rank2 { background: #C0C0C0; }
#players li.rank3 { background: #CD7F32; }
#players li.me { outline: 4px solid #E53935; }

#final-race { padding: 16px; text-align: center; font-size: 22px; font-weight: 900; color: #FFF; background: #FF1744; border: 4px solid #000; border-radius: 18px; }

/* Big screen: larger text, and the list in columns so 50 names fit. */
main:has(.display) { max-width: 1800px; }
main:has(.display) h1 { padding-top: 0; margin-bottom: 8px; }
.display { font-size: 24px; }
.display #final-race { font-size: 36px; }
.display #players { columns: 290px; column-gap: 16px; font-size: 20px; }
.display #players li { break-inside: avoid; padding: 6px 12px; }
@media (min-width: 1000px) {
    .display { display: flex; align-items: flex-start; gap: 24px; }
    .display #info { flex: 0 0 400px; }
    .display #info + .card { flex: 1; min-width: 0; }
}

.medal { font-size: 1.5em; line-height: 1; vertical-align: -0.15em; }
.dot { display: inline-block; width: 0.7em; height: 0.7em; background: #BBB; border-radius: 50%; }
.dot.online { background: #2E7D32; }

/* Explanation of the gains */
#edit-bet:not([hidden]), #gains-open:not([hidden]) { display: block; margin: 14px auto 0; }
#gains-dialog { width: min(94vw, 460px); padding: 20px; border: 5px solid #000; border-radius: 24px; }
#gains-dialog::backdrop { background: rgba(0, 0, 0, 0.7); }
#gains-list { max-height: 60vh; overflow-y: auto; margin-bottom: 16px; }
#gains-list section { margin-bottom: 12px; padding: 4px 14px; background: #FFF9C4; border: 3px solid #000; border-radius: 14px; }
#gains-list h3 { margin: 10px 0; font-size: 22px; }
#gains-list .race-total { margin: 4px 0 10px; padding-top: 8px; text-align: right; font-size: 24px; font-weight: 900; border-top: 3px solid #000; }
#gains-list .race-total:only-child { text-align: left; font-size: 18px; border: 0; }
#gains-list .newest { text-align: center; background: #FFF; }
#gains-list .total { margin: 0; font-size: 60px; font-weight: 900; line-height: 1.1; }
#gains-list .total.won { color: #2E7D32; animation: pop 0.5s; }
#gains-list .total.lost { color: #757575; }
#gains-list .message { min-height: 1.5em; margin: 4px 0 10px; font-weight: 600; }
.bet-card { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; padding: 8px 10px; text-align: left; background: #EEE; border-radius: 12px; }
.bet-card.won { background: #C8E6C9; }
.newest .bet-card { animation: slide-in 0.4s; }
.bet-card img { width: 52px; height: 52px; border: 3px solid #000; border-radius: 50%; }
.bet-card > div { flex: 1; min-width: 0; }
.bet-card small { display: block; }
.bet-card .amount { font-size: 22px; white-space: nowrap; }
#gains-fireworks { position: fixed; inset: 0; width: 100vw; height: 100vh; pointer-events: none; }
@keyframes pop { 50% { transform: scale(1.35); } }
@keyframes slide-in { from { opacity: 0; transform: translateX(-30px); } }
@media (prefers-reduced-motion: reduce) { #gains-list * { animation: none !important; } }

.countdown { position: sticky; top: 0; z-index: 2; margin: 0 0 16px; padding: 12px; text-align: center; font-size: 26px; font-weight: 900; color: #FFF; background: #FF5722; border: 4px solid #000; border-radius: 14px; }
