/* ==========================================================================
   Tennis 3D Pro - Stylesheet
   Grand Slam 3D WebGL Simulator
   ========================================================================== */

:root {
    --tennis-primary: #84cc16;
    --tennis-primary-hover: #a3e635;
    --tennis-primary-glow: rgba(132, 204, 22, 0.35);
    --tennis-accent: #0284c7;
    --tennis-accent-glow: rgba(2, 132, 199, 0.35);
    --tennis-clay: #ea580c;
    --tennis-bg-dark: #090d16;
    --tennis-card-bg: rgba(15, 23, 42, 0.82);
    --tennis-card-border: rgba(255, 255, 255, 0.1);
    --tennis-text-main: #f8fafc;
    --tennis-text-muted: #94a3b8;
}

body:has(.tennis-container) .main-container,
.main-container:has(.tennis-container) {
    max-width: 100% !important;
    width: 100% !important;
    padding-left: clamp(8px, 1.2vw, 24px) !important;
    padding-right: clamp(8px, 1.2vw, 24px) !important;
    padding-top: 0.25rem !important;
}

.tennis-container {
    max-width: 100% !important;
    width: 100% !important;
    margin: 0 auto;
    padding: 0.25rem 0 2rem;
    color: var(--tennis-text-main);
    font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
}

/* --------------------------------------------------------------------------
   Action Bar & Options
   -------------------------------------------------------------------------- */
.tennis-action-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    background: var(--tennis-card-bg);
    border: 1px solid var(--tennis-card-border);
    border-radius: 1rem;
    padding: 0.5rem 0.9rem;
    margin-bottom: 0.6rem;
    backdrop-filter: blur(10px);
}

.tennis-mobile-bar-header {
    display: none;
}

.tennis-quick-options {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem 0.7rem;
}

.tennis-select-wrap {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--tennis-text-muted);
}

.tennis-select {
    background: rgba(15, 23, 42, 0.9);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: #f8fafc;
    border-radius: 0.5rem;
    padding: 0.3rem 0.5rem;
    font-size: 0.76rem;
    max-width: 190px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.tennis-select:hover, .tennis-select:focus {
    border-color: var(--tennis-primary);
    outline: none;
}

.tennis-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.4rem 0.85rem;
    border-radius: 0.6rem;
    font-size: 0.8rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    border: 1px solid transparent;
}

.tennis-btn-primary {
    background: linear-gradient(135deg, #84cc16 0%, #65a30d 100%);
    color: #0f172a;
    box-shadow: 0 4px 14px var(--tennis-primary-glow);
}

.tennis-btn-primary:hover {
    background: linear-gradient(135deg, #a3e635 0%, #84cc16 100%);
    transform: translateY(-1px);
    box-shadow: 0 6px 18px var(--tennis-primary-glow);
}

.tennis-btn-secondary {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.15);
    color: #e2e8f0;
}

.tennis-btn-secondary:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.25);
    color: #ffffff;
}

.tennis-btn-outline {
    background: transparent;
    border-color: rgba(255, 255, 255, 0.18);
    color: #cbd5e1;
}

.tennis-btn-outline:hover {
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(255, 255, 255, 0.3);
}

