/* Base Styles - Theme-unabhängig */
* { 
    box-sizing: border-box; 
    margin: 0; 
    padding: 0; 
}

html, body {
    width: 100%;
    height: 100%;
    overflow-x: hidden;
}

body { 
    font-family: system-ui, -apple-system, sans-serif; 
    padding: 15px;
    min-height: 100vh;
    color: #fff;
    transition: background 0.5s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    border-radius: 20px;
    padding: 30px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    transition: background 0.3s ease, color 0.3s ease;
}

h1 { 
    text-align: center; 
    margin-bottom: 15px;
    font-size: clamp(1.5rem, 4vw, 2.5rem);
    transition: color 0.3s ease;
}

/* Theme Toggle Button */
.theme-toggle {
    position: fixed;
    top: 15px;
    right: 15px;
    background: rgba(255,255,255,0.2);
    border: 2px solid rgba(255,255,255,0.3);
    border-radius: 50px;
    padding: 10px 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 1rem;
    color: white;
    backdrop-filter: blur(10px);
    transition: all 0.3s ease;
    z-index: 3000;
}

.theme-toggle:hover {
    background: rgba(255,255,255,0.3);
    transform: scale(1.05);
}

.theme-icon {
    font-size: 1.4rem;
}

/* Lobby Styles */
.lobby-screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 30px;
    padding: 20px 10px;
    max-width: 1000px;
    margin: 0 auto;
}

.lobby-title {
    font-size: clamp(1.8rem, 5vw, 3rem);
    text-align: center;
    margin-bottom: 10px;
    transition: color 0.3s ease;
}

.lobby-subtitle {
    font-size: clamp(0.9rem, 2.5vw, 1.2rem);
    text-align: center;
    margin-bottom: 20px;
    transition: color 0.3s ease;
}

.lobby-options {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    width: 100%;
    max-width: 900px;
}

.lobby-card {
    border-radius: 15px;
    padding: 35px 25px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.lobby-card:hover {
    transform: translateY(-5px);
}

.lobby-card h3 {
    font-size: clamp(1.2rem, 3vw, 1.6rem);
    margin-bottom: 15px;
    transition: color 0.3s ease;
}

.lobby-card p {
    line-height: 1.6;
    transition: color 0.3s ease;
    font-size: clamp(0.85rem, 2vw, 1rem);
}

.lobby-card-icon {
    font-size: clamp(2.5rem, 6vw, 3.5rem);
    margin-bottom: 15px;
}

/* Modal */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.7);
    z-index: 2000;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal-overlay.active {
    display: flex;
}

.modal {
    border-radius: 20px;
    padding: 35px 25px;
    max-width: 500px;
    width: 100%;
    box-shadow: 0 20px 60px rgba(0,0,0,0.5);
    transition: background 0.3s ease;
}

.modal h2 {
    margin-bottom: 25px;
    text-align: center;
    transition: color 0.3s ease;
    font-size: clamp(1.3rem, 3vw, 1.8rem);
}

.modal-input {
    width: 100%;
    padding: 15px;
    font-size: clamp(0.9rem, 2.5vw, 1.1rem);
    border-radius: 10px;
    margin-bottom: 15px;
    text-align: center;
    text-transform: uppercase;
    transition: all 0.3s ease;
    border: 2px solid transparent;
}

.modal-buttons {
    display: flex;
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
}

/* Player Count Selector */
.player-count-selector {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 15px;
    margin: 20px 0;
}

.player-count-btn {
    padding: 25px 20px;
    border: 3px solid #667eea;
    border-radius: 15px;
    background: white;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    font-size: clamp(0.9rem, 2.5vw, 1.1rem);
    font-weight: 600;
}

.player-count-btn:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 20px rgba(102, 126, 234, 0.3);
    border-color: #764ba2;
}

.player-count-icon {
    font-size: clamp(2rem, 5vw, 3rem);
}

.local-player-name {
    font-size: clamp(0.85rem, 2vw, 1rem) !important;
}

