/* ===================================
   MEDICAL TETRIS - CLINICAL EDITION
   Stylesheet v1.0
   =================================== */

/* === ROOT VARIABLES === */
:root {
    --medical-blue: #0066CC;
    --scrub-green: #00916E;
    --red-cross: #E63946;
    --soft-cyan: #06D6A0;
    --sterile-gray: #E8ECF0;
    --clinical-bg: #F5F9FF;
    --dark-blue: #002B5C;
    --white: #FFFFFF;
    --shadow: rgba(0, 0, 0, 0.15);
    --glow-blue: rgba(0, 102, 204, 0.4);
    --emergency-orange: #FF6B35;
    --hospital-teal: #118AB2;
    --surgical-green: #2EC4B6;
}

/* === GLOBAL STYLES === */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Roboto', sans-serif;
    background: linear-gradient(135deg, #E3F2FD 0%, #BBDEFB 100%);
    color: var(--dark-blue);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

/* === CONTAINER === */
.container {
    max-width: 1400px;
    width: 100%;
    background: var(--white);
    border-radius: 20px;
    box-shadow: 0 10px 40px var(--shadow);
    overflow: hidden;
}

/* === HEADER === */
.game-header {
    background: linear-gradient(135deg, var(--medical-blue) 0%, var(--hospital-teal) 50%, var(--scrub-green) 100%);
    color: var(--white);
    padding: 30px;
    text-align: center;
    box-shadow: 0 4px 15px var(--shadow);
    position: relative;
    overflow: hidden;
}

.game-header::before {
    content: '⚕️';
    position: absolute;
    font-size: 8em;
    opacity: 0.1;
    top: -20px;
    right: 50px;
    animation: pulse 3s ease-in-out infinite;
}

.game-header h1 {
    font-family: 'Orbitron', sans-serif;
    font-size: 2.5em;
    margin-bottom: 10px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
    letter-spacing: 3px;
}

.medical-icon {
    animation: pulse 2s ease-in-out infinite;
}

.tagline {
    font-size: 1em;
    opacity: 0.9;
    letter-spacing: 2px;
    text-transform: uppercase;
}

/* === GAME CONTAINER === */
.game-container {
    display: grid;
    grid-template-columns: 300px 1fr 300px;
    gap: 25px;
    padding: 30px;
    background: var(--clinical-bg);
    max-width: 1400px;
    margin: 0 auto;
}

/* === PANEL CARDS === */
.panel-card {
    background: linear-gradient(135deg, var(--white) 0%, #FCFDFF 100%);
    border-radius: 15px;
    padding: 20px;
    box-shadow: 0 4px 15px var(--shadow);
    margin-bottom: 20px;
    border: 2px solid var(--sterile-gray);
    border-left: 4px solid var(--medical-blue);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.panel-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 25px var(--shadow);
    border-left-color: var(--surgical-green);
}

.panel-card h2 {
    font-size: 1.1em;
    color: var(--medical-blue);
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 2px solid var(--soft-cyan);
    display: flex;
    align-items: center;
    gap: 10px;
}

.icon {
    font-size: 1.3em;
}

/* === STATS === */
.stats {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.stat-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 15px;
    background: var(--sterile-gray);
    border-radius: 8px;
    transition: background 0.3s ease;
    min-height: 48px;
}

.stat-row:hover {
    background: linear-gradient(135deg, var(--surgical-green) 0%, var(--soft-cyan) 100%);
    color: var(--white);
    transform: scale(1.02);
}

.stat-row.highlight {
    background: linear-gradient(135deg, var(--medical-blue) 0%, var(--hospital-teal) 100%);
    color: var(--white);
    font-weight: bold;
    box-shadow: 0 2px 10px rgba(0, 102, 204, 0.3);
}

.stat-label {
    font-size: 0.95em;
    font-weight: 400;
}

.stat-value {
    font-family: 'Roboto Mono', monospace;
    font-size: 1.5em;
    font-weight: bold;
    min-width: 60px;
    text-align: right;
}

/* === CONTROLS INFO === */
.controls-info {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.control-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    background: var(--clinical-bg);
    border-radius: 6px;
    min-height: 40px;
}

.key {
    background: var(--medical-blue);
    color: var(--white);
    padding: 6px 12px;
    border-radius: 6px;
    font-family: 'Roboto Mono', monospace;
    font-size: 0.85em;
    font-weight: bold;
    min-width: 75px;
    text-align: center;
    box-shadow: 0 2px 5px var(--shadow);
    flex-shrink: 0;
}

/* === SOUND BUTTON === */
.sound-button {
    width: 100%;
    padding: 16px 18px;
    background: linear-gradient(135deg, var(--scrub-green) 0%, var(--medical-blue) 100%);
    color: var(--white);
    border: none;
    border-radius: 10px;
    font-size: 1em;
    font-weight: bold;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    box-shadow: 0 4px 10px var(--shadow);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 52px;
}

.sound-button:hover {
    transform: scale(1.02);
    box-shadow: 0 6px 15px var(--shadow);
}

.sound-button:active {
    transform: scale(0.98);
}

/* === GAME BOARD === */
.game-board-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    justify-content: center;
}

.canvas-wrapper {
    position: relative;
    background: linear-gradient(135deg, var(--white) 0%, var(--sterile-gray) 100%);
    border-radius: 15px;
    box-shadow: 0 8px 30px var(--shadow), inset 0 2px 10px rgba(0, 0, 0, 0.05);
    padding: 20px;
    border: 4px solid var(--medical-blue);
}

#gameCanvas {
    display: block;
    background: linear-gradient(180deg, #FFFFFF 0%, var(--clinical-bg) 100%);
    border-radius: 10px;
    image-rendering: crisp-edges;
    box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* === OVERLAYS === */
.overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, rgba(0, 43, 92, 0.96) 0%, rgba(0, 102, 204, 0.94) 100%);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10;
    border-radius: 10px;
    backdrop-filter: blur(8px);
}

