:root {
    --bg-color: #0f172a;
    --text-color: #f8fafc;
    --primary-color: #3b82f6;
    --primary-hover: #2563eb;
    --secondary-color: #475569;
    --secondary-hover: #334155;
    --accent-color: #10b981;
    --die-bg: #ffffff;
    --die-dot: #1e293b;
    --die-held-bg: #fbbf24;
    --die-held-dot: #78350f;
    --table-border: #334155;
    --glass-bg: rgba(30, 41, 59, 0.7);
    --glass-border: rgba(255, 255, 255, 0.1);
}

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

body {
    font-family: 'Outfit', sans-serif;
    background: linear-gradient(135deg, #0f172a 0%, #1e1b4b 100%);
    color: var(--text-color);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 2rem;
}

header {
    text-align: center;
    margin-bottom: 2rem;
}

h1 {
    font-size: 3.5rem;
    font-weight: 800;
    background: linear-gradient(to right, #38bdf8, #818cf8);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    text-shadow: 0 4px 15px rgba(56, 189, 248, 0.2);
    margin-bottom: 0.5rem;
}

.instructions-link {
    color: #94a3b8;
    text-decoration: none;
    font-size: 1.1rem;
    border-bottom: 1px dashed #94a3b8;
    transition: color 0.3s ease;
}

.instructions-link:hover {
    color: var(--primary-color);
    border-color: var(--primary-color);
}

main {
    width: 100%;
    max-width: 900px;
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    padding: 2rem;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
}

.screen {
    display: none;
    animation: fadeIn 0.5s ease;
}

.screen.active {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Setup Screen */
#setupScreen {
    text-align: center;
}

#setupScreen h2 {
    margin-bottom: 1.5rem;
    font-size: 2rem;
}

.setup-options {
    margin-bottom: 2rem;
}

select {
    padding: 0.75rem 1rem;
    font-size: 1.1rem;
    border-radius: 10px;
    border: 1px solid var(--table-border);
    background: #1e293b;
    color: white;
    font-family: inherit;
    outline: none;
    cursor: pointer;
}

/* Buttons */
.btn {
    padding: 0.75rem 1.5rem;
    font-size: 1.1rem;
    font-weight: 600;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: inherit;
}

.btn.primary {
    background: var(--primary-color);
    color: white;
    box-shadow: 0 4px 15px rgba(59, 130, 246, 0.4);
}

.btn.primary:hover {
    background: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(59, 130, 246, 0.6);
}

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

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

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* Game Info */
.game-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--glass-border);
}

#currentPlayerDisplay {
    color: var(--accent-color);
}

/* Dice Area */
.dice-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 3rem;
}

.dice-container {
    display: flex;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.die {
    width: 60px;
    height: 60px;
    background: var(--die-bg);
    border-radius: 12px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--die-dot);
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    box-shadow: inset 0 -4px 0 rgba(0,0,0,0.2), 0 4px 8px rgba(0,0,0,0.3);
    user-select: none;
}

.die.held {
    border: 3px solid #10b981; /* Grüne Umrandung für ausgewählte Würfel */
    transform: translateY(-10px);
    box-shadow: 0 14px 15px rgba(0,0,0,0.3);
}

.die.rolling {
    animation: roll 0.4s infinite linear;
}

@keyframes roll {
    0% { transform: rotate(0deg) scale(1); }
    50% { transform: rotate(180deg) scale(0.8); }
    100% { transform: rotate(360deg) scale(1); }
}

/* We will dynamically create dots using JS for better visuals */
.die .dot {
    width: 12px;
    height: 12px;
    background: currentColor;
    border-radius: 50%;
    position: absolute;
}

.controls {
    display: flex;
    gap: 1rem;
}

/* Scorecard */
.scorecard-area {
    width: 100%;
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    border: 1px solid var(--table-border);
    border-radius: 12px;
    overflow: hidden;
}

th, td {
    padding: 0.75rem 1rem;
    text-align: center;
    border-bottom: 1px solid var(--table-border);
    border-right: 1px solid var(--table-border);
}

th:last-child, td:last-child {
    border-right: none;
}

tr:last-child td {
    border-bottom: none;
}

th {
    background: rgba(30, 41, 59, 0.8);
    font-weight: 600;
}

td {
    background: rgba(15, 23, 42, 0.4);
    transition: background 0.3s ease;
}

.category-name {
    text-align: left;
    font-weight: 600;
}

/* Interactive Score Cells */
.score-cell.active-turn {
    cursor: pointer;
    background: rgba(59, 130, 246, 0.1);
    position: relative;
}

.score-cell.active-turn:hover {
    background: rgba(59, 130, 246, 0.3);
}

.score-cell.possible-score {
    color: var(--accent-color);
    font-weight: bold;
}

.score-cell.filled {
    font-weight: bold;
    color: white;
}

.score-cell.struck {
    color: #ef4444;
    text-decoration: line-through;
}

/* Sections */
.sum-row td {
    background: rgba(30, 41, 59, 0.6);
    font-weight: 800;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 100;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(5px);
    overflow: auto;
}

.modal.show {
    display: flex;
    justify-content: center;
    align-items: center;
}

.modal-content {
    background: #1e293b;
    margin: auto;
    padding: 2.5rem;
    border: 1px solid var(--table-border);
    border-radius: 16px;
    width: 90%;
    max-width: 600px;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    position: relative;
    color: var(--text-color);
    line-height: 1.6;
}

.modal-content h2 {
    margin-bottom: 1.5rem;
    color: var(--primary-color);
}

.modal-content h3 {
    margin-top: 1.5rem;
    margin-bottom: 0.5rem;
    color: #94a3b8;
}

.modal-content ul {
    margin-left: 1.5rem;
    margin-bottom: 1rem;
}

.close-btn {
    position: absolute;
    top: 15px;
    right: 20px;
    color: #94a3b8;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    transition: color 0.3s;
}

.close-btn:hover {
    color: white;
}

.hidden {
    display: none !important;
}

#gameOverArea {
    text-align: center;
    margin-top: 2rem;
    padding: 2rem;
    background: rgba(16, 185, 129, 0.1);
    border: 1px solid var(--accent-color);
    border-radius: 12px;
}

#winnerText {
    color: var(--accent-color);
    margin-bottom: 1rem;
}