/* Buttons */
.btn {
    padding: 14px 28px;
    font-size: clamp(0.9rem, 2.5vw, 1.1rem);
    font-weight: 600;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-primary {
    background: #667eea;
    color: white;
}

.btn-primary:hover {
    background: #5568d3;
    transform: translateY(-2px);
}

.btn-secondary {
    background: #ddd;
    color: #333;
}

.btn-secondary:hover {
    background: #ccc;
}

/* Waiting Screen */
.waiting-screen {
    text-align: center;
    padding: 30px 15px;
    max-width: 600px;
    margin: 0 auto;
}

.waiting-screen h2 {
    margin-bottom: 25px;
    font-size: clamp(1.3rem, 3vw, 1.8rem);
    transition: color 0.3s ease;
}

.room-code {
    padding: 18px 30px;
    border-radius: 10px;
    font-size: clamp(1.3rem, 4vw, 2rem);
    font-weight: bold;
    margin: 25px 0;
    letter-spacing: 0.3em;
    transition: background 0.3s ease, color 0.3s ease;
    word-break: break-all;
}

.spinner {
    border: 4px solid #f3f3f3;
    border-top: 4px solid #667eea;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    animation: spin 1s linear infinite;
    margin: 25px auto;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.player-list {
    margin: 25px 0;
}

.player-item {
    padding: 14px 18px;
    border-radius: 10px;
    margin: 12px 0;
    display: flex;
    align-items: center;
    gap: 12px;
    transition: background 0.3s ease;
    font-size: clamp(0.85rem, 2.5vw, 1rem);
}

.player-item .ready-status {
    margin-left: auto;
    font-size: 1.3rem;
}

.player-color {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    border: 3px solid #333;
    flex-shrink: 0;
}

.ready-button {
    margin: 20px 0 10px 0;
    padding: 16px 40px;
    font-size: clamp(1rem, 2.5vw, 1.2rem);
}

.ready-button.ready-active {
    background: #3cb44b !important;
    animation: pulse 1.5s infinite;
}

.countdown-display {
    margin: 30px 0;
    text-align: center;
}

.countdown-display h3 {
    font-size: clamp(1.1rem, 2.5vw, 1.4rem);
    margin-bottom: 15px;
    transition: color 0.3s ease;
}

.countdown-number {
    font-size: clamp(3rem, 8vw, 4.5rem);
    font-weight: bold;
    transition: color 0.3s ease;
    text-shadow: 0 4px 8px rgba(0,0,0,0.2);
}

@keyframes countdownPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.15); }
}

.back-button {
    margin-top: 20px;
}

/* Game Screen */
.game-screen {
    display: none;
    max-width: 900px;
    margin: 0 auto;
}

.game-screen.active {
    display: block;
}

/* Timer */
.timer-display {
    text-align: center;
    margin: 15px 0;
    padding: 10px;
    border-radius: 8px;
    background: rgba(0,0,0,0.1);
}

.timer-label {
    font-size: clamp(0.85rem, 2vw, 1rem);
    margin-right: 10px;
}

.timer-value {
    font-size: clamp(1.5rem, 4vw, 2rem);
    font-weight: bold;
    transition: color 0.3s;
}

@keyframes timerPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

/* Mode Selector */
.game-options {
    margin: 20px 0;
}

.game-options h3 {
    font-size: clamp(0.9rem, 2.5vw, 1.1rem);
    margin-bottom: 10px;
    text-align: center;
}

.mode-selector {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    margin: 15px 0;
}

.mode-btn {
    padding: 15px;
    border: 2px solid #ddd;
    border-radius: 10px;
    background: white;
    cursor: pointer;
    transition: all 0.3s;
    font-size: clamp(0.85rem, 2vw, 1rem);
    font-weight: 600;
}

.mode-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}

.mode-btn.active {
    background: #667eea;
    color: white;
    border-color: #667eea;
}

/* Stats Modal */
.stats-modal {
    max-width: 600px;
}

.stats-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 15px;
    margin: 20px 0;
}

.stat-item {
    display: flex;
    justify-content: space-between;
    padding: 15px;
    background: rgba(0,0,0,0.05);
    border-radius: 8px;
}

.stat-label {
    font-weight: 600;
}

.stat-value {
    font-size: 1.2em;
    font-weight: bold;
    color: #667eea;
}

.player-stat {
    padding: 15px;
    background: rgba(0,0,0,0.05);
    border-radius: 8px;
    border-left: 4px solid #667eea;
}

.player-stat-name {
    font-weight: bold;
    font-size: 1.1em;
    margin-bottom: 8px;
}

.player-stat-details {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
    font-size: 0.9em;
}

.player-stat-details span {
    padding: 4px 8px;
    background: rgba(255,255,255,0.5);
    border-radius: 4px;
}

#status {
    text-align: center;
    font-size: clamp(0.95rem, 2.5vw, 1.15rem);
    margin-bottom: 20px;
    padding: 12px;
    border-radius: 8px;
    font-weight: 600;
    transition: background 0.3s ease;
}

#board {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: clamp(8px, 1.5vw, 15px);
    margin: 25px auto;
    max-width: min(90vw, 500px);
    aspect-ratio: 1;
}

.cell {
    width: 100%;
    aspect-ratio: 1;
    border-radius: 12px;
    cursor: pointer;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    overflow: hidden;
}

.cell.winning-cell {
    animation: winningCellGlow 1s ease-in-out infinite;
}

@keyframes winningCellGlow {
    0%, 100% {
        box-shadow: 0 0 10px rgba(255, 215, 0, 0.5);
        transform: scale(1);
    }
    50% {
        box-shadow: 0 0 25px rgba(255, 215, 0, 0.8);
        transform: scale(1.05);
    }
}

.cell:hover {
    transform: scale(1.05);
}

.cell.disabled {
    cursor: not-allowed;
}

