@import url('https://fonts.googleapis.com/css2?family=Press+Start+2P&display=swap');

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --pixel-black: #0f0f23;
    --pixel-dark: #1a1a2e;
    --pixel-gray: #16213e;
    --pixel-blue: #4361ee;
    --pixel-red: #ef233c;
    --pixel-yellow: #ffd60a;
    --pixel-green: #2ec4b6;
    --pixel-white: #f8f9fa;
    --pixel-pink: #ff5d8f;
    --pixel-purple: #7209b7;
    --pixel-orange: #ff9500;
    --font-pixel: 'Press Start 2P', cursive;
}

body {
    font-family: var(--font-pixel);
    background: var(--pixel-black);
    color: var(--pixel-white);
    margin: 0;
    padding: 0;
    width: 100vw;
    height: 100vh;
    overflow: hidden;
}

#game-container {
    position: relative;
    width: 100vw;
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
}

#game-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: var(--pixel-black);
    display: block;
}

.screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    z-index: 10;
    padding: 30px 20px;
    overflow-y: auto;
    background: 
        linear-gradient(180deg, 
            var(--pixel-black) 0%, 
            var(--pixel-dark) 50%, 
            var(--pixel-black) 100%);
}

.screen::-webkit-scrollbar {
    width: 12px;
}

.screen::-webkit-scrollbar-track {
    background: var(--pixel-gray);
}

.screen::-webkit-scrollbar-thumb {
    background: var(--pixel-blue);
}

.screen::-webkit-scrollbar-thumb:hover {
    background: var(--pixel-yellow);
}

.screen.hidden {
    display: none;
}

@keyframes pixelGlow {
    0%, 100% { 
        text-shadow: 4px 4px 0 var(--pixel-red); 
    }
    50% { 
        text-shadow: 4px 4px 0 var(--pixel-yellow); 
    }
}

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

.game-title {
    font-family: var(--font-pixel);
    font-size: clamp(1rem, 3vw, 2.5rem);
    color: var(--pixel-yellow);
    text-transform: uppercase;
    margin-bottom: 40px;
    margin-top: 30px;
    text-align: center;
    animation: pixelGlow 2s step-end infinite, pixelBounce 3s step-end infinite;
}

.menu-buttons {
    display: flex;
    flex-direction: column;
    gap: 24px;
    margin-bottom: 40px;
    z-index: 100;
    position: relative;
}

.menu-btn {
    position: relative;
    padding: 16px 32px;
    font-family: var(--font-pixel);
    font-size: clamp(0.7rem, 1.5vw, 1rem);
    text-transform: uppercase;
    border: 4px solid var(--pixel-white);
    cursor: pointer;
    background: var(--pixel-gray);
    color: var(--pixel-white);
    box-shadow: 
        4px 4px 0 var(--pixel-white),
        8px 8px 0 var(--pixel-black);
}

.menu-btn:hover {
    background: var(--pixel-blue);
    transform: translate(-2px, -2px);
    box-shadow: 
        6px 6px 0 var(--pixel-white),
        10px 10px 0 var(--pixel-black);
}

.menu-btn:active {
    transform: translate(2px, 2px);
    box-shadow: 
        2px 2px 0 var(--pixel-white),
        4px 4px 0 var(--pixel-black);
}

.menu-btn.secondary {
    background: var(--pixel-dark);
}

.menu-btn.secondary:hover {
    background: var(--pixel-purple);
}

.controls-help {
    background: var(--pixel-gray);
    padding: 32px 40px;
    border: 4px solid var(--pixel-white);
    position: relative;
    z-index: 100;
    margin-bottom: 30px;
    box-shadow: 4px 4px 0 var(--pixel-white), 8px 8px 0 var(--pixel-black);
}

.controls-help h3 {
    font-family: var(--font-pixel);
    font-size: 1rem;
    text-align: center;
    color: var(--pixel-yellow);
    margin-bottom: 32px;
    text-transform: uppercase;
}

.controls-grid {
    display: flex;
    gap: 60px;
}

