:root {
    --primary: #FF416C;
    --secondary: #FF4B2B;
    --bg-dark: #0f172a;
    --text-light: #f8fafc;
    --glass-bg: rgba(255, 255, 255, 0.05);
    --glass-border: rgba(255, 255, 255, 0.1);
    --table-green: #0b4b2a;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Outfit', sans-serif;
}

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

.background-animation {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    background: radial-gradient(circle at top left, rgba(255,65,108,0.15), transparent 40%),
                radial-gradient(circle at bottom right, rgba(255,75,43,0.15), transparent 40%);
    z-index: -1;
}

.container {
    width: 100%;
    max-width: 450px;
    padding: 20px;
}

.screen {
    display: none;
    flex-direction: column;
    align-items: center;
    animation: fadeIn 0.4s ease-in-out;
}

.screen.active {
    display: flex;
}

.screen.hidden {
    display: none;
}

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

.logo {
    font-size: 4rem;
    font-weight: 800;
    background: linear-gradient(to right, var(--primary), var(--secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 5px;
    letter-spacing: 2px;
}

.subtitle {
    color: #94a3b8;
    margin-bottom: 30px;
    font-size: 1.1rem;
}

.card-glass {
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    padding: 30px;
    width: 100%;
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.3);
}

.input-group {
    display: flex;
    flex-direction: column;
    margin-bottom: 25px;
}

.input-group label {
    margin-bottom: 8px;
    font-weight: 300;
    color: #cbd5e1;
}

input[type="text"] {
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    padding: 15px;
    color: white;
    font-size: 1rem;
    outline: none;
    transition: border 0.3s ease;
}

input[type="text"]:focus {
    border-color: var(--primary);
}

.btn {
    width: 100%;
    padding: 15px;
    border: none;
    border-radius: 10px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

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

.btn.primary {
    background: linear-gradient(to right, var(--primary), var(--secondary));
    color: white;
    box-shadow: 0 4px 15px rgba(255, 65, 108, 0.4);
}

.btn.primary:disabled {
    background: #475569;
    box-shadow: none;
    cursor: not-allowed;
    color: #94a3b8;
}

.btn.secondary {
    background: rgba(255, 255, 255, 0.1);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.btn.secondary:hover {
    background: rgba(255, 255, 255, 0.15);
}

.divider {
    display: flex;
    align-items: center;
    margin: 20px 0;
    color: #64748b;
    font-size: 0.9rem;
}

.divider::before, .divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: rgba(255,255,255,0.1);
}

.divider span {
    padding: 0 15px;
}

.join-group {
    display: flex;
    gap: 10px;
}

.join-group input {
    flex: 1;
    text-transform: uppercase;
    letter-spacing: 2px;
    text-align: center;
}

.join-group .btn {
    flex: 1;
}

.error-msg {
    color: #ef4444;
    margin-top: 15px;
    text-align: center;
    font-size: 0.9rem;
    min-height: 20px;
}

/* Lobby Styles */
.lobby-card {
    text-align: center;
}

.lobby-card h2 {
    margin-bottom: 20px;
    font-weight: 400;
}

.room-code-display {
    background: rgba(0,0,0,0.3);
    padding: 15px;
    border-radius: 10px;
    margin-bottom: 30px;
    font-size: 1.2rem;
}

.room-code-display strong {
    color: var(--primary);
    font-size: 1.5rem;
    letter-spacing: 3px;
    margin-left: 10px;
}

.players-list-container {
    text-align: left;
    margin-bottom: 30px;
}

.players-list-container h3 {
    font-size: 1rem;
    color: #cbd5e1;
    margin-bottom: 15px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    padding-bottom: 10px;
}

.players-list {
    list-style: none;
}

.players-list li {
    background: rgba(255,255,255,0.05);
    padding: 12px 15px;
    border-radius: 8px;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.player-name {
    font-weight: 500;
}

.player-badge {
    background: var(--primary);
    font-size: 0.7rem;
    padding: 3px 8px;
    border-radius: 10px;
    font-weight: 600;
}

/* Game Screen */
#game-screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: radial-gradient(circle at 50% 30%, #3a2a6b, #1d163d);
    overflow: hidden;
    z-index: 100;
    display: none; /* Controlled by JS via .active */
    justify-content: center;
    align-items: center;
}

#game-screen.active {
    display: flex;
}

.game-table {
    width: 100%;
    max-width: 450px; /* same as .container */
    height: 100%;
    position: relative;
}
.top-bar-container {
    position: absolute;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    z-index: 20;
    width: 280px;
}
.top-bar {
    background: #0b4532;
    border: 2px solid #28c06e;
    border-radius: 40px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    height: 50px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.5);
}

