/* Acrophobia - Accessible Game Styles */

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 10px;
    color: #333;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.container {
    max-width: 800px;
    margin: 0 auto;
    background: white;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    padding: 20px;
}

header {
    text-align: center;
    margin-bottom: 30px;
    border-bottom: 3px solid #667eea;
    padding-bottom: 20px;
}

header h1 {
    font-size: 2.5em;
    color: #667eea;
    margin-bottom: 10px;
    word-wrap: break-word;
}

.subtitle {
    color: #666;
    font-size: 1.1em;
}

/* Screen reader only content */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

/* Phase indicator */
.phase-indicator {
    background: #f0f0f0;
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 20px;
    font-weight: bold;
    font-size: 1.1em;
    text-align: center;
    color: #667eea;
}

/* Timer display */
.timer-display {
    margin-top: 10px;
    padding: 10px;
    background: #fff;
    border-radius: 6px;
    border: 2px solid #667eea;
}

.timer-label {
    display: block;
    font-size: 0.9em;
    color: #666;
    margin-bottom: 5px;
}

.timer-value {
    display: block;
    font-size: 1.5em;
    font-weight: bold;
    color: #667eea;
    font-family: monospace;
}

.timer-value.warning {
    color: #ff9800;
}

.timer-value.danger {
    color: #f44336;
    animation: pulse 1s infinite;
}

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

/* Game code section */
.game-code-section {
    margin: 20px 0;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 8px;
    border: 2px solid #667eea;
}

.game-code-display label {
    display: block;
    margin-bottom: 10px;
    font-weight: bold;
    color: #667eea;
}

.game-code-wrapper {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}

#gameCodeText {
    flex: 1;
    min-width: 150px;
    padding: 12px;
    font-size: 1.2em;
    font-weight: bold;
    font-family: monospace;
    text-align: center;
    letter-spacing: 0.1em;
    border: 2px solid #ddd;
    border-radius: 6px;
    background: white;
    color: #667eea;
}

.copy-btn, .share-btn {
    padding: 10px 20px;
    font-size: 0.95em;
    min-width: 100px;
}

.copy-btn {
    background: #17a2b8;
}

.copy-btn:hover {
    background: #138496;
}

.share-btn {
    background: #28a745;
}

.share-btn:hover {
    background: #218838;
}

.game-code-hint {
    margin-top: 10px;
    font-size: 0.9em;
    color: #666;
    text-align: center;
}

/* Game phases */
.game-phase {
    display: none;
}

.game-phase[aria-hidden="false"] {
    display: block;
}

/* Acronym display */
.acronym-display {
    text-align: center;
    margin: 30px 0;
    padding: 30px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 12px;
    color: white;
}

.acronym-display h2 {
    margin-bottom: 15px;
    font-size: 1.3em;
}

.acronym {
    font-size: 4em;
    font-weight: bold;
    letter-spacing: 0.2em;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
    margin: 20px 0;
    word-break: break-all;
}

/* Forms */
form {
    margin: 30px 0;
}

label {
    display: block;
    margin-bottom: 10px;
    font-weight: bold;
    font-size: 1.1em;
}

textarea {
    width: 100%;
    padding: 12px;
    border: 2px solid #ddd;
    border-radius: 8px;
    font-size: 1em;
    font-family: inherit;
    resize: vertical;
    transition: border-color 0.3s;
}

textarea:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

button {
    background: #667eea;
    color: white;
    border: none;
    padding: 12px 30px;
    font-size: 1.1em;
    border-radius: 8px;
    cursor: pointer;
    font-weight: bold;
    transition: all 0.3s;
    margin-top: 15px;
    min-height: 44px; /* Minimum touch target size for mobile */
    -webkit-tap-highlight-color: rgba(102, 126, 234, 0.3);
    touch-action: manipulation; /* Prevents double-tap zoom */
}

button:hover {
    background: #5568d3;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.3);
}

button:active {
    transform: translateY(0);
}

button:focus {
    outline: 3px solid rgba(102, 126, 234, 0.5);
    outline-offset: 2px;
}

/* Definitions list for voting */
#definitionsList {
    margin: 20px 0;
}

.definition-item {
    background: #f8f9fa;
    border: 2px solid #ddd;
    border-radius: 8px;
    padding: 20px;
    margin: 15px 0;
    cursor: pointer;
    transition: all 0.3s;
    min-height: 60px; /* Minimum touch target size */
    -webkit-tap-highlight-color: rgba(102, 126, 234, 0.2);
    touch-action: manipulation;
    user-select: none;
    -webkit-user-select: none;
}

