/* ===== GLOBAL STYLES & DARK THEME ===== */
:root {
    /* Dark Theme Colors */
    --bg-primary: #0d1117;
    --bg-secondary: #161b22;
    --bg-tertiary: #21262d;
    --bg-hover: #30363d;
    
    /* Text Colors */
    --text-primary: #f0f6fc;
    --text-secondary: #8b949e;
    --text-muted: #6e7681;
    
    /* Accent Colors */
    --accent-primary: #58a6ff;
    --accent-secondary: #1f6feb;
    --accent-success: #238636;
    --accent-warning: #d29922;
    --accent-danger: #da3633;
    
    /* Game Colors */
    --player-red: #ff4757;
    --player-green: #2ed573;
    --player-blue: #3742fa;
    --player-yellow: #ffa502;
    
    /* Borders & Shadows */
    --border-color: #30363d;
    --shadow-light: 0 1px 3px rgba(0, 0, 0, 0.12);
    --shadow-medium: 0 4px 12px rgba(0, 0, 0, 0.15);
    --shadow-heavy: 0 8px 32px rgba(0, 0, 0, 0.3);
    
    /* Transitions */
    --transition-fast: 0.15s ease;
    --transition-medium: 0.3s ease;
    --transition-slow: 0.5s ease;
    
    /* Border Radius */
    --radius-small: 4px;
    --radius-medium: 8px;
    --radius-large: 12px;
    --radius-xl: 16px;
}

/* Reset & Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    height: 100%;
    overflow: hidden;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    overflow: hidden;
    height: 100vh;
}

/* App Container */
.app-container {
    height: 100vh;
    position: relative;
    overflow: hidden;
}

/* Screen Management */
.screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;
    opacity: 0;
    visibility: hidden;
    transition: all var(--transition-medium);
    background: var(--bg-primary);
}

.screen.active {
    opacity: 1;
    visibility: visible;
}

/* Buttons */
.btn {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    padding: 12px 24px;
    border-radius: var(--radius-medium);
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all var(--transition-fast);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    text-decoration: none;
}

.btn:hover {
    background: var(--bg-hover);
    transform: translateY(-1px);
    box-shadow: var(--shadow-medium);
}

.btn:active {
    transform: translateY(0);
}

.btn.primary {
    background: var(--accent-primary);
    border-color: var(--accent-secondary);
}

.btn.primary:hover {
    background: var(--accent-secondary);
}

.btn.success {
    background: var(--accent-success);
    border-color: var(--accent-success);
}

.btn.danger {
    background: var(--accent-danger);
    border-color: var(--accent-danger);
}

/* Back Button */
.back-btn {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    padding: 8px 16px;
    border-radius: var(--radius-medium);
    cursor: pointer;
    font-size: 14px;
    transition: all var(--transition-fast);
}

.back-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

/* Input Fields */
input[type="text"] {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 12px 16px;
    border-radius: var(--radius-medium);
    font-size: 14px;
    width: 100%;
    transition: all var(--transition-fast);
}

input[type="text"]:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(88, 166, 255, 0.1);
}

input[type="text"]::placeholder {
    color: var(--text-muted);
}

/* 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: 0;
}

/* Skip Links für Keyboard Navigation */
.skip-link {
    position: absolute;
    top: -40px;
    left: 6px;
    background: var(--accent-primary);
    color: white;
    padding: 8px;
    text-decoration: none;
    border-radius: 4px;
    z-index: 1000;
    transition: top 0.3s;
}

.skip-link:focus {
    top: 6px;
}

/* Focus Styles für bessere Keyboard Navigation */
*:focus {
    outline: 2px solid var(--accent-primary);
    outline-offset: 2px;
}

button:focus,
input:focus,
[tabindex]:focus {
    outline: 2px solid var(--accent-primary);
    outline-offset: 2px;
    box-shadow: 0 0 0 4px rgba(88, 166, 255, 0.2);
}

/* High Contrast Mode Support */
@media (prefers-contrast: high) {
    :root {
        --bg-primary: #000000;
        --bg-secondary: #1a1a1a;
        --text-primary: #ffffff;
        --border-color: #ffffff;
    }
}

/* Reduced Motion Support */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
    color: var(--text-primary);
    font-weight: 600;
    line-height: 1.3;
}

h1 { font-size: 2.5rem; }
h2 { font-size: 2rem; }
h3 { font-size: 1.5rem; }
h4 { font-size: 1.25rem; }

p {
    color: var(--text-secondary);
    margin-bottom: 1rem;
}

/* Scrollbar Styling */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-secondary);
}

