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

:root {
    --bg-dark: #1a1a2e;
    --bg-card: #16213e;
    --bg-card-light: #1f2f4e;
    --accent: #e94560;
    --accent-hover: #ff6b6b;
    --text: #eaeaea;
    --text-dim: #a0a0a0;
    --success: #4cc9f0;
    --warning: #ffd60a;
    --border: #2d3748;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: var(--bg-dark);
    color: var(--text);
    min-height: 100vh;
    line-height: 1.6;
    overflow-x: hidden;
}

.container {
    max-width: 900px;
    margin: 0 auto;
    padding: 10px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

header {
    margin-bottom: 10px;
    padding: 12px 15px;
    background: var(--bg-card);
    border-radius: 12px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.3);
    flex-shrink: 0;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
}

.header-title {
    flex: 1;
    text-align: center;
}

.btn-sound {
    font-size: 1.2rem;
    background: var(--bg-card-light);
    border: 2px solid var(--border);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.btn-sound:hover {
    background: var(--accent);
    border-color: var(--accent);
    transform: scale(1.1);
}

header h1 {
    font-size: clamp(1.5rem, 4vw, 2.5rem);
    margin-bottom: 2px;
    color: var(--accent);
    line-height: 1.2;
}

header p {
    color: var(--text-dim);
    font-size: clamp(0.75rem, 2vw, 0.9rem);
}

.screen {
    display: none;
    flex: 1;
    flex-direction: column;
}

.screen.active {
    display: flex;
}

/* Game Screen - one screen layout */
#gameScreen {
    overflow: hidden;
    display: none;
}

#gameScreen.active {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 20px);
}

/* Form Elements */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
}

input[type="text"],
input[type="number"],
select {
    width: 100%;
    padding: 16px 20px;
    font-size: 1.2rem;
    background: var(--bg-card-light);
    border: 3px solid var(--border);
    border-radius: 12px;
    color: var(--text);
    transition: all 0.3s;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

input[type="text"]:focus,
input[type="number"]:focus,
select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 15px rgba(233, 69, 96, 0.4);
    transform: translateY(-2px);
}

input[type="text"]::placeholder,
input[type="number"]::placeholder {
    color: var(--text-dim);
    font-weight: 400;
}