.overlay.hidden {
    display: none;
}

.overlay-content {
    text-align: center;
    color: var(--white);
    padding: 40px 35px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 15px;
    border: 2px solid var(--soft-cyan);
    max-width: 450px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
}

.overlay-content h2 {
    font-family: 'Orbitron', sans-serif;
    font-size: 2em;
    margin-bottom: 20px;
    color: var(--soft-cyan);
    text-shadow: 0 0 10px var(--glow-blue);
}

.emergency {
    color: var(--red-cross) !important;
    animation: blink 1s ease-in-out infinite;
}

.welcome-text {
    font-size: 1.1em;
    margin-bottom: 25px;
    line-height: 1.7;
    padding: 0 10px;
}

.instructions {
    text-align: left;
    margin: 25px 0;
    padding: 20px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 10px;
}

.instructions h3 {
    color: var(--soft-cyan);
    margin-bottom: 12px;
    font-size: 1.1em;
}

.instructions ul {
    list-style-position: inside;
    line-height: 2;
    font-size: 0.95em;
}

.game-over-message {
    font-size: 1.2em;
    margin-bottom: 25px;
    line-height: 1.5;
}

.final-stats {
    margin: 25px 0;
    padding: 20px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 10px;
}

.final-stats p {
    margin: 10px 0;
    font-size: 1.15em;
    font-weight: 500;
}

.hint {
    font-size: 0.9em;
    opacity: 0.8;
    margin-top: 15px;
}

/* === BUTTONS === */
.btn-primary {
    background: linear-gradient(135deg, var(--red-cross) 0%, var(--emergency-orange) 100%);
    color: var(--white);
    padding: 16px 32px;
    border: none;
    border-radius: 12px;
    font-size: 1em;
    font-weight: bold;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    box-shadow: 0 4px 15px rgba(230, 57, 70, 0.5);
    margin-top: 25px;
    font-family: 'Roboto', sans-serif;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    position: relative;
    overflow: hidden;
}

.btn-primary::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.3), transparent);
    transition: left 0.5s;
}

.btn-primary:hover::before {
    left: 100%;
}

.btn-primary:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 25px rgba(230, 57, 70, 0.7);
}

.btn-primary:active {
    transform: scale(0.98);
}

