/* 8bit Carcass - Retro Styling */

/* Custom 8-bit font using CSS */
@font-face {
    font-family: 'PixelFont';
    src: local('Press Start 2P'), local('Courier New');
}

/* CSS Variables - 8-bit Color Palette */
:root {
    --bg-dark: #1a1a2e;
    --bg-medium: #16213e;
    --bg-light: #0f3460;
    --primary: #e94560;
    --secondary: #ff6b6b;
    --accent: #ffc93c;
    --success: #4ecca3;
    --text: #eaeaea;
    --text-dim: #888;
    --danger: #ff0000;
    --skin: #ffcc99;
    --skin-shadow: #cc9966;
}

/* Reset and Base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
}

body {
    font-family: 'Press Start 2P', 'Courier New', monospace;
    background-color: var(--bg-dark);
    color: var(--text);
    display: flex;
    justify-content: center;
    align-items: center;
}

/* Game Container */
#game-container {
    width: 100%;
    height: 100%;
    max-width: 450px;
    max-height: 100vh;
    position: relative;
    overflow: hidden;
    background: linear-gradient(180deg, var(--bg-dark) 0%, var(--bg-medium) 100%);
}

/* Screens */
.screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.screen.active {
    display: flex;
}

.screen.overlay {
    background: rgba(0, 0, 0, 0.85);
    z-index: 100;
}

/* Title */
.game-title {
    font-size: 2.5rem;
    text-align: center;
    color: var(--primary);
    text-shadow:
        4px 4px 0 var(--bg-dark),
        -2px -2px 0 var(--secondary);
    margin-bottom: 40px;
    line-height: 1.3;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.02); }
}

h2 {
    font-size: 1.5rem;
    color: var(--accent);
    margin-bottom: 30px;
    text-align: center;
}

/* Pixel Buttons */
.pixel-btn {
    font-family: inherit;
    font-size: 0.8rem;
    padding: 15px 25px;
    margin: 8px;
    background: var(--bg-light);
    color: var(--text);
    border: 4px solid var(--text);
    cursor: pointer;
    position: relative;
    transition: all 0.1s;
    text-transform: uppercase;
    min-width: 200px;
}

.pixel-btn:hover, .pixel-btn:active {
    background: var(--primary);
    transform: translate(2px, 2px);
}

.pixel-btn:active {
    transform: translate(4px, 4px);
}

.pixel-btn.small {
    min-width: auto;
    padding: 10px 15px;
    font-size: 0.7rem;
}

/* Menu */
.menu {
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* Game HUD */
/* Patient Name Display */
#patient-name-display {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    text-align: center;
    padding: 8px;
    background: rgba(0, 0, 0, 0.85);
    font-size: 0.7rem;
    color: var(--success);
    z-index: 11;
    border-bottom: 2px solid var(--primary);
}

#patient-name {
    color: var(--accent);
    font-weight: bold;
}

#game-hud {
    position: absolute;
    top: 32px;
    left: 0;
    right: 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 15px;
    background: rgba(0, 0, 0, 0.7);
    font-size: 0.6rem;
    z-index: 10;
}

#score-display, #timer-display {
    color: var(--accent);
}

#lives-display {
    display: flex;
    gap: 5px;
}

.heart {
    width: 20px;
    height: 20px;
    background: var(--danger);
    clip-path: path('M10 18 L2 10 A5 5 0 0 1 10 4 A5 5 0 0 1 18 10 Z');
    transition: all 0.3s;
}

.heart:not(.active) {
    background: var(--text-dim);
    opacity: 0.3;
}

.heart.lost {
    animation: heartLost 0.5s ease-out;
}

@keyframes heartLost {
    0% { transform: scale(1); }
    50% { transform: scale(1.5); background: white; }
    100% { transform: scale(0.8); opacity: 0.3; }
}

/* Canvas */
#game-canvas {
    display: block;
    margin: auto;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
    touch-action: none;
}

#btn-pause {
    position: absolute;
    bottom: 15px;
    right: 15px;
    z-index: 10;
}