/* Buttons */
.btn {
    padding: 12px 24px;
    font-size: 1rem;
    font-weight: 600;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

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

.btn-primary:hover {
    background: var(--accent-hover);
    transform: translateY(-2px);
}

.btn-secondary {
    background: var(--bg-card-light);
    color: var(--text);
    border: 2px solid var(--border);
}

.btn-secondary:hover {
    background: var(--bg-card);
    border-color: var(--accent);
}

.btn-small {
    padding: 8px 16px;
    font-size: 0.9rem;
}

.btn-back {
    margin-bottom: 10px;
}

/* Games List */
.games-list {
    margin: 20px 0;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.game-card {
    background: var(--bg-card);
    border: 2px solid var(--border);
    border-radius: 12px;
    padding: 20px;
    transition: all 0.3s;
}

.game-card:hover {
    border-color: var(--accent);
    transform: translateX(5px);
}

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

.game-mode {
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--accent);
}

.game-status {
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
}

.game-status.waiting {
    background: var(--success);
    color: var(--bg-dark);
}

.game-status.playing {
    background: var(--warning);
    color: var(--bg-dark);
}

.game-status.finished {
    background: var(--text-dim);
}

.game-players {
    color: var(--text-dim);
    font-size: 0.95rem;
}

.divider {
    height: 2px;
    background: var(--border);
    margin: 30px 0;
}

/* Scoreboard */
.scoreboard {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 10px;
    margin: 8px 0;
    flex-shrink: 0;
}

.player-card {
    background: var(--bg-card);
    border: 2px solid var(--border);
    border-radius: 12px;
    padding: 12px;
    text-align: center;
    transition: all 0.3s;
}

.player-card.active {
    border-color: var(--accent);
    box-shadow: 0 0 15px rgba(233, 69, 96, 0.3);
    transform: scale(1.02);
}

.player-card.winner {
    border-color: var(--success);
    box-shadow: 0 0 30px rgba(76, 201, 240, 0.5);
}

.player-name {
    font-size: clamp(0.9rem, 2.5vw, 1.1rem);
    margin-bottom: 8px;
    color: var(--text-dim);
}

.player-card.active .player-name {
    color: var(--accent);
}

.player-score {
    font-size: clamp(2rem, 6vw, 3rem);
    font-weight: bold;
    color: var(--text);
    line-height: 1;
}

.player-card.winner .player-score {
    color: var(--success);
}

/* Finish Suggestion */
.finish-suggestion {
    background: linear-gradient(135deg, var(--bg-card), var(--bg-card-light));
    border: 2px solid var(--success);
    border-radius: 10px;
    padding: 10px;
    margin: 8px 0;
    text-align: center;
    flex-shrink: 0;
}

.finish-suggestion h3 {
    color: var(--success);
    margin-bottom: 5px;
    font-size: clamp(0.9rem, 2.5vw, 1.1rem);
}

.finish-suggestion p {
    font-size: clamp(1rem, 3vw, 1.2rem);
    margin-bottom: 8px;
}

.finish-suggestion .finish-options {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 6px;
}

.finish-option {
    background: var(--bg-dark);
    padding: 6px 10px;
    border-radius: 6px;
    font-family: monospace;
    font-size: clamp(0.9rem, 2.5vw, 1.1rem);
    border: 1px solid var(--border);
}

/* Throw Input */
.throw-input {
    background: var(--bg-card);
    border-radius: 12px;
    padding: 15px;
    margin: 8px 0;
    position: relative;
    overflow-y: auto;
    overflow-x: hidden;
    flex: 1;
    min-height: 0;
}

.throw-input h3 {
    margin-bottom: 12px;
    color: var(--accent);
    text-align: center;
    font-size: clamp(1.1rem, 3vw, 1.3rem);
}

/* Current Throws Display */
.current-throws {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    margin-bottom: 15px;
    padding: 10px;
    background: var(--bg-card-light);
    border-radius: 8px;
    flex-wrap: wrap;
}

.throw-slot {
    font-size: clamp(1.3rem, 4vw, 1.8rem);
    font-weight: bold;
    min-width: 50px;
    text-align: center;
    padding: 8px 12px;
    background: var(--bg-dark);
    border: 2px solid var(--border);
    border-radius: 8px;
    color: var(--text);
}

.throw-slot.filled {
    border-color: var(--accent);
    color: var(--accent);
}

.throws-total {
    font-size: clamp(1.3rem, 4vw, 1.8rem);
    font-weight: bold;
    color: var(--success);
    padding: 8px 15px;
    background: var(--bg-dark);
    border: 2px solid var(--success);
    border-radius: 8px;
}

/* Multiplier Selection */
.multiplier-selection {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
    justify-content: center;
    flex-wrap: wrap;
}

.btn-mult {
    padding: 12px 18px;
    background: var(--bg-card-light);
    border: 3px solid var(--border);
    border-radius: 10px;
    color: var(--text);
    cursor: pointer;
    font-weight: bold;
    font-size: clamp(0.9rem, 2.5vw, 1.1rem);
    transition: all 0.2s;
    flex: 1;
    min-width: 100px;
}

.btn-mult:hover {
    background: var(--bg-dark);
    border-color: var(--accent);
}

.btn-mult.active {
    background: var(--accent);
    border-color: var(--accent);
    color: white;
    transform: scale(1.05);
}

/* Number Grid */
.number-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 6px;
    margin-bottom: 12px;
}

.btn-num {
    padding: 0;
    background: var(--bg-card-light);
    border: 3px solid var(--border);
    border-radius: 10px;
    color: var(--text);
    cursor: pointer;
    font-weight: bold;
    font-size: clamp(1.4rem, 5vw, 2.5rem);
    transition: all 0.2s;
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: clamp(50px, 12vw, 70px);
    max-height: 80px;
    line-height: 1;
    overflow: hidden;
}

.btn-num:hover {
    background: var(--accent);
    border-color: var(--accent);
    color: white;
    transform: scale(1.1);
}

.btn-num:active {
    transform: scale(0.95);
}

/* Bull Buttons */
.bull-buttons {
    display: flex;
    gap: 8px;
    margin-bottom: 15px;
    justify-content: center;
}