.definition-item:hover {
    background: #e9ecef;
    border-color: #667eea;
}

.definition-item.selected {
    background: #667eea;
    color: white;
    border-color: #5568d3;
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.3);
}

.definition-item.touching {
    background: #e9ecef;
    transform: scale(0.98);
}

.definition-item .definition-text {
    font-size: 1.2em;
    margin-bottom: 10px;
}

.definition-item .definition-meta {
    font-size: 0.9em;
    opacity: 0.8;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 10px;
}

.definition-author {
    font-weight: bold;
    color: #667eea;
}

.definition-votes {
    font-weight: bold;
}

/* Own submission styling */
.definition-item.own-submission {
    background: #e8e8e8;
    border-color: #999;
    opacity: 0.7;
    cursor: not-allowed !important;
}

.definition-item.own-submission:hover {
    background: #e8e8e8;
    border-color: #999;
    transform: none;
}

.definition-item.own-submission.selected {
    background: #e8e8e8;
    border-color: #999;
}

.own-submission-badge {
    display: block;
    font-size: 0.85em;
    color: #666;
    font-style: italic;
    margin-top: 5px;
}

/* Cancel game section */
.cancel-game-section {
    margin-top: 30px;
    padding-top: 20px;
    border-top: 2px solid #eee;
    text-align: center;
}

.cancel-btn {
    background: #dc3545;
    font-size: 1em;
    padding: 12px 30px;
    margin-bottom: 10px;
}

.cancel-btn:hover {
    background: #c82333;
}

.cancel-hint {
    font-size: 0.9em;
    color: #666;
    font-style: italic;
}

/* Status messages */
#submissionStatus,
#votingStatus {
    margin: 20px 0;
    padding: 15px;
    border-radius: 8px;
    font-weight: bold;
}

#submissionStatus.success,
#votingStatus.success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

#submissionStatus.error,
#votingStatus.error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

/* Results */
#winnerDisplay {
    background: #d4edda;
    border: 2px solid #c3e6cb;
    border-radius: 8px;
    padding: 20px;
    margin: 20px 0;
    text-align: center;
}

#winnerDisplay h3 {
    color: #155724;
    margin-bottom: 15px;
}

#winnerDisplay .winner-definition {
    font-size: 1.3em;
    font-weight: bold;
    color: #155724;
}

/* Scoreboard */
#scoreboard {
    margin: 30px 0;
}

#scoreboard h3 {
    margin-bottom: 15px;
    color: #667eea;
}

#scoreList {
    list-style: none;
    background: #f8f9fa;
    border-radius: 8px;
    padding: 20px;
}

#scoreList li {
    padding: 12px;
    border-bottom: 1px solid #ddd;
    display: flex;
    justify-content: space-between;
    font-size: 1.1em;
}

#scoreList li:last-child {
    border-bottom: none;
}

.score-name {
    font-weight: bold;
}

.score-value {
    color: #667eea;
    font-weight: bold;
}

/* Controls */
.controls {
    display: flex;
    gap: 15px;
    justify-content: center;
    margin-top: 30px;
    padding-top: 20px;
    border-top: 2px solid #eee;
}

.controls button {
    background: #6c757d;
    font-size: 1em;
    padding: 10px 20px;
}

.controls button:hover {
    background: #5a6268;
}

.audio-icon {
    font-size: 1.2em;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal[aria-hidden="false"] {
    display: flex;
}

.modal-content {
    background: white;
    padding: 30px;
    border-radius: 12px;
    max-width: 600px;
    max-height: 80vh;
    overflow-y: auto;
    position: relative;
    margin: 20px;
}

.modal-close {
    position: absolute;
    top: 15px;
    right: 15px;
    background: #dc3545;
    width: 35px;
    height: 35px;
    border-radius: 50%;
    font-size: 1.5em;
    line-height: 1;
    padding: 0;
    margin: 0;
}

.modal-close:hover {
    background: #c82333;
}

.help-content {
    margin-top: 20px;
}

.help-content ol,
.help-content ul {
    margin-left: 20px;
    margin-top: 15px;
}

.help-content li {
    margin: 10px 0;
    line-height: 1.6;
}

.help-content kbd {
    background: #f8f9fa;
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 3px 8px;
    font-family: monospace;
    font-size: 0.9em;
}

/* Waiting room */
.player-count {
    font-size: 1.2em;
    text-align: center;
    margin: 20px 0;
    color: #667eea;
    font-weight: bold;
}

/* Lobby styles */
#joinGameSection {
    margin: 2em 0;
    padding: 1.5em;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    border: 2px solid rgba(255, 255, 255, 0.1);
}

