/* ========================
   CSS Custom Properties
   ======================== */
:root {
    /* Background */
    --bg-primary: #1a1a2e;
    --bg-secondary: #16213e;
    --bg-card: rgba(255, 255, 255, 0.06);
    --bg-card-border: rgba(255, 255, 255, 0.1);

    /* Choice Colors */
    --color-rock: #e74c3c;
    --color-paper: #3498db;
    --color-scissors: #f39c12;
    --color-lizard: #2ecc71;
    --color-spock: #9b59b6;

    /* Text */
    --text-primary: #e8e8e8;
    --text-secondary: #a0a0b8;
    --text-heading: #ffffff;

    /* Results */
    --color-win: #2ecc71;
    --color-lose: #e74c3c;
    --color-draw: #f39c12;

    /* Accent */
    --color-accent: #f1c40f;

    /* Spacing */
    --space-xs: 0.25rem;
    --space-sm: 0.5rem;
    --space-md: 1rem;
    --space-lg: 1.5rem;
    --space-xl: 2rem;
    --space-2xl: 3rem;

    /* Border Radius */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-full: 50%;
}

/* ========================
   Base Styles
   ======================== */
*,
*::before,
*::after {
    box-sizing: border-box;
}

body {
    font-family: 'Roboto', sans-serif;
    font-weight: 400;
    color: var(--text-primary);
    text-align: center;
    padding: 0;
    margin: 0;
    background: radial-gradient(ellipse at top, var(--bg-secondary), var(--bg-primary));
    min-height: 100vh;
}

h2 {
    font-family: 'Barlow Semi Condensed', sans-serif;
    font-weight: 700;
    color: var(--text-heading);
    text-align: center;
    margin-top: 0;
}

/* ========================
   Skip Navigation Link
   ======================== */
.skip-link {
    position: absolute;
    top: -40px;
    left: 0;
    background: var(--color-accent);
    color: var(--bg-primary);
    padding: 8px 16px;
    z-index: 100;
    font-size: 1em;
    font-weight: 700;
    text-decoration: none;
    border-radius: 0 0 var(--radius-sm) 0;
}

.skip-link:focus {
    top: 0;
}

/* ========================
   Header & Score Bar
   ======================== */
header {
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--bg-card-border);
    padding: var(--space-lg) 0 var(--space-md);
}

header h1 {
    font-family: 'Barlow Semi Condensed', sans-serif;
    font-size: 2em;
    font-weight: 700;
    margin: 0 0 var(--space-md);
    color: var(--text-heading);
    text-transform: uppercase;
    letter-spacing: 2px;
}

#score-bar {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: var(--space-xl);
    max-width: 500px;
    margin: 0 auto;
    padding: 0 var(--space-md);
}

.score-group {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-xs);
}

.score-group--round {
    background: var(--bg-card);
    border: 1px solid var(--bg-card-border);
    border-radius: var(--radius-md);
    padding: var(--space-sm) var(--space-lg);
}

.score-label {
    font-size: 0.8em;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-secondary);
}

.score-value {
    font-family: 'Barlow Semi Condensed', sans-serif;
    font-size: 2em;
    font-weight: 700;
    color: var(--color-accent);
    line-height: 1;
}

#round-indicator {
    font-weight: 500;
    font-size: 0.9em;
    color: var(--text-secondary);
}

/* ========================
   Main Layout
   ======================== */
main {
    max-width: 700px;
    margin: 0 auto;
    padding: var(--space-xl) var(--space-md) var(--space-2xl);
}

/* ========================
   Game Content Section
   ======================== */
#game-content {
    margin-bottom: var(--space-xl);
}

#result {
    margin-bottom: var(--space-lg);
}

#message {
    font-size: 1.15em;
    font-weight: 500;
    min-height: 1.5em;
    animation: slideUp 0.4s ease-out;
}

#score {
    font-size: 0.95em;
    color: var(--text-secondary);
    margin-top: var(--space-sm);
}

/* ========================
   Game Choice Buttons
   ======================== */
#game {
    display: flex;
    justify-content: center;
    gap: var(--space-md);
    flex-wrap: wrap;
    margin-bottom: var(--space-md);
}

.choice-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
    width: 100px;
    height: 100px;
    border: 3px solid;
    border-radius: var(--radius-lg);
    background: var(--bg-card);
    color: var(--text-primary);
    font-family: 'Roboto', sans-serif;
    font-size: 0.8em;
    font-weight: 500;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.choice-btn i {
    font-size: 2em;
    margin: 0;
}

