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

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

body {
    background-color: #000000;
    color: #00ff00;
    height: 100vh;
    overflow: hidden;
    font-family: 'Press Start 2P', monospace;
    transition: background-color 0.5s ease, color 0.5s ease;
    image-rendering: pixelated;
    image-rendering: -moz-crisp-edges;
    image-rendering: crisp-edges;
    touch-action: manipulation;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
    -webkit-tap-highlight-color: transparent;
}

.container {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    height: 100vh;
    width: 100vw;
    padding: 20px;
    text-align: center;
    position: relative;
}

.score-display {
    position: absolute;
    top: 20px;
    right: 20px;
    color: #00ff00;
    font-size: 0.8rem;
    text-shadow: 0 0 5px #00ff00;
    background: rgba(0, 0, 0, 0.8);
    padding: 10px;
    border: 2px solid #00ff00;
    border-radius: 5px;
}

#main-text {
    font-size: clamp(2rem, 8vw, 6rem);
    font-weight: 400;
    text-align: center;
    font-family: 'Press Start 2P', monospace;
    transition: font-family 0.3s ease;
    user-select: none;
    text-shadow: 0 0 10px #00ff00, 2px 2px 0px #003300;
    margin-bottom: 15px;
    letter-spacing: 0.1em;
}

.subtitle {
    font-size: clamp(0.8rem, 3vw, 1.5rem);
    margin-bottom: 10px;
    font-family: 'Press Start 2P', monospace;
    text-shadow: 0 0 5px #00ff00;
    letter-spacing: 0.05em;
}

.description {
    font-size: clamp(0.6rem, 2vw, 1rem);
    max-width: 600px;
    margin: 0 auto 10px auto;
    color: white;
    font-family: 'Press Start 2P', monospace;
    line-height: 1.6;
    letter-spacing: 0.02em;
}

.question {
    font-size: clamp(0.6rem, 2vw, 1rem);
    color: white;
    margin-bottom: 30px;
    font-family: 'Press Start 2P', monospace;
    letter-spacing: 0.02em;
}

#start-button {
    background-color: #00ff00;
    color: #000000;
    padding: 15px 25px;
    border: 3px solid #00cc00;
    font-size: clamp(0.8rem, 3vw, 1.2rem);
    cursor: pointer;
    border-radius: 0;
    transition: all 0.2s ease;
    font-family: 'Press Start 2P', monospace;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    box-shadow: 4px 4px 0px #003300;
}

#start-button:hover {
    background-color: #00cc00;
    transform: translate(-2px, -2px);
    box-shadow: 6px 6px 0px #003300;
}

/* New style for loading text */
.loading-text {
    font-size: clamp(1.2rem, 6vw, 3rem); /* Match or be slightly smaller than main title */
    font-weight: 400; /* Make it bold */
    text-align: center;
    color: white; /* Make loading text white */
    margin-bottom: 20px; /* Space between text and spinner */
    font-family: 'Press Start 2P', monospace;
    text-shadow: 2px 2px 0px #333;
    letter-spacing: 0.05em;
}

/* Styles for the loading spinner */
.loading-spinner {
  display: inline-block;
  width: 50px;
  height: 50px;
  border: 5px solid rgba(0, 255, 0, 0.3); /* Light green border */
  border-radius: 50%;
  border-top-color: #00ff00; /* Green top border */
  animation: spin 1s ease-in-out infinite; /* Spin animation */
}

/* Keyframes for the spin animation */
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* Game interface styles */
.game-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    width: 100%;
    max-width: 800px;
    margin: 0 auto;
    padding: 20px;
    position: relative;
    font-family: 'Press Start 2P', monospace;
}

.game-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding: 0 10px;
}

.game-title {
    font-size: 1.2rem;
    color: #00ff00;
    font-weight: 400;
    font-family: 'Press Start 2P', monospace;
    text-shadow: 0 0 5px #00ff00;
}

.timer {
    font-size: 1.2rem;
    color: #00ff00;
    font-weight: 400;
    text-shadow: 0 0 5px #00ff00;
    font-family: 'Press Start 2P', monospace;
}

