:root {
    --color-primary: #163e52;
    --color-primary-hover: #1d977f;
    --color-success: #d09a04;
    --color-info: #2196f3;
    --color-danger: #c21307;

    --bg-body: #1b644b;
    --bg-panel-main: rgba(0, 0, 0, 0.2);
    --bg-panel-dark: rgba(0, 0, 0, 0.4);
    --bg-card: rgba(0, 0, 0, 0.3);
    --bg-glass: rgba(255, 255, 255, 0.1);
    --bg-glass-light: rgba(255, 255, 255, 0.05);
    --bg-modal: rgba(0, 0, 0, 0.85);

    --text-light: #ffffff;
    --text-muted: #cccccc;
    --text-dark: #000000;

    --radius-sm: 5px;
    --radius-md: 8px;
}

body { 
    font-family: Arial, sans-serif; 
    background-color: var(--bg-body); 
    color: var(--text-light); 
    text-align: center; 
    margin: 0; 
    padding: 5px; 
}

h2 {
    font-size: 1.1rem;
    color: #00ffb7;
}

#game-board { 
    margin: 0 auto; 
    background: var(--bg-panel-main); 
    padding: 10px;
    padding-bottom: 80px; 
    border-radius: var(--radius-sm); 
}

.empty-text { color: var(--text-muted); }
.turn-indicator-text { color: var(--color-primary); font-size: 1rem; padding-bottom: 20px; }
.stat-value-orange { float: right; color: var(--color-success);margin-left: 5px; }
.stat-value-blue { float: right; color: var(--color-info); margin-left: 5px; }

button { 
    padding: 10px 20px; 
    font-size: 16px; 
    cursor: pointer; 
    background: var(--color-primary); 
    color: var(--text-light);
    border: none; 
    border-radius: var(--radius-sm); 
    font-weight: bold; 
    margin: 5px; 
    transition: background 0.2s ease;
}

button:hover:not(:disabled) { background: var(--color-primary-hover); }
button:disabled { background: #555; cursor: not-allowed; opacity: 0.7; }

.btn-blue { background: var(--color-info); }
.btn-green { background: var(--color-success); }
.btn-red { background: var(--color-danger); }
.btn-large {
    font-size: 1.2em;
    padding: 15px 30px;
}

.hand { 
    display: flex; 
    justify-content: center; 
    flex-wrap: wrap; 
    gap: 5px; 
    margin-top: 10px; 
    min-height: 80px; 
}

.tile { 
    width: 50px; 
    height: 70px; 
    cursor: pointer;
    transition: transform 0.1s, filter 0.1s;
    border-radius: var(--radius-sm);
    border: 2px solid #eee;
    box-shadow: 2px 2px 5px rgba(0,0,0,0.3);
    touch-action: manipulation;
    -webkit-user-select: none;
    user-select: none;
    transition: transform 0.15s cubic-bezier(0.2, 0.8, 0.2, 1), filter 0.15s ease;
}

.tile img {
    width: 100%;
    height: 100%;
    pointer-events: none; 
}

.tile:hover:not(.disabled) { transform: translateY(-10px); filter: brightness(1.2); }
.tile.disabled { cursor: not-allowed; opacity: 0.6; }
.tile.dragging { opacity: 0.4; transform: scale(0.95); transition: none; }

.tile-placeholder {
    width: 50px;
    height: 70px;
    background: var(--bg-glass);
    border: 2px dashed var(--color-primary);
    border-radius: var(--radius-sm);
    pointer-events: none;
    transition: all 0.1s ease;
    animation: placeholderOpen 0.15s ease-out forwards;
    margin: 0 2px;
}

@keyframes placeholderOpen {
    from { width: 0; opacity: 0; margin: 0; }
    to { width: 50px; opacity: 1; margin: 0 2px; }
}

.info-panel { 
    margin: 10px 0; 
    padding: 10px; 
    background: var(--bg-panel-dark); 
    border-radius: var(--radius-sm); 
}

.discard-river { 
    display: flex; 
    gap: 5px; 
    overflow-x: auto; 
    padding: 10px; 
    background: var(--bg-glass-light); 
    min-height: 60px; 
    align-items: center; 
    scroll-behavior: smooth;
}

.discard-river .tile {
    cursor: default;
    flex-shrink: 0;
    height: 50px;
    width: 35px;
    align-self: center;
}

.opponents { 
    display: flex; 
    justify-content: space-around; 
    margin-bottom: 20px; 
}

.opponent { 
    background: var(--bg-card); 
    padding: 10px; 
    border-radius: var(--radius-sm); 
    width: 30%;
}

/* Exposed Melds */
.exposed-container {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    margin-top: 10px;
    justify-content: center;
}

.meld-group {
    display: flex;
    gap: 2px;
    background: var(--bg-glass);
    padding: 4px;
    border-radius: var(--radius-sm);
}

.mini-tile {
    width: 25px;
    height: 35px;
    border-radius: 3px;
    border: 1px solid var(--text-muted);
    background: ivory;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.mini-tile img {
    width: 100%;
    height: 100%;
    pointer-events: none;
}

#player-exposed {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-top: 10px;
    min-height: 50px;
}

#setup-panel {
    background: var(--bg-panel-dark);
    padding: 20px;
    border-radius: var(--radius-sm);
    margin-bottom: 20px;
}