.cell.disabled:hover {
    transform: none;
}

/* Rings */
.ring {
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    color: white;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.5);
    position: absolute;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
    transition: all 0.3s ease;
    animation: ringDrop 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes ringDrop {
    0% {
        transform: translateY(-150px) scale(0.3);
        opacity: 0;
    }
    60% {
        transform: translateY(10px) scale(1.05);
    }
    80% {
        transform: translateY(-5px) scale(0.95);
    }
    100% {
        transform: translateY(0) scale(1);
        opacity: 1;
    }
}

.ring.winning {
    animation: winningBlink 0.8s ease-in-out infinite;
}

@keyframes winningBlink {
    0%, 100% { 
        opacity: 1; 
        filter: brightness(1);
        box-shadow: 0 2px 8px rgba(0,0,0,0.3);
    }
    50% { 
        opacity: 0.5; 
        filter: brightness(2);
        box-shadow: 0 0 20px currentColor;
    }
}

.ring.size1 { 
    width: 38%;
    height: 38%;
    border-width: clamp(5px, 1vw, 8px);
    border-style: solid;
    background: transparent !important;
}

.ring.size2 { 
    width: 65%;
    height: 65%;
    border-width: clamp(6px, 1.2vw, 10px);
    border-style: solid;
    background: transparent !important;
}

.ring.size3 { 
    width: 90%;
    height: 90%;
    border-width: clamp(7px, 1.5vw, 12px);
    border-style: solid;
    background: transparent !important;
}

/* Controls */
.controls {
    text-align: center;
    margin: 25px 0;
}

.controls h3 {
    margin-bottom: 15px;
    transition: color 0.3s ease;
    font-size: clamp(0.95rem, 2.5vw, 1.15rem);
}

.ring-selector {
    display: flex;
    justify-content: center;
    gap: clamp(8px, 2vw, 15px);
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.ring-btn {
    padding: 12px 20px;
    font-size: clamp(0.8rem, 2vw, 0.95rem);
    font-weight: 600;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
    min-width: 95px;
}

.ring-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}

.ring-btn.disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.ring-btn.disabled:hover {
    transform: none;
}

.inventory-badge {
    position: absolute;
    top: -8px;
    right: -8px;
    background: #f58231;
    color: white;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: bold;
}

/* Players Info */
.players-info {
    display: flex;
    justify-content: center;
    gap: clamp(8px, 2vw, 12px);
    margin: 20px 0;
    flex-wrap: wrap;
}

.player-card {
    padding: 10px 18px;
    border-radius: 8px;
    font-weight: 600;
    border: 3px solid transparent;
    transition: all 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
    font-size: clamp(0.8rem, 2vw, 0.95rem);
    position: relative;
    overflow: hidden;
}

.player-card::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;
}

.player-card.active::before {
    left: 100%;
}

.player-card.active {
    animation: activePlayerPulse 1.5s ease-in-out infinite;
    transform: scale(1.1);
}

@keyframes activePlayerPulse {
    0%, 100% { 
        opacity: 1;
        box-shadow: 0 0 0 rgba(255,255,255,0.4);
    }
    50% { 
        opacity: 0.85;
        box-shadow: 0 0 15px rgba(255,255,255,0.6);
    }
}

/* Winner Banner */
.winner-banner {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: white;
    padding: 25px 35px;
    border-radius: 15px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.4);
    text-align: center;
    z-index: 1000;
    animation: slideDown 0.4s ease-out;
    max-width: 90%;
}

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

.winner-banner h2 {
    font-size: clamp(1.3rem, 3vw, 1.8rem);
    margin-bottom: 18px;
}

.winner-banner button {
    padding: 14px 32px;
    font-size: clamp(0.9rem, 2.5vw, 1.1rem);
    font-weight: 600;
    background: #3cb44b;
    color: white;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s;
}

.winner-banner button:hover {
    background: #2d8b38;
}

/* Mobile Optimierungen */
@media (max-width: 768px) {
    body {
        padding: 10px;
    }
    
    .container {
        padding: 20px 15px;
        border-radius: 15px;
    }
    
    .theme-toggle {
        top: 10px;
        right: 10px;
        padding: 8px 14px;
    }
    
    .lobby-options {
        grid-template-columns: 1fr;
        max-width: 400px;
    }
    
    .lobby-card {
        padding: 30px 20px;
    }
    
    .modal {
        padding: 30px 20px;
    }
}

/* iPhone SE und kleinere Geräte */
@media (max-width: 375px) {
    body {
        padding: 8px;
    }
    
    .container {
        padding: 18px 12px;
    }
    
    .ring-btn {
        min-width: 85px;
        padding: 10px 16px;
    }
}

/* Große Bildschirme (4K, etc.) */
@media (min-width: 1920px) {
    .container {
        max-width: 1400px;
    }
    
    #board {
        max-width: 600px;
    }
    
    .lobby-options {
        max-width: 1100px;
    }
}