:root {
    --ivirez-coral: #f2563f;
    --ivirez-orange: #ff8d2b;
    --ivirez-gold: #ffc56f;
    --ivirez-cream: #fff5e8;
    --arena-blue: #0c56d0;
    --arena-deep: #063a94;
    --panel-shadow: 0 24px 52px rgba(24, 10, 4, 0.3);
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    font-family: "Trebuchet MS", "Segoe UI", sans-serif;
    color: var(--ivirez-cream);
    background:
        radial-gradient(circle at top, rgba(255, 141, 43, 0.32), transparent 32%),
        linear-gradient(155deg, #251712 0%, #5d2f24 45%, #201616 100%);
}

body {
    min-height: 100vh;
    min-height: 100dvh;
}

.app-shell {
    width: min(1360px, calc(100vw - 16px));
    height: 100vh;
    height: 100dvh;
    margin: 0 auto;
    padding: 8px 0;
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
    gap: 8px;
}

.topbar,
.arena-frame {
    border: 1px solid rgba(255, 197, 111, 0.18);
    background: rgba(255, 245, 232, 0.08);
    box-shadow: var(--panel-shadow);
    backdrop-filter: blur(12px);
}

.topbar {
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: 12px;
    align-items: center;
    padding: 10px 14px;
    border-radius: 24px;
    min-height: 76px;
}

.brand-block {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.brand-logo {
    width: 56px;
    height: 56px;
    object-fit: contain;
    flex: 0 0 auto;
    filter: drop-shadow(0 10px 18px rgba(255, 95, 56, 0.3));
}

.eyebrow {
    margin: 0 0 3px;
    color: var(--ivirez-gold);
    font-size: 0.72rem;
    letter-spacing: 0.22em;
    text-transform: uppercase;
}

.brand-copy h1 {
    margin: 0;
    font-size: clamp(1.6rem, 2.2vw, 2.4rem);
    line-height: 0.95;
    letter-spacing: 0.08em;
    color: #fff3e3;
}

.round-note {
    margin: 0;
    font-size: 0.9rem;
    line-height: 1.35;
    color: rgba(255, 245, 232, 0.88);
    text-align: center;
}

.topbar-center {
    min-width: 0;
    display: grid;
    gap: 7px;
}

.community-strip {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    flex-wrap: wrap;
}

.social-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px 12px;
    border-radius: 999px;
    background: rgba(60, 30, 23, 0.72);
    border: 1px solid rgba(255, 197, 111, 0.16);
    color: var(--ivirez-cream);
    font-size: 0.78rem;
    line-height: 1;
    text-decoration: none;
    white-space: nowrap;
    transition: background 0.2s ease, transform 0.2s ease;
}

.social-button:hover {
    background: rgba(88, 41, 28, 0.84);
    transform: translateY(-1px);
}

.install-button[hidden] {
    display: none;
}

.yappy-link {
    background: linear-gradient(135deg, rgba(242, 86, 63, 0.92), rgba(255, 141, 43, 0.92));
    border-color: rgba(255, 214, 154, 0.34);
    color: #fffaf3;
    box-shadow: 0 10px 22px rgba(242, 86, 63, 0.2);
}

.yappy-link:hover {
    background: linear-gradient(135deg, rgba(249, 101, 55, 0.98), rgba(255, 157, 62, 0.98));
}

.primary-button {
    appearance: none;
    border: none;
    border-radius: 999px;
    padding: 11px 18px;
    font-size: 0.94rem;
    font-weight: 700;
    cursor: pointer;
    color: #fff7ef;
    background: linear-gradient(135deg, var(--ivirez-coral), var(--ivirez-orange));
    box-shadow: 0 14px 28px rgba(242, 86, 63, 0.3);
    transition: transform 0.2s ease, filter 0.2s ease, box-shadow 0.2s ease;
}

.primary-button:hover {
    transform: translateY(-1px);
    filter: saturate(1.05);
    box-shadow: 0 18px 32px rgba(242, 86, 63, 0.38);
}

.primary-button:active {
    transform: translateY(1px);
}

.top-start {
    min-width: 168px;
}

.stage-shell {
    min-height: 0;
    height: 100%;
}

.arena-frame {
    position: relative;
    height: 100%;
    min-height: 0;
    padding: 8px;
    border-radius: 28px;
    display: grid;
    place-items: center;
    overflow: hidden;
}

#gameCanvas {
    display: block;
    width: min(100%, calc((100dvh - 118px) * 1.6667));
    height: auto;
    max-height: 100%;
    aspect-ratio: 5 / 3;
    border-radius: 24px;
    background:
        radial-gradient(circle at 30% 25%, rgba(255, 255, 255, 0.18), transparent 18%),
        linear-gradient(180deg, #2f89ff 0%, var(--arena-blue) 38%, var(--arena-deep) 100%);
    border: 3px solid rgba(255, 245, 232, 0.24);
    touch-action: manipulation;
}

.hud-strip {
    position: absolute;
    top: 14px;
    left: 14px;
    right: 14px;
    z-index: 3;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px;
    pointer-events: none;
}

.hud-chip {
    padding: 8px 10px;
    border-radius: 16px;
    background: rgba(51, 28, 20, 0.62);
    border: 1px solid rgba(255, 197, 111, 0.18);
    text-align: center;
}

.hud-label {
    display: block;
    font-size: 0.66rem;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: rgba(255, 245, 232, 0.72);
}

.hud-chip strong {
    display: block;
    margin-top: 2px;
    font-size: clamp(1.05rem, 1.8vw, 1.45rem);
    color: #fffaf3;
}

.status-banner {
    position: absolute;
    left: 14px;
    right: 14px;
    bottom: 52px;
    z-index: 3;
    margin: 0;
    padding: 7px 10px;
    border-radius: 999px;
    background: rgba(44, 22, 16, 0.7);
    border: 1px solid rgba(255, 197, 111, 0.16);
    text-align: center;
    font-size: 0.82rem;
    line-height: 1.25;
}

.rules-strip {
    position: absolute;
    left: 14px;
    right: 14px;
    bottom: 14px;
    z-index: 3;
    display: flex;
    justify-content: center;
    gap: 12px;
    flex-wrap: wrap;
    padding: 7px 12px;
    border-radius: 999px;
    background: rgba(44, 22, 16, 0.76);
    border: 1px solid rgba(255, 197, 111, 0.16);
    font-size: 0.78rem;
    line-height: 1.2;
}

.rules-strip span {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.legend-dot {
    width: 13px;
    height: 13px;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, 0.35);
    flex: 0 0 auto;
}

.blue-dot {
    background: linear-gradient(135deg, #8ec7ff, #2e81ff);
}

.red-dot {
    background: linear-gradient(135deg, #ffad80, #ff4a3a);
}

.white-dot {
    background: #fffef8;
}

.mask-dot {
    border-radius: 4px;
    background: linear-gradient(135deg, #9abf3d, #f2563f);
}

.overlay {
    position: absolute;
    inset: 8px;
    border-radius: 24px;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
    z-index: 4;
    background: linear-gradient(180deg, rgba(12, 18, 45, 0.16), rgba(12, 18, 45, 0.74));
}

.overlay.visible {
    display: flex;
}

.overlay-card {
    width: min(100%, 420px);
    text-align: center;
    padding: 22px 20px;
    border-radius: 28px;
    background: rgba(45, 22, 14, 0.88);
    border: 1px solid rgba(255, 197, 111, 0.24);
    box-shadow: 0 24px 44px rgba(0, 0, 0, 0.34);
}

.overlay-kicker {
    margin: 0 0 8px;
    color: var(--ivirez-gold);
    text-transform: uppercase;
    letter-spacing: 0.18em;
    font-size: 0.74rem;
}

.overlay-card h2 {
    margin: 0 0 10px;
    font-size: clamp(1.8rem, 3vw, 2.8rem);
}

.overlay-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
}

#overlayText {
    margin: 0 0 18px;
    line-height: 1.5;
    color: rgba(255, 245, 232, 0.9);
    white-space: pre-line;
}

.secondary-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 43px;
    padding: 10px 16px;
    border-radius: 999px;
    border: 1px solid rgba(255, 214, 154, 0.28);
    background: rgba(64, 31, 22, 0.82);
    color: #fff4e5;
    font: inherit;
    font-size: 0.88rem;
    font-weight: 700;
    text-decoration: none;
    cursor: pointer;
}

.secondary-button[hidden] {
    display: none;
}

.yappy-secondary {
    background: linear-gradient(135deg, rgba(242, 86, 63, 0.94), rgba(255, 141, 43, 0.94));
}

@media (max-width: 900px) {
    .topbar {
        grid-template-columns: auto auto;
        justify-content: space-between;
    }

    .topbar-center {
        grid-column: 1 / -1;
        order: 3;
    }

    .round-note {
        font-size: 0.82rem;
    }

    #gameCanvas {
        width: min(100%, calc((100dvh - 178px) * 1.6667));
    }
}

