:root {
    --primary: #6366f1;
    --primary-hover: #4f46e5;
    --secondary: #334155;
    --success: #22c55e;
    --warning: #f59e0b;
    --danger: #ef4444;
    --bg-dark: #0f172a;
    --bg-card: rgba(30, 41, 59, 0.7);
    --text: #f8fafc;
    --text-muted: #94a3b8;
    --text-dim: rgba(248, 250, 252, 0.4);
    --glass-border: rgba(255, 255, 255, 0.1);
    --card-yellow: #facc15;
    --card-blue: #3b82f6;
    --card-text-dark: #1e293b;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Outfit', sans-serif;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    /* Prevent text selection for native feel */
}

body {
    background: var(--bg-dark);
    color: var(--text);
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
}

#app {
    width: 100%;
    max-width: 500px;
    height: 100vh;
    height: 100dvh;
    padding: 20px;
    display: flex;
    flex-direction: column;
    position: relative;
}

.screen {
    display: none;
    flex-direction: column;
    height: 100%;
    animation: fadeIn 0.3s ease-out;
}

.screen.active {
    display: flex;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: scale(0.95);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

.glass-card {
    background: var(--bg-card);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border);
    border-radius: 32px;
    padding: 30px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
    text-align: center;
    margin: auto 0;
    width: 100%;
}

/* Physical Card Aesthetic */
.physical-card {
    background: white;
    border-radius: 24px;
    overflow: hidden;
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.6);
    transition: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    transform-style: preserve-3d;
    margin: 20px 0;
    background-size: cover;
    background-position: center;
    border: 4px solid rgba(255, 255, 255, 0.2);
}