.kata-tokens {
    display: flex;
    justify-content: space-between;
    width: 100%;
    margin-top: 5px;
    padding: 0 30px;
    box-sizing: border-box;
}
.kata-group {
    display: flex;
    gap: 3px;
}
.kata-token {
    width: 8px;
    height: 12px;
    background: linear-gradient(135deg, #4f8ee5, #2457a6);
    border: 1px solid rgba(255,255,255,0.8);
    border-radius: 2px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.5);
}

.team-score {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.score-number {
    font-size: 1.2rem;
    font-weight: 800;
    color: white;
}

.score-label {
    font-size: 0.8rem;
    color: #e2e8f0;
    margin-top: 2px;
}

.trump-circle {
    width: 46px;
    height: 46px;
    background: white;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.8rem;
    box-shadow: inset 0 2px 5px rgba(0,0,0,0.2);
}

.game-status {
    position: absolute;
    top: 80px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0,0,0,0.5);
    padding: 5px 15px;
    border-radius: 20px;
    font-weight: 500;
    z-index: 10;
    text-align: center;
    font-size: 0.9rem;
    color: #e2e8f0;
}

/* Opponents */
.opponent {
    position: absolute;
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 80px;
    background: transparent;
    padding: 0;
}

.opponent .name {
    font-size: 0.9rem;
    font-weight: 500;
    margin-bottom: 5px;
    color: white;
    text-shadow: 0 1px 3px rgba(0,0,0,0.5);
}

.opponent .avatar {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    border: 3px solid #0d9450;
    background: #1a202c;
    overflow: visible;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: 0 4px 10px rgba(0,0,0,0.5);
    position: relative;
}

.opponent .avatar img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
}

.trump-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #fff;
    border-radius: 50%;
    width: 22px;
    height: 22px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 14px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.5);
    border: 2px solid #333;
    z-index: 10;
}

.mini-cards {
    display: flex;
    gap: 2px;
    margin-bottom: 5px;
    height: 14px;
}