.opponent-info {
    color: white;
    text-align: center;
    margin-bottom: 20px;
    font-size: 0.8rem;
    font-family: 'Press Start 2P', monospace;
    line-height: 1.4;
}

.chat-area {
    flex: 1;
    background-color: #111;
    border: 2px solid #333;
    border-radius: 15px;
    padding: 20px;
    overflow-y: auto;
    margin-bottom: 20px;
    min-height: 400px;
    display: flex;
    flex-direction: column;
    gap: 15px;
    -webkit-overflow-scrolling: touch;
}

.chat-message {
    max-width: 70%;
    padding: 12px 18px;
    border-radius: 20px;
    word-wrap: break-word;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
    animation: bounceIn 0.3s ease-out;
    position: relative;
}

.chat-message.user {
    background: linear-gradient(135deg, #00ff00, #00cc00);
    color: #000;
    align-self: flex-end;
    border-bottom-right-radius: 5px;
}

.chat-message.opponent {
    background: linear-gradient(135deg, #333, #444);
    color: white;
    align-self: flex-start;
    border-bottom-left-radius: 5px;
}

.message-timestamp {
    font-size: 0.7rem;
    opacity: 0.7;
    margin-top: 5px;
    text-align: right;
}

.opponent .message-timestamp {
    text-align: left;
}

.typing-indicator {
    max-width: 70%;
    padding: 12px 18px;
    border-radius: 20px;
    background: linear-gradient(135deg, #333, #444);
    color: white;
    align-self: flex-start;
    border-bottom-left-radius: 5px;
    animation: bounceIn 0.3s ease-out;
}

.typing-dots {
    display: flex;
    gap: 4px;
    align-items: center;
}

.typing-dot {
    width: 8px;
    height: 8px;
    background-color: #888;
    border-radius: 50%;
    animation: typingBounce 1.4s infinite ease-in-out;
}

.typing-dot:nth-child(1) { animation-delay: -0.32s; }
.typing-dot:nth-child(2) { animation-delay: -0.16s; }
.typing-dot:nth-child(3) { animation-delay: 0s; }

.chat-input-area {
    display: flex;
    gap: 10px;
    align-items: center;
    margin-bottom: 15px;
}

.message-input {
    flex: 1;
    padding: 15px 20px;
    border: 2px solid #333;
    border-radius: 25px;
    background-color: #222;
    color: white;
    font-size: 1rem;
    transition: all 0.3s ease;
    -webkit-appearance: none;
    appearance: none;
}

.message-input:focus {
    outline: none;
    border-color: #00ff00;
    box-shadow: 0 0 10px rgba(0, 255, 0, 0.3);
}

.send-button {
    background: linear-gradient(135deg, #00ff00, #00cc00);
    color: #000;
    padding: 15px 25px;
    border: none;
    border-radius: 25px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: bold;
    transition: all 0.3s ease;
    box-shadow: 0 2px 10px rgba(0, 255, 0, 0.3);
}

.send-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(0, 255, 0, 0.4);
}

.end-chat-button {
    background-color: transparent;
    color: #666;
    padding: 10px 20px;
    border: 1px solid #444;
    border-radius: 20px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.3s ease;
    align-self: center;
}

.end-chat-button:hover {
    color: #ff6666;
    border-color: #ff6666;
}

@keyframes bounceIn {
    0% {
        opacity: 0;
        transform: scale(0.3) translateY(20px);
    }
    50% {
        opacity: 1;
        transform: scale(1.05);
    }
    70% {
        transform: scale(0.95);
    }
    100% {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

@keyframes typingBounce {
    0%, 80%, 100% {
        transform: scale(0);
    }
    40% {
        transform: scale(1);
    }
}

/* Voting interface styles */
.vote-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100vh;
    gap: 30px;
}

.vote-title {
    color: white;
    font-size: 2rem;
    text-align: center;
    font-family: 'Press Start 2P', monospace;
    text-shadow: 2px 2px 0px #333;
}

.vote-button {
    padding: 15px 30px;
    font-size: 1.5rem;
    border: 3px solid;
    border-radius: 0;
    cursor: pointer;
    transition: all 0.2s ease;
    min-width: 150px;
    font-family: 'Press Start 2P', monospace;
    text-transform: uppercase;
    box-shadow: 4px 4px 0px #333;
}

.human-vote {
    background-color: #00ff00;
    color: #000;
    border-color: #00cc00;
}

.human-vote:hover {
    background-color: #00cc00;
    transform: translate(-2px, -2px);
    box-shadow: 6px 6px 0px #333;
}

.ai-vote {
    background-color: #ff0000;
    color: white;
    border-color: #cc0000;
}

.ai-vote:hover {
    background-color: #cc0000;
    transform: translate(-2px, -2px);
    box-shadow: 6px 6px 0px #333;
}

/* Result interface styles */
.result-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100vh;
    gap: 20px;
    text-align: center;
}

.play-again-button {
    background-color: #00ff00;
    color: #000;
    padding: 15px 30px;
    border: 3px solid #00cc00;
    border-radius: 0;
    font-size: 1.2rem;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: 'Press Start 2P', monospace;
    text-transform: uppercase;
    box-shadow: 4px 4px 0px #003300;
}

.play-again-button:hover {
    background-color: #00cc00;
    transform: translate(-2px, -2px);
    box-shadow: 6px 6px 0px #003300;
}

/* Mobile responsiveness for game interface */
@media (max-width: 768px) {
    #main-text {
        font-size: clamp(1.5rem, 10vw, 4rem);
    }
    .subtitle {
         font-size: clamp(0.8rem, 4vw, 1.5rem);
    }
     .description, .question {
         font-size: clamp(0.7rem, 3vw, 1rem);
    }

    #start-button {
        font-size: clamp(0.9rem, 3.5vw, 1.2rem);
        padding: 8px 16px;
    }
    .loading-text {
         font-size: clamp(1rem, 7vw, 3rem); /* Adjust loading text size for mobile */
    }
     .loading-spinner {
        width: 40px;
        height: 40px;
        border-width: 4px; /* Adjust border width for smaller spinner */
    }
    
    .game-container {
        padding: 10px;
    }
    
    .timer {
        font-size: 1.5rem;
    }
    
    .opponent-info {
        font-size: 1rem;
    }
    
    .message-input {
        font-size: 0.9rem;
        padding: 10px;
    }
    
    .send-button {
        padding: 10px 15px;
        font-size: 0.9rem;
    }
    
    .vote-button {
        padding: 12px 25px;
        font-size: 1.2rem;
        min-width: 120px;
    }
    
    .vote-title {
        font-size: 1.5rem;
    }
}

@media (max-width: 480px) {
    .game-header {
        flex-direction: column;
        gap: 10px;
        text-align: center;
    }
    
    .game-title, .timer {
        font-size: 1rem;
    }
    
    .opponent-info {
        font-size: 0.8rem;
        padding: 0 10px;
    }
    
    .chat-input-area {
        flex-direction: column;
        gap: 10px;
    }
    
    .message-input {
        width: 100%;
    }
    
    .send-button {
        width: 100%;
        border-radius: 15px;
    }
}

/* Tablet Landscape */
@media (min-width: 769px) and (max-width: 1024px) and (orientation: landscape) {
    .game-container {
        max-width: 90%;
    }
    
    .chat-area {
        min-height: 350px;
    }
}

/* High DPI Display Support */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    body {
        image-rendering: auto;
    }
}