.btn-bull {
    padding: 15px 25px;
    background: linear-gradient(135deg, #2d5016, #1a3009);
    border: 3px solid #4a7c23;
    border-radius: 10px;
    color: #4caf50;
    cursor: pointer;
    font-weight: bold;
    font-size: clamp(1rem, 3vw, 1.3rem);
    transition: all 0.2s;
    flex: 1;
    max-width: 220px;
    min-height: 50px;
}

.btn-bull:hover {
    background: linear-gradient(135deg, #4a7c23, #2d5016);
    color: #81c784;
    transform: scale(1.05);
}

.btn-bull:active {
    transform: scale(0.95);
}

/* Miss Button */
.btn-miss {
    padding: 18px 40px;
    background: linear-gradient(135deg, #8b0000, #5c0000);
    border: 3px solid #ff4444;
    border-radius: 10px;
    color: #ffcccc;
    cursor: pointer;
    font-weight: bold;
    font-size: clamp(1.1rem, 3vw, 1.4rem);
    transition: all 0.2s;
    min-width: 200px;
    display: block;
    margin: 0 auto;
    box-shadow: 0 4px 8px rgba(0,0,0,0.3);
}

.btn-miss:hover {
    background: linear-gradient(135deg, #a00000, #700000);
    color: #ffffff;
    transform: scale(1.05);
    box-shadow: 0 6px 12px rgba(0,0,0,0.4);
}

.btn-miss:active {
    transform: scale(0.95);
}

@media (max-width: 600px) {
    .btn-miss {
        padding: 20px 30px;
        font-size: 1.3rem;
        min-width: 200px;
    }
}

/* Action Buttons */
.action-buttons {
    display: flex;
    gap: 8px;
    margin-bottom: 15px;
    flex-wrap: wrap;
}

.btn-large {
    padding: 12px 20px;
    font-size: clamp(0.95rem, 2.5vw, 1.1rem);
    flex: 1;
    min-width: 160px;
}

/* Manual Input */
.manual-input {
    display: flex;
    gap: 8px;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 2px solid var(--border);
    flex-wrap: wrap;
}

#throwScore {
    flex: 1;
    min-width: 150px;
    padding: 10px 14px;
    font-size: 1.1rem;
    text-align: center;
    background: var(--bg-card-light);
    border: 2px solid var(--border);
    border-radius: 8px;
    color: var(--text);
}

#submitThrowBtn {
    padding: 10px 18px;
    white-space: nowrap;
    font-size: 0.95rem;
}

/* Turn Info */
.turn-info {
    text-align: center;
    padding: 10px 15px;
    background: var(--bg-card-light);
    border-radius: 10px;
    margin: 8px 0;
    font-size: 1rem;
    border: 2px solid var(--border);
    flex-shrink: 0;
}

.turn-info.your-turn {
    background: linear-gradient(135deg, rgba(233, 69, 96, 0.2), var(--bg-card-light));
    border-color: var(--accent);
    animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% {
        box-shadow: 0 0 20px rgba(233, 69, 96, 0.3);
    }
    50% {
        box-shadow: 0 0 40px rgba(233, 69, 96, 0.6);
    }
}

.turn-info .turn-player {
    font-size: clamp(1.2rem, 3.5vw, 1.6rem);
    font-weight: bold;
    color: var(--text);
    display: block;
    margin-bottom: 8px;
}

.turn-info.your-turn .turn-player {
    color: var(--accent);
}

.turn-info .your-turn-badge {
    display: inline-block;
    background: var(--accent);
    color: white;
    padding: 8px 20px;
    border-radius: 25px;
    font-weight: bold;
    font-size: clamp(1rem, 2.5vw, 1.1rem);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 10px;
}

.turn-info .not-your-turn {
    display: inline-block;
    background: var(--text-dim);
    color: var(--bg-dark);
    padding: 6px 16px;
    border-radius: 18px;
    font-size: 0.9rem;
    margin-bottom: 8px;
}

.turn-info .darts {
    display: inline-block;
    font-size: clamp(1.3rem, 3.5vw, 1.6rem);
    margin-top: 8px;
}

/* Stats Display - Hidden by default to save space */
.stats-display {
    display: none;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 10px;
    margin-top: 10px;
    padding: 12px;
    background: var(--bg-card);
    border-radius: 10px;
    border: 2px solid var(--border);
}

.stats-display.show {
    display: grid;
}

.stat-item {
    text-align: center;
    padding: 12px 10px;
    background: var(--bg-card-light);
    border-radius: 8px;
    border: 2px solid transparent;
    transition: all 0.3s;
}

.stat-item:hover {
    border-color: var(--accent);
    transform: translateY(-2px);
}

.stat-label {
    font-size: 0.85rem;
    color: var(--text-dim);
    margin-bottom: 6px;
    font-weight: 600;
}

.stat-value {
    font-size: clamp(1.5rem, 4vw, 2rem);
    font-weight: bold;
    color: var(--success);
    line-height: 1;
}

/* Disabled state for input when not your turn */
.throw-input.disabled {
    opacity: 0.5;
    pointer-events: none;
    position: relative;
}

.throw-input.disabled::after {
    content: '🔒 Warte auf Gegner...';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0,0,0,0.9);
    color: var(--text);
    padding: 20px 30px;
    border-radius: 15px;
    font-weight: bold;
    font-size: 1.3rem;
    z-index: 10;
    white-space: nowrap;
    text-align: center;
    box-shadow: 0 4px 20px rgba(0,0,0,0.5);
}

/* History - Hidden by default to save space */
.history {
    display: none;
    background: var(--bg-card);
    border-radius: 10px;
    padding: 12px;
    margin-top: 10px;
    max-height: 200px;
    overflow-y: auto;
}

.history.show {
    display: block;
}

.history h3 {
    margin-bottom: 10px;
    color: var(--text-dim);
    font-size: 1rem;
}

.history-item {
    padding: 8px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    font-size: 0.9rem;
}

.history-item:last-child {
    border-bottom: none;
}

.history-item.bust {
    background: rgba(233, 69, 96, 0.1);
    color: var(--accent);
}

.history-player {
    font-weight: 600;
}

/* Game Info */
.game-info {
    text-align: center;
    margin-bottom: 10px;
    flex-shrink: 0;
}

.game-info h2 {
    color: var(--accent);
    font-size: clamp(1.3rem, 3.5vw, 1.8rem);
}

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

.modal.show {
    display: flex;
}

.modal-content {
    background: var(--bg-card);
    border-radius: 20px;
    padding: 40px;
    text-align: center;
    max-width: 400px;
    animation: modalPop 0.3s ease;
}

@keyframes modalPop {
    0% { transform: scale(0.5); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}

.modal-content h2 {
    color: var(--success);
    font-size: 2.5rem;
    margin-bottom: 20px;
}

.modal-content p {
    font-size: 1.3rem;
    margin-bottom: 30px;
}

.modal-content button {
    margin: 5px;
}

/* Responsive */
@media (max-width: 600px) {
    #gameScreen.active {
        height: calc(100vh - 10px);
    }

    header {
        padding: 10px 12px;
        margin-bottom: 8px;
    }

    header h1 {
        font-size: 1.5rem;
    }

    header p {
        font-size: 0.8rem;
    }

    .scoreboard {
        grid-template-columns: 1fr;
        gap: 8px;
        margin: 6px 0;
    }

    .player-card {
        padding: 10px;
    }

    .player-score {
        font-size: 2.5rem;
    }

    .player-score .preview {
        font-size: 0.8em;
    }

    .player-name {
        font-size: 1rem;
    }

    .throw-input {
        padding: 12px;
    }

    .quick-score,
    .single-triple-double {
        justify-content: center;
    }

    .btn-score {
        font-size: 0.85rem;
        padding: 6px 10px;
        min-width: 45px;
    }

    .quick-label {
        width: 100%;
        text-align: center;
        margin-bottom: 5px;
    }

    .modal-content {
        padding: 25px;
        margin: 20px;
        max-width: calc(100% - 40px);
    }

    .modal-content h2 {
        font-size: 1.8rem;
    }

    .modal-content p {
        font-size: 1rem;
    }

    .throw-input.disabled::after {
        font-size: 1rem;
        padding: 12px 18px;
        max-width: 90%;
    }

    .btn {
        width: 100%;
        margin-bottom: 8px;
    }

    .btn-small {
        width: auto;
        margin-bottom: 0;
    }

    #undoThrowBtn {
        margin-left: 0;
        margin-top: 8px;
        width: 100%;
    }
}