.mini-card {
    width: 8px;
    height: 14px;
    background: linear-gradient(135deg, #4f8ee5, #2457a6);
    border: 1px solid rgba(255,255,255,0.7);
    border-radius: 1px;
}

.player-top {
    top: 110px;
    left: 50%;
    transform: translateX(-50%);
}

.player-left {
    top: 45%;
    left: 10px;
    transform: translateY(-50%);
}
.player-left .mini-cards { margin-bottom: 0; margin-top: 5px; }

.player-right {
    top: 45%;
    right: 10px;
    transform: translateY(-50%);
}
.player-right .mini-cards { margin-bottom: 0; margin-top: 5px; }

/* Play Area */
.play-area-container {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 280px;
    height: 340px;
    z-index: 5;
}

.play-area-board {
    width: 100%;
    height: 100%;
    background: linear-gradient(to bottom right, #e89e53, #d97836);
    border: 6px solid #f9d71c;
    border-radius: 20px;
    position: relative;
    box-shadow: 0 10px 30px rgba(0,0,0,0.6);
    overflow: hidden;
}

.mandala-bg {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 180px;
    height: 180px;
    border: 2px solid rgba(0,0,0,0.05);
    border-radius: 50%;
    background: radial-gradient(circle, rgba(0,0,0,0.03) 30%, transparent 70%);
}

.play-area {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
}

.playing-card.in-trick {
    position: absolute;
    bottom: auto;
    left: auto;
    right: auto;
    top: auto;
    margin: 0;
    transform-origin: center center;
    z-index: 10;
    box-shadow: 0 6px 12px rgba(0,0,0,0.4);
}

.playing-card.bottom-card {
    top: 60%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.playing-card.top-card {
    top: 20%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.playing-card.left-card {
    left: 30%;
    top: 40%;
    transform: translate(-50%, -50%) rotate(10deg);
}

.playing-card.right-card {
    left: 70%;
    top: 40%;
    transform: translate(-50%, -50%) rotate(-10deg);
}

.player-label {
    display: none; /* Hide label, position is obvious */
}

/* Bottom Dock */
.bottom-dock {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 150px;
    z-index: 30;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.dock-curve {
    position: absolute;
    bottom: -60px;
    left: 50%;
    transform: translateX(-50%);
    width: 130%;
    height: 140px;
    background: radial-gradient(ellipse at top, #148f58, #053b21);
    border-top: 4px solid #cca143;
    border-top-left-radius: 50% 100%;
    border-top-right-radius: 50% 100%;
    z-index: 31;
}

.my-avatar-container {
    position: absolute;
    bottom: 10px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 32;
    display: flex;
    justify-content: center;
    align-items: center;
}

.my-avatar {
    width: 55px;
    height: 55px;
    background: #1a202c;
    border-radius: 50%;
    border: 3px solid #cca143;
    box-shadow: 0 4px 10px rgba(0,0,0,0.5);
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
}

.my-avatar img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
}

.my-hand {
    position: absolute;
    bottom: 60px;
    left: 0;
    width: 100%;
    height: 120px;
    display: flex;
    justify-content: center;
    align-items: flex-end;
    z-index: 30;
}

/* Playing Card */
.my-hand .playing-card {
    left: 50%;
    margin-left: -32.5px; /* Half of width to perfectly center before transform */
}

.playing-card {
    width: 65px;
    height: 95px;
    background: white;
    border-radius: 6px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.3);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    font-size: 1.2rem;
    font-weight: bold;
    position: absolute;
    bottom: 0;
    cursor: pointer;
    transition: bottom 0.2s, transform 0.2s;
    transform-origin: bottom center;
}

.playing-card:hover {
    bottom: 15px !important;
    z-index: 50 !important;
}

.playing-card.red { color: #e74c3c; }
.playing-card.black { color: #2c3e50; }

.card-top-left {
    position: absolute;
    top: 3px; left: 3px;
    font-size: 0.9rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    line-height: 1;
}

.card-bottom-right {
    position: absolute;
    bottom: 3px; right: 3px;
    font-size: 0.9rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    transform: rotate(180deg);
    line-height: 1;
}

/* Modal */
.modal {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.85);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.trump-popup {
    background: #fff;
    border-radius: 20px;
    padding: 30px 20px;
    position: relative;
    width: 320px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
    display: flex;
    flex-direction: column;
    align-items: center;
}

.trump-ribbon {
    position: absolute;
    top: -20px;
    background: #25c4f8;
    color: #0b4a6b;
    font-size: 1.5rem;
    font-weight: 800;
    padding: 8px 30px;
    border-radius: 10px;
    border: 3px solid #1ba5d6;
    box-shadow: 0 4px 8px rgba(0,0,0,0.3);
}

.trump-cards-box {
    background: #333;
    border-radius: 10px;
    padding: 15px;
    display: flex;
    gap: 10px;
    margin-top: 20px;
    margin-bottom: 20px;
}

.trump-cards-box .playing-card {
    position: relative;
    bottom: auto;
    left: auto;
    margin: 0;
    transform: none !important;
    width: 50px;
    height: 75px;
    font-size: 1rem;
    box-shadow: 0 2px 5px rgba(0,0,0,0.5);
    cursor: default;
}
.trump-cards-box .playing-card:hover {
    bottom: auto !important;
}

.btn-suit-square {
    width: 50px;
    height: 50px;
    border-radius: 10px;
    background: #62d854;
    border: 3px solid #1f6b15;
    font-size: 2rem;
    color: black;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    box-shadow: 0 4px 0 #1f6b15;
    transition: all 0.1s;
}

.btn-suit-square.red-suit {
    color: #e74c3c;
}

.btn-suit-square:active, .btn-suit-square.selected {
    transform: translateY(4px);
    box-shadow: 0 0 0 #1f6b15;
    background: #8cf080;
}

.suit-buttons-row {
    display: flex;
    gap: 15px;
    margin-bottom: 15px;
}

.new-popup p {
    color: #718096;
    margin-bottom: 20px;
    font-size: 0.95rem;
}

.suit-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
}

.btn-suit {
    padding: 10px 15px;
    font-size: 1.5rem;
    border: 2px solid #e2e8f0;
    border-radius: 10px;
    cursor: pointer;
    background: white;
    transition: transform 0.2s, background 0.2s;
}

.btn-suit:hover { 
    transform: scale(1.05); 
    background: #f8fafc;
}

.btn-ok {
    background: #68d345;
    border: 3px solid #1a202c;
    border-radius: 20px;
    padding: 10px 40px;
    font-size: 1.2rem;
    font-weight: bold;
    color: white;
    cursor: pointer;
    margin-top: 15px;
    box-shadow: inset 0 -4px 0 rgba(0,0,0,0.3);
    text-transform: uppercase;
}

.btn-ok:active {
    box-shadow: inset 0 -1px 0 rgba(0,0,0,0.3);
    transform: translateY(3px);
}

.hidden { display: none !important; }

.copyright-notice {
    text-align: center;
    color: #cbd5e1;
    font-size: 0.85rem;
    margin-top: 15px;
    text-shadow: 0 1px 2px rgba(0,0,0,0.5);
}
