:root {
    --primary-blue: #0b3d91;
    --primary-red: #bf0a30;
    --off-white: #f5f5f0;
    --gold: #d4af37;
    --text-dark: #222;
    --text-light: #fff;
    --card-width: 80px;
    --card-height: 120px;
}

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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--off-white);
    color: var(--text-dark);
    height: 100vh;
    height: 100dvh; /* For mobile browsers */
    overflow: hidden;
    display: flex;
    justify-content: center;
}

#app {
    width: 100%;
    max-width: 600px;
    height: 100%;
    display: flex;
    flex-direction: column;
    background: linear-gradient(to bottom, #e0e0d8, var(--off-white));
    box-shadow: 0 0 20px rgba(0,0,0,0.1);
}

/* --- Layout Areas --- */
.player-area {
    display: flex;
    flex-direction: column;
    padding: 10px;
    flex: 1;
    min-height: 0;
}

.ai-area {
    background-color: rgba(11, 61, 145, 0.05);
    border-bottom: 2px solid rgba(0,0,0,0.1);
}

.user-area {
    background-color: rgba(191, 10, 48, 0.05);
    border-top: 2px solid rgba(0,0,0,0.1);
}

.copyright-notice {
    text-align: center;
    font-size: 0.65rem;
    color: rgba(0, 0, 0, 0.5);
    margin-top: auto;
    padding-top: 5px;
}

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

.avatar {
    font-size: 1.1rem;
}

.score-container {
    background: var(--gold);
    color: var(--text-dark);
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 0.9rem;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.center-area {
    display: flex;
    align-items: center;
    padding: 10px;
    flex: 1.5;
    gap: 10px;
    background: radial-gradient(circle, #fcfcfc 0%, #e8e8e8 100%);
}

#trick-area {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 15px;
    flex: 1;
    min-width: 100px;
}

.trick-slot {
    width: var(--card-width);
    height: var(--card-height);
    border: 2px dashed rgba(0,0,0,0.2);
    border-radius: 8px;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
}

.trick-slot .card {
    position: absolute;
    margin: 0;
    box-shadow: 0 5px 15px rgba(0,0,0,0.3);
    animation: dropCard 0.3s ease-out forwards;
}

@keyframes dropCard {
    from { transform: scale(1.2); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

/* --- Hands & Cards --- */
.hand {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    overflow-y: hidden;
    padding-bottom: 10px;
    flex: 1;
    align-items: center;
    scrollbar-width: none; /* Firefox */
}
.hand::-webkit-scrollbar {
    display: none; /* Safari and Chrome */
}

.card {
    min-width: var(--card-width);
    height: var(--card-height);
    background-color: #fff;
    border: 2px solid var(--primary-blue);
    border-radius: 8px;
    box-shadow: 0 3px 6px rgba(0,0,0,0.15);
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    padding: 6px;
    cursor: pointer;
    transition: transform 0.2s;
    user-select: none;
    position: relative;
}

.player-hand .card:active {
    transform: scale(0.95);
}

.card-group {
    font-size: 0.55rem;
    text-transform: uppercase;
    color: var(--primary-red);
    font-weight: bold;
    text-align: center;
    margin-bottom: 5px;
    line-height: 1.1;
    border-bottom: 1px solid #ccc;
    padding-bottom: 3px;
}

.card.is-trump {
    border-color: var(--gold);
    background: linear-gradient(135deg, #fff, #fff9e6);
}
.card.is-trump .card-group {
    color: #b8860b;
}

.card-name {
    font-size: 0.75rem;
    font-weight: bold;
    text-align: center;
    color: var(--primary-blue);
    line-height: 1.2;
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 1;
}

.card-rank {
    position: absolute;
    top: 2px;
    left: 4px;
    font-size: 0.7rem;
    font-weight: bold;
    color: var(--text-dark);
}
.card-rank.bottom {
    top: auto;
    bottom: 2px;
    left: auto;
    right: 4px;
    transform: rotate(180deg);
}

.card-back {
    min-width: var(--card-width);
    height: var(--card-height);
    background-image: url('card_back.png');
    background-size: cover;
    background-position: center;
    border: 2px solid var(--text-dark);
    border-radius: 8px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}

.ai-hand .card {
    background: transparent;
    border: none;
    box-shadow: none;
    background-image: url('card_back.png');
    background-size: cover;
    background-position: center;
    border-radius: 8px;
}
.ai-hand .card * {
    display: none; /* Hide text on AI cards */
}

/* --- Deck & Logs --- */
#deck-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
}

#deck-count {
    font-size: 0.8rem;
    font-weight: bold;
    color: var(--text-dark);
}

.text-btn {
    background: none;
    border: 1px solid var(--primary-blue);
    color: var(--primary-blue);
    border-radius: 4px;
    padding: 4px 8px;
    font-size: 0.75rem;
    cursor: pointer;
    margin-top: 5px;
    font-weight: bold;
    transition: all 0.2s;
}

.text-btn:active {
    background: var(--primary-blue);
    color: white;
}

#log-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    height: 100%;
}

#turn-indicator {
    font-size: 1.1rem;
    font-weight: bold;
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 1px;
}
.player-turn { color: var(--primary-blue); }
.ai-turn { color: var(--primary-red); }