/* Statistiche a fianco delle telecamere, nella stessa barra */
.tennis-hud-stats {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.tennis-stat-chip {
    background: rgba(15, 23, 42, 0.85);
    border: 1px solid var(--tennis-card-border);
    padding: 0.28rem 0.6rem;
    border-radius: 0.5rem;
    font-size: 0.72rem;
    font-weight: 700;
    color: #cbd5e1;
    display: flex;
    align-items: center;
    gap: 0.35rem;
    backdrop-filter: blur(10px);
    white-space: nowrap;
}

.tennis-stat-chip strong {
    color: #a3e635;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

.tennis-btn-icon {
    background: rgba(15, 23, 42, 0.85);
    border: 1px solid var(--tennis-card-border);
    color: #cbd5e1;
    width: 30px;
    height: 30px;
    border-radius: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.2s ease;
    backdrop-filter: blur(10px);
}

.tennis-btn-icon:hover {
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
}

.tennis-btn-icon.is-muted {
    border-color: rgba(248, 113, 113, 0.5);
    color: #fca5a5;
}

@media (max-width: 900px) {
    .tennis-hud-topbar {
        gap: 0.3rem;
    }

    .tennis-hud-stats {
        flex-wrap: wrap;
        justify-content: flex-end;
    }
}

/* --------------------------------------------------------------------------
   Main Game Studio Wrapper & Canvas
   -------------------------------------------------------------------------- */
.tennis-game-wrapper {
    position: relative;
    scroll-margin-top: 96px;
    background: var(--tennis-bg-dark);
    border: 1px solid var(--tennis-card-border);
    border-radius: 1.25rem;
    overflow: hidden;
    box-shadow: 0 20px 45px rgba(0, 0, 0, 0.6);
    margin-bottom: 1rem;
    user-select: none;
}

.tennis-canvas-container {
    position: relative;
    width: 100%;
    /* Desktop: occupa lo spazio utile verticale dello schermo per un gameplay immersivo */
    height: clamp(520px, calc(100vh - 145px), 940px);
    outline: none;
    cursor: default;
    background: #0b1120;
    display: flex;
    align-items: center;
    justify-content: center;
}

@media (max-width: 900px) {
    .tennis-canvas-container {
        height: clamp(380px, 64vh, 560px);
    }
}

@media (max-width: 600px) {
    .tennis-canvas-container {
        height: clamp(320px, 55vh, 440px);
    }
}

.tennis-canvas-container canvas {
    display: block;
    width: 100%;
    height: 100%;
}

/* --------------------------------------------------------------------------
   Modalità Schermo Intero (Fullscreen)
   -------------------------------------------------------------------------- */
.tennis-game-wrapper:fullscreen,
.tennis-game-wrapper:-webkit-full-screen {
    width: 100vw !important;
    height: 100vh !important;
    max-width: 100vw !important;
    max-height: 100vh !important;
    border: none !important;
    border-radius: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    box-shadow: none !important;
    background: #000 !important;
}

.tennis-game-wrapper:fullscreen .tennis-canvas-container,
.tennis-game-wrapper:-webkit-full-screen .tennis-canvas-container {
    width: 100vw !important;
    height: 100vh !important;
    max-height: 100vh !important;
    border-radius: 0 !important;
}

/* --------------------------------------------------------------------------
   TV Broadcast Scoreboard
   -------------------------------------------------------------------------- */
.tennis-tv-scoreboard {
    position: absolute;
    top: 18px;
    left: 18px;
    z-index: 20;
    background: rgba(10, 15, 30, 0.88);
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 0.75rem;
    padding: 0.6rem 0.8rem;
    min-width: 260px;
    backdrop-filter: blur(14px);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
    pointer-events: none;
    font-family: system-ui, -apple-system, sans-serif;
}

.scoreboard-header {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem 0.6rem;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.45rem;
    font-size: 0.7rem;
    font-weight: 800;
    letter-spacing: 0.05em;
    color: var(--tennis-text-muted);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    padding-bottom: 0.35rem;
}

.scoreboard-surface-tag {
    color: #38bdf8;
}

.scoreboard-mode-tag {
    color: #a3e635;
}

.scoreboard-serve-tag {
    color: #cbd5e1;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 999px;
    padding: 0.1rem 0.5rem;
    font-size: 0.62rem;
    letter-spacing: 0.06em;
    white-space: nowrap;
}

.scoreboard-serve-tag.is-second {
    color: #0f172a;
    background: #fbbf24;
}

.scoreboard-rows {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.scoreboard-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(255, 255, 255, 0.03);
    padding: 0.35rem 0.5rem;
    border-radius: 0.4rem;
    font-size: 0.85rem;
}

.scoreboard-row.is-user {
    background: rgba(132, 204, 22, 0.12);
    border: 1px solid rgba(132, 204, 22, 0.25);
}

.player-identity {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-weight: 700;
    color: #f1f5f9;
}

.server-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #a3e635;
    box-shadow: 0 0 8px #a3e635;
    visibility: hidden;
}

.server-dot.is-serving {
    visibility: visible;
}

.score-cells {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-weight: 800;
}

.score-sets, .score-games {
    color: #94a3b8;
    min-width: 14px;
    text-align: center;
}

.score-points {
    background: rgba(0, 0, 0, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.15);
    padding: 0.15rem 0.45rem;
    border-radius: 0.3rem;
    color: #f8fafc;
    min-width: 28px;
    text-align: center;
}

.scoreboard-row.is-user .score-points {
    background: #84cc16;
    color: #0f172a;
}

/* --------------------------------------------------------------------------
   Camera Floating Switcher
   -------------------------------------------------------------------------- */
.tennis-hud-topbar {
    position: absolute;
    top: 14px;
    right: 14px;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 0.4rem;
    max-width: calc(100% - 28px);
}

.tennis-cam-bar {
    display: flex;
    gap: 0.4rem;
    background: rgba(15, 23, 42, 0.85);
    border: 1px solid var(--tennis-card-border);
    padding: 0.35rem;
    border-radius: 0.75rem;
    backdrop-filter: blur(10px);
}

.cam-btn {
    background: transparent;
    border: none;
    color: #cbd5e1;
    font-size: 0.78rem;
    font-weight: 700;
    padding: 0.4rem 0.75rem;
    border-radius: 0.5rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.cam-btn:hover {
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
}

.cam-btn.is-active {
    background: #0284c7;
    color: #fff;
    box-shadow: 0 2px 10px rgba(2, 132, 199, 0.4);
}

/* --------------------------------------------------------------------------
   Shot Feedback & Announcements Overlay
   -------------------------------------------------------------------------- */
.tennis-feedback-banner {
    position: absolute;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    z-index: 20;
    background: rgba(15, 23, 42, 0.92);
    border: 1px solid rgba(255, 255, 255, 0.2);
    padding: 0.5rem 1.25rem;
    border-radius: 2rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(12px);
    opacity: 0;
    pointer-events: none;
    transition: all 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.tennis-feedback-banner.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.feedback-shot-type {
    font-size: 0.82rem;
    font-weight: 800;
    color: #38bdf8;
    letter-spacing: 0.05em;
}

.feedback-timing {
    font-size: 0.88rem;
    font-weight: 900;
    color: #bef264;
}

.feedback-timing.early, .feedback-timing.late {
    color: #facc15;
}

.feedback-timing.miss {
    color: #f87171;
}

.feedback-speed {
    font-family: ui-monospace, SFMono-Regular, monospace;
    font-size: 0.85rem;
    font-weight: 700;
    color: #cbd5e1;
}

/* Umpire Big Call Overlay */
.tennis-call-overlay {
    position: absolute;
    top: 38%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.6);
    z-index: 30;
    pointer-events: none;
    opacity: 0;
    transition: all 0.28s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    display: flex;
    justify-content: center;
    align-items: center;
    width: max-content;
    max-width: 90%;
}

.tennis-call-overlay.show {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
}

.call-text {
    display: inline-block;
    white-space: nowrap !important;
    font-size: clamp(1.4rem, 4vw, 2.6rem);
    font-weight: 900;
    letter-spacing: 0.06em;
    text-align: center;
    color: #fff;
    text-shadow: 0 4px 20px rgba(0, 0, 0, 0.9), 0 0 35px rgba(132, 204, 22, 0.7);
    background: rgba(15, 23, 42, 0.94);
    padding: 0.75rem 2.2rem;
    border-radius: 9999px;
    border: 2px solid #84cc16;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(10px);
}

/* Serve Gauge */
.tennis-serve-gauge {
    position: absolute;
    bottom: 80px;
    right: 30px;
    z-index: 20;
    background: rgba(15, 23, 42, 0.92);
    border: 1px solid rgba(255, 255, 255, 0.2);
    padding: 0.75rem 1rem;
    border-radius: 0.85rem;
    width: 200px;
    backdrop-filter: blur(12px);
    display: none;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.4);
}

.tennis-serve-gauge.active {
    display: block;
}

.gauge-label {
    font-size: 0.7rem;
    font-weight: 800;
    color: var(--tennis-text-muted);
    letter-spacing: 0.05em;
    margin-bottom: 0.4rem;
}

.gauge-track {
    position: relative;
    height: 12px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 6px;
    overflow: hidden;
    margin-bottom: 0.35rem;
}

.gauge-sweetspot {
    position: absolute;
    left: 40%;
    width: 20%;
    height: 100%;
    background: rgba(132, 204, 22, 0.45);
    border-left: 2px dashed #bef264;
    border-right: 2px dashed #bef264;
}

.gauge-fill {
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #38bdf8 0%, #a3e635 75%, #ef4444 100%);
    transition: width 0.03s linear;
}

.gauge-cursor {
    position: absolute;
    top: 0;
    left: 0%;
    width: 4px;
    height: 100%;
    background: #fff;
    box-shadow: 0 0 6px #fff;
}

.gauge-hint {
    font-size: 0.68rem;
    color: #94a3b8;
    text-align: center;
}

/* --------------------------------------------------------------------------
   Pause Overlay
   -------------------------------------------------------------------------- */
.tennis-pause-overlay {
    position: absolute;
    inset: 0;
    z-index: 28;
    display: none;
    align-items: center;
    justify-content: center;
    background: rgba(5, 9, 18, 0.72);
    backdrop-filter: blur(6px);
}

.tennis-pause-overlay.show {
    display: flex;
}

.pause-card {
    text-align: center;
    background: rgba(15, 23, 42, 0.92);
    border: 1px solid var(--tennis-card-border);
    border-radius: 1rem;
    padding: 1.5rem 2.25rem;
    box-shadow: 0 20px 45px rgba(0, 0, 0, 0.6);
}

.pause-card .pause-icon {
    font-size: 2.5rem;
    line-height: 1;
    margin-bottom: 0.5rem;
    color: var(--tennis-primary);
}

.pause-card h3 {
    margin: 0 0 0.35rem;
    font-size: 1.15rem;
    font-weight: 800;
    color: var(--tennis-text-main);
}

.pause-card p {
    margin: 0;
    font-size: 0.85rem;
    color: var(--tennis-text-muted);
}

.pause-card kbd {
    background: rgba(255, 255, 255, 0.12);
    border-radius: 0.3rem;
    padding: 0.05rem 0.4rem;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    color: #e2e8f0;
}

/* --------------------------------------------------------------------------
   Start Screen & Focus Overlay
   -------------------------------------------------------------------------- */
.tennis-start-screen {
    position: absolute;
    inset: 0;
    z-index: 30;
    background: rgba(9, 13, 22, 0.88);
    backdrop-filter: blur(16px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
}

.tennis-start-screen.hidden {
    display: none;
}

.start-screen-card {
    background: linear-gradient(135deg, rgba(30, 41, 59, 0.95), rgba(15, 23, 42, 0.98));
    border: 1px solid rgba(255, 255, 255, 0.16);
    border-radius: 1.5rem;
    padding: 2.25rem;
    max-width: 580px;
    text-align: center;
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.7);
}

.start-icon {
    font-size: 3.5rem;
    margin-bottom: 0.5rem;
    animation: ballBounce 1.5s infinite ease-in-out;
}

@keyframes ballBounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-12px); }
}