.control-column {
    text-align: center;
}

.control-column h4 {
    font-family: var(--font-pixel);
    color: var(--pixel-green);
    margin-bottom: 24px;
    font-size: 0.8rem;
    text-transform: uppercase;
}

.control-column p {
    margin: 12px 0;
    color: var(--pixel-white);
    font-size: 0.7rem;
    line-height: 1.8;
}

.book-container {
    display: flex;
    justify-content: center;
    gap: 0;
    margin: 24px auto;
    z-index: 100;
    position: relative;
}

.book-left-page,
.book-right-page {
    background: var(--pixel-gray);
    border: 4px solid var(--pixel-white);
    padding: 24px 20px;
    width: 300px;
    min-height: 420px;
    display: flex;
    flex-direction: column;
    align-items: center;
    box-shadow: 4px 4px 0 var(--pixel-white), 8px 8px 0 var(--pixel-black);
}

.book-left-page {
    border-right: 2px solid var(--pixel-white);
}

.book-right-page {
    border-left: 2px solid var(--pixel-white);
}

.vs-container {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 16px;
    z-index: 10;
}

.vs-text {
    font-family: var(--font-pixel);
    font-size: 2rem;
    color: var(--pixel-red);
    text-transform: uppercase;
    position: relative;
    animation: pixelGlow 1s step-end infinite;
    text-shadow: 4px 4px 0 var(--pixel-yellow);
}

.page-header {
    font-family: var(--font-pixel);
    color: var(--pixel-yellow);
    font-size: 0.8rem;
    text-transform: uppercase;
    margin-bottom: 20px;
    text-align: center;
}

.character-animation {
    width: 180px;
    height: 180px;
    margin: 12px 0 20px;
    background: var(--pixel-dark);
    display: flex;
    justify-content: center;
    align-items: center;
}

.character-animation canvas {
    display: block;
}

.character-info {
    width: 100%;
    text-align: center;
}

.info-name {
    font-family: var(--font-pixel);
    color: var(--pixel-white);
    font-size: 0.85rem;
    margin-bottom: 10px;
}

.info-class {
    color: var(--pixel-green);
    font-size: 0.7rem;
    text-transform: uppercase;
    margin-bottom: 12px;
}

.info-identity {
    font-size: 0.65rem;
    color: var(--pixel-yellow);
    margin: 10px 0;
    min-height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.info-mechanic {
    font-size: 0.6rem;
    color: var(--pixel-white);
    margin-top: 16px;
    padding: 16px;
    background: var(--pixel-dark);
    border: 2px solid var(--pixel-white);
    line-height: 1.8;
    min-height: 120px;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
}

.character-list-container {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 40px;
    margin: 32px 0 24px;
    z-index: 100;
    position: relative;
}

.character-select-container {
    display: none;
}

.player-select {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.player-select h3 {
    font-family: var(--font-pixel);
    color: var(--pixel-yellow);
    margin-bottom: 28px;
    font-size: 0.9rem;
    text-transform: uppercase;
}

.character-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    max-height: 420px;
    overflow-y: auto;
    padding: 12px;
}

.character-grid::-webkit-scrollbar {
    width: 12px;
}

.character-grid::-webkit-scrollbar-track {
    background: var(--pixel-gray);
}

.character-grid::-webkit-scrollbar-thumb {
    background: var(--pixel-blue);
}

.character-grid::-webkit-scrollbar-thumb:hover {
    background: var(--pixel-yellow);
}

.character-card {
    width: 110px;
    cursor: pointer;
    position: relative;
}

.character-card-inner {
    background: var(--pixel-gray);
    border: 4px solid var(--pixel-white);
    padding: 12px;
    text-align: center;
    transition: all 0.1s step-end;
    box-shadow: 4px 4px 0 var(--pixel-white), 8px 8px 0 var(--pixel-black);
}

.character-card:hover .character-card-inner {
    background: var(--pixel-blue);
    transform: translate(-2px, -2px);
    box-shadow: 6px 6px 0 var(--pixel-white), 10px 10px 0 var(--pixel-black);
}

.character-portrait {
    width: 70px;
    height: 100px;
    background-size: cover;
    background-position: center;
    margin: 0 auto 12px;
    border: 3px solid var(--pixel-white);
}

.character-name {
    font-family: var(--font-pixel);
    color: var(--pixel-white);
    font-size: 0.65rem;
    margin-bottom: 6px;
}

.character-class {
    color: var(--pixel-green);
    font-size: 0.55rem;
    text-transform: uppercase;
    margin-bottom: 8px;
}

.selected-character {
    display: none;
}

#character-select-screen .menu-btn {
    margin-top: 16px;
    margin-bottom: 16px;
}

