:root {
    --slate-950: #020617;
    --slate-900: #0f172a;
    --slate-800: #1e293b;
    --slate-700: #334155;
    --slate-400: #94a3b8;
    --slate-300: #cbd5e1;
    --slate-100: #f1f5f9;
    
    --emerald-950: #022c22;
    --emerald-900: #064e3b;
    --emerald-600: #059669;
    --emerald-500: #10b981;

    --zinc-900: #18181b;
    --zinc-700: #3f3f46;

    --amber-500: #f59e0b;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html, body {
    width: 100vw;
    height: 100vh;
    overflow: hidden;
    overscroll-behavior: none;
    -webkit-overflow-scrolling: auto;
    touch-action: pan-x pan-y;
}

body {
    font-family: 'Outfit', sans-serif;
}

body {
    background-color: var(--slate-900);
    background-image: 
        radial-gradient(circle at 10% 20%, rgba(241, 245, 249, 0.04) 0%, transparent 500px),
        radial-gradient(circle at 90% 80%, rgba(0, 0, 0, 0.5) 0%, transparent 500px),
        radial-gradient(circle at 50% 100%, rgba(16, 185, 129, 0.06) 0%, transparent 600px);
    color: var(--slate-100);
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    position: relative;
    z-index: 1;
}

body::before {
    content: '';
    position: absolute;
    inset: 0;
    z-index: -1;
    pointer-events: none;
    background-image: 
        linear-gradient(rgba(255, 255, 255, 0.02) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.02) 1px, transparent 1px);
    background-size: 32px 32px;
    mask-image: radial-gradient(circle at center, black 40%, transparent 100%);
    -webkit-mask-image: radial-gradient(circle at center, black 40%, transparent 100%);
}

.app-container {
    width: 100%;
    max-width: 450px;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.screen {
    display: none;
    flex-direction: column;
    gap: 24px;
    animation: fadeIn 0.4s ease;
}

.screen.active {
    display: flex;
}

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

/* MENU SPECIFIC (Kept simple but styled to match) */
.logo {
    text-align: center;
    font-size: 2.5rem;
    font-weight: 800;
    letter-spacing: 2px;
}
.logo span { color: var(--emerald-500); }

.menu-card {
    background: var(--slate-900);
    border: 1px solid var(--slate-800);
    padding: 24px;
    border-radius: 16px;
}

.menu-card h2 {
    font-size: 1.1rem;
    color: var(--slate-300);
    margin-bottom: 16px;
}

.modes {
    display: flex;
    gap: 12px;
}

.btn {
    flex: 1;
    padding: 12px;
    border: none;
    border-radius: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: 0.3s;
    color: white;
}

.btn-primary { background: var(--slate-800); border: 1px solid var(--slate-700); }
.btn-primary:hover { background: var(--slate-700); }

.btn-secondary { background: var(--emerald-600); }
.btn-secondary:hover { background: var(--emerald-500); }

.input-field {
    width: 100%;
    padding: 12px;
    background: var(--slate-950);
    border: 1px solid var(--slate-700);
    border-radius: 12px;
    color: white;
    outline: none;
    margin-top: 16px;
    margin-bottom: 8px;
}

/* TOP HEADER IN GAME (Leave Btn) */
.header {
    display: flex;
    justify-content: space-between;
}
.btn-icon-text {
    background: var(--slate-800);
    color: var(--slate-300);
    border: 1px solid var(--slate-700);
    padding: 6px 12px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.3s ease;
}

.hint-btn {
    background: rgba(245, 158, 11, 0.1);
    border-color: rgba(245, 158, 11, 0.3);
    color: var(--amber-500);
    display: none;
}

.hint-btn:hover {
    background: rgba(245, 158, 11, 0.2);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(245, 158, 11, 0.2);
}

.room-badge {
    background: var(--slate-900);
    border: 1px solid var(--slate-800);
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 0.9rem;
    color: var(--slate-400);
}

/* SCORE BOARD (React Style) */
.score-board {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.player-card {
    flex: 1;
    padding: 16px;
    border-radius: 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
    transition: all 0.3s ease;
    background: rgba(15, 23, 42, 0.5); /* bg-slate-900/50 */
    opacity: 0.7;
}

.player-card.active {
    opacity: 1;
    background: var(--slate-800);
    box-shadow: 0 0 15px rgba(16, 185, 129, 0.3);
    outline: 2px solid var(--emerald-500);
}

.avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    margin-bottom: 8px;
}

.avatar-black {
    background: var(--zinc-900);
    border: 1px solid var(--zinc-700);
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.5);
}

.avatar-white {
    background: var(--slate-100);
    border: 1px solid var(--slate-300);
    box-shadow: inset 0 -2px 4px rgba(0,0,0,0.1);
}

.score {
    font-size: 1.875rem; /* 3xl */
    font-weight: 700;
}
.name {
    font-size: 0.875rem; /* sm */
    color: var(--slate-400);
    font-weight: 500;
}

/* BOARD */
.board-container {
    position: relative;
    width: 100%;
    aspect-ratio: 1/1;
    background: var(--emerald-900);
    padding: 8px;
    border-radius: 12px; /* xl */
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25); /* 2xl */
    border-bottom: 4px solid var(--emerald-950);
}

.board {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    grid-template-rows: repeat(8, 1fr);
    gap: 4px; /* gap-1 = 0.25rem = 4px */
    width: 100%;
    height: 100%;
}

.cell {
    position: relative;
    background: var(--emerald-600);
    border-radius: 2px; /* sm */
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    transition: background-color 0.2s;
}

.cell:hover {
    background: var(--emerald-500);
}