.start-screen-card h2 {
    font-size: 1.6rem;
    font-weight: 800;
    margin: 0 0 0.5rem;
    color: #fff;
}

.start-screen-card p {
    font-size: 0.92rem;
    color: var(--tennis-text-muted);
    margin: 0 0 1.5rem;
    line-height: 1.5;
}

@media (max-width: 720px) {
    .start-screen-card {
        padding: 1.1rem 1rem;
        border-radius: 1rem;
    }

    .start-icon {
        font-size: 2.2rem;
        margin-bottom: 0.25rem;
    }

    .start-screen-card h2 {
        font-size: 1.05rem;
        line-height: 1.3;
    }

    .start-screen-card p {
        font-size: 0.8rem;
        margin-bottom: 0.9rem;
    }
}

/* La spiegazione dei tasti non serve su touch: c'e gia il D-pad a schermo */
@media (hover: none) and (pointer: coarse) {
    .start-screen-card > p {
        display: none;
    }
}

.start-quick-keys {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.85rem;
    margin-bottom: 1.8rem;
    text-align: center;
}

@media (max-width: 550px) {
    .start-quick-keys {
        grid-template-columns: repeat(2, 1fr);
    }
}

.key-group {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 0.75rem;
    padding: 0.6rem 0.4rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.35rem;
}