#character-select-screen h2 {
    font-family: var(--font-pixel);
    color: var(--pixel-yellow);
    font-size: clamp(1rem, 2.5vw, 1.5rem);
    text-transform: uppercase;
    margin-top: 24px;
    margin-bottom: 24px;
    text-align: center;
}

.result-buttons {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 24px;
    margin-top: 48px;
    margin-bottom: 48px;
    z-index: 100;
    position: relative;
}

#result-text {
    font-family: var(--font-pixel);
    font-size: clamp(1.2rem, 4vw, 2.5rem);
    text-transform: uppercase;
    text-align: center;
    animation: pixelGlow 1s step-end infinite;
    position: relative;
    z-index: 100;
    margin-top: 48px;
    color: var(--pixel-yellow);
}

.pause-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: var(--pixel-gray);
    padding: 40px 48px;
    border: 4px solid var(--pixel-white);
    position: relative;
    z-index: 100;
    margin-top: 48px;
    box-shadow: 4px 4px 0 var(--pixel-white), 8px 8px 0 var(--pixel-black);
}

.pause-title {
    font-family: var(--font-pixel);
    font-size: 1.8rem;
    color: var(--pixel-yellow);
    text-transform: uppercase;
    text-shadow: 4px 4px 0 var(--pixel-red);
    margin-bottom: 40px;
}

.pause-buttons {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.pause-volume {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 24px;
    color: var(--pixel-white);
    font-family: var(--font-pixel);
    font-size: 1rem;
}

.pause-volume label {
    min-width: 80px;
}

.pause-volume input[type="range"] {
    flex: 1;
    height: 12px;
    -webkit-appearance: none;
    appearance: none;
    background: var(--pixel-gray);
    border: 3px solid var(--pixel-white);
    box-shadow: inset 2px 2px 0 var(--pixel-black);
    outline: none;
}

.pause-volume input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 24px;
    height: 24px;
    background: var(--pixel-yellow);
    border: 3px solid var(--pixel-white);
    box-shadow: 2px 2px 0 var(--pixel-black);
    cursor: pointer;
}

.pause-volume input[type="range"]::-moz-range-thumb {
    width: 24px;
    height: 24px;
    background: var(--pixel-yellow);
    border: 3px solid var(--pixel-white);
    box-shadow: 2px 2px 0 var(--pixel-black);
    cursor: pointer;
}

.animation-preview-container {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 32px;
    margin: 24px 0;
    width: 100%;
    max-width: 1400px;
    z-index: 100;
    position: relative;
}

.character-select-panel,
.animation-display-panel {
    background: var(--pixel-gray);
    padding: 32px;
    border: 4px solid var(--pixel-white);
    box-shadow: 4px 4px 0 var(--pixel-white), 8px 8px 0 var(--pixel-black);
}

.character-select-panel {
    flex: 1;
    min-width: 320px;
}

.character-select-panel h3,
.animation-display-panel h3 {
    font-family: var(--font-pixel);
    color: var(--pixel-yellow);
    margin-bottom: 24px;
    text-align: center;
    font-size: 0.9rem;
    text-transform: uppercase;
}

.animation-display-panel {
    flex: 2;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

#preview-canvas {
    width: 100%;
    height: 420px;
    background: var(--pixel-dark);
    border: 4px solid var(--pixel-white);
}

