:root {
    --bg-color: #f8f9fa;
    --card-bg: #ffffff;
    --primary: #4cc9f0; /* Pastel Blue */
    --secondary: #ff758f; /* Pastel Red/Pink */
    --text-color: #1b263b;
    --accent: #fff3b0; /* Pastel Yellow */
    --glass: rgba(255, 255, 255, 0.7);
    --glass-border: rgba(0, 0, 0, 0.05);
    --shadow: 0 10px 40px rgba(0, 0, 0, 0.05);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: 'Outfit', sans-serif;
    background: radial-gradient(circle at top right, #e0f2fe 0%, #f8f9fa 100%);
    color: var(--text-color);
    overflow-x: hidden;
    height: 100vh;
    width: 100vw;
    display: flex;
    justify-content: center;
    align-items: center;
}

#app {
    width: 100%;
    height: 100%;
    max-width: 500px; /* Mobile first constraint */
    position: relative;
    display: flex;
    flex-direction: column;
}

#screen-container {
    flex: 1;
    padding: 20px;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

/* Glassmorphism utility */
.glass-panel {
    background: var(--glass);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    padding: 20px;
    box-shadow: var(--shadow);
}

/* Typography */
h1 { font-size: 2.5rem; font-weight: 800; text-align: center; margin-bottom: 20px; color: var(--primary); text-shadow: 0 0 10px rgba(255, 215, 0, 0.3); }
h2 { font-size: 1.5rem; font-weight: 600; margin-bottom: 15px; }

/* Buttons */
button {
    background: var(--primary);
    color: var(--text-color);
    border: none;
    padding: 15px 25px;
    border-radius: 12px;
    font-family: inherit;
    font-weight: 800;
    font-size: 1rem;
    cursor: pointer;
    transition: transform 0.2s, background 0.2s, box-shadow 0.2s;
    box-shadow: 0 4px 15px rgba(255, 215, 0, 0.2);
}

