:root {
    --bingo-red: #e74c3c;
    --bingo-blue: #3498db;
    --bingo-green: #2ecc71;
    --bingo-yellow: #f39c12;
    --bingo-purple: #9b59b6;
    --bg-dark: #2c3e50;
    --bg-light: #ecf0f1;
    --card-dark: #34495e;
    --card-light: #ffffff;
    --text-dark: #ecf0f1;
    --text-light: #2c3e50;
}

.theme-dark body {
    background: var(--bg-dark);
    color: var(--text-dark);
}

.theme-light body {
    background: var(--bg-light);
    color: var(--text-light);
}

* { 
    box-sizing: border-box; 
}

body {
    margin: 0;
    font-family: 'Comic Sans MS', 'Segoe UI', Tahoma, sans-serif;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

header {
    padding: 1rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 20;
    border-bottom: 4px solid var(--bingo-red);
    background: var(--card-dark);
}

.theme-light header {
    background: #ffffff;
    border-bottom-color: var(--bingo-blue);
}

header h1 {
    margin: 0;
    font-size: 2rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-weight: 900;
    color: var(--bingo-red);
    text-shadow: 2px 2px 0px rgba(0,0,0,0.2);
}

.theme-light header h1 {
    color: var(--bingo-blue);
}

header h1 span.logo-dot {
    width: 16px; 
    height: 16px; 
    border-radius: 50%;
    background: var(--bingo-yellow);
    display: inline-block;
    animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.2); }
}