#preview-character-info {
    text-align: center;
    padding: 20px;
    background: var(--pixel-dark);
    border: 3px solid var(--pixel-white);
    color: var(--pixel-white);
    font-family: var(--font-pixel);
    font-size: 0.7rem;
}

.animation-controls {
    margin-top: 16px;
}

.animation-button-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
}

.anim-btn {
    padding: 12px 16px;
    font-family: var(--font-pixel);
    font-size: 0.6rem;
    text-transform: uppercase;
    border: 3px solid var(--pixel-white);
    cursor: pointer;
    background: var(--pixel-gray);
    color: var(--pixel-white);
    box-shadow: 3px 3px 0 var(--pixel-white), 6px 6px 0 var(--pixel-black);
}

.anim-btn:hover {
    background: var(--pixel-blue);
    transform: translate(-1px, -1px);
    box-shadow: 4px 4px 0 var(--pixel-white), 8px 8px 0 var(--pixel-black);
}

.anim-btn.active {
    background: var(--pixel-yellow);
    color: var(--pixel-black);
    box-shadow: 3px 3px 0 var(--pixel-white), 6px 6px 0 var(--pixel-black);
}

.animation-preview-controls {
    display: flex;
    gap: 24px;
    align-items: flex-end;
    justify-content: center;
    margin-bottom: 24px;
    flex-wrap: wrap;
    background: var(--pixel-gray);
    padding: 28px;
    border: 4px solid var(--pixel-white);
    width: 100%;
    max-width: 1000px;
    z-index: 100;
    position: relative;
    box-shadow: 4px 4px 0 var(--pixel-white), 8px 8px 0 var(--pixel-black);
}

.preview-select-group {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.preview-select-group label {
    color: var(--pixel-yellow);
    font-family: var(--font-pixel);
    font-size: 0.7rem;
    text-align: center;
    text-transform: uppercase;
}

.preview-select {
    padding: 12px 20px;
    font-family: var(--font-pixel);
    font-size: 0.7rem;
    border: 3px solid var(--pixel-white);
    background: var(--pixel-dark);
    color: var(--pixel-white);
    cursor: pointer;
    min-width: 220px;
}

.preview-select:focus {
    outline: none;
    border-color: var(--pixel-yellow);
}

.preview-select:hover {
    border-color: var(--pixel-green);
}

.animation-preview-display {
    width: 100%;
    max-width: 1050px;
    background: var(--pixel-gray);
    padding: 32px;
    border: 4px solid var(--pixel-white);
    z-index: 100;
    position: relative;
    box-shadow: 4px 4px 0 var(--pixel-white), 8px 8px 0 var(--pixel-black);
}

#preview-canvas {
    width: 100%;
    height: 420px;
    background: var(--pixel-dark);
    border: 4px solid var(--pixel-white);
    margin-bottom: 20px;
}

@media (max-width: 1024px) {
    .controls-grid {
        gap: 32px;
    }
    
    .menu-btn {
        padding: 14px 28px;
    }
}

@media (max-width: 768px) {
    .controls-grid {
        flex-direction: column;
        gap: 28px;
    }
    
    .result-buttons {
        flex-direction: column;
        gap: 20px;
    }
    
    .controls-help {
        padding: 24px 28px;
    }
    
    .pause-content {
        padding: 32px 40px;
    }
}

.stats-container {
    width: 100%;
    max-width: 1200px;
    background: var(--pixel-gray);
    padding: 32px;
    border: 4px solid var(--pixel-white);
    box-shadow: 4px 4px 0 var(--pixel-white), 8px 8px 0 var(--pixel-black);
    margin: 24px 0;
}

.stats-tabs {
    display: flex;
    gap: 16px;
    margin-bottom: 32px;
    justify-content: center;
}

.stats-tab {
    padding: 12px 24px;
    font-family: var(--font-pixel);
    font-size: 0.7rem;
    text-transform: uppercase;
    border: 3px solid var(--pixel-white);
    cursor: pointer;
    background: var(--pixel-dark);
    color: var(--pixel-white);
    box-shadow: 3px 3px 0 var(--pixel-white), 6px 6px 0 var(--pixel-black);
    transition: all 0.1s step-end;
}