.btn-large {
    font-size: 1.1em;
    padding: 18px 35px;
}

/* === ECG MONITOR === */
.ecg-monitor {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 18px 20px;
    background: linear-gradient(135deg, #1a1a1a 0%, #2d2d2d 100%);
    border-radius: 10px;
    box-shadow: 0 4px 15px var(--shadow), inset 0 2px 5px rgba(0, 0, 0, 0.3);
    border: 3px solid var(--surgical-green);
    width: 100%;
    max-width: 330px;
}

.ecg-label {
    font-weight: bold;
    color: var(--surgical-green);
    text-shadow: 0 0 10px rgba(46, 196, 182, 0.5);
}

.ecg-line {
    flex: 1;
    height: 40px;
    background: #1a1a1a;
    border-radius: 5px;
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ecg-line::before {
    content: '';
    position: absolute;
    width: 100%;
    height: 2px;
    background: var(--surgical-green);
    top: 50%;
    animation: ecg-pulse 2s linear infinite;
    box-shadow: 0 0 8px var(--surgical-green);
}

.heartbeat-pulse {
    font-size: 1.5em;
    z-index: 1;
    animation: heartbeat 1s ease-in-out infinite;
}

/* === NEXT PIECE === */
.next-piece-container {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 25px;
    background: var(--clinical-bg);
    border-radius: 10px;
    min-height: 150px;
}

#nextPieceCanvas {
    display: block;
    image-rendering: crisp-edges;
}

.prescription-note {
    text-align: center;
    font-style: italic;
    color: var(--scrub-green);
    margin-top: 12px;
    font-size: 0.9em;
    font-weight: 500;
}

/* === VITALS === */
.vitals {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.vital-row {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.vital-label {
    font-weight: bold;
    color: var(--medical-blue);
    font-size: 0.95em;
}

.progress-bar {
    width: 100%;
    height: 24px;
    background: var(--sterile-gray);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: inset 0 2px 5px var(--shadow);
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--surgical-green) 0%, var(--soft-cyan) 100%);
    width: 0%;
    transition: width 0.3s ease, background 0.3s ease;
    border-radius: 10px;
    box-shadow: 0 0 10px rgba(46, 196, 182, 0.4);
}

.progress-fill.warning {
    background: linear-gradient(90deg, #FFB84D 0%, var(--emergency-orange) 100%);
    box-shadow: 0 0 10px rgba(255, 107, 53, 0.4);
}

.progress-fill.danger {
    background: linear-gradient(90deg, var(--red-cross) 0%, #FF3838 100%);
    box-shadow: 0 0 10px rgba(230, 57, 70, 0.6);
    animation: pulse 1s ease-in-out infinite;
}

.vital-value {
    font-family: 'Roboto Mono', monospace;
    font-weight: bold;
    color: var(--scrub-green);
    font-size: 1.1em;
}

.status-badge {
    display: inline-block;
    padding: 10px 20px;
    background: var(--scrub-green);
    color: var(--white);
    border-radius: 25px;
    font-weight: bold;
    font-size: 0.95em;
    text-align: center;
    box-shadow: 0 2px 8px var(--shadow);
    letter-spacing: 0.5px;
}

.status-badge.active {
    background: var(--soft-cyan);
    animation: pulse 1.5s ease-in-out infinite;
}

.status-badge.critical {
    background: var(--red-cross);
    animation: blink 0.5s ease-in-out infinite;
}

/* === ACHIEVEMENTS === */
.achievements {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.achievement {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 16px;
    background: var(--sterile-gray);
    border-radius: 8px;
    opacity: 0.4;
    transition: opacity 0.3s ease, transform 0.3s ease;
    min-height: 52px;
}

.achievement.unlocked {
    opacity: 1;
    background: linear-gradient(135deg, var(--surgical-green) 0%, var(--soft-cyan) 100%);
    color: var(--white);
    animation: unlock 0.5s ease-out;
    box-shadow: 0 4px 15px rgba(6, 214, 160, 0.4);
    border: 2px solid rgba(255, 255, 255, 0.3);
}

.achievement-icon {
    font-size: 1.6em;
    flex-shrink: 0;
}

.achievement-text {
    font-size: 0.95em;
    font-weight: bold;
    line-height: 1.3;
}

/* === FOOTER === */
.game-footer {
    background: var(--dark-blue);
    color: var(--white);
    padding: 25px 20px;
    text-align: center;
    font-size: 0.9em;
    letter-spacing: 0.5px;
}

.pulse {
    display: inline-block;
    color: var(--scrub-green);
    animation: pulse 2s ease-in-out infinite;
}

/* === ANIMATIONS === */
@keyframes pulse {
    0%, 100% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 0.6;
        transform: scale(1.1);
    }
}

@keyframes blink {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.3;
    }
}

@keyframes heartbeat {
    0%, 100% {
        transform: scale(1);
    }
    10% {
        transform: scale(1.3);
    }
    20% {
        transform: scale(1);
    }
    30% {
        transform: scale(1.3);
    }
    40% {
        transform: scale(1);
    }
}

@keyframes ecg-pulse {
    0% {
        transform: translateX(-100%);
    }
    100% {
        transform: translateX(100%);
    }
}

@keyframes unlock {
    0% {
        transform: scale(0.5) rotate(-10deg);
        opacity: 0;
    }
    50% {
        transform: scale(1.1) rotate(5deg);
    }
    100% {
        transform: scale(1) rotate(0deg);
        opacity: 1;
    }
}

/* === RESPONSIVE DESIGN === */
@media (max-width: 1300px) {
    .game-container {
        grid-template-columns: 260px 1fr 260px;
        gap: 20px;
        padding: 20px;
    }
    
    .panel-card {
        padding: 18px;
    }
}

@media (max-width: 1100px) {
    .game-container {
        grid-template-columns: 1fr;
        grid-template-rows: auto;
        gap: 25px;
        padding: 25px;
    }
    
    .left-panel, .right-panel {
        order: 2;
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
        gap: 20px;
    }
    
    .game-board-container {
        order: 1;
    }
    
    .ecg-monitor {
        max-width: 100%;
    }
    
    .canvas-wrapper {
        max-width: 500px;
        margin: 0 auto;
    }
}

@media (max-width: 900px) {
    .left-panel, .right-panel {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .game-header h1 {
        font-size: 1.8em;
        letter-spacing: 2px;
    }
    
    .tagline {
        font-size: 0.85em;
        letter-spacing: 1px;
    }
    
    .game-container {
        padding: 15px;
        gap: 20px;
    }
    
    .panel-card {
        padding: 18px;
        margin-bottom: 15px;
    }
    
    .left-panel, .right-panel {
        grid-template-columns: 1fr;
    }
    
    .canvas-wrapper {
        padding: 15px;
        width: 100%;
    }
    
    #gameCanvas {
        max-width: 100%;
        height: auto;
        width: 100%;
    }
    
    .overlay-content {
        padding: 25px;
        max-width: 90%;
    }
    
    .ecg-monitor {
        flex-direction: column;
        gap: 10px;
        padding: 15px;
    }
    
    .ecg-line {
        width: 100%;
    }
}

@media (max-width: 480px) {
    body {
        padding: 5px;
    }
    
    .game-header {
        padding: 15px;
    }
    
    .game-header h1 {
        font-size: 1.4em;
        letter-spacing: 1px;
    }
    
    .tagline {
        font-size: 0.75em;
    }
    
    .game-container {
        padding: 10px;
        gap: 15px;
    }
    
    .panel-card {
        padding: 15px;
    }
    
    .panel-card h2 {
        font-size: 1em;
    }
    
    .btn-large {
        font-size: 0.95em;
        padding: 15px 20px;
    }
    
    .stat-value {
        font-size: 1.2em;
    }
    
    .control-item {
        padding: 6px;
        font-size: 0.9em;
    }
    
    .key {
        min-width: 60px;
        padding: 4px 8px;
        font-size: 0.8em;
    }
}

/* === PRINT STYLES === */
@media print {
    body {
        background: white;
    }
    
    .container {
        box-shadow: none;
    }
    
    .sound-button, .controls-info {
        display: none;
    }
}
