:root {
    --navy: #062b4f;
    --navy-2: #0a3964;
    --orange: #ff7a00;
    --orange-2: #ff5b2e;
    --paper: #f7fafc;
    --white: #ffffff;
    --green: #1fa463;
    --ink: #10243d;
    --muted: #5d6f82;
    --line: #d9e3ec;
    --shadow: 0 18px 45px rgba(6, 43, 79, .16);
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { background: var(--paper); color: var(--ink); }
body { margin: 0; min-height: 100vh; padding-bottom: 110px; }
a { color: inherit; }
button, input, select { font: inherit; }

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 14px max(18px, env(safe-area-inset-left)) 10px max(18px, env(safe-area-inset-right));
    max-width: 1120px;
    margin: 0 auto;
}
.topbar.compact { padding-bottom: 4px; }
.brand { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; font-weight: 900; font-size: 1.55rem; color: var(--navy); }
.brand span span { color: var(--orange); }
.brand-logo-full { width: 156px; height: auto; display: block; object-fit: contain; mix-blend-mode: multiply; }
.topbar:not(.compact) .brand-logo-full { width: 190px; }
.toplink { text-decoration: none; color: var(--navy); font-weight: 800; padding: 10px 12px; border-radius: 8px; }

.home-shell, .game-shell, .coupe-shell { width: min(1120px, 100%); margin: 0 auto; padding: 12px 18px 28px; }
.hero { min-height: calc(100vh - 190px); display: grid; grid-template-columns: 1fr; align-items: center; gap: 24px; }
.kicker { margin: 0 0 8px; color: var(--orange); text-transform: uppercase; letter-spacing: 0; font-weight: 900; font-size: .82rem; }
h1, h2, p { overflow-wrap: anywhere; }
.hero h1 { margin: 0; color: var(--navy); font-size: clamp(3rem, 12vw, 6.8rem); line-height: .92; letter-spacing: 0; }
.hero h2 { margin: 8px 0 10px; color: var(--orange); font-size: clamp(2.1rem, 8vw, 4.2rem); line-height: 1; letter-spacing: 0; }
.hero p { max-width: 620px; color: var(--navy); font-size: 1.18rem; line-height: 1.45; font-weight: 700; }
.cta-row { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 22px; }