.stats-tab:hover {
    background: var(--pixel-blue);
    transform: translate(-1px, -1px);
}

.stats-tab.active {
    background: var(--pixel-yellow);
    color: var(--pixel-black);
}

.stats-content {
    min-height: 400px;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

.stats-summary {
    display: flex;
    justify-content: center;
    gap: 24px;
    margin-bottom: 32px;
    flex-wrap: wrap;
}

.stat-card {
    background: var(--pixel-dark);
    padding: 24px 32px;
    border: 3px solid var(--pixel-white);
    text-align: center;
    box-shadow: 3px 3px 0 var(--pixel-white), 6px 6px 0 var(--pixel-black);
}

.stat-label {
    font-size: 0.65rem;
    color: var(--pixel-yellow);
    text-transform: uppercase;
    margin-bottom: 12px;
}

.stat-value {
    font-size: 1.5rem;
    color: var(--pixel-white);
}

.stats-table-container {
    overflow-x: auto;
}

.stats-table {
    width: 100%;
    border-collapse: collapse;
    font-family: var(--font-pixel);
}

.stats-table thead th {
    background: var(--pixel-dark);
    color: var(--pixel-yellow);
    padding: 16px 12px;
    text-align: left;
    font-size: 0.7rem;
    text-transform: uppercase;
    border: 2px solid var(--pixel-white);
}

.stats-table tbody td {
    padding: 12px;
    font-size: 0.65rem;
    border: 2px solid var(--pixel-white);
    color: var(--pixel-white);
}

.stats-table tbody tr:nth-child(even) {
    background: var(--pixel-dark);
}

.stats-table tbody tr:hover {
    background: var(--pixel-blue);
}

.character-cell {
    display: flex;
    align-items: center;
    gap: 12px;
}

.table-portrait {
    width: 40px;
    height: 57px;
    object-fit: cover;
    border: 2px solid var(--pixel-white);
}

.win-rate {
    font-weight: bold;
}

.win-rate.high {
    color: var(--pixel-green);
}

.win-rate.low {
    color: var(--pixel-red);
}

.stats-actions {
    display: flex;
    gap: 24px;
    margin-top: 32px;
    justify-content: center;
}

.matchup-selectors {
    display: flex;
    align-items: center;
    gap: 24px;
    justify-content: center;
    margin-bottom: 32px;
    flex-wrap: wrap;
}

.vs-text-small {
    font-family: var(--font-pixel);
    font-size: 1rem;
    color: var(--pixel-red);
    text-transform: uppercase;
    text-shadow: 2px 2px 0 var(--pixel-yellow);
}

.matchup-result {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.select-hint {
    font-family: var(--font-pixel);
    font-size: 0.7rem;
    color: var(--pixel-yellow);
}

.matchup-card {
    display: flex;
    align-items: center;
    gap: 32px;
    background: var(--pixel-dark);
    padding: 32px;
    border: 3px solid var(--pixel-white);
    box-shadow: 3px 3px 0 var(--pixel-white), 6px 6px 0 var(--pixel-black);
}

.matchup-character {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

.matchup-portrait {
    width: 100px;
    height: 143px;
    object-fit: cover;
    border: 3px solid var(--pixel-white);
}

.matchup-name {
    font-size: 0.75rem;
    color: var(--pixel-white);
    text-transform: uppercase;
}

.matchup-wins {
    font-size: 0.65rem;
    color: var(--pixel-yellow);
}

.matchup-winrate {
    font-size: 1.2rem;
    font-weight: bold;
}

.matchup-winrate.high {
    color: var(--pixel-green);
}

.matchup-winrate.low {
    color: var(--pixel-red);
}

.matchup-total {
    margin-top: 24px;
    font-size: 0.7rem;
    color: var(--pixel-yellow);
    text-transform: uppercase;
}