#room-info {
    font-size: 1.2em;
    font-weight: bold;
    color: var(--color-success);
}

.lobby-section { margin: 15px 0; }

#invite-link-container {
    font-family: monospace;
    background: #222;
    padding: 10px;
    border-radius: var(--radius-sm);
    display: none;
}

label[for="ai-difficulty"] {
    font-size: 1.1em;
    margin-right: 10px;
}

#ai-difficulty {
    padding: 8px;
    font-size: 1em;
    border-radius: var(--radius-sm);
}

.lobby-players-container {
    background: var(--bg-glass);
    padding: 15px;
    border-radius: var(--radius-sm);
    margin-bottom: 15px;
}

.lobby-players-container h3 { margin-top: 0; }
#lobby-players { list-style-type: none; padding: 0; font-size: 1.2em; }

#action-menu {
    display: none;
    background: var(--color-primary);
    padding: 15px;
    border-radius: var(--radius-sm);
    position: fixed;
    top: 30%;
    left: 50%;
    transform: translateX(-50%);
    z-index: 100;
    box-shadow: 0 4px 15px rgba(0,0,0,0.5);
}

h3 {
    font-size: 1rem;
    font-weight: normal;
}

.action-header {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    margin-bottom: 15px;
}

.action-header h3 { margin: 0; }

.overlay-modal {
    display: none;
    position: fixed; 
    top: 0; 
    left: 0; 
    width: 100%; 
    height: 100%; 
    background: var(--bg-modal); 
    z-index: 1000; 
    align-items: center; 
    justify-content: center;
}

.modal-content {
    background: var(--bg-body);
    padding: 40px;
    border-radius: var(--radius-sm);
    border: 4px solid var(--color-primary);
    text-align: center;
    max-width: 500px;
    box-shadow: 0 0 30px rgba(255, 152, 0, 0.5);
}

.modal-title { color: var(--color-primary); margin-top: 0; font-size: 3em; }
.modal-button-group { display: flex; gap: 10px; justify-content: center; margin-top: 20px; }

#winner-name { font-size: 2em; margin-bottom: 5px; }
#winner-type { font-weight: normal; font-style: italic; color: var(--text-muted); margin-top: 0; }

.score-display {
    color: var(--color-success);
    background: var(--bg-card);
    padding: 10px;
    border-radius: var(--radius-sm);
}

#btn-show-modal {
    display: none; 
    position: fixed; 
    bottom: 20px; 
    right: 20px; 
    z-index: 1000; 
    box-shadow: 0 4px 10px rgba(0,0,0,0.5);
}

.profile-title { color: var(--color-success); margin-top: 0; font-size: 2.5em; }

.stats-container {
    background: var(--bg-card); 
    padding: 20px; 
    border-radius: var(--radius-sm); 
    text-align: left; 
    font-size: 1.2em; 
    line-height: 1.8;
}

.stats-divider {
    border: none;
    border-top: 1px solid #555; 
    margin: 15px 0;
}

#btn-close-stats { margin-top: 25px; width: 100%; }
#btn-play-again { margin: 0; }

#game-over-modal {
    display: none; 
    position: fixed; 
    top: 0; left: 0; width: 100%; height: 100%; 
    background: var(--bg-modal); 
    z-index: 1000; 
    align-items: center; justify-content: center;
}

.winner-highlight {
    border: 2px solid var(--color-primary) !important;
    box-shadow: 0 0 25px rgba(255, 152, 0, 0.6);
    background: rgba(255, 152, 0, 0.15) !important;
    transform: scale(1.02);
    transition: all 0.3s ease;
    border-radius: var(--radius-md);
}

#player-hand.winner-highlight {
    margin-bottom: 120px;
}

.winner-highlight .turn-indicator-text {
    color: #ffeb14;
    font-size: 1.2rem;
    font-weight: bold;
}

@keyframes waiting {
    0% {
        box-shadow: 0 0 25px rgba(33, 150, 243, 0.7), inset 0 0 10px rgba(33, 150, 243, 0.1);
        border-color: rgba(33, 150, 243, 0.6);
    }
    50% {
        box-shadow: 0 0 5px rgba(33, 150, 243, 0.1);
        border-color: transparent;
    }
    100% {
        box-shadow: 0 0 25px rgba(33, 150, 243, 0.7), inset 0 0 10px rgba(33, 150, 243, 0.1);
        border-color: rgba(33, 150, 243, 0.6);
    }
}

.active-player-glow {
    animation: waiting 4s ease-in-out infinite;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    transition: padding 0.3s ease;
}