#log {
    font-size: 0.9rem;
    line-height: 1.4;
    background: rgba(255,255,255,0.7);
    padding: 10px;
    border-radius: 8px;
    border-left: 4px solid var(--gold);
    min-height: 60px;
    display: flex;
    align-items: center;
}

/* --- Modals --- */
.modal {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.6);
    display: flex;
    justify-content: center;
    align-items: flex-end; /* Bottom sheet style for mobile */
    z-index: 100;
    opacity: 1;
    transition: opacity 0.3s;
}

.modal.hidden {
    opacity: 0;
    pointer-events: none;
}

.modal-content {
    background: white;
    width: 100%;
    max-width: 600px;
    border-radius: 20px 20px 0 0;
    padding: 20px;
    transform: translateY(0);
    transition: transform 0.3s;
    box-shadow: 0 -5px 15px rgba(0,0,0,0.2);
}

.modal.hidden .modal-content {
    transform: translateY(100%);
}

#game-over-modal {
    align-items: center; /* Center game over modal */
}
#game-over-modal .modal-content {
    border-radius: 12px;
    width: 90%;
    text-align: center;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 5px;
}

.modal-header h3 {
    color: var(--primary-blue);
}

.close-btn {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: #666;
}

#modal-group-name {
    font-size: 0.85rem;
    color: #666;
    margin-bottom: 15px;
    font-weight: bold;
    text-transform: uppercase;
}

.rules-text {
    text-align: left;
    font-size: 0.95rem;
    line-height: 1.4;
    color: #333;
    max-height: 60vh;
    overflow-y: auto;
    padding: 10px 5px;
}

.rules-text p {
    margin-bottom: 12px;
}

.options-container {
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-height: 50vh;
    overflow-y: auto;
}

.option-btn {
    background: var(--off-white);
    border: 2px solid var(--primary-blue);
    padding: 15px;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: bold;
    color: var(--primary-blue);
    cursor: pointer;
    transition: background 0.2s;
}

.option-btn:active {
    background: var(--primary-blue);
    color: white;
}

.primary-btn {
    background: var(--primary-red);
    color: white;
    border: none;
    padding: 15px 30px;
    border-radius: 8px;
    font-size: 1.1rem;
    font-weight: bold;
    margin-top: 20px;
    cursor: pointer;
    width: 100%;
}
.primary-btn:active {
    background: #990022;
}

/* Animations */
@keyframes drawCard {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.animate-draw {
    animation: drawCard 0.4s ease forwards;
}