/* Retro Windows 95 CSS Theme with Mobile Support */

body {
    
    font-family: 'Lucida Console', Monaco, monospace;
    background: linear-gradient(45deg, #008080, #004040);
    color: #FFF;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    margin: 0;
    padding: 10px;
    box-sizing: border-box;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    -khtml-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    overflow-x: hidden;
}

.container {
    width: 90%;
    max-width: 1200px;
    border: 3px outset #C0C0C0;
    box-shadow: 5px 5px 15px rgba(0,0,0,0.5), inset 1px 1px 2px rgba(255,255,255,0.3);
    background: #C0C0C0;
    border-radius: 0;
}

.header, .toolbar, .status-bar {
    background: linear-gradient(to bottom, #0080FF, #000080);
    color: #FFF;
    padding: 8px;
    border-bottom: 2px inset #C0C0C0;
    text-shadow: 1px 1px 1px rgba(0,0,0,0.5);
}

.title-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: linear-gradient(to bottom, #0080FF, #000080);
    padding: 5px 10px;
}

.title-bar-text {
    font-weight: bold;
    font-size: 14px;
    color: #FFF;
}

.title-bar-controls {
    display: flex;
    gap: 2px;
}

.title-bar-control {
    background: linear-gradient(to bottom, #DFDFDF, #BFBFBF);
    border: 1px outset #C0C0C0;
    color: #000;
    font-size: 12px;
    cursor: pointer;
    width: 20px;
    height: 18px;
    text-align: center;
    line-height: 16px;
}

.title-bar-control:hover {
    background: linear-gradient(to bottom, #EFEFEF, #CFCFCF);
}

.title-bar-control.close {
    background: linear-gradient(to bottom, #FF8080, #FF4040);
    color: #FFF;
}

.subtitle {
    font-size: 12px;
    text-align: center;
    margin-top: 5px;
    font-style: italic;
}

.btn {
    background: linear-gradient(to bottom, #DFDFDF, #BFBFBF);
    border: 2px outset #C0C0C0;
    color: #000;
    padding: 6px 12px;
    cursor: pointer;
    margin: 3px;
    font-family: 'MS Sans Serif', sans-serif;
    font-size: 11px;
    min-width: 75px;
}

.btn:hover {
    background: linear-gradient(to bottom, #EFEFEF, #CFCFCF);
}

.btn:active {
    border: 2px inset #C0C0C0;
    background: linear-gradient(to bottom, #BFBFBF, #DFDFDF);
}

.btn.danger {
    background: linear-gradient(to bottom, #FF8080, #FF4040);
    color: #FFF;
}

.btn.cursed {
    background: linear-gradient(to bottom, #8080FF, #4040FF);
    color: #FFF;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

.games-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 15px;
    padding: 15px;
    background: #C0C0C0;
}

.game-card {
    background: linear-gradient(to bottom, #DFDFDF, #BFBFBF);
    border: 2px outset #C0C0C0;
    padding: 15px;
    text-align: center;
    cursor: pointer;
    color: #000;
    transition: all 0.2s;
}

.game-card:hover {
    background: linear-gradient(to bottom, #EFEFEF, #CFCFCF);
    transform: translateY(-2px);
}

.game-card:active {
    border: 2px inset #C0C0C0;
    background: linear-gradient(to bottom, #BFBFBF, #DFDFDF);
}

.game-card.cursed {
    background: linear-gradient(to bottom, #FF8080, #FF4040);
    color: #FFF;
    animation: cursed-glow 3s infinite;
}

@keyframes cursed-glow {
    0%, 100% { box-shadow: 0 0 5px rgba(255,0,0,0.5); }
    50% { box-shadow: 0 0 20px rgba(255,0,0,0.8); }
}

.game-icon {
    font-size: 2.5em;
    margin-bottom: 10px;
}

.difficulty {
    font-size: 0.8em;
    margin-top: 8px;
    color: #666;
    font-style: italic;
}

.section {
    display: none;
    padding: 20px;
    background: #C0C0C0;
    color: #000;
}

.section.active {
    display: block;
}

.section h2 {
    color: #000080;
    border-bottom: 2px solid #000080;
    padding-bottom: 5px;
    margin-bottom: 15px;
}

.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.7);
}

.modal-content {
    background: #C0C0C0;
    margin: 5% auto;
    padding: 0;
    border: 3px outset #C0C0C0;
    width: 90%;
    max-width: 600px;
    box-shadow: 5px 5px 15px rgba(0,0,0,0.5);
}

.modal-header {
    background: linear-gradient(to bottom, #0080FF, #000080);
    color: #FFF;
    padding: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-body {
    padding: 20px;
    text-align: center;
}

.close-btn {
    background: linear-gradient(to bottom, #FF8080, #FF4040);
    color: #FFF;
    border: 1px outset #C0C0C0;
    width: 20px;
    height: 18px;
    text-align: center;
    line-height: 16px;
    cursor: pointer;
    font-size: 12px;
}
.game-controls {
    margin-top: 15px;
}

.status-bar {
    padding: 8px 15px;
    font-size: 11px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: relative;
    overflow: hidden;
    min-height: 25px;
}

.insult-ticker {
    position: absolute;
    right: 0;
    width: 60%;
    text-align: right;
    font-style: italic;
    color: #FFE138;
    opacity: 0.8;
    font-size: 10px;
    white-space: nowrap;
    overflow: hidden;
    animation: marquee-scroll 15s linear infinite;
}

@keyframes marquee-scroll {
    0% { 
        transform: translateX(100%);
    }
    100% { 
        transform: translateX(-100%);
    }
}

.form-container {
    background: #C0C0C0;
    padding: 20px;
    border: 2px inset #C0C0C0;
    margin: 10px;
}

.input {
    background: #FFF;
    border: 2px inset #C0C0C0;
    padding: 4px;
    margin: 5px;
    font-family: 'MS Sans Serif', sans-serif;
    font-size: 11px;
}

.message-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 2000;
}

.message {
    background: linear-gradient(to bottom, #DFDFDF, #BFBFBF);
    border: 2px outset #C0C0C0;
    padding: 10px;
    margin: 5px 0;
    color: #000;
    font-size: 11px;
    max-width: 300px;
    animation: slideIn 0.3s ease-in;
}

.message.error {
    background: linear-gradient(to bottom, #FF8080, #FF4040);
    color: #FFF;
}

.message.success {
    background: linear-gradient(to bottom, #80FF80, #40FF40);
    color: #000;
}

@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

@keyframes rainbow {
    0% { filter: hue-rotate(0deg); }
    100% { filter: hue-rotate(360deg); }
}

/* Leaderboard Styling */
.game-selector {
    margin-bottom: 20px;
    text-align: center;
}

.game-selector .btn {
    margin: 5px;
    min-width: 80px;
}

.leaderboard-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    border: 2px outset #C0C0C0;
    background: #FFF;
    font-family: 'MS Sans Serif', sans-serif;
    font-size: 11px;
}

.leaderboard-table thead {
    background: linear-gradient(to bottom, #0080FF, #000080);
    color: #FFF;
}

.leaderboard-table th {
    padding: 8px 12px;
    text-align: left;
    border-right: 1px solid #4060A0;
    font-weight: bold;
    text-shadow: 1px 1px 1px rgba(0,0,0,0.5);
}

.leaderboard-table th:last-child {
    border-right: none;
}

.leaderboard-table tbody tr {
    background: #FFF;
    border-bottom: 1px solid #C0C0C0;
}

.leaderboard-table tbody tr:nth-child(odd) {
    background: #F8F8F8;
}

.leaderboard-table tbody tr:hover {
    background: linear-gradient(to right, #E8E8FF, #F0F0FF);
}

.leaderboard-table td {
    padding: 6px 12px;
    border-right: 1px solid #E0E0E0;
    color: #000;
}

.leaderboard-table td:last-child {
    border-right: none;
}

/* Rank-specific styling */
.leaderboard-table tr.rank-1 {
    background: linear-gradient(to right, #FFD700, #FFF8DC) !important;
    font-weight: bold;
}

.leaderboard-table tr.rank-2 {
    background: linear-gradient(to right, #C0C0C0, #F5F5F5) !important;
    font-weight: bold;
}

.leaderboard-table tr.rank-3 {
    background: linear-gradient(to right, #CD7F32, #F5DEB3) !important;
    font-weight: bold;
}

.rank-badge {
    display: inline-block;
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 10px;
    font-weight: bold;
    margin-right: 5px;
}

.rank-1 .rank-badge {
    background: #FFD700;
    color: #000;
}

.rank-2 .rank-badge {
    background: #C0C0C0;
    color: #000;
}

.rank-3 .rank-badge {
    background: #CD7F32;
    color: #FFF;
}

.title-cell {
    font-weight: bold;
    font-style: italic;
}

.score-cell {
    font-family: 'Courier New', monospace;
    font-weight: bold;
    text-align: right;
}

.username-cell {
    font-weight: bold;
}

/* Achievements styling */
.achievements-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    padding: 15px;
}

.achievement-card {
    background: linear-gradient(to bottom, #DFDFDF, #BFBFBF);
    border: 2px outset #C0C0C0;
    padding: 15px;
    text-align: center;
    color: #000;
}

.achievement-icon {
    font-size: 2em;
    margin-bottom: 10px;
}

.achievement-card h4 {
    margin: 10px 0 5px 0;
    color: #000080;
}

.achievement-card p {
    margin: 5px 0;
    font-size: 0.9em;
}

.achievement-card small {
    color: #666;
    font-size: 0.8em;
}

/* Tab styling */
.form-tabs {
    display: flex;
    margin-bottom: 15px;
}

.tab-btn {
    background: linear-gradient(to bottom, #DFDFDF, #BFBFBF);
    border: 2px outset #C0C0C0;
    border-bottom: none;
    padding: 8px 16px;
    cursor: pointer;
    margin-right: 2px;
    color: #000;
}

.tab-btn.active {
    background: #C0C0C0;
    border: 2px inset #C0C0C0;
    border-bottom: 2px solid #C0C0C0;
}

.tab-content {
    display: none;
    padding: 15px;
    border: 2px inset #C0C0C0;
    background: #C0C0C0;
}

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

/* Additional Leaderboard Styling */
.leaderboard-header {
    text-align: center;
    margin-bottom: 20px;
    padding: 15px;
    background: linear-gradient(to bottom, #DFDFDF, #BFBFBF);
    border: 2px outset #C0C0C0;
}

.leaderboard-subtitle {
    font-style: italic;
    color: #666;
    margin: 5px 0;
}

.empty-leaderboard {
    text-align: center;
    padding: 40px;
    background: linear-gradient(to bottom, #F8F8F8, #E8E8E8);
    border: 2px inset #C0C0C0;
    color: #666;
}

.current-user {
    background: linear-gradient(to right, #E8FFE8, #F0FFF0) !important;
    border: 2px solid #00AA00 !important;
    animation: highlight 2s ease-in-out;
}

@keyframes highlight {
    0%, 100% { box-shadow: none; }
    50% { box-shadow: 0 0 10px rgba(0, 170, 0, 0.5); }
}

.rank-cell {
    text-align: center;
    font-weight: bold;
}

.games-cell {
    text-align: center;
    color: #666;
}

.user-stats {
    margin-top: 20px;
    padding: 15px;
    background: linear-gradient(to bottom, #FFE8E8, #FFF0F0);
    border: 2px outset #C0C0C0;
    text-align: center;
}

.user-stats h4 {
    color: #CC0000;
    margin-bottom: 10px;
}

/* Game selector enhancements */
.game-selector {
    background: linear-gradient(to bottom, #F0F0F0, #E0E0E0);
    padding: 15px;
    border: 2px inset #C0C0C0;
    margin-bottom: 20px;
}

.game-selector .btn.active {
    background: linear-gradient(to bottom, #0080FF, #000080);
    color: #FFF;
    border: 2px inset #C0C0C0;
}

/* Mobile Responsive Design */
@media (max-width: 768px) {
    body {
        padding: 5px;
        align-items: flex-start;
        padding-top: 20px;
    }
    
    .container {
        width: 100%;
        min-height: calc(100vh - 40px);
        border: 2px outset #C0C0C0;
    }
    
    .title-bar-text {
        font-size: 12px;
    }
    
    .subtitle {
        font-size: 10px;
        display: none; /* Hide on mobile for space */
    }
    
    .toolbar {
        padding: 5px;
        display: flex;
        flex-wrap: wrap;
        justify-content: center;
    }
    
    .btn {
        font-size: 10px;
        padding: 8px 12px;
        margin: 2px;
        min-width: 60px;
        touch-action: manipulation;
    }
    
    .games-grid {
        grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
        gap: 10px;
        padding: 10px;
    }
    
    .game-card {
        padding: 12px;
        touch-action: manipulation;
    }
    
    .game-icon {
        font-size: 2em;
    }
    
    .section {
        padding: 10px;
    }
    
    .section h2 {
        font-size: 1.2em;
        margin-bottom: 10px;
    }
    
    .modal-content {
        width: 95%;
        margin: 2% auto;
        max-height: 90vh;
        overflow-y: auto;
    }
    
    .modal-body {
        padding: 10px;
    }
    
    #gameCanvas {
        max-width: 100%;
        height: auto;
        touch-action: none;
    }
    
    .leaderboard-table {
        font-size: 10px;
        width: 100%;
        overflow-x: auto;
        display: block;
        white-space: nowrap;
    }
    
    .leaderboard-table thead,
    .leaderboard-table tbody,
    .leaderboard-table tr {
        display: table;
        width: 100%;
        table-layout: fixed;
    }
    
    .leaderboard-table th,
    .leaderboard-table td {
        padding: 4px 2px;
        font-size: 9px;
    }
    
    .form-container {
        padding: 10px;
        margin: 5px;
    }
    
    .input {
        width: 100%;
        padding: 8px;
        margin: 3px 0;
        font-size: 14px;
        box-sizing: border-box;
    }
    
    .message {
        font-size: 10px;
        padding: 8px;
        max-width: 250px;
    }
    
    .status-bar {
        font-size: 9px;
        padding: 8px;
        flex-direction: column;
        text-align: center;
        min-height: 35px;
    }
    
    .insult-ticker {
        position: absolute;
        right: 0;
        width: 60%;
        text-align: right;
        margin-top: 5px;
        font-size: 8px;
        animation: marquee-scroll 15s linear infinite;
    }
    
    .achievements-grid {
        grid-template-columns: 1fr;
        gap: 10px;
        padding: 10px;
    }
    
    .achievement-card {
        padding: 10px;
    }
    
    .game-selector {
        padding: 10px;
    }
    
    .game-selector .btn {
        margin: 2px;
        min-width: 50px;
        font-size: 9px;
    }
}

@media (max-width: 480px) {
    .container {
        border: 1px outset #C0C0C0;
    }
    
    .title-bar {
        padding: 3px 8px;
    }
    
    .title-bar-text {
        font-size: 11px;
    }
    
    .title-bar-control {
        width: 18px;
        height: 16px;
        font-size: 10px;
        line-height: 14px;
    }
    
    .games-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
        padding: 8px;
    }
    
    .game-card {
        padding: 8px;
    }
    
    .game-icon {
        font-size: 1.5em;
        margin-bottom: 5px;
    }
    
    .btn {
        font-size: 9px;
        padding: 6px 8px;
        min-width: 50px;
    }
    
    .modal-content {
        width: 98%;
        margin: 1% auto;
    }
    
    .leaderboard-table th,
    .leaderboard-table td {
        padding: 2px 1px;
        font-size: 8px;
    }
    
    .section h2 {
        font-size: 1.1em;
    }
}

/* Touch Controls for Games */
.mobile-controls {
    display: none;
    position: fixed;
    bottom: 10px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1000;
    background: rgba(192, 192, 192, 0.9);
    border: 2px outset #C0C0C0;
    border-radius: 10px;
    padding: 10px;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: center;
}

.control-btn {
    background: linear-gradient(to bottom, #DFDFDF, #BFBFBF);
    border: 2px outset #C0C0C0;
    color: #000;
    padding: 15px;
    font-size: 18px;
    min-width: 50px;
    min-height: 50px;
    touch-action: manipulation;
    user-select: none;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 5px;
}

.control-btn:active {
    border: 2px inset #C0C0C0;
    background: linear-gradient(to bottom, #BFBFBF, #DFDFDF);
}

.direction-pad {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 5px;
    margin-right: 20px;
}

.action-buttons {
    display: flex;
    gap: 10px;
    align-items: center;
}

/* Only show mobile controls on actual touch devices */
@media (hover: none) and (pointer: coarse) {
    .mobile-controls {
        display: flex;
    }
    
    .modal-body {
        padding-bottom: 120px; /* Space for controls */
    }
}

/* Additional check for touch-enabled devices */
@media (max-width: 768px) and (hover: none) {
    .mobile-controls {
        display: flex;
    }
}

/* Landscape orientation adjustments */
@media (max-height: 500px) and (orientation: landscape) {
    .container {
        width: 98%;
        min-height: auto;
    }
    
    .modal-content {
        margin: 1% auto;
        max-height: 95vh;
    }
    
    .mobile-controls {
        bottom: 5px;
        padding: 5px;
    }
    
    .control-btn {
        padding: 10px;
        min-width: 40px;
        min-height: 40px;
        font-size: 14px;
    }
}