/* VALID MOVE (Black dot) */
.cell.valid-move::after {
    content: '';
    position: absolute;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.2);
    animation: scaleIn 0.3s ease forwards;
}

/* HINT MOVE (Amber dot) */
.cell.hint-move::after {
    content: '';
    position: absolute;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--amber-500);
    box-shadow: 0 0 15px var(--amber-500);
    animation: hintPulse 1s infinite;
    z-index: 5;
}

@keyframes hintPulse {
    0% { transform: scale(1); opacity: 0.6; }
    50% { transform: scale(1.3); opacity: 1; }
    100% { transform: scale(1); opacity: 0.6; }
}

@keyframes scaleIn {
    from { transform: scale(0); }
    to { transform: scale(1); }
}

/* PIECE (3D Spring) */
.piece {
    width: 85%;
    height: 85%;
    position: relative;
    transform-style: preserve-3d;
    transition: transform 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    transform: scale(0); /* initial */
}

/* Show piece */
.piece.show {
    transform: scale(1) rotateY(0deg);
}

.piece.show.flip {
    transform: scale(1) rotateY(180deg);
}

.face {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    backface-visibility: hidden;
}

.face-black {
    background: linear-gradient(to bottom right, var(--zinc-700), var(--zinc-900));
    box-shadow: inset 0 -2px 4px rgba(0,0,0,0.6), 0 2px 4px rgba(0,0,0,0.5);
    transform: rotateY(0deg);
}

.face-white {
    background: linear-gradient(to bottom right, white, var(--slate-300));
    box-shadow: inset 0 -2px 4px rgba(0,0,0,0.2), 0 2px 4px rgba(0,0,0,0.5);
    transform: rotateY(180deg);
}

/* OVERLAYS */
.overlay {
    position: absolute;
    inset: 0;
    background: rgba(2, 6, 23, 0.8); /* slate-950/80 */
    backdrop-filter: blur(4px);
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 24px;
    z-index: 10;
}

.modal-card {
    background: var(--slate-900);
    padding: 32px;
    border-radius: 16px;
    text-align: center;
    border: 1px solid var(--slate-800);
    width: 100%;
    max-width: 320px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
}

.modal-title {
    font-size: 1.875rem;
    font-weight: 700;
    color: white;
    margin-bottom: 8px;
}

.modal-desc {
    color: var(--slate-400);
    margin-bottom: 24px;
}

.room-code-box {
    margin: 10px 0 24px 0;
    padding: 16px;
    background: var(--slate-950);
    border: 2px dashed var(--slate-700);
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    transition: all 0.2s ease;
}

.room-code-box:hover {
    border-color: var(--emerald-500);
    background: var(--emerald-950);
}

.room-code-box:hover #room-code-text {
    transform: scale(1.05);
}

#room-code-text {
    font-size: 3rem;
    font-weight: 800;
    letter-spacing: 6px;
    color: var(--emerald-500);
    text-shadow: 0 0 15px rgba(16, 185, 129, 0.4);
    transition: transform 0.2s ease;
}

.copy-hint {
    font-size: 0.8rem;
    color: var(--slate-400);
    margin-top: 4px;
}

/* WAIT NOTIFICATION (Toast style) */
.toast-msg {
    background: rgba(245, 158, 11, 0.9); /* amber-500/90 */
    color: #fffbeb;
    padding: 8px 16px;
    border-radius: 999px;
    font-size: 0.875rem;
    font-weight: 500;
    box-shadow: 0 10px 15px -3px rgba(0,0,0,0.1);
    position: absolute;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    white-space: nowrap;
    z-index: 50;
    transition: opacity 0.3s, transform 0.3s;
}

.toast-hidden {
    opacity: 0;
    transform: translate(-50%, -20px);
    pointer-events: none;
}

/* ACTIVE ROOMS STYLING */
.active-rooms-container {
    margin-top: 16px;
    border-top: 1px solid var(--slate-800);
    padding-top: 16px;
}

.active-rooms-container h3 {
    font-size: 0.9rem;
    color: var(--slate-400);
    margin-bottom: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    text-align: left;
}

.active-rooms-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 200px;
    overflow-y: auto;
    padding-right: 4px;
}

/* Custom scrollbar for rooms list */
.active-rooms-list::-webkit-scrollbar {
    width: 6px;
}
.active-rooms-list::-webkit-scrollbar-track {
    background: var(--slate-950);
    border-radius: 3px;
}
.active-rooms-list::-webkit-scrollbar-thumb {
    background: var(--slate-800);
    border-radius: 3px;
}
.active-rooms-list::-webkit-scrollbar-thumb:hover {
    background: var(--slate-700);
}

.room-item {
    background: var(--slate-950);
    border: 1px solid var(--slate-800);
    padding: 10px 14px;
    border-radius: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: left;
}

.room-item:hover {
    border-color: var(--emerald-500);
    background: rgba(16, 185, 129, 0.05);
    transform: translateY(-1px);
}

.room-item-info {
    display: flex;
    flex-direction: column;
}

.room-item-id {
    font-weight: 700;
    color: var(--emerald-500);
    font-size: 1rem;
}

.room-item-time {
    font-size: 0.75rem;
    color: var(--slate-400);
    margin-top: 2px;
}

.room-item-btn {
    background: var(--emerald-600);
    color: white;
    font-size: 0.8rem;
    padding: 6px 12px;
    border-radius: 6px;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: background 0.2s;
}

.room-item:hover .room-item-btn {
    background: var(--emerald-500);
}

.no-rooms {
    font-size: 0.85rem;
    color: var(--slate-400);
    text-align: center;
    padding: 16px 0;
    font-style: italic;
}
