@import url('https://fonts.googleapis.com/css2?family=Bungee&family=Russo+One&display=swap');

/* ==============================
   MONSTER CLASH
   ============================== */

:root {
    --mc-bg: #070a14;
    --mc-panel: rgba(12, 16, 28, 0.86);
    --mc-card: rgba(255, 255, 255, 0.05);
    --mc-line: rgba(255, 255, 255, 0.12);
    --mc-text: #eef3fb;
    --mc-muted: #9ba7bd;
    --mc-cyan: #6ff7ff;
    --mc-cyan-deep: #1792b0;
    --mc-gold: #ffd23f;
    --mc-red: #ff4757;
    --mc-red-deep: #a3192a;
    --mc-amber: #ffb020;
    --mc-display: 'Bungee', 'Russo One', Impact, sans-serif;
    --mc-numeric: 'Russo One', system-ui, sans-serif;
    --wq-accent: var(--mc-cyan);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    overflow: hidden;
    background: var(--mc-bg);
    color: var(--mc-text);
    font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
    touch-action: manipulation;
}

button,
input {
    font: inherit;
}

button:focus-visible,
input:focus-visible {
    outline: 3px solid var(--mc-gold);
    outline-offset: 2px;
}

#gameCanvas {
    position: fixed;
    inset: 0;
    z-index: 1;
}

#gameCanvas canvas {
    display: block;
}

/* ---------- screens ---------- */

.screen {
    display: none;
    position: fixed;
    inset: 0;
    flex-direction: column;
    align-items: center;
    padding-left: 16px;
    padding-right: 16px;
    z-index: 100;
    text-align: center;
    background:
        radial-gradient(ellipse at 15% -10%, rgba(111, 247, 255, 0.14), transparent 50%),
        radial-gradient(ellipse at 85% 110%, rgba(255, 106, 31, 0.16), transparent 55%),
        rgba(7, 10, 20, 0.97);
}

.screen.active {
    display: flex;
}

.mc-panel {
    width: 100%;
    max-width: 940px;
    padding: 24px 0 32px;
}

.mc-title {
    margin: 0;
    font-family: var(--mc-display);
    font-weight: 400;
    font-size: clamp(2.8rem, 9vw, 5.6rem);
    line-height: 1;
    color: var(--mc-cyan);
    text-shadow: 0 0 26px rgba(111, 247, 255, 0.4), 0 5px 0 #0d4f63;
}

.mc-title span {
    color: #ff7a3d;
    text-shadow: 0 0 26px rgba(255, 122, 61, 0.45), 0 5px 0 #6b2108;
}

.mc-tagline {
    margin: 14px 0 22px;
    font-size: 1.2rem;
    color: var(--mc-muted);
}

.mc-heading {
    margin: 0 0 6px;
    font-family: var(--mc-display);
    font-weight: 400;
    font-size: 2rem;
    color: var(--mc-cyan);
}

.mc-sub {
    margin: 0 0 18px;
    color: var(--mc-muted);
}

.mc-section-title {
    margin: 30px 0 12px;
    font-family: var(--mc-numeric);
    font-weight: 400;
    font-size: 1rem;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--mc-muted);
}

/* ---------- buttons ---------- */

.mc-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 12px;
}

.mc-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 14px 26px;
    border: 2px solid rgba(255, 255, 255, 0.22);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.06);
    color: var(--mc-text);
    font-weight: 800;
    font-size: 1.05rem;
    cursor: pointer;
    transition: transform 0.12s ease, background 0.12s ease, border-color 0.12s ease;
}

.mc-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    border-color: var(--mc-cyan);
    background: rgba(111, 247, 255, 0.12);
}

.mc-btn:active:not(:disabled) {
    transform: translateY(0);
}