#joinGameSection h3 {
    margin-top: 0;
    color: #4CAF50;
}

#joinGameSection form {
    display: flex;
    flex-direction: column;
    gap: 1em;
}

#gameCodeInput {
    padding: 0.75em;
    font-size: 1.5em;
    font-weight: bold;
    letter-spacing: 0.3em;
    text-align: center;
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 4px;
    color: #fff;
    font-family: 'Courier New', monospace;
    text-transform: uppercase;
    min-height: 60px;
}

#gameCodeInput:focus {
    outline: none;
    border-color: #4CAF50;
    background: rgba(255, 255, 255, 0.15);
    box-shadow: 0 0 10px rgba(76, 175, 80, 0.3);
}

#joinGameBtn {
    padding: 0.75em 1.5em;
    font-size: 1.1em;
    background: #4CAF50;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.3s;
    min-height: 44px;
}

#joinGameBtn:hover {
    background: #45a049;
}

#joinGameBtn:active {
    background: #3d8b40;
}

#joinGameStatus {
    margin-top: 1em;
    padding: 0.5em;
    border-radius: 4px;
    min-height: 1.5em;
}

#joinGameStatus.success {
    background: rgba(76, 175, 80, 0.2);
    color: #4CAF50;
}

#joinGameStatus.error {
    background: rgba(244, 67, 54, 0.2);
    color: #f44336;
}

#usernameSection {
    margin: 30px 0;
}

#usernameInput {
    width: 100%;
    padding: 12px;
    border: 2px solid #ddd;
    border-radius: 8px;
    font-size: 1em;
    font-family: inherit;
    transition: border-color 0.3s;
    margin-bottom: 15px;
}

#usernameInput:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

#usernameStatus {
    margin: 15px 0;
    padding: 12px;
    border-radius: 8px;
    font-weight: bold;
}

#usernameStatus.success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

#usernameStatus.error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.player-list-section {
    margin: 30px 0;
    background: #f8f9fa;
    border-radius: 8px;
    padding: 20px;
}

.player-list-section h3 {
    margin-bottom: 15px;
    color: #667eea;
}

#playerList {
    list-style: none;
    margin: 15px 0;
}

.player-item {
    padding: 12px;
    margin: 8px 0;
    background: white;
    border-radius: 6px;
    border: 2px solid #ddd;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.player-item.host {
    border-color: #667eea;
    background: #f0f4ff;
}

.player-username {
    font-weight: bold;
    font-size: 1.1em;
}

.host-badge {
    background: #667eea;
    color: white;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 0.85em;
    font-weight: bold;
}

#hostControls {
    margin: 30px 0;
    text-align: center;
}

/* Game settings */
.game-settings {
    background: white;
    border: 2px solid #667eea;
    border-radius: 8px;
    padding: 20px;
    margin: 20px 0;
    text-align: left;
}

.game-settings h3 {
    margin-bottom: 20px;
    color: #667eea;
    text-align: center;
}

.setting-group {
    margin-bottom: 20px;
}

.setting-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: bold;
    color: #333;
}

.setting-group input[type="number"] {
    width: 100%;
    padding: 10px;
    border: 2px solid #ddd;
    border-radius: 6px;
    font-size: 1.1em;
    font-family: inherit;
    transition: border-color 0.3s;
}

.setting-group input[type="number"]:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.setting-hint {
    display: block;
    font-size: 0.85em;
    color: #666;
    margin-top: 5px;
    font-style: italic;
}

#settingsStatus {
    margin-top: 15px;
    padding: 12px;
    border-radius: 6px;
    font-weight: bold;
}

#settingsStatus.success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

#settingsStatus.error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

#startGameBtn {
    background: #28a745;
    font-size: 1.2em;
    padding: 15px 40px;
    margin-bottom: 15px;
}

#startGameBtn:hover {
    background: #218838;
}

#waitingForHost {
    text-align: center;
    margin: 30px 0;
    padding: 20px;
    background: #fff3cd;
    border: 2px solid #ffc107;
    border-radius: 8px;
    color: #856404;
}

.instruction {
    text-align: center;
    margin: 20px 0;
    font-size: 1.1em;
    color: #666;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    body {
        background: #000;
    }
    
    .container {
        background: #fff;
        border: 3px solid #000;
    }
    
    button {
        border: 2px solid #000;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    * {
        animation: none !important;
        transition: none !important;
    }
}