.button {
    min-height: 48px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 18px;
    border: 0;
    border-radius: 8px;
    text-decoration: none;
    cursor: pointer;
    font-weight: 900;
    line-height: 1.15;
}
.button.primary { background: var(--orange); color: var(--white); box-shadow: 0 10px 24px rgba(255, 122, 0, .28); }
.button.secondary { background: var(--navy); color: var(--white); }
.button.ghost { background: var(--white); color: var(--navy); border: 1px solid var(--line); }
.button.facebook { background: #1877f2; color: var(--white); box-shadow: 0 10px 24px rgba(24, 119, 242, .22); white-space: nowrap; }
.button.small { min-height: 40px; padding: 9px 13px; font-size: .94rem; }

.phone-preview { display: none; }
.phone-card { background: var(--white); border: 10px solid #111827; border-radius: 34px; padding: 18px; box-shadow: var(--shadow); transform: rotate(4deg); }
.mini-board { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.mini-board span { min-height: 66px; display: grid; place-items: center; text-align: center; padding: 7px; border: 1px solid var(--line); border-radius: 6px; color: var(--navy); font-weight: 800; font-size: .8rem; }
.mini-board .marked { background: var(--navy); color: var(--white); position: relative; }
.mini-board .marked::after { content: "×"; color: var(--orange); font-size: 2.4rem; line-height: 1; }

.route-panel, .how, .fit, .panel, .status-panel, .nickname-box, .location-box {
    background: var(--white);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 18px;
    box-shadow: 0 8px 22px rgba(6, 43, 79, .06);
}
.route-panel[hidden] { display: none; }
.route-form { display: grid; gap: 12px; }
label { display: grid; gap: 6px; color: var(--navy); font-weight: 850; }
input, select {
    width: 100%;
    min-height: 46px;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 10px 12px;
    background: var(--white);
    color: var(--ink);
}
.soft-note { color: var(--muted); font-weight: 650; margin-bottom: 0; }
.how, .fit { margin-top: 18px; }
.steps { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.steps div, .chip-list li { background: #eef5fa; border-radius: 8px; padding: 12px; color: var(--navy); font-weight: 800; }
.steps strong { display: inline-grid; place-items: center; width: 28px; height: 28px; margin-right: 8px; border-radius: 50%; background: var(--orange); color: var(--white); }
.chip-list { list-style: none; display: flex; flex-wrap: wrap; gap: 10px; padding: 0; margin: 0; }

.game-head { display: flex; justify-content: space-between; align-items: end; gap: 14px; margin: 8px 0 12px; }
.game-head h1 { margin: 0; color: var(--navy); font-size: clamp(1.8rem, 8vw, 3.2rem); line-height: 1.05; letter-spacing: 0; }
.status-panel { display: grid; gap: 4px; margin-bottom: 12px; }
.status-panel.bingo { border-color: var(--orange); box-shadow: 0 0 0 3px rgba(255, 122, 0, .13); }
.status-panel strong { color: var(--navy); font-size: 1.05rem; }
.status-panel span { color: var(--muted); font-weight: 700; }
.share-inline { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.share-inline[hidden] { display: none; }

.board-wrap { width: 100%; }
.board {
    --size: 5;
    display: grid;
    grid-template-columns: repeat(var(--size), minmax(0, 1fr));
    gap: 6px;
    width: min(100%, 680px);
    margin: 0 auto;
}
.board.loading { display: grid; place-items: center; min-height: 320px; color: var(--muted); font-weight: 800; background: var(--white); border: 1px solid var(--line); border-radius: 8px; }
.cell {
    position: relative;
    aspect-ratio: 1 / 1;
    min-width: 0;
    border: 1px solid #b9c9d8;
    border-radius: 6px;
    background: var(--white);
    color: var(--navy);
    padding: 6px;
    font-size: clamp(.68rem, 2.7vw, .95rem);
    line-height: 1.1;
    font-weight: 850;
    text-align: center;
    display: grid;
    place-items: center;
    box-shadow: 0 1px 0 rgba(6, 43, 79, .06);
    cursor: pointer;
}
.board[data-size="3"] .cell { font-size: clamp(.92rem, 5vw, 1.2rem); }
.board[data-size="4"] .cell { font-size: clamp(.78rem, 3.6vw, 1rem); }
.cell.marked { background: #fff6ed; border-color: var(--orange); color: var(--navy); }
.cell.marked::after {
    content: "×";
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    color: var(--orange-2);
    font-size: clamp(2.1rem, 11vw, 4rem);
    font-weight: 950;
    opacity: .9;
    pointer-events: none;
}
.cell.free { background: var(--navy); color: var(--white); }
.cell.free::after { content: "★"; font-size: clamp(1.8rem, 9vw, 3.3rem); color: var(--orange); opacity: .95; }
.cell.line { box-shadow: 0 0 0 3px rgba(31, 164, 99, .22); border-color: var(--green); }
.game-actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin-top: 16px; }

.coupe-shell { max-width: 940px; }
.nickname-box { display: grid; grid-template-columns: 1fr; gap: 10px; margin-bottom: 14px; }
.location-box { display: grid; gap: 12px; margin-bottom: 14px; align-items: center; }
.location-box strong { display: block; color: var(--navy); font-size: 1.05rem; }
.location-box span { display: block; color: var(--muted); font-weight: 700; line-height: 1.4; }
.coupe-grid { display: grid; gap: 12px; }
.panel h2 { margin-top: 0; color: var(--navy); }
.players-list, .messages-list, .message-buttons { display: grid; gap: 8px; }
.nearby-list { display: grid; gap: 8px; margin-top: 10px; }
.player-row, .message-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 10px;
    background: #f0f6fb;
    border-radius: 8px;
    font-weight: 800;
}
.online-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--green); display: inline-block; margin-right: 7px; }
.message-buttons { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.message-buttons button { min-height: 44px; border: 1px solid var(--line); border-radius: 8px; background: var(--white); color: var(--navy); font-weight: 850; cursor: pointer; }

.ad-banner {
    position: fixed;
    left: max(10px, env(safe-area-inset-left));
    right: max(10px, env(safe-area-inset-right));
    bottom: max(10px, env(safe-area-inset-bottom));
    z-index: 20;
    min-height: 70px;
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
    gap: 10px;
    padding: 12px 12px 12px 16px;
    background: var(--navy);
    color: var(--white);
    border: 2px solid var(--orange);
    border-radius: 8px;
    box-shadow: var(--shadow);
}
.ad-banner-image {
    width: min(1060px, calc(100% - 20px));
    padding: 7px;
    grid-template-columns: 1fr;
}
.ad-banner strong { display: block; color: var(--white); font-size: 1rem; }
.ad-banner span { display: block; color: #dcebf7; font-weight: 700; font-size: .86rem; }
.ad-banner a { justify-self: start; color: var(--white); font-weight: 900; text-decoration: none; background: var(--orange); padding: 9px 12px; border-radius: 7px; }
.ad-close { position: absolute; right: 4px; top: 2px; width: 30px; height: 30px; border: 0; background: transparent; color: var(--white); font-size: 1.4rem; cursor: pointer; }
.banner-image-link { display: block; width: 100%; }
.banner-image { display: block; width: 100%; max-height: 120px; object-fit: contain; border-radius: 6px; background: var(--white); }
.banner-preview { display: grid; gap: 8px; padding: 10px; border: 1px solid var(--line); border-radius: 8px; background: #f0f6fb; }
.banner-preview img { display: block; max-width: 100%; max-height: 180px; object-fit: contain; border-radius: 6px; background: white; }
.ad-banner.slide_train::before { content: "▰"; color: var(--orange); animation: trainSlide 2.4s ease-in-out infinite; }
@keyframes trainSlide { 0%,100% { transform: translateX(0); } 50% { transform: translateX(12px); } }

.site-footer {
    width: min(1120px, 100%);
    margin: 18px auto 0;
    padding: 0 18px 24px;
    color: var(--muted);
}
.footer-inner {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 10px 16px;
    border-top: 1px solid var(--line);
    padding-top: 14px;
    font-weight: 750;
}
.footer-inner nav { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.footer-inner a, .site-footer button {
    border: 0;
    background: transparent;
    color: var(--muted);
    text-decoration: underline;
    cursor: pointer;
    padding: 8px 0;
    font-weight: 750;
}
.cookie-consent {
    position: fixed;
    inset: 0;
    z-index: 50;
    display: grid;
    align-items: end;
    padding: 14px;
    background: rgba(6, 43, 79, .38);
}
.cookie-consent__panel {
    width: min(760px, 100%);
    margin: 0 auto;
    background: var(--white);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 18px;
    box-shadow: var(--shadow);
}
.cookie-consent__panel h2 { margin: 0 0 8px; color: var(--navy); }
.cookie-consent__panel p { margin: 0 0 14px; color: var(--muted); font-weight: 700; line-height: 1.4; }
.cookie-options { display: grid; gap: 8px; }
.cookie-options label {
    grid-template-columns: auto 1fr;
    align-items: start;
    gap: 8px 10px;
    padding: 10px;
    background: #f0f6fb;
    border-radius: 8px;
}
.cookie-options input { width: 20px; min-height: 20px; margin-top: 2px; }
.cookie-options span { color: var(--navy); font-weight: 900; }
.cookie-options small { grid-column: 2; color: var(--muted); font-weight: 700; }
.cookie-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 14px; justify-content: end; }

.share-modal {
    position: fixed;
    inset: 0;
    z-index: 45;
    display: grid;
    place-items: center;
    padding: 16px;
    background: rgba(6, 43, 79, .42);
}
.share-card, .share-hero {
    width: min(620px, 100%);
    background: var(--white);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 20px;
    box-shadow: var(--shadow);
}
.share-card h2, .share-hero h1 { margin: 0 0 10px; color: var(--navy); line-height: 1.05; letter-spacing: 0; }
.share-card p, .share-hero p { color: var(--muted); font-weight: 750; line-height: 1.45; }
.share-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 14px; }
.share-page { width: min(900px, 100%); margin: 0 auto; padding: 24px 18px; display: grid; place-items: center; min-height: calc(100vh - 230px); }
.share-stats { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.share-stats span { background: #eef5fa; color: var(--navy); border-radius: 8px; padding: 9px 11px; font-weight: 850; }
.toast {
    position: fixed;
    left: 50%;
    bottom: 110px;
    transform: translateX(-50%);
    z-index: 60;
    background: var(--navy);
    color: var(--white);
    border-radius: 8px;
    padding: 10px 14px;
    box-shadow: var(--shadow);
    font-weight: 850;
}

.offline { display: grid; place-items: center; padding: 24px; }
.offline-box { text-align: center; max-width: 420px; }
.offline-box h1 { color: var(--navy); }

@media (min-width: 700px) {
    .hero { grid-template-columns: minmax(0, 1.1fr) minmax(280px, .7fr); }
    .phone-preview { display: block; }
    .route-form { grid-template-columns: repeat(2, 1fr); align-items: end; }
    .steps { grid-template-columns: repeat(4, 1fr); }
    .nickname-box { grid-template-columns: 1fr auto; align-items: end; }
    .location-box { grid-template-columns: 1fr auto; }
    .coupe-grid { grid-template-columns: 1fr 1fr; }
    .coupe-grid .panel:first-child { grid-row: span 2; }
    .ad-banner { width: min(760px, calc(100% - 24px)); left: 50%; right: auto; transform: translateX(-50%); }
    .ad-banner-image { width: min(1060px, calc(100% - 24px)); }
}

@media (max-width: 640px) {
    .banner-image { max-height: 96px; }
}