@media (max-width: 640px) {
    .app-shell {
        width: calc(100vw - 10px);
        padding: 4px 0;
        gap: 4px;
    }

    .topbar {
        grid-template-columns: minmax(0, 1fr) auto;
        grid-template-areas:
            "brand start"
            "center center";
        padding: 7px 9px;
        gap: 6px 8px;
        min-height: 0;
    }

    .brand-block {
        grid-area: brand;
        gap: 8px;
    }

    .brand-logo {
        width: 40px;
        height: 40px;
    }

    .eyebrow {
        font-size: 0.58rem;
        letter-spacing: 0.16em;
    }

    .brand-copy h1 {
        font-size: 1.28rem;
    }

    .topbar-center {
        grid-area: center;
        gap: 5px;
    }

    .round-note {
        display: none;
    }

    .community-strip {
        justify-content: center;
        flex-wrap: wrap;
        gap: 5px;
    }

    .social-button {
        flex: 0 0 auto;
        padding: 6px 9px;
        font-size: 0.66rem;
    }

    .yappy-link {
        flex: 0 0 auto;
    }

    .top-start {
        grid-area: start;
        min-width: 116px;
    }

    .primary-button {
        padding: 8px 14px;
        font-size: 0.8rem;
    }

    .arena-frame {
        padding: 5px;
        border-radius: 20px;
    }

    #gameCanvas {
        width: min(100%, calc((100dvh - 150px) * 0.6667));
    }

    .hud-strip {
        top: 8px;
        left: 8px;
        right: 8px;
        gap: 5px;
    }

    .hud-chip {
        padding: 5px 7px;
        border-radius: 12px;
    }

    .hud-label {
        font-size: 0.54rem;
    }

    .hud-chip strong {
        font-size: 0.95rem;
    }

    .status-banner {
        left: 8px;
        right: 8px;
        bottom: 42px;
        padding: 5px 7px;
        font-size: 0.66rem;
    }

    .rules-strip {
        left: 8px;
        right: 8px;
        bottom: 8px;
        gap: 7px;
        padding: 5px 8px;
        font-size: 0.62rem;
    }

    .overlay-actions {
        gap: 8px;
    }

    .overlay {
        inset: 5px;
        padding: 10px;
    }

    .overlay-card {
        padding: 16px 14px;
    }
}

@media (max-width: 420px) {
    .topbar {
        grid-template-columns: minmax(0, 1fr) auto;
    }

    .brand-block {
        justify-content: flex-start;
    }

    .top-start {
        width: auto;
        min-width: 104px;
    }

    .hud-strip {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    #gameCanvas {
        width: min(100%, calc((100dvh - 142px) * 0.6667));
    }
}