/* Mobile Responsive Styles */
@media (max-width: 768px) {
    body {
        padding: 5px;
    }
    
    .container {
        padding: 15px;
        border-radius: 8px;
        margin: 5px;
    }
    
    header h1 {
        font-size: 2em;
    }
    
    .subtitle {
        font-size: 1em;
    }
    
    .phase-indicator {
        padding: 12px;
        font-size: 1em;
    }
    
    .acronym-display {
        padding: 20px;
        margin: 20px 0;
    }
    
    .acronym-display h2 {
        font-size: 1.1em;
    }
    
    .acronym {
        font-size: 2.5em;
        letter-spacing: 0.1em;
        margin: 15px 0;
    }
    
    form {
        margin: 20px 0;
    }
    
    label {
        font-size: 1em;
    }
    
    textarea {
        padding: 15px;
        font-size: 16px; /* Prevents zoom on iOS */
        min-height: 120px;
    }
    
    button {
        width: 100%;
        padding: 15px;
        font-size: 1em;
        margin-top: 15px;
    }
    
    .definition-item {
        padding: 15px;
        margin: 10px 0;
    }
    
    .definition-item .definition-text {
        font-size: 1.1em;
    }
    
    .controls {
        flex-direction: column;
        gap: 10px;
    }
    
    .controls button {
        width: 100%;
        margin-top: 0;
    }
    
    .modal-content {
        margin: 10px;
        padding: 20px;
        max-width: calc(100% - 20px);
        max-height: calc(100vh - 20px);
    }
    
    .modal-close {
        width: 40px;
        height: 40px;
        font-size: 1.8em;
        top: 10px;
        right: 10px;
    }
    
    #scoreboard {
        margin: 20px 0;
    }
    
    #scoreList {
        padding: 15px;
    }
    
    #scoreList li {
        padding: 10px;
        font-size: 1em;
        flex-direction: column;
        gap: 5px;
    }
    
    .player-count {
        font-size: 1.1em;
    }
    
    .instruction {
        font-size: 1em;
        margin: 15px 0;
    }
    
    #winnerDisplay {
        padding: 15px;
        margin: 15px 0;
    }
    
    #winnerDisplay .winner-definition {
        font-size: 1.1em;
    }
}

/* Small mobile devices */
@media (max-width: 480px) {
    .container {
        padding: 10px;
        border-radius: 6px;
    }
    
    header h1 {
        font-size: 1.75em;
    }
    
    .acronym {
        font-size: 2em;
    }
    
    .acronym-display {
        padding: 15px;
    }
    
    .definition-item {
        padding: 12px;
    }
    
    .definition-item .definition-text {
        font-size: 1em;
    }
    
    .phase-indicator {
        padding: 10px;
        font-size: 0.95em;
    }
    
    .help-content {
        font-size: 0.95em;
    }
    
    .help-content kbd {
        font-size: 0.85em;
        padding: 2px 6px;
    }
}

/* Landscape orientation on mobile */
@media (max-width: 768px) and (orientation: landscape) {
    .acronym {
        font-size: 3em;
    }
    
    .modal-content {
        max-height: calc(100vh - 40px);
    }
}

/* Prevent text size adjustment on iOS */
@media screen and (max-width: 768px) {
    html {
        -webkit-text-size-adjust: 100%;
    }
    
    input, textarea, select {
        font-size: 16px !important; /* Prevents zoom on focus in iOS */
    }
    
    /* Ensure buttons don't zoom on tap */
    button, .definition-item {
        font-size: 16px;
    }
    
    /* Lobby mobile styles */
    #usernameInput {
        font-size: 16px; /* Prevents zoom on iOS */
    }
    
    .player-list-section {
        padding: 15px;
    }
    
    .player-item {
        padding: 10px;
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }
    
    #startGameBtn {
        width: 100%;
        padding: 15px;
    }
    
    .game-code-wrapper {
        flex-direction: column;
    }
    
    #gameCodeText {
        width: 100%;
    }
    
    .copy-btn, .share-btn {
        width: 100%;
    }
    
    .game-settings {
        padding: 15px;
    }
    
    .setting-group input[type="number"] {
        font-size: 16px; /* Prevents zoom on iOS */
    }
}

/* Touch device optimizations */
@media (hover: none) and (pointer: coarse) {
    /* Mobile device - optimize touch targets */
    button, .definition-item, .modal-close {
        min-height: 44px;
        min-width: 44px;
    }
    
    /* Larger tap targets for controls */
    .controls button {
        min-width: 100%;
    }
}