/* Achievement System Styles */
.achievement-notification {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: linear-gradient(135deg, #ffd700, #ffb347);
    color: #000;
    padding: 15px 25px;
    border-radius: 10px;
    font-family: 'Press Start 2P', monospace;
    font-size: 0.8rem;
    text-align: center;
    box-shadow: 0 4px 20px rgba(255, 215, 0, 0.4);
    z-index: 1000;
    animation: achievementSlideIn 0.5s ease-out;
    max-width: 90%;
    word-wrap: break-word;
}

.achievement-list {
    position: absolute;
    top: 70px;
    left: 20px;
    background: rgba(0, 0, 0, 0.9);
    border: 2px solid #00ff00;
    border-radius: 10px;
    padding: 15px;
    max-width: 300px;
    max-height: 70vh;
    overflow-y: auto;
    z-index: 100;
    display: none;
}

.achievement-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px;
    margin-bottom: 5px;
    border-radius: 5px;
    font-size: 0.7rem;
    line-height: 1.2;
}

.achievement-item.unlocked {
    background: rgba(0, 255, 0, 0.1);
    color: #00ff00;
}

.achievement-item.locked {
    background: rgba(100, 100, 100, 0.1);
    color: #666;
}

.achievement-icon {
    font-size: 1rem;
    min-width: 20px;
}

