/* Kindgerechtes Design */
*, *::before, *::after {
    box-sizing: border-box;
}

:root {
    --content-max-width: 1200px;
}

body {
    font-family: 'Comic Neue', cursive, sans-serif;
    background-color: #f0f9ff;
    color: #333;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px;
    margin: 0;
    min-height: 100vh;
    overflow-x: hidden;
}

h1 {
    color: #ff6b6b;
    text-shadow: 2px 2px #ffeb3b;
    text-align: center;
    line-height: 1.2;
    margin: 0 0 0.5rem;
}

.page-intro {
    text-align: center;
    font-size: 1.1rem;
    color: #555;
    max-width: 520px;
    margin: 0 0 1.25rem;
    line-height: 1.5;
}

.game-container {
    background: white;
    padding: 30px;
    border-radius: 30px;
    box-shadow: 0 10px 0 #bae6fd;
    width: fit-content;
    max-width: min(100%, var(--content-max-width));
    text-align: center;
    margin-bottom: 40px;
    overflow-wrap: break-word;
}

.sentence {
    line-height: 3;
    font-size: 1.5rem;
}

.connector {
    white-space: nowrap;
}

.word-box {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: #fef08a;
    padding: 8px 15px;
    border-radius: 15px;
    border: 3px dashed #facc15;
    margin: 0 5px;
    min-width: 100px;
    cursor: pointer;
    user-select: none;
    transition: transform 0.1s, box-shadow 0.1s;
    box-shadow: 0 4px 0 #facc15;
    vertical-align: middle;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

.word-box:hover {
    background: #fde047;
}

.word-box:active {
    transform: translateY(4px);
    box-shadow: none;
}

.word {
    font-weight: bold;
    color: #e67e22;
    word-break: break-word;
    overflow-wrap: anywhere;
    text-align: center;
    max-width: 100%;
}

.dice-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #ff8787;
    border-radius: 50%;
    width: 45px;
    height: 45px;
    font-size: 1.3rem;
    box-shadow: 0 4px 0 #fa5252;
    margin-bottom: 4px;
    pointer-events: none;
    flex-shrink: 0;
}

/* Admin & Tabelle */
.admin-area {
    background: white;
    padding: 20px;
    border-radius: 20px;
    width: 100%;
    max-width: var(--content-max-width);
    box-shadow: 0 5px 15px rgba(0,0,0,0.05);
}

.input-group {
    margin-bottom: 20px;
    text-align: center;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
    align-items: center;
}

.input-group h3 {
    width: 100%;
    margin: 0 0 0.25rem;
}

.section-hint {
    width: 100%;
    margin: 0 0 0.5rem;
    font-size: 0.95rem;
    color: #666;
    line-height: 1.45;
}

input, select {
    padding: 10px;
    border-radius: 10px;
    border: 2px solid #4ecdc4;
    font-family: inherit;
    font-size: 1rem;
    min-height: 44px;
}

#wordInput {
    flex: 1 1 180px;
    max-width: 100%;
}

.add-btn {
    background: #4ecdc4;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 10px;
    cursor: pointer;
    font-weight: bold;
    font-family: inherit;
    font-size: 1rem;
    min-height: 44px;
    touch-action: manipulation;
}

.table-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 0 -4px;
    padding: 0 4px;
}

table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 20px;
    background: #fff;
    min-width: 520px;
}

th {
    background: #4ecdc4;
    color: white;
    padding: 10px;
    font-size: 0.95rem;
}

td {
    border: 1px solid #eee;
    padding: 8px;
    text-align: center;
    font-size: 0.95rem;
}

.delete-btn {
    background: #ff6b6b;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    padding: 4px 10px;
    min-width: 32px;
    min-height: 32px;
    font-family: inherit;
    touch-action: manipulation;
}

