* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: #111;
    color: #eee;
    font-family: Arial, sans-serif;
}

.container {
    max-width: 1050px;
    margin: auto;
    padding: 25px;
}

h1 {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 18px;
    text-align: center;
    flex-wrap: wrap;
}

.home-btn {
    display: inline-block;
    padding: 10px 14px;
    font-size: 16px;
    border-radius: 6px;
    border: none;
    background: #22c55e;
    color: #000;
    font-weight: bold;
    text-decoration: none;
}

.home-btn:hover {
    opacity: 0.85;
}

.intro {
    max-width: 820px;
    margin: 0 auto;
    text-align: center;
    color: #ccc;
    line-height: 1.5;
}

.settings {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin: 25px 0 15px;
    flex-wrap: wrap;
}

.settings label {
    font-weight: bold;
}

select,
button {
    padding: 10px 14px;
    font-size: 16px;
    border-radius: 6px;
    border: none;
}

button {
    cursor: pointer;
    background: #22c55e;
    color: #000;
    font-weight: bold;
}

button:disabled {
    cursor: default;
    opacity: 0.65;
}

.status-row {
    display: flex;
    justify-content: center;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 15px;
}

.controller-status,
.stick-status {
    background: #1d1d1d;
    border: 1px solid #333;
    border-radius: 8px;
    padding: 9px 13px;
    color: #ddd;
}

.controller-status.connected {
    border-color: #22c55e;
    color: #86efac;
}

.keyboard-help {
    background: #1d1d1d;
    padding: 12px 15px;
    border-radius: 8px;
    max-width: 430px;
    margin: 0 auto 25px;
    text-align: center;
}

.keyboard-help h3 {
    margin: 0 0 8px;
}

.keyboard-help p {
    margin: 5px 0;
}

.game-area {
    margin-top: 25px;
    background: #000;
    border: 1px solid #333;
    border-radius: 10px;
    padding: 22px;
    min-height: 500px;
    text-align: center;
}

.hidden {
    display: none;
}

.scoreboard {
    display: flex;
    justify-content: center;
    gap: 24px;
    margin-bottom: 22px;
    flex-wrap: wrap;
}

.scoreboard span {
    background: #171717;
    border: 1px solid #333;
    border-radius: 7px;
    padding: 9px 12px;
}

.field-and-stick {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 28px;
    flex-wrap: wrap;
}

.football-field {
    position: relative;
    width: min(660px, 100%);
    aspect-ratio: 4 / 5;
    overflow: hidden;
    border: 5px solid #f4f4f4;
    border-radius: 8px;
    background-color: #126534;
    background-image:
        repeating-linear-gradient(
            to bottom,
            transparent 0,
            transparent calc(10% - 2px),
            rgba(255, 255, 255, 0.72) calc(10% - 2px),
            rgba(255, 255, 255, 0.72) 10%
        ),
        repeating-linear-gradient(
            to right,
            rgba(255, 255, 255, 0.035) 0,
            rgba(255, 255, 255, 0.035) 7%,
            rgba(0, 0, 0, 0.035) 7%,
            rgba(0, 0, 0, 0.035) 14%
        );
}

.end-zone {
    position: absolute;
    z-index: 1;
    left: 0;
    width: 100%;
    height: 8%;
    display: flex;
    align-items: center;
    justify-content: center;
    letter-spacing: 6px;
    font-weight: bold;
    color: rgba(255, 255, 255, 0.55);
    background: rgba(0, 0, 0, 0.18);
}

.end-zone-top {
    top: 0;
}

.end-zone-bottom {
    bottom: 0;
}

.hash {
    position: absolute;
    top: 9%;
    bottom: 9%;
    width: 1px;
    z-index: 1;
    background-image: repeating-linear-gradient(
        to bottom,
        rgba(255, 255, 255, 0.7) 0,
        rgba(255, 255, 255, 0.7) 6px,
        transparent 6px,
        transparent 18px
    );
}

.hash-left {
    left: 39%;
}

.hash-right {
    right: 39%;
}

.defender-layer,
.flick-arrow-svg {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
}

.defender-layer {
    z-index: 4;
}

.flick-arrow-svg {
    z-index: 3;
    pointer-events: none;
}

#flickArrow {
    stroke: #fff;
    stroke-width: 1.1;
    stroke-linecap: round;
    opacity: 0;
    filter: drop-shadow(0 0 2px #000);
}

#flickArrow.visible {
    opacity: 0.95;
}

#flickArrow.correct-arrow {
    stroke: #86efac;
}

#flickArrow.wrong-arrow {
    stroke: #fca5a5;
}

.arrow-head {
    fill: #fff;
}

.defender {
    position: absolute;
    width: 58px;
    height: 58px;
    transform: translate(-50%, -50%);
    display: flex;
    align-items: center;
    justify-content: center;
    border: 4px solid #e5e7eb;
    border-radius: 50%;
    background: #1e3a8a;
    color: #fff;
    font-size: 13px;
    font-weight: bold;
    box-shadow: 0 4px 9px rgba(0, 0, 0, 0.5);
    user-select: none;
}