.mc-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.mc-btn-primary {
    border-color: var(--mc-cyan);
    background: linear-gradient(180deg, #9ffbff 0%, #33c4dd 100%);
    color: #062631;
    box-shadow: 0 6px 20px rgba(111, 247, 255, 0.25);
}

.mc-btn-primary:hover:not(:disabled) {
    background: linear-gradient(180deg, #c2fdff 0%, #45d3ea 100%);
}

.mc-btn-small {
    padding: 9px 16px;
    font-size: 0.95rem;
}

.mc-connection {
    min-height: 1.4em;
    margin-top: 14px;
    color: var(--mc-muted);
    line-height: 1.5;
}

.mc-connection ul {
    display: inline-block;
    margin: 6px 0 0;
    text-align: left;
}

/* ---------- how to play ---------- */

.mc-howto {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 14px;
    text-align: left;
}

.mc-howto-card {
    padding: 18px;
    border: 1px solid var(--mc-line);
    border-radius: 16px;
    background: var(--mc-card);
}

.mc-howto-icon {
    font-size: 1.8rem;
    line-height: 1;
}

.mc-howto-card h3 {
    margin: 10px 0 8px;
    font-size: 1.1rem;
}

.mc-howto-card p {
    margin: 0;
    color: var(--mc-muted);
    line-height: 1.5;
}

/* A still of the power bar in a clash: the rider's fill past the monster's marker. */
.mc-mini-gauge {
    position: relative;
    height: 16px;
    margin: 14px 6px 16px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.08);
}

.mc-mini-fill {
    position: absolute;
    inset: 0 28% 0 0;
    border-radius: inherit;
    background: linear-gradient(90deg, var(--mc-cyan-deep), var(--mc-cyan));
    box-shadow: 0 0 14px rgba(111, 247, 255, 0.45);
}

.mc-mini-gauge .mc-gauge-line {
    left: 55%;
}

.mc-roster {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.mc-roster li {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    border: 1px solid var(--mc-line);
    border-radius: 999px;
    background: var(--mc-card);
    font-weight: 700;
}

.mc-roster span {
    font-size: 1.3rem;
}

/* ---------- countdown ---------- */

/* See-through, so the arena and the waiting monster show behind the numbers. */
#countdownScreen {
    justify-content: center;
    background: radial-gradient(ellipse at 50% 45%, rgba(7, 10, 20, 0.72) 0%, rgba(7, 10, 20, 0.35) 55%, rgba(7, 10, 20, 0.2) 100%);
}

.mc-count-level {
    margin: 0;
    font-family: var(--mc-numeric);
    font-size: 1.5rem;
}

.countdown {
    font-family: var(--mc-display);
    font-size: clamp(5.5rem, 17vw, 9.5rem);
    line-height: 1.05;
    color: var(--mc-cyan);
    text-shadow: 0 0 40px rgba(111, 247, 255, 0.5);
    animation: mc-pulse 1s ease-in-out infinite;
}

.mc-count-goal {
    margin: 0;
    font-size: 1.3rem;
    font-weight: 800;
    color: var(--mc-gold);
}

.mc-count-hint {
    margin: 8px 0 0;
    color: var(--mc-muted);
}

/* ---------- HUD ---------- */

.mc-hud {
    position: fixed;
    inset: 0;
    z-index: 20;
    pointer-events: none;
}

.mc-card {
    border: 1px solid var(--mc-line);
    border-radius: 14px;
    background: var(--mc-panel);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
    backdrop-filter: blur(6px);
}

.mc-card-label {
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--mc-muted);
}

.mc-hud-top {
    position: absolute;
    top: 80px;
    left: 16px;
    right: 16px;
    display: grid;
    grid-template-columns: auto auto minmax(0, 440px);
    justify-content: space-between;
    align-items: start;
    gap: 12px;
}

.mc-hero {
    padding: 8px 14px 10px;
}

.mc-hearts {
    display: flex;
    gap: 4px;
    margin-top: 4px;
    font-size: 1.65rem;
    line-height: 1;
}

.mc-heart {
    display: inline-block;
    transition: transform 0.3s ease, filter 0.3s ease, opacity 0.3s ease;
}

.mc-heart.lost {
    filter: grayscale(1) brightness(0.55);
    opacity: 0.45;
    transform: scale(0.8);
    animation: mc-heart-lost 0.6s ease;
}

.mc-round {
    padding: 10px 16px;
    text-align: center;
}

.mc-round-level {
    font-family: var(--mc-numeric);
}

.mc-round-time {
    margin-top: 4px;
    color: var(--mc-muted);
    font-variant-numeric: tabular-nums;
}

.mc-foe {
    width: 100%;
    padding: 10px 14px 12px;
}

.mc-foe-head {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.mc-foe-icon {
    font-size: 1.35rem;
    line-height: 1;
}

.mc-foe-name {
    flex: 1;
    font-family: var(--mc-numeric);
    font-size: 1.05rem;
    white-space: nowrap;
}

.mc-foe-status {
    font-size: 0.85rem;
    font-weight: 800;
    color: var(--mc-amber);
    white-space: nowrap;
}

.mc-hp {
    position: relative;
    height: 20px;
    overflow: hidden;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.08);
}

.mc-hp-fill {
    position: absolute;
    inset: 0 auto 0 0;
    width: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, #c1272d, #ff6a3d);
    transition: width 0.3s ease-out;
}

.mc-hp-fill.low {
    animation: mc-throb 0.8s ease-in-out infinite;
}

.mc-hp-text {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    font-family: var(--mc-numeric);
    font-size: 0.8rem;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
    font-variant-numeric: tabular-nums;
}