.header-right {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.pill {
    padding: 0.4rem 0.9rem;
    border-radius: 20px;
    font-size: 0.85rem;
    border: 3px solid var(--bingo-yellow);
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font-weight: 700;
    background: var(--bingo-yellow);
    color: #2c3e50;
}

.pill-admin { 
    border-color: var(--bingo-purple);
    background: var(--bingo-purple);
    color: #ffffff; 
}

.btn {
    border: 3px solid #2c3e50; 
    border-radius: 12px; 
    padding: 0.6rem 1.2rem;
    font-size: 0.95rem; 
    cursor: pointer;
    display: inline-flex; 
    align-items: center; 
    gap: 0.5rem;
    font-weight: 700; 
    transition: all 0.15s;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.btn-primary {
    background: var(--bingo-green); 
    color: #ffffff;
    border-color: #27ae60;
}

.btn-primary:hover {
    background: #27ae60;
    transform: scale(1.05);
}

.btn-secondary { 
    background: var(--bingo-blue); 
    color: #ffffff;
    border-color: #2980b9;
}

.btn-secondary:hover {
    background: #2980b9;
    transform: scale(1.05);
}

.btn-ghost { 
    background: #7f8c8d; 
    color: #ffffff;
    border-color: #95a5a6;
}

.btn-ghost:hover {
    background: #95a5a6;
    transform: scale(1.05);
}

.btn-danger { 
    background: var(--bingo-red); 
    color: #ffffff;
    border-color: #c0392b;
}

.btn-danger:hover {
    background: #c0392b;
    transform: scale(1.05);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
}

.container {
    flex: 1;
    padding: 1rem 0.8rem 2rem;
    max-width: 1200px;
    margin: 0 auto; 
    width: 100%;
}

/* Container padding wenn Items-Bar vorhanden */
body:has(.items-bottom-bar) .container {
    padding-bottom: 200px;
}

@media (max-width: 768px) {
    body:has(.items-bottom-bar) .container {
        padding-bottom: 280px;
    }
}

.card {
    border-radius: 16px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    border: 4px solid #2c3e50;
    background: var(--card-dark);
    box-shadow: 6px 6px 0px rgba(0,0,0,0.3);
}

.theme-light .card {
    background: var(--card-light);
    border-color: var(--bingo-blue);
    box-shadow: 6px 6px 0px rgba(52,152,219,0.2);
}

.card-header {
    display: flex; 
    justify-content: space-between; 
    align-items: center;
    gap: 1rem; 
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 3px dotted rgba(255,255,255,0.3);
}

.theme-light .card-header {
    border-bottom-color: rgba(0,0,0,0.1);
}

.card-header h2 { 
    margin: 0; 
    font-size: 1.5rem;
    font-weight: 900;
    color: var(--bingo-yellow);
    text-transform: uppercase;
}

.theme-light .card-header h2 {
    color: var(--bingo-red);
}

.card-subtitle { 
    font-size:0.8rem; 
    opacity:0.8; 
}

.message {
    border-radius: 12px; 
    padding: 0.8rem 1rem; 
    margin-bottom: 1rem;
    font-size: 0.95rem;
    font-weight: 700;
    display: flex; 
    align-items: center; 
    gap: 0.75rem;
    border: 3px solid;
}

.message.error { 
    background: var(--bingo-red);
    border-color: #c0392b;
    color: #ffffff; 
}

.message.info { 
    background: var(--bingo-green);
    border-color: #27ae60;
    color: #ffffff; 
}

label { 
    font-size:0.8rem; 
    display:block; 
    margin-bottom:0.3rem; 
    opacity:0.9; 
}

input[type="text"], input[type="password"], select {
    width: 100%; 
    border-radius: 8px; 
    border: 3px solid #2c3e50;
    padding: 0.6rem 0.9rem; 
    font-size: 0.95rem;
    font-weight: 600;
    background: #ecf0f1; 
    color: #2c3e50;
    transition: all 0.2s;
}

input[type="text"]:focus, input[type="password"]:focus, select:focus {
    outline: none;
    border-color: var(--bingo-blue);
    transform: scale(1.02);
}

.theme-light input[type="text"], .theme-light input[type="password"], .theme-light select {
    background: #ffffff; 
    color: #2c3e50;
    border-color: var(--bingo-blue);
}

.color-picker {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
    margin-top: 0.5rem;
}

.color-option {
    cursor: pointer;
    position: relative;
}

.color-option input[type="radio"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.color-preview {
    display: block;
    width: 40px;
    height: 40px;
    border-radius: 0.5rem;
    border: 3px solid transparent;
    transition: all 0.2s;
}

.color-option input[type="radio"]:checked + .color-preview {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(99,102,241,0.3);
}

.color-option:hover .color-preview {
    transform: scale(1.1);
}

.small { 
    font-size:0.8rem; 
    opacity:0.8; 
}

.grid-2 { 
    display:grid; 
    gap:1rem; 
}

.grid-3 { 
    display:grid; 
    gap:1rem; 
}

@media (min-width:900px) {
    .grid-2 { 
        grid-template-columns: 2.2fr 1.4fr; 
    }
    .grid-3 { 
        grid-template-columns: 1.1fr 2fr 1.4fr; 
    }
}

.players-list {
    display:flex;
    flex-direction:column;
    gap:0.5rem;
}

.player-card {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    border-radius: 12px;
    border: 3px solid #2c3e50;
    background: var(--card-dark);
    box-shadow: 3px 3px 0px rgba(0,0,0,0.2);
}

.theme-light .player-card {
    background: #ffffff;
    border-color: var(--bingo-blue);
}

.player-avatar {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: var(--bingo-purple);
    overflow: hidden;
    flex-shrink: 0;
    border: 3px solid #2c3e50;
}

.player-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Bingo: rechteckige Felder */
.bingo-grid {
    display:grid;
    gap:0.5rem;
    width:100%;
    max-width:550px;
    margin:0.75rem auto 0;
}

@media (max-width: 768px) {
    .bingo-grid {
        gap:0.3rem;
        max-width:100%;
    }
}

.bingo-cell-button {
    border:none;
    padding:0;
    background:transparent;
    cursor:pointer;
}

.bingo-cell-button:disabled {
    cursor:default;
    opacity:0.7;
}

.bingo-cell {
    width: 100%;
    aspect-ratio: 1/1;
    border-radius: 12px;
    padding: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    font-family: 'Comic Sans MS', 'Segoe UI', Tahoma, sans-serif;
    font-size: clamp(0.7rem, 1.6vw, 0.9rem);
    font-weight: 700;
    line-height: 1.3;
    word-wrap: break-word;
    overflow-wrap: break-word;
    hyphens: auto;
    overflow: hidden;
    border: 4px solid #2c3e50;
    background: #ecf0f1;
    color: #2c3e50;
    transition: all 0.2s;
    box-sizing: border-box;
    box-shadow: 3px 3px 0px rgba(0,0,0,0.2);
}

/* Größenspezifische Anpassungen */
.bingo-grid[data-size="5"] .bingo-cell {
    font-size:clamp(0.55rem, 1.3vw, 0.7rem);
    padding:0.3rem;
}

.bingo-grid[data-size="4"] .bingo-cell {
    font-size:clamp(0.6rem, 1.4vw, 0.75rem);
    padding:0.35rem;
}

.bingo-grid[data-size="3"] .bingo-cell {
    font-size:clamp(0.65rem, 1.6vw, 0.85rem);
    padding:0.5rem;
}

/* Mobile Anpassungen */
@media (max-width: 768px) {
    .bingo-cell {
        font-size:clamp(0.5rem, 2vw, 0.65rem);
        padding:0.25rem;
    }
    
    .bingo-grid[data-size="5"] .bingo-cell {
        font-size:clamp(0.45rem, 1.8vw, 0.6rem);
        padding:0.2rem;
    }
    
    .bingo-grid[data-size="4"] .bingo-cell {
        font-size:clamp(0.5rem, 1.9vw, 0.65rem);
        padding:0.25rem;
    }
    
    .bingo-grid[data-size="3"] .bingo-cell {
        font-size:clamp(0.55rem, 2vw, 0.7rem);
        padding:0.3rem;
    }
}

.theme-light .bingo-cell {
    background: #ffffff;
    color: #2c3e50;
    border-color: var(--bingo-blue);
}

.bingo-cell:hover:not(.checked) {
    border-color: var(--bingo-yellow);
    transform: scale(1.05) rotate(-2deg);
}

.bingo-cell.checked {
    background: var(--bingo-red);
    border-color: #c0392b;
    color: #ffffff;
    text-decoration: line-through;
    text-decoration-thickness: 3px;
    transform: rotate(3deg);
}

.theme-light .bingo-cell.checked {
    background: var(--bingo-green);
    border-color: #27ae60;
    color: #ffffff;
}

.chat-container { 
    display: flex; 
    flex-direction: column; 
    height: 240px; 
}

.chat-messages {
    flex: 1; 
    overflow-y: auto; 
    border-radius: 12px;
    padding: 1rem;
    border: 4px solid #2c3e50;
    background: #ffffff;
    scroll-behavior: smooth;
}

.theme-light .chat-messages {
    background: #ffffff;
    border-color: var(--bingo-blue);
}

.theme-dark .chat-messages {
    background: #34495e;
    color: #ecf0f1;
}

.chat-message { 
    font-size: 0.9rem;
    font-weight: 700;
    margin-bottom: 0.6rem;
    padding: 0.4rem 0.5rem;
    background: rgba(52,152,219,0.1);
    border-radius: 8px;
    border-left: 4px solid var(--bingo-blue);
}

.theme-dark .chat-message {
    background: rgba(52,152,219,0.15);
    color: #ecf0f1;
}

.chat-message.system { 
    background: rgba(155,89,182,0.15);
    border-left-color: var(--bingo-purple);
    color: var(--bingo-purple);
    font-style: italic;
}

.theme-dark .chat-message.system {
    color: #bb8fce;
}

.chat-message strong {
    font-weight: 900;
}

.chat-message .small {
    opacity: 0.7;
    font-size: 0.75rem;
}

.chat-input-row { 
    display:flex; 
    gap:0.3rem; 
    margin-top:0.4rem; 
}

.chat-input-row input[type="text"] { 
    flex:1; 
}

.field-list {
    border-radius:0.7rem; 
    border:1px solid rgba(148,163,184,0.35);
    padding:0.4rem; 
    max-height:200px; 
    overflow-y:auto;
    background:rgba(15,23,42,0.5);
}

.theme-light .field-list { 
    background:rgba(243,244,246,0.9); 
}

.field-row { 
    display:flex; 
    gap:0.3rem; 
    margin-bottom:0.3rem; 
}

.field-row input[type="text"] { 
    flex:1; 
    padding:0.3rem 0.5rem; 
}

.badge {
    border-radius: 16px; 
    padding: 0.3rem 0.8rem;
    border: 3px solid #2c3e50;
    font-size: 0.8rem;
    font-weight: 700;
    background: #95a5a6;
    color: #ffffff;
}

.badge-live { 
    border-color: var(--bingo-green);
    background: var(--bingo-green);
    color: #ffffff;
}

.badge-ended { 
    border-color: var(--bingo-red);
    background: var(--bingo-red);
    color: #ffffff;
}

/* Admin Navigation */
.admin-nav {
    position: fixed;
    left: 0;
    top: 60px;
    bottom: 0;
    width: 70px;
    background: var(--card-dark);
    border-right: 1px solid var(--border-dark);
    display: flex;
    flex-direction: column;
    padding: 1rem 0;
    gap: 0.5rem;
    z-index: 15;
}

.theme-light .admin-nav {
    background: var(--card-light);
    border-right-color: var(--border-light);
}

.admin-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 0.75rem;
    text-decoration: none;
    color: #94a3b8;
    font-size: 1.5rem;
    transition: all 0.2s;
    position: relative;
    border-left: 3px solid transparent;
}

.admin-nav-item:hover {
    color: var(--accent);
    background: rgba(99,102,241,0.1);
}

.admin-nav-item.active {
    color: var(--accent);
    border-left-color: var(--accent);
    background: rgba(99,102,241,0.15);
}

.admin-nav-label {
    font-size: 0.625rem;
    margin-top: 0.25rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.admin-content {
    margin-left: 70px;
}

.admin-page {
    display: none;
}

.admin-page.active {
    display: block;
}

.admin-tile-grid {
    display:grid;
    gap:0.75rem;
}

@media (min-width:700px) {
    .admin-tile-grid { 
        grid-template-columns: repeat(2, minmax(0, 1fr)); 
    }
}

.admin-tile {
    border-radius: 12px;
    padding: 1.25rem;
    border: 4px solid #2c3e50;
    background: var(--card-dark);
    box-shadow: 4px 4px 0px rgba(0,0,0,0.2);
}

.theme-light .admin-tile {
    background: #ffffff;
    border-color: var(--bingo-blue);
}

.overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.9);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    z-index: 1000; /* Über Items-Bar (z-index 100) */
}

.overlay-content {
    position: relative;
    max-width: 600px;
    width: 100%;
    border-radius: 1rem;
    padding: 2rem 1.5rem;
    text-align: center;
    background: var(--card-dark);
    color: var(--text-dark);
    border: 1px solid var(--border-dark);
}

.theme-light .overlay-content {
    background: var(--card-light);
    color: var(--text-light);
}

.overlay-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: rgba(255,255,255,0.1);
    border: none;
    color: inherit;
    font-size: 1.5rem;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.overlay-close:hover {
    background: rgba(255,255,255,0.2);
    transform: scale(1.1);
}

/* Mobile Modal-Optimierung */
@media (max-width: 768px) {
    .overlay {
        padding: 0;
        align-items: flex-end; /* Modal von unten */
        -webkit-overflow-scrolling: touch;
    }
    
    .overlay-content {
        max-width: 100%;
        width: 100%;
        border-radius: 1.5rem 1.5rem 0 0;
        max-height: 80vh;
        overflow-y: auto;
        padding: 1.5rem 1rem 2rem;
        -webkit-overflow-scrolling: touch;
    }
    
    .overlay-content h2 {
        font-size: 1.5rem;
        margin-top: 0.5rem;
    }
    
    .overlay-close {
        width: 44px;
        height: 44px;
        font-size: 2rem;
        top: 0.5rem;
        right: 0.5rem;
        background: rgba(231,76,60,0.9);
        color: #ffffff;
    }
    
    .overlay-close:hover {
        background: rgba(192,57,43,1);
    }
    
    /* Größere Touch-Targets für alle Buttons in Modals */
    .overlay-content .btn {
        min-height: 52px;
        padding: 0.85rem 1.5rem;
        font-size: 1.05rem;
    }
    
    .overlay-content select,
    .overlay-content input[type="text"] {
        min-height: 52px;
        font-size: 1.05rem;
        padding: 0.75rem 1rem;
    }
    
    .overlay-content label {
        font-size: 1rem;
        font-weight: 700;
        margin-bottom: 0.5rem;
    }
}

@media (max-width: 768px) {
    .admin-nav {
        top: auto;
        bottom: 0;
        left: 0;
        right: 0;
        width: 100%;
        height: 60px;
        flex-direction: row;
        padding: 0;
        border-right: none;
        border-top: 1px solid var(--border-dark);
    }
    .theme-light .admin-nav {
        border-top-color: var(--border-light);
    }
    .admin-nav-item {
        flex: 1;
        border-left: none;
        border-top: 3px solid transparent;
    }
    .admin-nav-item.active {
        border-left-color: transparent;
        border-top-color: var(--accent);
    }
    .admin-content {
        margin-left: 0;
        padding-bottom: 80px;
    }
}

/* ===== ITEMS SYSTEM - FIXIERTE BOTTOM BAR ===== */
.items-bottom-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--bingo-yellow);
    border-top: 5px solid #2c3e50;
    padding: 1rem;
    z-index: 100;
    box-shadow: 0 -4px 20px rgba(0,0,0,0.3);
}