button:active { transform: scale(0.95); }
button:disabled { background: #555; cursor: not-allowed; box-shadow: none; }
button.secondary { background: var(--secondary); color: white; box-shadow: 0 4px 15px rgba(230, 57, 70, 0.2); }

/* Inputs */
input {
    background: var(--glass);
    border: 1px solid var(--glass-border);
    padding: 15px;
    border-radius: 12px;
    color: var(--text-color);
    font-family: inherit;
    font-size: 1.1rem;
    width: 100%;
    margin-bottom: 15px;
}

button.rood { background: #ffccd5 !important; color: #a4133c !important; }
button.zwart { background: #e9ecef !important; color: #212529 !important; }
button.hoger { background: #d8f3dc !important; color: #1b4332 !important; }
button.lager { background: #fde2e4 !important; color: #a4133c !important; }
button.binnen { background: #caf0f8 !important; color: #03045e !important; }
button.buiten { background: #faedcd !important; color: #bc6c25 !important; }
button.klaver { background: #f8f9fa !important; color: #212529 !important; border: 1px solid #dee2e6 !important; }
button.ruiten { background: #fde2e4 !important; color: #c9184a !important; border: 1px solid #ffb3c1 !important; }
button.harten { background: #ffccd5 !important; color: #800f2f !important; border: 1px solid #ffb3c1 !important; }
button.schoppen { background: #e0e1dd !important; color: #1b263b !important; border: 1px solid #778da9 !important; }
button.accent { background: #fff3b0 !important; color: #335c67 !important; }

/* Card Component */
.card-container {
    perspective: 1000px;
    width: 65px; /* Slightly smaller to fit 5 cards */
    height: 95px;
    position: relative;
    margin: 3px;
    flex-shrink: 0;
}

.card-inner {
    position: relative;
    width: 100%;
    height: 100%;
    text-align: center;
    transition: transform 0.6s;
    transform-style: preserve-3d;
}

.card-container.flipped .card-inner { transform: rotateY(180deg); }

.card-front, .card-back {
    position: absolute;
    width: 100%;
    height: 100%;
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
    border-radius: 10px;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: 0 4px 8px rgba(0,0,0,0.3);
}

.card-back {
    background: linear-gradient(135deg, #1e1e3f 0%, #0a0a1a 100%);
    border: 2px solid var(--primary);
    color: var(--primary);
    font-weight: 800;
    font-size: 1.5rem;
}

.card-front {
    background: white;
    color: black;
    transform: rotateY(180deg);
    flex-direction: column;
    padding: 5px;
}

.card-container.blocked {
    opacity: 0.6;
    filter: grayscale(0.8) brightness(0.8);
    pointer-events: none;
}

.card-container.blocked::after {
    content: '✖';
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    font-size: 2rem;
    color: var(--secondary);
    z-index: 10;
    opacity: 0.8;
}

.card-front.rood { color: var(--secondary); }
.card-front.zwart { color: #333; }

.card-value { font-size: 1.2rem; font-weight: 800; line-height: 1; }
.card-suit { font-size: 1.5rem; }

.pyramid-container {
    display: flex;
    flex-direction: column-reverse;
    align-items: center;
    gap: 15px;
    margin: 20px 0;
    width: 100%;
}

.pyramid-row {
    display: flex;
    gap: 10px;
    justify-content: center;
}

.pyramid-card-slot {
    width: 65px;
    height: 95px;
    border-radius: 10px;
    border: 2px dashed var(--glass-border);
    display: flex;
    justify-content: center;
    align-items: center;
}

/* Toasts */
#toast-container {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1000;
    width: 90%;
    max-width: 400px;
}

.toast {
    background: var(--glass);
    backdrop-filter: blur(15px);
    border: 1px solid var(--glass-border);
    padding: 15px 20px;
    border-radius: 15px;
    margin-bottom: 10px;
    animation: slideIn 0.3s ease-out;
    display: flex;
    align-items: center;
    gap: 10px;
    box-shadow: var(--shadow);
}

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

/* Timer */
#global-timer {
    position: fixed;
    top: 0; left: 0; right: 0;
    background: linear-gradient(to bottom, rgba(0,0,0,0.9) 0%, rgba(0,0,0,0) 100%);
    display: flex;
    flex-direction: row;
    justify-content: center;
    align-items: center;
    padding: 20px;
    z-index: 2000;
    gap: 15px;
}

.timer-circle {
    position: relative;
    width: 60px;
    height: 60px;
}

.timer-circle svg { width: 60px; height: 60px; transform: rotate(-90deg); }
.timer-circle circle {
    fill: none;
    stroke-width: 6;
    stroke: rgba(255,255,255,0.1);
}

#timer-progress {
    stroke: var(--primary);
    stroke-dasharray: 251; /* Might need adjustment for smaller circle */
    stroke-dashoffset: 0;
    transition: stroke-dashoffset 1s linear;
}

#timer-text {
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    font-size: 1.2rem;
    font-weight: 800;
}

#timer-msg {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--primary);
}

/* Helper Classes */
.hidden { display: none !important; }
.flex-center { display: flex; justify-content: center; align-items: center; }
.col { flex-direction: column; }
.full-width { width: 100%; }
.mt-20 { margin-top: 20px; }

/* Phase specific */
.player-cards {
    display: flex;
    justify-content: center;
    flex-wrap: nowrap;
    gap: 2px;
    margin-bottom: 20px;
    width: 100%;
    overflow-x: auto;
    padding-bottom: 5px;
}

.controls {
    display: flex;
    gap: 8px;
    justify-content: center;
    width: 100%;
}

.controls button {
    flex: 1;
    padding: 12px 5px; /* Smaller padding to fit more buttons */
    font-size: 0.85rem;
    min-width: 0; /* Allow shrinking */
    white-space: nowrap;
}

.player-cards.tiny .card-container {
    width: 40px;
    height: 60px;
    margin: 1px;
}

.player-cards.tiny .card-value { font-size: 0.7rem; }
.player-cards.tiny .card-suit { font-size: 0.9rem; }

/* Result Overlay */
.result-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    z-index: 3000;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    background: rgba(0,0,0,0.8);
    backdrop-filter: blur(5px);
    animation: fadeIn 0.3s ease-out;
    pointer-events: none;
}

.result-text {
    font-size: 4rem;
    font-weight: 800;
    text-shadow: 0 0 20px rgba(0,0,0,0.5);
    transform: scale(0.5);
    animation: popIn 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

.result-overlay.success .result-text { color: #4ade80; }
.result-overlay.error .result-text { color: var(--secondary); }

.result-subtext {
    font-size: 1.5rem;
    margin-top: 10px;
    opacity: 0;
    animation: fadeIn 0.3s 0.3s forwards;
}

@keyframes popIn {
    to { transform: scale(1); }
}

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

/* Screen Shake */
.shake {
    animation: shake 0.5s cubic-bezier(.36,.07,.19,.97) both;
}

@keyframes shake {
    10%, 90% { transform: translate3d(-1px, 0, 0); }
    20%, 80% { transform: translate3d(2px, 0, 0); }
    30%, 50%, 70% { transform: translate3d(-4px, 0, 0); }
    40%, 60% { transform: translate3d(4px, 0, 0); }
}

/* Confetti (Simple CSS version) */
.confetti {
    position: absolute;
    width: 10px; height: 10px;
    background: var(--primary);
    top: -10px;
    animation: fall 3s linear forwards;
}

@keyframes fall {
    to { transform: translateY(100vh) rotate(360deg); }
}