::-webkit-scrollbar-thumb {
    background: var(--bg-hover);
    border-radius: var(--radius-small);
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* Game Screen Styles */
.game-container {
    height: 100vh;
    display: flex;
    flex-direction: column;
    background: var(--bg-primary);
    overflow: hidden;
}

.game-header {
    display: none !important; /* Header komplett versteckt im Spiel */
}

.game-info {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
}

.current-player {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.current-player.player-0 { color: var(--player-red); }
.current-player.player-1 { color: var(--player-green); }
.current-player.player-2 { color: var(--player-blue); }
.current-player.player-3 { color: var(--player-yellow); }

#game-mode-display {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.game-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 1rem;
    padding: 2rem;
    overflow: hidden;
    height: 100vh;
}

.game-main-section {
    display: flex;
    justify-content: center;
    align-items: flex-end;
    gap: 1rem;
    flex-shrink: 0;
    position: relative;
    margin-top: 3rem;
}

.game-sidebar-right {
    width: 320px;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    flex-shrink: 0;
    height: calc(100vh - 8rem);
    align-self: stretch;
}

.board-section {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 0;
    width: calc(100vh - 8rem);
    height: calc(100vh - 8rem);
    flex-shrink: 0;
    align-self: stretch;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-large);
    padding: 1rem;
}

.board-section canvas {
    width: 100% !important;
    height: 100% !important;
    max-width: calc(100vh - 10rem);
    outline: none !important; /* Entfernt den Focus-Rand */
    max-height: calc(100vh - 10rem);
    border-radius: var(--radius-medium);
}

/* Game Header Controls */
.back-to-menu-btn {
    position: absolute;
    top: -3rem;
    left: 0;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-medium);
    padding: 0.75rem 1.5rem;
    color: var(--text-primary);
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    z-index: 10;
}

.back-to-menu-btn:hover {
    background: var(--bg-tertiary);
    border-color: var(--text-secondary);
}

.round-timer {
    position: absolute;
    top: -3.5rem;
    right: 0;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-medium);
    padding: 0.75rem 1.5rem;
    color: var(--text-primary);
    font-size: 0.9rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    z-index: 10;
}

.timer-icon {
    width: 16px;
    height: 16px;
    border: 2px solid var(--text-secondary);
    border-radius: 50%;
    position: relative;
}

.timer-icon::after {
    content: '';
    position: absolute;
    top: 1px;
    left: 50%;
    width: 1px;
    height: 6px;
    background: var(--text-secondary);
    transform: translateX(-50%);
}

/* Menu Footer */
.menu-footer {
    margin-top: auto;
    padding-top: 2rem;
}

.footer-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
    padding: 1rem 0;
    border-top: 1px solid var(--border-color);
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.footer-info,
.footer-links {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.separator {
    color: var(--border-color);
}

.game-version {
    font-weight: 600;
    color: var(--text-primary);
}

.footer-link {
    cursor: pointer;
    transition: color 0.2s ease;
}

.footer-link:hover {
    color: var(--text-primary);
}

@media (max-width: 768px) {
    .footer-content {
        flex-direction: column;
        text-align: center;
    }
}

/* Dice Section */
.dice-section {
    background: var(--bg-secondary);
    border-radius: var(--radius-large);
    padding: 1rem;
    border: 1px solid var(--border-color);
    flex-shrink: 0;
}

.dice-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
}

.dice {
    width: 60px;
    height: 60px;
    background: linear-gradient(145deg, #ffffff, #e0e0e0);
    border-radius: var(--radius-large);
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.5rem;
    font-weight: bold;
    color: #333;
    box-shadow: var(--shadow-medium);
    transition: transform var(--transition-medium);
}

.dice.rolling {
    animation: diceRoll 0.8s ease-in-out;
}

@keyframes diceRoll {
    0%, 100% { transform: rotate(0deg) scale(1); }
    25% { transform: rotate(90deg) scale(1.1); }
    50% { transform: rotate(180deg) scale(1.2); }
    75% { transform: rotate(270deg) scale(1.1); }
}

.dice-btn {
    padding: 0.75rem 1.5rem;
    background: var(--accent-primary);
    color: white;
    border: none;
    border-radius: var(--radius-medium);
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-medium);
    min-width: 120px;
}

.dice-btn:hover:not(:disabled) {
    background: var(--accent-secondary);
    transform: translateY(-2px);
}

.dice-btn:disabled,
.dice-btn.disabled {
    background: #555555;
    color: #888888;
    cursor: not-allowed;
    opacity: 0.5;
    transform: none;
}

/* Players Section */
.players-section {
    background: var(--bg-secondary);
    border-radius: var(--radius-large);
    padding: 1rem;
    border: 1px solid var(--border-color);
    flex-shrink: 0;
}