/* The power bar. Between clashes it's a damage meter; in a clash, the monster's marker shows
   what to beat. */
.mc-gauge {
    position: absolute;
    left: 50%;
    bottom: 52px;
    width: min(780px, calc(100vw - 32px));
    padding: 12px 20px 18px;
    transform: translateX(-50%);
    transition: border-color 0.2s ease;
}

.mc-gauge-head {
    display: grid;
    grid-template-columns: 1fr 2fr 1fr;
    align-items: end;
    gap: 10px;
    margin-bottom: 12px;
}

.mc-gauge-power {
    font-family: var(--mc-numeric);
    font-size: 2.4rem;
    line-height: 1;
    text-align: left;
    font-variant-numeric: tabular-nums;
}

.mc-gauge-power small {
    margin-left: 4px;
    font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
    font-size: 1rem;
    font-weight: 700;
    color: var(--mc-muted);
}

.mc-gauge-status {
    align-self: center;
    font-weight: 800;
    font-size: 1.08rem;
    text-align: center;
    color: var(--mc-cyan);
}

.mc-gauge-goal {
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--mc-muted);
    text-align: right;
}

.mc-gauge-goal strong {
    display: block;
    font-family: var(--mc-numeric);
    font-weight: 400;
    font-size: 1.55rem;
    letter-spacing: 0;
    text-transform: none;
    color: var(--mc-text);
}

.mc-gauge-track {
    position: relative;
    height: 26px;
    border-radius: 13px;
    background: rgba(255, 255, 255, 0.08);
}

.mc-gauge-fill {
    position: absolute;
    inset: 0 auto 0 0;
    width: 0;
    border-radius: inherit;
    background: linear-gradient(90deg, var(--mc-cyan-deep), var(--mc-cyan));
    box-shadow: 0 0 16px rgba(111, 247, 255, 0.35);
    transition: width 0.25s ease-out;
}

.mc-gauge.dazed .mc-gauge-fill {
    background: linear-gradient(90deg, #c98d06, var(--mc-gold));
    box-shadow: 0 0 18px rgba(255, 210, 63, 0.5);
}

.mc-gauge.dazed .mc-gauge-status {
    color: var(--mc-gold);
}

.mc-gauge.warning {
    border-color: var(--mc-amber);
}

.mc-gauge.warning .mc-gauge-status {
    color: var(--mc-amber);
}

.mc-gauge.clash {
    animation: mc-clash-glow 0.7s ease-in-out infinite;
}

.mc-gauge.ahead .mc-gauge-fill {
    box-shadow: 0 0 22px rgba(111, 247, 255, 0.6);
}

.mc-gauge.behind {
    border-color: var(--mc-red);
}

.mc-gauge.behind .mc-gauge-fill {
    background: linear-gradient(90deg, var(--mc-red-deep), var(--mc-red));
    box-shadow: none;
}

.mc-gauge.behind .mc-gauge-status {
    color: var(--mc-red);
}

/* The monster's marker: in a clash, what the rider's bar has to get past. */
.mc-gauge-line {
    position: absolute;
    top: -7px;
    bottom: -7px;
    display: none;
    width: 4px;
    margin-left: -2px;
    border-radius: 2px;
    background: #ffffff;
    box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.55);
    transition: left 0.2s linear;
}

.mc-gauge-line.active {
    display: block;
}

.mc-gauge-line span {
    position: absolute;
    top: 50%;
    left: 50%;
    display: grid;
    place-items: center;
    width: 32px;
    height: 32px;
    border: 2px solid #ff7a3d;
    border-radius: 50%;
    background: #12161d;
    font-size: 17px;
    line-height: 1;
    transform: translate(-50%, -50%);
}

/* Red screen edges while the monster's beam is closing in on the mech. */
.mc-vignette {
    position: fixed;
    inset: 0;
    z-index: 15;
    pointer-events: none;
    opacity: 0;
    background: radial-gradient(ellipse at center, transparent 45%, rgba(190, 0, 20, 0.6) 100%);
    transition: opacity 0.25s ease;
}

/* ---------- results ---------- */

.mc-end-title {
    margin: 0;
    font-family: var(--mc-display);
    font-weight: 400;
    font-size: clamp(3rem, 10vw, 5.4rem);
    line-height: 1.05;
}

.mc-end-title.won {
    color: var(--mc-gold);
    text-shadow: 0 0 30px rgba(255, 210, 63, 0.45), 0 5px 0 #6b4a05;
}

.mc-end-title.lost {
    color: var(--mc-red);
    text-shadow: 0 0 30px rgba(255, 71, 87, 0.4), 0 5px 0 #4a0b13;
}