.achievements-button {
    position: absolute;
    top: 20px;
    left: 20px;
    background: rgba(0, 0, 0, 0.8);
    color: #00ff00;
    border: 2px solid #00ff00;
    border-radius: 5px;
    padding: 8px 12px;
    font-family: 'Press Start 2P', monospace;
    font-size: 0.7rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.achievements-button:hover {
    background: rgba(0, 255, 0, 0.1);
    transform: scale(1.05);
}

@keyframes achievementSlideIn {
    0% {
        opacity: 0;
        transform: translateX(-50%) translateY(-50px);
    }
    100% {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

/* Enhanced Mobile Responsiveness */
@media (max-width: 768px) {
    .container {
        padding: 15px;
    }
    
    .score-display {
        top: 10px;
        right: 10px;
        font-size: 0.7rem;
        padding: 8px;
    }
    
    .achievements-button {
        top: 10px;
        left: 10px;
        padding: 6px 10px;
        font-size: 0.6rem;
    }
    
    .achievement-list {
        top: 50px;
        left: 10px;
        right: 10px;
        max-width: none;
        width: auto;
    }
    
    .chat-message {
        max-width: 85%;
        padding: 10px 15px;
        font-size: 0.9rem;
    }
    
    .message-input {
        font-size: 16px; /* Prevents zoom on iOS */
        padding: 12px 16px;
    }
    
    .send-button {
        padding: 12px 16px;
        font-size: 0.8rem;
    }
}

.volume-control {
    position: absolute;
    bottom: 20px;
    right: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(0, 0, 0, 0.8);
    padding: 10px;
    border: 2px solid #00ff00;
    border-radius: 5px;
}

.volume-control label {
    color: #00ff00;
    font-size: 1.2rem;
}

#volume-slider {
    width: 100px;
    height: 5px;
    background: #333;
    outline: none;
    border-radius: 5px;
    -webkit-appearance: none;
    appearance: none;
}

#volume-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 15px;
    height: 15px;
    background: #00ff00;
    border-radius: 50%;
    cursor: pointer;
}

#volume-slider::-moz-range-thumb {
    width: 15px;
    height: 15px;
    background: #00ff00;
    border-radius: 50%;
    cursor: pointer;
    border: none;
}

.game-selection {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    margin-top: 30px;
}

.game-selection h3 {
    color: white;
    font-size: 1.2rem;
    font-family: 'Press Start 2P', monospace;
    margin-bottom: 10px;
}

.game-buttons {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
    justify-content: center;
}

.game-button {
    background-color: #333;
    color: #00ff00;
    border: 2px solid #00ff00;
    padding: 10px 20px;
    font-family: 'Press Start 2P', monospace;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 2px 2px 0px #001100;
}

.game-button:hover {
    background-color: #00ff00;
    color: #000;
    transform: translate(-1px, -1px);
    box-shadow: 3px 3px 0px #001100;
}

.game-button.active {
    background-color: #00ff00;
    color: #000;
}

.mini-game-container {
    width: 400px;
    height: 300px;
    border: 2px solid #00ff00;
    background: #000;
    margin: 20px auto;
    position: relative;
    display: none;
}

.mini-game-canvas {
    width: 100%;
    height: 100%;
    display: block;
}

.game-controls {
    text-align: center;
    margin-top: 10px;
    color: white;
    font-family: 'Press Start 2P', monospace;
    font-size: 0.6rem;
    line-height: 1.4;
}