.card-header {
    padding: 15px;
    text-align: center;
    font-weight: 900;
    font-size: 1.3rem;
    text-transform: uppercase;
    letter-spacing: 3px;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.physical-card.yellow {
    background-image: url('assets/card_yellow_bg.png');
}

.physical-card.yellow .card-header {
    background: rgba(0, 0, 0, 0.1);
    color: var(--card-text-dark);
}

.physical-card.blue {
    background-image: url('assets/card_blue_bg.png');
}

.physical-card.blue .card-header {
    background: rgba(0, 0, 0, 0.2);
    color: white;
}

.word-list-container {
    padding: 20px 10px;
    background: transparent;
    /* Show the card background */
}

.word-item {
    font-size: 1.8rem;
    font-weight: 700;
    color: rgba(0, 0, 0, 0.2);
    /* Faded for pending */
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    text-align: center;
    padding: 10px 0;
    text-shadow: 0 1px 2px rgba(255, 255, 255, 0.5);
}

.physical-card.blue .word-item {
    color: rgba(255, 255, 255, 0.3);
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

.word-item.active {
    font-size: 2.6rem;
    font-weight: 800;
    color: var(--card-text-dark);
    transform: scale(1.05);
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.physical-card.blue .word-item.active {
    color: white;
    text-shadow: 0 2px 15px rgba(0, 0, 0, 0.3);
}

.word-item.correct {
    color: var(--success);
    font-size: 1.6rem;
    opacity: 1;
    text-shadow: 0 0 10px rgba(34, 197, 94, 0.4);
}

.word-item.skipped {
    color: #64748b;
    text-decoration: line-through;
    font-size: 1.6rem;
    opacity: 0.6;
}

.title {
    font-size: 3.5rem;
    font-weight: 800;
    margin-bottom: 5px;
    letter-spacing: -1px;
    background: linear-gradient(to right, #818cf8, #c084fc);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.subtitle {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 30px;
    text-transform: uppercase;
    letter-spacing: 2px;
}

.bible-verse-container {
    font-style: italic;
    color: var(--text-muted);
    font-size: 0.95rem;
    margin-bottom: 30px;
    padding: 15px;
    border-left: 4px solid var(--primary);
    background: rgba(255, 255, 255, 0.05);
    border-radius: 0 16px 16px 0;
    text-align: left;
    line-height: 1.4;
}

.button-group {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.secondary-btns {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.btn {
    padding: 18px 24px;
    border-radius: 20px;
    border: none;
    font-size: 1.1rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    text-transform: uppercase;
}

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

.btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.primary {
    background: var(--primary);
    color: white;
    box-shadow: 0 8px 20px rgba(99, 102, 241, 0.3);
}

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

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

.warning {
    background: var(--secondary);
    color: var(--text-muted);
}

.large-text {
    font-size: 1.4rem;
    letter-spacing: 1px;
}

.btn-sm {
    padding: 8px 15px;
    font-size: 0.85rem;
    border-radius: 12px;
    width: auto;
}

/* Category Grid */
.category-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin: 15px 0;
    max-height: 60vh;
    overflow-y: auto;
    padding: 5px;
}

.category-grid::-webkit-scrollbar {
    width: 4px;
}

.category-grid::-webkit-scrollbar-thumb {
    background: var(--glass-border);
    border-radius: 10px;
}

.cat-card {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    padding: 12px 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.cat-card.selected {
    background: var(--primary);
    border-color: #818cf8;
    transform: translateY(-3px);
    box-shadow: 0 8px 15px rgba(99, 102, 241, 0.3);
}

.cat-card.special {
    grid-column: span 3;
    background: linear-gradient(45deg, #6366f1, #a855f7);
    flex-direction: row;
    justify-content: center;
    gap: 15px;
    padding: 10px;
}

.cat-icon {
    font-size: 1.5rem;
}

.cat-name {
    font-weight: 700;
    font-size: 0.75rem;
    white-space: nowrap;
}

/* Gameplay */
.game-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding: 10px;
}

.team-badge {
    background: var(--primary);
    padding: 12px 24px;
    border-radius: 100px;
    font-weight: 800;
    font-size: 1.1rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.timer {
    font-size: 4.5rem;
    font-weight: 800;
    color: var(--success);
    font-variant-numeric: tabular-nums;
    text-shadow: 0 0 20px rgba(34, 197, 94, 0.3);
}

.gameplay-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    margin-bottom: 30px;
}

.word-list {
    display: flex;
    flex-direction: column;
    gap: 15px;
    padding: 0 10px;
}

.word-item {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-dim);
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    text-align: center;
}

.word-item.active {
    font-size: 3rem;
    font-weight: 800;
    color: var(--text);
    transform: scale(1.1);
    text-shadow: 0 0 15px rgba(255, 255, 255, 0.2);
}

.word-item.correct {
    color: var(--success);
    font-size: 1.8rem;
    opacity: 0.8;
}

.word-item.skipped {
    color: var(--text-dim);
    text-decoration: line-through;
    font-size: 1.8rem;
    opacity: 0.5;
}

.game-controls {
    display: flex;
    flex-direction: column;
    gap: 15px;
    padding-bottom: 20px;
}

.btn-action {
    height: 90px;
    font-size: 2rem;
    background: var(--success);
    box-shadow: 0 10px 25px rgba(34, 197, 94, 0.3);
}

.btn-action-small {
    height: 60px;
    font-size: 1.2rem;
    background: var(--secondary);
}

/* Dice */
.dice-container {
    margin: 40px 0;
    perspective: 1000px;
}

.dice {
    width: 120px;
    height: 120px;
    background: white;
    color: var(--bg-dark);
    font-size: 4rem;
    font-weight: 800;
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 0 auto;
    border-radius: 24px;
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.4);
}

.dice.rolling {
    animation: roll 0.5s infinite linear;
}

@keyframes roll {
    0% {
        transform: rotateX(0) rotateY(0);
    }

    100% {
        transform: rotateX(360deg) rotateY(360deg);
    }
}

/* Overlay */
.overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.98);
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    backdrop-filter: blur(15px);
    padding: 30px;
    text-align: center;
}

.overlay.active {
    display: flex;
}

.times-up-text {
    font-size: 3.5rem;
    font-weight: 900;
    color: var(--danger);
    margin-bottom: 15px;
    letter-spacing: -2px;
}

.motivational-text {
    font-size: 1.8rem;
    margin-bottom: 40px;
    color: var(--text-muted);
    font-weight: 600;
}

/* Board */
.board-container {
    margin: 20px 0;
    background: rgba(0, 0, 0, 0.4);
    border-radius: 24px;
    padding: 25px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.team-track {
    display: flex;
    align-items: center;
    gap: 15px;
}

.track-name {
    width: 120px;
    font-weight: 800;
    font-size: 1rem;
    text-align: left;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.track-bar-bg {
    flex: 1;
    height: 20px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 10px;
    position: relative;
    overflow: hidden;
    border: 1px solid var(--glass-border);
}

.track-bar-fill {
    height: 100%;
    background: linear-gradient(to right, #6366f1, #a855f7);
    width: 0%;
    transition: width 1s cubic-bezier(0.34, 1.56, 0.64, 1);
    border-radius: 10px;
    box-shadow: 0 0 15px rgba(99, 102, 241, 0.4);
}

/* Scores List */
.scores-list {
    margin: 20px 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.score-item {
    display: flex;
    justify-content: space-between;
    padding: 15px 20px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 16px;
    font-weight: 700;
}

.score-item.active {
    border: 2px solid var(--primary);
    background: rgba(99, 102, 241, 0.1);
}

.score-val {
    color: var(--primary);
    font-size: 1.2rem;
}

/* Team Setup */
.setup-form {
    display: flex;
    gap: 10px;
    margin: 20px 0;
}

input[type="text"] {
    flex: 1;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    padding: 15px 20px;
    color: white;
    font-size: 1.1rem;
    font-weight: 600;
    outline: none;
    transition: all 0.3s ease;
}

input[type="text"]:focus {
    border-color: var(--primary);
    background: rgba(255, 255, 255, 0.1);
    box-shadow: 0 0 15px rgba(99, 102, 241, 0.2);
}

.teams-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 30px;
    max-height: 200px;
    overflow-y: auto;
    padding-right: 5px;
}

.teams-list::-webkit-scrollbar {
    width: 5px;
}

.teams-list::-webkit-scrollbar-thumb {
    background: var(--glass-border);
    border-radius: 10px;
}

.team-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(255, 255, 255, 0.03);
    padding: 12px 20px;
    border-radius: 16px;
    border: 1px solid var(--glass-border);
    animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(-10px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.team-item span {
    font-weight: 700;
    font-size: 1.1rem;
}

.btn-remove {
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger);
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    font-weight: 800;
    transition: all 0.2s ease;
}

.btn-remove:hover {
    background: var(--danger);
    color: white;
}

/* Mobile Adjustments */
@media (max-height: 750px) {
    .title {
        font-size: 2.8rem;
    }

    .glass-card {
        padding: 20px;
    }

    .word-item {
        font-size: 1.6rem;
    }

    .word-item.active {
        font-size: 2.4rem;
    }

    .timer {
        font-size: 3.5rem;
    }

    .btn-action {
        height: 75px;
        font-size: 1.6rem;
    }
}

@media (max-width: 400px) {
    #app {
        padding: 15px;
    }

    .glass-card {
        padding: 15px;
    }

    .track-name {
        width: 90px;
    }
}