.mc-stars {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin: 8px 0 0;
    font-size: 3.4rem;
    line-height: 1;
}

.mc-star {
    color: rgba(255, 255, 255, 0.15);
    animation: mc-star-pop 0.45s cubic-bezier(0.2, 1.6, 0.4, 1) both;
}

.mc-star.on {
    color: var(--mc-gold);
    text-shadow: 0 0 18px rgba(255, 210, 63, 0.55);
}

.mc-stars-caption {
    margin: 6px 0 0;
    color: var(--mc-muted);
}

.mc-end-reason {
    margin: 16px 0 4px;
    font-size: 1.2rem;
    font-weight: 700;
}

.mc-end-tip {
    margin: 0 auto;
    max-width: 580px;
    color: var(--mc-amber);
}

.mc-end-tip:empty {
    display: none;
}

.mc-score {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    margin: 18px auto 0;
}

.mc-score-label {
    font-size: 0.78rem;
    font-weight: 800;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--mc-muted);
}

.mc-score-value {
    font-family: var(--mc-numeric);
    font-size: 2.6rem;
    color: var(--mc-cyan);
    font-variant-numeric: tabular-nums;
}

.mc-score-breakdown {
    font-size: 0.85rem;
    color: var(--mc-muted);
}

.mc-result-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    margin: 16px auto 6px;
    max-width: 640px;
}

.mc-result {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 12px 8px;
    border: 1px solid var(--mc-line);
    border-radius: 12px;
    background: var(--mc-card);
}

.mc-result-label {
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--mc-muted);
}

.mc-result-value {
    font-family: var(--mc-numeric);
    font-size: 1.25rem;
    font-variant-numeric: tabular-nums;
}

.mc-results .leaderboard-title {
    margin-top: 26px;
}

/* ---------- level select ---------- */

.wq-effort-toggle .wq-effort-btn.active {
    color: #062631;
}

/* ---------- animations ---------- */

@keyframes mc-pulse {
    50% { transform: scale(1.08); }
}

@keyframes mc-throb {
    50% { opacity: 0.55; }
}

@keyframes mc-clash-glow {
    50% { box-shadow: 0 0 0 4px rgba(111, 247, 255, 0.22), 0 8px 24px rgba(0, 0, 0, 0.35); }
}

@keyframes mc-heart-lost {
    0% { transform: scale(1.6); filter: none; opacity: 1; }
    40% { transform: scale(1.6) rotate(-12deg); }
    100% { transform: scale(0.8); }
}

@keyframes mc-star-pop {
    from { transform: scale(0.2); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
    .countdown,
    .mc-gauge.clash,
    .mc-hp-fill.low,
    .mc-heart.lost,
    .mc-star {
        animation: none;
    }
}

/* ---------- small screens ---------- */

@media (max-width: 900px) {
    .mc-howto {
        grid-template-columns: 1fr;
    }

    .mc-result-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    /* Hearts and the round share the first row; the monster's card takes the second. */
    .mc-hud-top {
        top: 70px;
        left: 10px;
        right: 10px;
        grid-template-columns: auto auto;
        gap: 8px;
    }

    .mc-foe {
        grid-column: 1 / -1;
        padding: 8px 12px 10px;
    }

    .mc-round {
        justify-self: end;
        padding: 8px 12px;
    }

    .mc-hearts {
        font-size: 1.35rem;
    }

    .mc-gauge {
        padding: 10px 14px 14px;
    }

    .mc-gauge-power {
        font-size: 2rem;
    }

    .mc-gauge-status {
        font-size: 0.95rem;
    }
}

@media (max-width: 600px) {
    .mc-gauge {
        bottom: 12px;
    }

    .mc-gauge-head {
        grid-template-columns: 1fr 1fr;
    }

    .mc-gauge-status {
        grid-column: 1 / -1;
        grid-row: 2;
    }

    .mc-hud-top {
        top: 92px;
    }

    /* Below the two HUD rows, so a callout never hides the monster's health. */
    .wq-banner {
        top: 250px;
    }
}

@media (max-height: 520px) {
    .mc-hud-top {
        top: 62px;
        grid-template-columns: auto auto minmax(0, 360px);
    }

    .mc-foe {
        grid-column: auto;
    }

    .mc-card-label,
    .mc-round-time {
        display: none;
    }

    .mc-gauge {
        bottom: 8px;
        padding: 6px 14px 10px;
    }

    .mc-gauge-head {
        margin-bottom: 6px;
    }

    .mc-gauge-power {
        font-size: 1.6rem;
    }

    .mc-gauge-goal strong {
        font-size: 1.2rem;
    }

    .wq-banner {
        top: 120px;
        padding: 6px 14px;
        font-size: 0.9rem;
    }
}