#piece-info {
    position: absolute;
    bottom: 60px;
    left: 0;
    right: 0;
    text-align: center;
    font-size: 0.6rem;
    color: var(--accent);
    padding: 5px;
}

/* Game Over Screen */
#final-score {
    font-size: 1.2rem;
    color: var(--accent);
    margin-bottom: 20px;
}

#name-entry {
    margin: 20px 0;
    text-align: center;
}

#name-entry p {
    font-size: 0.7rem;
    margin-bottom: 15px;
    color: var(--text-dim);
}

#name-input {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-bottom: 15px;
}

.name-char {
    font-size: 1.5rem;
    width: 42px;
    height: 52px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-light);
    border: 3px solid var(--text);
    color: var(--accent);
}

.name-char.selected {
    border-color: var(--primary);
    animation: blink 0.5s infinite;
}

@keyframes blink {
    0%, 100% { border-color: var(--primary); }
    50% { border-color: var(--accent); }
}

#name-controls {
    display: flex;
    justify-content: center;
    gap: 10px;
}

/* Leaderboard */
#leaderboard-list {
    width: 100%;
    max-width: 300px;
    margin-bottom: 20px;
}

.leaderboard-entry {
    display: flex;
    justify-content: space-between;
    padding: 8px 15px;
    margin: 5px 0;
    background: var(--bg-light);
    border: 2px solid var(--text-dim);
    font-size: 0.7rem;
}

.leaderboard-entry.highlight {
    border-color: var(--accent);
    background: var(--bg-medium);
}

.leaderboard-entry .rank {
    color: var(--text-dim);
    width: 30px;
}

.leaderboard-entry .name {
    color: var(--accent);
    width: 60px;
    text-align: center;
    letter-spacing: 2px;
}

.leaderboard-entry .score {
    color: var(--success);
    width: 80px;
    text-align: right;
}

/* Patient Selection */
#patient-list {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 15px;
    margin-bottom: 20px;
}

.patient-card {
    width: 110px;
    height: 150px;
    background: var(--bg-light);
    border: 3px solid var(--text);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    padding: 8px;
}

.patient-card:hover, .patient-card:active {
    border-color: var(--primary);
    transform: scale(1.05);
}

.patient-card.locked {
    opacity: 0.5;
    cursor: not-allowed;
}

.patient-card .patient-preview {
    width: 60px;
    height: 80px;
    background: var(--skin);
    margin-bottom: 5px;
}

.patient-card .patient-name {
    font-size: 0.6rem;
    text-align: center;
    color: var(--accent);
}

/* Instructions */
.instruction-content {
    text-align: center;
    margin-bottom: 20px;
}

.instruction-content p {
    font-size: 1.1rem;
    margin: 18px 0;
    line-height: 1.5;
}

/* Screen Shake Animation */
.shake {
    animation: shake 0.3s ease-in-out;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-10px); }
    40% { transform: translateX(10px); }
    60% { transform: translateX(-10px); }
    80% { transform: translateX(10px); }
}

/* Success Flash */
.flash-success {
    animation: flashSuccess 0.3s ease-out;
}

@keyframes flashSuccess {
    0% { filter: brightness(1); }
    50% { filter: brightness(1.5); }
    100% { filter: brightness(1); }
}

/* Touch Indicator (for debugging) */
.touch-indicator {
    position: absolute;
    width: 30px;
    height: 30px;
    border: 3px solid var(--accent);
    border-radius: 50%;
    pointer-events: none;
    transform: translate(-50%, -50%);
    z-index: 200;
}

/* Responsive adjustments */
@media (max-height: 600px) {
    .game-title {
        font-size: 1.8rem;
        margin-bottom: 20px;
    }

    .pixel-btn {
        padding: 10px 20px;
        margin: 5px;
    }

    h2 {
        font-size: 1.2rem;
        margin-bottom: 15px;
    }
}

@media (min-width: 768px) {
    #game-container {
        border: 4px solid var(--text);
        border-radius: 0;
    }
}