.key-cap {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 28px;
    height: 28px;
    padding: 0 0.4rem;
    background: linear-gradient(180deg, #334155 0%, #1e293b 100%);
    border: 1px solid #475569;
    border-bottom: 3px solid #0f172a;
    border-radius: 0.35rem;
    font-size: 0.75rem;
    font-weight: 800;
    color: #f8fafc;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.4);
}

.key-cap.wide {
    padding: 0 0.75rem;
}

.key-row {
    display: flex;
    gap: 0.2rem;
}

.key-desc {
    font-size: 0.72rem;
    font-weight: 600;
    color: #94a3b8;
}

.tennis-btn-glow {
    background: linear-gradient(135deg, #84cc16 0%, #4d7c0f 100%);
    border: none;
    color: #0f172a;
    padding: 0.85rem 2.25rem;
    border-radius: 0.85rem;
    font-size: 1.05rem;
    font-weight: 900;
    cursor: pointer;
    box-shadow: 0 8px 30px var(--tennis-primary-glow);
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.tennis-btn-glow:hover {
    transform: translateY(-2px) scale(1.02);
    box-shadow: 0 12px 35px var(--tennis-primary-glow);
    background: linear-gradient(135deg, #a3e635 0%, #65a30d 100%);
}

/* --------------------------------------------------------------------------
   Bottom Keyboard Ribbon
   -------------------------------------------------------------------------- */
.tennis-keyboard-ribbon {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 0.75rem;
    background: rgba(15, 23, 42, 0.8);
    border-top: 1px solid var(--tennis-card-border);
    padding: 0.75rem 1.25rem;
    font-size: 0.82rem;
}

.ribbon-item {
    display: flex;
    align-items: center;
    gap: 0.45rem;
}

.kbd-badge {
    display: inline-block;
    background: linear-gradient(180deg, #334155 0%, #1e293b 100%);
    border: 1px solid #475569;
    border-bottom: 2px solid #0f172a;
    padding: 0.15rem 0.55rem;
    border-radius: 0.35rem;
    font-family: ui-monospace, SFMono-Regular, monospace;
    font-size: 0.75rem;
    font-weight: 800;
    color: #bef264;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.ribbon-text {
    color: #94a3b8;
    font-weight: 600;
}

.ribbon-divider {
    width: 1px;
    height: 14px;
    background: rgba(255, 255, 255, 0.1);
}

@media (max-width: 800px) {
    .ribbon-divider {
        display: none;
    }
}

/* Su touch la guida da tastiera non serve: si mostra quella dei comandi a schermo */
.start-touch-hint {
    display: none;
    margin: 0 0 1rem;
    font-size: 0.85rem;
    color: #cbd5e1;
    line-height: 1.5;
}

@media (hover: none) and (pointer: coarse) {
    .start-quick-keys {
        display: none;
    }

    .start-touch-hint {
        display: block;
    }
}

/* --------------------------------------------------------------------------
   Dritto & Rovescio Guidance Tip Banner (Base definition)
   -------------------------------------------------------------------------- */
.tennis-stroke-guide-banner {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    padding: 0.65rem 1rem;
    background: rgba(15, 23, 42, 0.92);
    border: 1px solid rgba(148, 163, 184, 0.2);
    border-radius: 12px;
    margin-top: 0.5rem;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

.stroke-tag {
    font-size: 0.82rem;
    padding: 0.3rem 0.65rem;
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font-weight: 500;
}

.stroke-tag strong {
    font-weight: 800;
}

.stroke-tag.forehand {
    background: rgba(132, 204, 22, 0.15);
    color: #bef264;
    border: 1px solid rgba(132, 204, 22, 0.3);
}

.stroke-tag.backhand {
    background: rgba(56, 189, 248, 0.15);
    color: #38bdf8;
    border: 1px solid rgba(56, 189, 248, 0.3);
}

.stroke-tag.serve {
    background: rgba(234, 179, 8, 0.15);
    color: #fde047;
    border: 1px solid rgba(234, 179, 8, 0.3);
}

/* --------------------------------------------------------------------------
   Mobile Virtual Touch Controls (Base definition)
   -------------------------------------------------------------------------- */
.tennis-touch-controls {
    display: none;
    width: 100%;
    justify-content: space-between;
    align-items: center;
    padding: 0.55rem 0.9rem;
    background: rgba(10, 15, 30, 0.95);
    border-top: 1px solid var(--tennis-card-border);
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
    box-sizing: border-box;
}

.touch-dpad {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.35rem;
}

.dpad-mid {
    display: flex;
    gap: 0.35rem;
}

.touch-btn {
    width: 44px;
    height: 44px;
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.22);
    border-radius: 0.65rem;
    color: #fff;
    font-size: 1.15rem;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
    cursor: pointer;
    transition: background 0.1s, transform 0.08s;
}

.touch-btn:active {
    background: rgba(132, 204, 22, 0.45);
    border-color: #84cc16;
    transform: scale(0.92);
}

.touch-actions {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.45rem;
}

.touch-action-btn {
    min-width: 58px;
    height: 44px;
    padding: 0.2rem 0.45rem;
    background: rgba(255, 255, 255, 0.10);
    border: 1px solid rgba(255, 255, 255, 0.20);
    border-radius: 0.65rem;
    color: #fff;
    font-size: 0.72rem;
    font-weight: 800;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    line-height: 1.1;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
    cursor: pointer;
    transition: background 0.1s, transform 0.08s;
}

.touch-action-btn:active {
    transform: scale(0.92);
}

.touch-action-btn small {
    font-size: 0.58rem;
    opacity: 0.75;
    font-weight: 600;
}

.touch-action-btn.action-flat {
    background: rgba(132, 204, 22, 0.25);
    border-color: #84cc16;
    color: #bef264;
}

.touch-action-btn.action-flat:active {
    background: rgba(132, 204, 22, 0.55);
}

.touch-action-btn.action-topspin {
    background: rgba(56, 189, 248, 0.20);
    border-color: #38bdf8;
    color: #7dd3fc;
}

.touch-action-btn.action-topspin:active {
    background: rgba(56, 189, 248, 0.50);
}

.touch-action-btn.action-slice {
    background: rgba(245, 158, 11, 0.20);
    border-color: #f59e0b;
    color: #fcd34d;
}

.touch-action-btn.action-slice:active {
    background: rgba(245, 158, 11, 0.50);
}

.touch-action-btn.action-lob {
    background: rgba(168, 85, 247, 0.20);
    border-color: #a855f7;
    color: #d8b4fe;
}

.touch-action-btn.action-lob:active {
    background: rgba(168, 85, 247, 0.50);
}

/* --------------------------------------------------------------------------
   Modals (Match Over, Controls, Options)
   -------------------------------------------------------------------------- */
.tennis-modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 1000;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(14px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.25rem;
}

.tennis-modal-card {
    background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
    border: 1px solid rgba(255, 255, 255, 0.16);
    border-radius: 1.25rem;
    padding: 2rem;
    max-width: 520px;
    width: 100%;
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.7);
    color: #fff;
}

.tennis-modal-card.large {
    max-width: 760px;
}

.modal-header {
    text-align: center;
    margin-bottom: 1.5rem;
}

.modal-trophy, .modal-icon {
    font-size: 3rem;
    margin-bottom: 0.4rem;
}

.modal-header h2 {
    font-size: clamp(1.8rem, 4vw, 2.4rem);
    font-weight: 900;
    margin: 0 0 0.4rem;
    white-space: nowrap !important;
    text-align: center;
    letter-spacing: 0.04em;
    color: #bef264;
    text-shadow: 0 0 25px rgba(190, 242, 100, 0.5);
}

.modal-header p {
    color: var(--tennis-text-muted);
    font-size: 0.95rem;
    margin: 0;
    line-height: 1.5;
}

.match-summary-stats {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 0.85rem;
    padding: 1.25rem;
    margin-bottom: 1.5rem;
}

.summary-col {
    flex: 1;
}

.summary-col h4 {
    margin: 0 0 0.75rem;
    font-size: 0.95rem;
    color: #a3e635;
    text-align: center;
}

.summary-stat-row {
    display: flex;
    justify-content: space-between;
    font-size: 0.82rem;
    margin-bottom: 0.4rem;
    color: var(--tennis-text-muted);
}

.summary-stat-row strong {
    color: #fff;
    font-family: ui-monospace, SFMono-Regular, monospace;
}

.summary-divider {
    font-size: 1.2rem;
    font-weight: 900;
    color: rgba(255, 255, 255, 0.2);
    padding: 0 1rem;
}

.modal-actions {
    display: flex;
    gap: 0.75rem;
    justify-content: center;
}

.modal-actions.flex-right {
    justify-content: flex-end;
}

/* Controls Guide Grid */
.controls-guide-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
    margin-bottom: 1.5rem;
    text-align: left;
}

@media (max-width: 650px) {
    .controls-guide-grid {
        grid-template-columns: 1fr;
    }
}

.guide-box {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 0.75rem;
    padding: 1rem;
}

.guide-box h3 {
    font-size: 0.95rem;
    font-weight: 800;
    margin: 0 0 0.6rem;
    color: #38bdf8;
}

.guide-box ul {
    margin: 0;
    padding-left: 1.2rem;
    font-size: 0.82rem;
    color: #cbd5e1;
    line-height: 1.5;
}

.guide-box li {
    margin-bottom: 0.4rem;
}

.guide-box kbd {
    background: #334155;
    border: 1px solid #475569;
    padding: 0.1rem 0.35rem;
    border-radius: 0.25rem;
    font-family: ui-monospace, SFMono-Regular, monospace;
    font-weight: bold;
    color: #bef264;
}

/* Settings Form */
.settings-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.setting-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.88rem;
    font-weight: 600;
    color: #cbd5e1;
}

.setting-row input[type="range"] {
    accent-color: #84cc16;
}

.setting-row input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: #84cc16;
}

/* --------------------------------------------------------------------------
   SEO Informative Article & Guide
   -------------------------------------------------------------------------- */
.tennis-info-article {
    background: var(--tennis-card-bg);
    border: 1px solid var(--tennis-card-border);
    border-radius: 1.25rem;
    padding: 2.25rem;
    backdrop-filter: blur(12px);
    margin-top: 2rem;
}

.info-article-header {
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    padding-bottom: 1.25rem;
    margin-bottom: 1.5rem;
}

.info-article-header h2 {
    font-size: 1.45rem;
    font-weight: 800;
    margin: 0 0 0.5rem;
    color: #f8fafc;
}

.info-article-header p {
    font-size: 0.95rem;
    color: var(--tennis-text-muted);
    margin: 0;
    line-height: 1.5;
}

.info-columns {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.5rem;
}

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

.info-column h3 {
    font-size: 1.05rem;
    font-weight: 800;
    margin: 0 0 0.6rem;
    color: #bef264;
}

.info-column p {
    font-size: 0.88rem;
    color: #cbd5e1;
    line-height: 1.55;
    margin: 0;
}

/* ==========================================================================
   Mobile & Tablet Responsive Layout (Overrides & Optimizations)
   ========================================================================== */
@media (max-width: 820px) {
    /* Hide desktop-only elements */
    .tennis-hero-sub,
    .tennis-hero-badges,
    .tennis-hud-stats,
    .tennis-keyboard-ribbon,
    .tennis-stroke-guide-banner {
        display: none !important;
    }

    .tennis-header-hero {
        padding: 0.5rem 0.8rem;
        margin-bottom: 0.4rem;
    }

    .tennis-hero-icon {
        width: 32px;
        height: 32px;
        font-size: 1.1rem;
    }

    .tennis-hero-title {
        font-size: 0.95rem;
    }

    /* Action bar */
    .tennis-action-bar {
        padding: 0.4rem 0.6rem;
        margin-bottom: 0.35rem;
        border-radius: 0.75rem;
    }

    .tennis-mobile-bar-header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        width: 100%;
        gap: 0.35rem;
    }

    .tennis-mobile-match-pills {
        display: flex;
        align-items: center;
        gap: 0.3rem;
        min-width: 0;
        overflow: hidden;
    }

    .mobile-pill {
        font-size: 0.68rem;
        font-weight: 700;
        color: #e2e8f0;
        background: rgba(255, 255, 255, 0.08);
        padding: 0.2rem 0.45rem;
        border-radius: 0.45rem;
        white-space: nowrap;
        text-overflow: ellipsis;
        overflow: hidden;
        max-width: 105px;
        border: 1px solid rgba(255, 255, 255, 0.12);
        flex-shrink: 1;
    }

    .tennis-mobile-header-actions {
        display: flex;
        align-items: center;
        gap: 0.3rem;
        flex-shrink: 0;
    }

    .tennis-btn-xs {
        padding: 0.28rem 0.5rem;
        font-size: 0.72rem;
        border-radius: 0.45rem;
        gap: 0.2rem;
    }

    .mobile-menu-arrow {
        transition: transform 0.2s ease;
        display: inline-block;
        font-size: 0.65rem;
    }

    .tennis-action-bar.menu-open .mobile-menu-arrow {
        transform: rotate(180deg);
    }

    .tennis-quick-options {
        display: none;
        width: 100%;
        flex-direction: column;
        gap: 0.45rem;
        margin-top: 0.45rem;
        padding-top: 0.45rem;
        border-top: 1px solid rgba(255, 255, 255, 0.1);
    }

    .tennis-quick-options.is-expanded {
        display: flex;
        animation: tennisSlideDown 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    }

    @keyframes tennisSlideDown {
        from { opacity: 0; transform: translateY(-5px); }
        to { opacity: 1; transform: translateY(0); }
    }

    .tennis-quick-options.is-expanded .tennis-select-wrap {
        width: 100%;
        display: flex;
        justify-content: space-between;
        align-items: center;
        font-size: 0.75rem;
    }

    .tennis-quick-options.is-expanded .tennis-select {
        width: 58%;
        max-width: 220px;
    }

    .tennis-quick-options.is-expanded .tennis-btn {
        width: 100%;
        justify-content: center;
    }

    /* Game wrapper */
    .tennis-game-wrapper {
        border-radius: 0.85rem;
        margin-bottom: 0.5rem;
    }

    /* Canvas: fits viewport with touch controls */
    .tennis-canvas-container {
        height: clamp(320px, calc(100vh - 280px), 520px) !important;
        min-height: 310px;
    }

    /* TV Scoreboard: compact on mobile */
    .tennis-tv-scoreboard {
        top: 4px;
        left: 4px;
        min-width: 0;
        transform: scale(0.66);
        transform-origin: top left;
        max-width: 52%;
        z-index: 10;
        opacity: 0.94;
    }

    /* Camera bar */
    .tennis-hud-topbar {
        top: 4px;
        right: 4px;
        transform: scale(0.76);
        transform-origin: top right;
        gap: 0.25rem;
        z-index: 10;
        max-width: 48%;
    }

    .tennis-cam-bar {
        gap: 0.2rem;
        background: rgba(10, 15, 30, 0.88);
        padding: 0.2rem 0.35rem;
        border-radius: 0.5rem;
    }

    .tennis-cam-bar .cam-btn {
        padding: 0.22rem 0.4rem;
        font-size: 0.7rem;
    }

    .tennis-cam-bar .cam-btn .cam-label {
        display: none;
    }

    /* Always show touch controls on <= 820px */
    .tennis-touch-controls {
        display: flex !important;
        padding: 0.5rem 0.75rem;
        background: rgba(10, 15, 30, 0.96);
    }
}

@media (max-width: 480px) {
    .tennis-canvas-container {
        height: clamp(290px, calc(100vh - 260px), 430px) !important;
        min-height: 290px;
    }

    .btn-text-hide-sm {
        display: none;
    }

    .mobile-pill {
        max-width: 85px;
        font-size: 0.65rem;
        padding: 0.18rem 0.35rem;
    }

    .tennis-touch-controls {
        padding: 0.4rem 0.55rem;
    }

    .touch-btn {
        width: 42px;
        height: 42px;
        font-size: 1.05rem;
    }

    .touch-action-btn {
        min-width: 52px;
        height: 42px;
        font-size: 0.68rem;
    }

    .tennis-tv-scoreboard {
        transform: scale(0.60);
    }

    .tennis-hud-topbar {
        transform: scale(0.70);
    }
}