.theme-light .items-bottom-bar {
    background: var(--bingo-yellow);
    border-top-color: var(--bingo-blue);
}

.items-bar-header {
    font-size: 1.2rem;
    font-weight: 900;
    margin-bottom: 0.75rem;
    text-align: center;
    color: #2c3e50;
    text-transform: uppercase;
}

.items-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 1rem;
    max-width: 1200px;
    margin: 0 auto;
}

.item-card {
    background: #ffffff;
    border: 4px solid #2c3e50;
    border-radius: 12px;
    padding: 1rem;
    text-align: center;
    transition: all 0.2s;
    box-shadow: 3px 3px 0px rgba(0,0,0,0.3);
    position: relative;
}

.item-card:hover {
    transform: scale(1.05) rotate(-2deg);
    border-color: var(--bingo-red);
}

.item-count-badge {
    position: absolute;
    top: -8px;
    right: -8px;
    background: var(--bingo-red);
    color: #ffffff;
    font-size: 0.85rem;
    font-weight: 900;
    padding: 0.25rem 0.6rem;
    border-radius: 20px;
    border: 3px solid #2c3e50;
    box-shadow: 2px 2px 0px rgba(0,0,0,0.3);
    z-index: 10;
}

.item-icon {
    font-size: 3rem;
    margin-bottom: 0.5rem;
    animation: itemFloat 2s ease-in-out infinite;
}