/* Desktop: Satz möglichst in einer Zeile, bricht bei Bedarf um */
@media (min-width: 601px) {
    .sentence {
        display: flex;
        flex-wrap: wrap;
        justify-content: center;
        align-items: center;
        gap: 0.15rem 0.25rem;
        line-height: 2;
    }

    .word-box {
        flex-direction: row;
        gap: 8px;
        min-width: auto;
        max-width: 100%;
        padding: 6px 14px;
    }

    .dice-icon {
        width: 38px;
        height: 38px;
        font-size: 1.1rem;
        margin-bottom: 0;
    }
}

/* Tablet */
@media (max-width: 768px) {
    body {
        padding: 16px;
    }

    h1 {
        font-size: 1.6rem;
    }

    .game-container {
        padding: 20px 16px;
        border-radius: 24px;
    }

    .sentence {
        font-size: 1.25rem;
        line-height: 2.5;
    }

    .admin-area {
        padding: 16px;
    }
}

/* Smartphone */
@media (max-width: 600px) {
    body {
        padding: 12px;
    }

    h1 {
        font-size: 1.35rem;
    }

    .game-container {
        padding: 16px 12px;
        margin-bottom: 24px;
        box-shadow: 0 6px 0 #bae6fd;
    }

    .sentence {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 0.35rem;
        line-height: 1.4;
        font-size: 1.15rem;
    }

    .connector {
        color: #555;
        font-size: 1rem;
        padding: 0.1rem 0;
    }

    .connector-end {
        font-size: 1.5rem;
        line-height: 1;
    }

    .word-box {
        width: min(100%, 220px);
        min-width: 0;
        margin: 0;
        padding: 10px 16px;
    }

    .dice-icon {
        width: 50px;
        height: 50px;
        font-size: 1.4rem;
    }

    .word {
        font-size: 1.1rem;
    }

    .input-group {
        flex-direction: column;
        align-items: stretch;
    }

    #catSelect,
    #wordInput,
    .add-btn {
        width: 100%;
    }

    th, td {
        padding: 10px 8px;
        font-size: 0.85rem;
    }

    .delete-btn {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        min-width: 36px;
        min-height: 36px;
        margin-left: 4px;
    }
}

/* Footer & Rechtliches */
.site-footer {
    width: 100%;
    max-width: var(--content-max-width);
    margin-top: auto;
    padding: 28px 12px 8px;
    text-align: center;
    font-size: 0.8rem;
    color: #9ca3af;
}

.site-footer a {
    color: #9ca3af;
    text-decoration: none;
}

.site-footer a:hover {
    color: #6b7280;
    text-decoration: underline;
}

.site-footer span {
    margin: 0 0.4rem;
}

.legal-page {
    width: 100%;
    max-width: 720px;
    background: white;
    padding: 28px 32px;
    border-radius: 20px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.05);
    margin-bottom: 24px;
    font-size: 1rem;
    line-height: 1.6;
}

.legal-page h1 {
    color: #333;
    text-shadow: none;
    font-size: 1.75rem;
    margin: 0 0 1.5rem;
    text-align: left;
}

.legal-page h2 {
    font-size: 1.15rem;
    margin: 1.5rem 0 0.5rem;
    color: #444;
}

.legal-page h3 {
    font-size: 1rem;
    margin: 1rem 0 0.4rem;
    color: #555;
}

.legal-page p {
    margin: 0 0 0.75rem;
}

.legal-page a {
    color: #4ecdc4;
}

.legal-page section + section {
    margin-top: 0.5rem;
}

.back-link {
    margin: 0 0 1.25rem;
    font-size: 0.9rem;
}

.back-link a {
    color: #888;
    text-decoration: none;
}

.back-link a:hover {
    color: #4ecdc4;
    text-decoration: underline;
}

@media (max-width: 600px) {
    .legal-page {
        padding: 20px 16px;
        border-radius: 16px;
    }

    .legal-page h1 {
        font-size: 1.4rem;
    }
}