.players-section h3 {
    margin: 0 0 0.75rem 0;
    color: var(--text-primary);
    font-size: 1rem;
}

.players-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.player-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.75rem;
    background: var(--bg-tertiary);
    border-radius: var(--radius-medium);
    transition: all var(--transition-medium);
}

.player-item.active {
    background: var(--accent-primary);
    color: white;
    box-shadow: 0 2px 8px rgba(88, 166, 255, 0.3);
}

.player-color {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.3);
}

.player-color.player-0 { background: var(--player-red); }
.player-color.player-1 { background: var(--player-green); }
.player-color.player-2 { background: var(--player-blue); }
.player-color.player-3 { background: var(--player-yellow); }

.player-info {
    flex: 1;
}

.player-name {
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.player-stats {
    display: flex;
    gap: 0.75rem;
    font-size: 0.85rem;
    opacity: 0.8;
}

.stat {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

/* Messages Section */
.messages-section {
    background: var(--bg-secondary);
    border-radius: var(--radius-large);
    padding: 1rem;
    border: 1px solid var(--border-color);
    flex: 1;
    max-height: calc(100vh - 12rem);
    min-height: 200px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.messages-section h3 {
    margin: 0 0 0.75rem 0;
    color: var(--text-primary);
    font-size: 1rem;
    flex-shrink: 0;
}

.messages-container {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    min-height: 0;
    max-height: 100%;
    background: var(--bg-tertiary);
    border-radius: var(--radius-medium);
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    scrollbar-width: thin;
    scrollbar-color: var(--border-color) transparent;
}

.messages-container::-webkit-scrollbar {
    width: 6px;
}

.messages-container::-webkit-scrollbar-track {
    background: transparent;
}

.messages-container::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 3px;
}

.messages-container::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}

.game-message {
    padding: 0.5rem 0.75rem;
    background: var(--bg-primary);
    border-radius: var(--radius-small);
    font-size: 0.9rem;
    line-height: 1.4;
    position: relative;
}

.game-message::after {
    content: attr(data-time);
    position: absolute;
    right: 0.5rem;
    top: 0.25rem;
    font-size: 0.7rem;
    opacity: 0.5;
}

/* Game Board */
#game-board {
    border-radius: var(--radius-large);
    box-shadow: var(--shadow-heavy);
    cursor: pointer;
    background: var(--bg-secondary);
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

/* Responsive Design */
@media (max-width: 1400px) {
    .game-sidebar {
        width: 250px;
    }
}

@media (max-width: 1200px) {
    .game-content {
        grid-template-columns: 1fr;
        grid-template-rows: auto 1fr auto;
        gap: 1rem;
    }
    
    .game-sidebar-left {
        order: 3;
        flex-direction: row;
        overflow-x: auto;
    }
    
    .game-sidebar-right {
        order: 1;
        flex-direction: row;
        overflow-x: auto;
    }
    
    .board-section {
        order: 2;
    }
    
    .dice-section,
    .players-section {
        flex: 1;
        min-width: 0;
    }
    
    .messages-section {
        flex: 2;
        max-height: 200px;
    }
    
    .board-section {
        flex: 1;
        min-height: 400px;
    }
}

@media (max-width: 768px) {
    .game-container {
        height: 100vh;
        overflow: hidden;
    }
    
    .game-content {
        padding: 0.5rem;
        gap: 0.5rem;
    }
    
    .game-sidebar {
        flex-direction: column;
        max-height: 250px;
        gap: 0.5rem;
        gap: 1rem;
        padding: 0.5rem;
    }
    
    .dice-section,
    .players-section,
    .messages-section {
        padding: 0.75rem;
    }
    
    .dice {
        width: 50px;
        height: 50px;
        font-size: 1.2rem;
    }
    
    .dice-btn {
        padding: 0.5rem 1rem;
        font-size: 0.9rem;
        min-width: 100px;
    }
    
    .player-item {
        padding: 0.5rem;
    }
    
    .messages-container {
        max-height: 150px;
    }
}

@media (max-width: 480px) {
    .game-content {
        padding: 0.5rem;
        gap: 0.75rem;
    }
    
    .dice-section,
    .players-section,
    .messages-section {
        padding: 0.5rem;
    }
    
    .dice {
        width: 45px;
        height: 45px;
        font-size: 1.1rem;
    }
    
    .dice-btn {
        padding: 0.5rem 0.75rem;
        font-size: 0.8rem;
        min-width: 80px;
    }
    
    .messages-container {
        max-height: 120px;
    }
}