.choice-btn span {
    text-transform: uppercase;
    letter-spacing: 1px;
    font-size: 0.85em;
}

/* Individual choice colors */
.choice-btn--rock {
    border-color: var(--color-rock);
    color: var(--color-rock);
}

.choice-btn--rock:hover,
.choice-btn--rock:focus-visible {
    background: var(--color-rock);
    color: #fff;
    box-shadow: 0 0 20px rgba(231, 76, 60, 0.4);
}

.choice-btn--paper {
    border-color: var(--color-paper);
    color: var(--color-paper);
}

.choice-btn--paper:hover,
.choice-btn--paper:focus-visible {
    background: var(--color-paper);
    color: #fff;
    box-shadow: 0 0 20px rgba(52, 152, 219, 0.4);
}

.choice-btn--scissors {
    border-color: var(--color-scissors);
    color: var(--color-scissors);
}

.choice-btn--scissors:hover,
.choice-btn--scissors:focus-visible {
    background: var(--color-scissors);
    color: #fff;
    box-shadow: 0 0 20px rgba(243, 156, 18, 0.4);
}

.choice-btn--lizard {
    border-color: var(--color-lizard);
    color: var(--color-lizard);
}

.choice-btn--lizard:hover,
.choice-btn--lizard:focus-visible {
    background: var(--color-lizard);
    color: #fff;
    box-shadow: 0 0 20px rgba(46, 204, 113, 0.4);
}

.choice-btn--spock {
    border-color: var(--color-spock);
    color: var(--color-spock);
}

.choice-btn--spock:hover,
.choice-btn--spock:focus-visible {
    background: var(--color-spock);
    color: #fff;
    box-shadow: 0 0 20px rgba(155, 89, 182, 0.4);
}

.choice-btn:hover {
    transform: translateY(-4px);
}

.choice-btn:active {
    transform: translateY(0) scale(0.95);
}

.choice-btn:focus-visible {
    outline: 3px solid var(--color-accent);
    outline-offset: 3px;
}

/* ========================
   Scoreboard Section
   ======================== */
#scoreboard {
    background: var(--bg-card);
    border: 1px solid var(--bg-card-border);
    padding: var(--space-lg);
    border-radius: var(--radius-lg);
    margin-bottom: var(--space-xl);
}

#scoreboard table {
    width: 100%;
    border-collapse: collapse;
    margin: var(--space-md) 0;
}

#scoreboard th {
    background: var(--bg-secondary);
    color: var(--text-heading);
    padding: var(--space-sm) var(--space-md);
    font-weight: 600;
    text-align: center;
}

#scoreboard td {
    padding: var(--space-sm) var(--space-md);
    border-bottom: 1px solid var(--bg-card-border);
    text-align: center;
}

#scoreboard-body tr:nth-child(even) {
    background: rgba(255, 255, 255, 0.03);
}

#scoreboard table {
    border: none;
}

#win-ratio, #win-percentage, #games-played {
    font-weight: 500;
    font-size: 0.95em;
    margin: var(--space-sm) 0;
    color: var(--text-secondary);
}

/* ========================
   Buttons (Reset, Play Again)
   ======================== */
#reset-button,
#play-again-button {
    padding: var(--space-sm) var(--space-lg);
    font-family: 'Roboto', sans-serif;
    font-size: 0.95em;
    font-weight: 500;
    cursor: pointer;
    border: 2px solid var(--text-secondary);
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-primary);
    transition: background 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
    margin-top: var(--space-sm);
    display: inline-flex;
    align-items: center;
    gap: var(--space-sm);
}

#reset-button:hover,
#play-again-button:hover {
    background: var(--bg-card-border);
    border-color: var(--text-primary);
}

#reset-button:active,
#play-again-button:active {
    transform: scale(0.97);
}

#reset-button:focus-visible,
#play-again-button:focus-visible {
    outline: 3px solid var(--color-accent);
    outline-offset: 3px;
}

#reset-button i {
    margin-right: 0;
}

/* ========================
   How to Play Section
   ======================== */
#how-to-play {
    background: var(--bg-card);
    border: 1px solid var(--bg-card-border);
    padding: var(--space-lg);
    border-radius: var(--radius-lg);
    text-align: left;
    margin-bottom: var(--space-xl);
}

#how-to-play h2 {
    text-align: center;
}

#how-to-play ul {
    list-style: none;
    padding: 0;
    margin: var(--space-md) 0;
}