@media (max-width: 400px) {
    header h1 {
        font-size: 1.5rem;
    }

    .player-score {
        font-size: 2.5rem;
    }

    .game-mode {
        font-size: 1.2rem;
    }

    .finish-option {
        font-size: 0.9rem;
        padding: 8px 12px;
    }
}

/* Toast Notifications */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
}

.toast {
    background: var(--bg-card);
    border: 2px solid var(--border);
    border-radius: 10px;
    padding: 15px 20px;
    min-width: 300px;
    max-width: 400px;
    box-shadow: 0 8px 16px rgba(0,0,0,0.4);
    pointer-events: auto;
    display: flex;
    align-items: center;
    gap: 12px;
    animation: slideIn 0.3s ease, fadeOut 0.3s ease 2.7s forwards;
    backdrop-filter: blur(10px);
}

.toast.error {
    border-color: var(--accent);
    background: linear-gradient(135deg, rgba(233, 69, 96, 0.2), var(--bg-card));
}

.toast.success {
    border-color: var(--success);
    background: linear-gradient(135deg, rgba(76, 201, 240, 0.2), var(--bg-card));
}

.toast.info {
    border-color: var(--warning);
    background: linear-gradient(135deg, rgba(255, 214, 10, 0.2), var(--bg-card));
}

.toast-icon {
    font-size: 1.5rem;
    flex-shrink: 0;
}

.toast-message {
    flex: 1;
    color: var(--text);
    font-size: 0.95rem;
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes fadeOut {
    from {
        opacity: 1;
    }
    to {
        opacity: 0;
    }
}

@media (max-width: 600px) {
    .toast-container {
        right: 10px;
        left: 10px;
        top: 10px;
    }

    .toast {
        min-width: auto;
        width: 100%;
    }
}