.defender::after {
    content: attr(data-role);
    position: absolute;
    top: calc(100% + 4px);
    left: 50%;
    transform: translateX(-50%);
    padding: 2px 5px;
    border-radius: 4px;
    background: rgba(0, 0, 0, 0.76);
    color: #fff;
    font-size: 10px;
    white-space: nowrap;
}

.defender.controlled {
    z-index: 7;
    border-color: #fde047;
    background: #854d0e;
    box-shadow: 0 0 0 5px rgba(253, 224, 71, 0.25), 0 4px 9px rgba(0, 0, 0, 0.55);
}

.defender.controlled::before {
    content: "YOU";
    position: absolute;
    bottom: calc(100% + 4px);
    left: 50%;
    transform: translateX(-50%);
    padding: 2px 6px;
    border-radius: 4px;
    background: #fde047;
    color: #111;
    font-size: 10px;
}

.defender.target {
    z-index: 6;
    border-color: #fb923c;
    background: #9a3412;
    animation: targetPulse 0.72s infinite alternate;
}

.defender.selected-correct {
    border-color: #86efac;
    background: #166534;
    box-shadow: 0 0 0 7px rgba(134, 239, 172, 0.27);
}

.defender.selected-wrong {
    border-color: #fca5a5;
    background: #991b1b;
    box-shadow: 0 0 0 7px rgba(252, 165, 165, 0.27);
}

@keyframes targetPulse {
    from {
        transform: translate(-50%, -50%) scale(1);
        box-shadow: 0 0 0 4px rgba(251, 146, 60, 0.28);
    }
    to {
        transform: translate(-50%, -50%) scale(1.16);
        box-shadow: 0 0 0 12px rgba(251, 146, 60, 0.08);
    }
}

.stick-panel {
    width: 190px;
    padding: 16px;
    border: 1px solid #333;
    border-radius: 10px;
    background: #151515;
}

.stick-panel h3 {
    margin: 0 0 12px;
}

.stick-box {
    position: relative;
    width: 130px;
    height: 130px;
    margin: 0 auto 12px;
    border: 3px solid #777;
    border-radius: 50%;
    background: #222;
    overflow: hidden;
}

.stick-cross {
    position: absolute;
    background: #555;
}

.stick-cross-horizontal {
    top: 50%;
    left: 10%;
    width: 80%;
    height: 1px;
}

.stick-cross-vertical {
    top: 10%;
    left: 50%;
    width: 1px;
    height: 80%;
}

.stick-dot {
    position: absolute;
    left: 50%;
    top: 50%;
    width: 22px;
    height: 22px;
    transform: translate(-50%, -50%);
    border-radius: 50%;
    background: #22c55e;
    box-shadow: 0 0 9px rgba(34, 197, 94, 0.8);
}

#flickDetails {
    min-height: 48px;
    margin: 0;
    color: #ccc;
    line-height: 1.35;
}

.legend {
    display: flex;
    justify-content: center;
    gap: 20px;
    flex-wrap: wrap;
    margin-top: 20px;
    color: #ddd;
}

.legend span {
    display: inline-flex;
    align-items: center;
    gap: 7px;
}

.legend-dot {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    display: inline-block;
    border: 3px solid #eee;
}

.controlled-dot {
    background: #854d0e;
    border-color: #fde047;
}

.target-dot {
    background: #9a3412;
    border-color: #fb923c;
}

.coverage-dot {
    background: #1e3a8a;
    border-color: #e5e7eb;
}

.feedback {
    font-size: 27px;
    margin-top: 25px;
    min-height: 68px;
    line-height: 1.3;
}

.feedback.good {
    color: #86efac;
}

.feedback.bad {
    color: #fca5a5;
}

.feedback.info {
    color: #fcd34d;
}

@media (max-width: 760px) {
    .container {
        padding: 14px;
    }

    h1 {
        font-size: 25px;
    }

    .game-area {
        padding: 12px;
    }

    .scoreboard {
        gap: 8px;
        margin-bottom: 15px;
    }

    .scoreboard span {
        font-size: 14px;
        padding: 7px 8px;
    }

    .football-field {
        width: 100%;
    }

    .defender {
        width: 46px;
        height: 46px;
        border-width: 3px;
        font-size: 11px;
    }

    .defender::after,
    .defender.controlled::before {
        font-size: 8px;
    }

    .stick-panel {
        width: 100%;
        max-width: 260px;
    }

    .feedback {
        font-size: 22px;
    }
}

/* ---------------------------------------------------------
   Version 2: moving receiver / route-reaction drill
   --------------------------------------------------------- */