#how-to-play li {
    padding: var(--space-sm) 0;
    font-size: 0.95em;
    color: var(--text-secondary);
}

#how-to-play li strong {
    color: var(--text-primary);
}

#how-to-play li i {
    margin-right: var(--space-sm);
    width: 1.2em;
    text-align: center;
}

#how-to-play li:nth-child(1) i { color: var(--color-rock); }
#how-to-play li:nth-child(2) i { color: var(--color-paper); }
#how-to-play li:nth-child(3) i { color: var(--color-scissors); }
#how-to-play li:nth-child(4) i { color: var(--color-lizard); }
#how-to-play li:nth-child(5) i { color: var(--color-spock); }

#how-to-play p {
    text-align: center;
    color: var(--text-secondary);
}

/* ========================
   Modal
   ======================== */
.modal {
    display: none;
    position: fixed;
    z-index: 10;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0, 0, 0, 0.7);
}

.modal-content {
    background: var(--bg-secondary);
    border: 1px solid var(--bg-card-border);
    margin: 15% auto;
    padding: var(--space-2xl) var(--space-xl);
    width: 90%;
    max-width: 440px;
    border-radius: var(--radius-lg);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
    text-align: center;
    animation: modalIn 0.3s ease-out;
}

.close {
    color: var(--text-secondary);
    float: right;
    font-size: 1.75em;
    font-weight: bold;
    line-height: 1;
    cursor: pointer;
    background: none;
    border: none;
    padding: 0;
    font-family: inherit;
}

.close:hover,
.close:focus {
    color: var(--text-primary);
}

.close:focus-visible {
    outline: 3px solid var(--color-accent);
    outline-offset: 2px;
}

#final-message {
    font-family: 'Barlow Semi Condensed', sans-serif;
    font-size: 1.8em;
    font-weight: 700;
    margin: var(--space-md) 0 var(--space-lg);
}

/* ========================
   Result Color Classes (applied via JS)
   ======================== */
.result--win { color: var(--color-win); }
.result--lose { color: var(--color-lose); }
.result--draw { color: var(--color-draw); }

/* ========================
   Animations
   ======================== */
@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes modalIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes scorePulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.3); }
    100% { transform: scale(1); }
}

/* ========================
   Reduced Motion
   ======================== */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* ========================
   Responsive - Tablet (min-width: 768px)
   ======================== */
@media (min-width: 768px) {
    header h1 {
        font-size: 2.5em;
    }

    .choice-btn {
        width: 110px;
        height: 110px;
    }

    .choice-btn i {
        font-size: 2.2em;
    }

    #final-message {
        font-size: 2em;
    }
}

/* ========================
   Responsive - Mobile (max-width: 767px)
   ======================== */
@media (max-width: 767px) {
    header {
        padding: var(--space-md) var(--space-sm) var(--space-sm);
    }

    header h1 {
        font-size: 1.15em;
        letter-spacing: 0.5px;
        padding: 0 var(--space-sm);
    }

    #score-bar {
        gap: var(--space-sm);
    }

    .score-value {
        font-size: 1.4em;
    }

    .score-group--round {
        padding: var(--space-xs) var(--space-sm);
    }

    #round-indicator {
        font-size: 0.8em;
    }

    main {
        padding: var(--space-lg) var(--space-sm) var(--space-xl);
    }

    #game {
        display: grid;
        grid-template-columns: repeat(3, 1fr);
        gap: var(--space-sm);
        max-width: 280px;
        margin: 0 auto var(--space-md);
    }

    .choice-btn {
        width: 100%;
        height: 80px;
        border-width: 2px;
    }

    .choice-btn i {
        font-size: 1.4em;
    }

    .choice-btn span {
        font-size: 0.65em;
    }

    #message {
        font-size: 1em;
    }

    #score {
        font-size: 0.85em;
    }

    #scoreboard,
    #how-to-play {
        padding: var(--space-md);
    }

    #how-to-play li {
        font-size: 0.85em;
    }

    #how-to-play p {
        font-size: 0.9em;
    }

    .modal-content {
        margin: 25% auto;
        padding: var(--space-xl) var(--space-lg);
    }
}

/* ========================
   Responsive - Small Mobile (max-width: 374px)
   ======================== */
@media (max-width: 374px) {
    header h1 {
        font-size: 1em;
    }

    .score-value {
        font-size: 1.2em;
    }

    #game {
        max-width: 240px;
    }

    .choice-btn {
        height: 70px;
    }

    .choice-btn i {
        font-size: 1.2em;
    }
}