@keyframes itemFloat {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-8px); }
}

.item-name {
    font-size: 0.95rem;
    font-weight: 900;
    margin-bottom: 0.75rem;
    color: #2c3e50;
    text-transform: uppercase;
}

.btn-sm {
    padding: 0.5rem 1rem;
    font-size: 0.85rem;
    width: 100%;
}

/* Mobile Optimierung für Items */
@media (max-width: 768px) {
    .items-bottom-bar {
        padding: 1rem 0.75rem;
        max-height: 50vh;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch; /* Smooth scrolling iOS */
    }
    
    .items-bar-header {
        font-size: 1.1rem;
        margin-bottom: 0.75rem;
    }
    
    .items-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.75rem;
    }
    
    .item-card {
        padding: 1rem 0.75rem;
        min-height: 140px; /* Mehr Platz für Touch */
    }
    
    .item-icon {
        font-size: 2.5rem;
        margin-bottom: 0.5rem;
    }
    
    .item-name {
        font-size: 0.85rem;
        margin-bottom: 0.75rem;
    }
    
    .btn-sm {
        padding: 0.7rem 1rem;
        font-size: 0.85rem;
        min-height: 44px; /* Apple's empfohlene Touch-Target-Größe */
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    /* Mehr Padding für Container damit nichts hinter Items verschwindet */
    body:has(.items-bottom-bar) .container {
        padding-bottom: 320px;
    }
}

@media (max-width:900px) {
    header { 
        flex-direction:column; 
        align-items:flex-start; 
        gap:0.4rem; 
    }
    .header-right { 
        width:100%; 
        justify-content:space-between; 
    }
    .grid-2, .grid-3 { 
        grid-template-columns:1fr; 
    }
}