.route-trail-svg,
.receiver-layer {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.route-trail-svg {
    z-index: 2;
}

#routeTrail {
    fill: none;
    stroke: rgba(255, 255, 255, 0.72);
    stroke-width: 0.7;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-dasharray: 2.2 1.4;
    filter: drop-shadow(0 0 1.5px rgba(0, 0, 0, 0.85));
}

.receiver-layer {
    z-index: 5;
}

.receiver {
    position: absolute;
    width: 48px;
    height: 48px;
    transform: translate(-50%, -50%);
    display: flex;
    align-items: center;
    justify-content: center;
    border: 4px solid #fff;
    border-radius: 50%;
    background: #b91c1c;
    color: #fff;
    font-size: 12px;
    font-weight: bold;
    box-shadow: 0 4px 9px rgba(0, 0, 0, 0.55);
    user-select: none;
}

.receiver::after {
    content: attr(data-label);
    position: absolute;
    top: calc(100% + 4px);
    left: 50%;
    transform: translateX(-50%);
    padding: 2px 5px;
    border-radius: 4px;
    background: rgba(0, 0, 0, 0.78);
    color: #fff;
    font-size: 10px;
    white-space: nowrap;
}

.receiver.breaking {
    border-color: #fdba74;
    background: #c2410c;
    box-shadow:
        0 0 0 7px rgba(251, 146, 60, 0.20),
        0 4px 9px rgba(0, 0, 0, 0.55);
}

.catch-point {
    position: absolute;
    width: 58px;
    height: 58px;
    transform: translate(-50%, -50%);
    border: 4px dashed #fb923c;
    border-radius: 50%;
    background: rgba(251, 146, 60, 0.10);
    opacity: 0;
}

.catch-point.visible {
    opacity: 1;
    animation: catchPointPulse 0.55s infinite alternate;
}

@keyframes catchPointPulse {
    from {
        transform: translate(-50%, -50%) scale(0.90);
        box-shadow: 0 0 0 2px rgba(251, 146, 60, 0.25);
    }
    to {
        transform: translate(-50%, -50%) scale(1.10);
        box-shadow: 0 0 0 10px rgba(251, 146, 60, 0.05);
    }
}

.defender.target-reveal {
    z-index: 8;
    border-color: #86efac;
    box-shadow:
        0 0 0 8px rgba(134, 239, 172, 0.25),
        0 4px 9px rgba(0, 0, 0, 0.55);
}

.receiver-dot {
    background: #b91c1c;
    border-color: #fff;
}

select:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

@media (max-width: 760px) {
    .receiver {
        width: 40px;
        height: 40px;
        border-width: 3px;
        font-size: 10px;
    }

    .receiver::after {
        font-size: 8px;
    }

    .catch-point {
        width: 48px;
        height: 48px;
        border-width: 3px;
    }
}

/* ---------------------------------------------------------
   Version 3: switch-and-cover movement phase
   --------------------------------------------------------- */

.stick-panels {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.left-stick-dot {
    background: #38bdf8;
    box-shadow: 0 0 9px rgba(56, 189, 248, 0.8);
}

#movementDetails {
    min-height: 48px;
    margin: 0;
    color: #ccc;
    line-height: 1.35;
}

.cover-hud {
    width: min(660px, 100%);
    margin: 18px auto 0;
    padding: 12px 14px;
    border: 1px solid #444;
    border-radius: 9px;
    background: #151515;
    text-align: left;
}

.cover-hud-row {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 8px;
    color: #ddd;
}

.pass-meter {
    width: 100%;
    height: 16px;
    overflow: hidden;
    border: 1px solid #555;
    border-radius: 999px;
    background: #2a2a2a;
}

.pass-meter-fill {
    width: 100%;
    height: 100%;
    background: #22c55e;
    transition: width 0.05s linear;
}

.cover-hud.urgent .pass-meter-fill {
    background: #ef4444;
}

.catch-point.cover-zone {
    width: 92px;
    height: 92px;
    border-width: 4px;
}

.catch-point.defended {
    border-color: #86efac;
    background: rgba(34, 197, 94, 0.18);
    box-shadow: 0 0 0 10px rgba(34, 197, 94, 0.10);
    animation: none;
}

.catch-point.open {
    border-color: #fca5a5;
    background: rgba(239, 68, 68, 0.16);
    box-shadow: 0 0 0 10px rgba(239, 68, 68, 0.08);
    animation: none;
}

.catch-dot {
    background: rgba(251, 146, 60, 0.22);
    border-color: #fb923c;
}

.defender.moving-controlled {
    box-shadow:
        0 0 0 5px rgba(56, 189, 248, 0.24),
        0 4px 9px rgba(0, 0, 0, 0.55);
}

@media (max-width: 760px) {
    .stick-panels {
        width: 100%;
        max-width: 260px;
    }

    .catch-point.cover-zone {
        width: 72px;
        height: 72px;
    }

    .cover-hud-row {
        font-size: 14px;
    }
}
