:root {
    --bg-dark: #0f0c29;
    --bg-gradient: linear-gradient(135deg, #0f0c29, #302b63, #24243e);
    --glass-bg: rgba(255, 255, 255, 0.05);
    --accent: #00d2ff;
    --text: #ffffff;
    --sq-light: #e0e0e0;
    --sq-dark: #3a7ca5;
    --highlight: rgba(0, 255, 170, 0.6);
}

.hidden {
    display: none !important;
}

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

body {
    background: var(--bg-dark);
    color: var(--text);
    height: 100vh;
    overflow: hidden;
}

.bg-gradient {
    position: absolute;
    width: 100%;
    height: 100%;
    background: var(--bg-gradient);
    z-index: -1;
}

.app-layout {
    display: flex;
    height: 100%;
    align-items: center;
    justify-content: center;
    gap: 30px;
    padding: 20px;
    transition: padding-right 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.app-layout.chat-open {
    padding-right: 450px;
}

.glass-panel {
    background: var(--glass-bg);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

.sidebar {
    width: 300px;
    height: 90vh;
    padding: 25px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

/* Mobile Menu Header - Hidden on desktop */
.mobile-menu-header {
    display: none;
}

.sidebar-content {
    display: flex;
    flex-direction: column;
    flex: 1;
    gap: 10px;
}

.brand h1 {
    font-size: 1.8rem;
    margin-bottom: 5px;
}

.badge {
    font-size: 0.8rem;
    background: #e67e22;
    padding: 4px 10px;
    border-radius: 4px;
    display: inline-block;
}

.highlight {
    color: var(--accent);
}

/* Ping Indicator */
.ping-indicator {
    position: fixed;
    top: 10px;
    left: 10px;
    z-index: 1000;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(10px);
    padding: 5px 10px;
    border-radius: 20px;
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 0.75rem;
    border: 1px solid rgba(255, 255, 255, 0.1);
    transition: all 0.3s ease;
}

.ping-indicator:hover {
    background: rgba(0, 0, 0, 0.8);
    transform: scale(1.05);
}

.ping-icon {
    font-size: 0.7rem;
}

.ping-value {
    font-family: 'Courier New', monospace;
    font-weight: bold;
    min-width: 25px;
    text-align: right;
}

.ping-unit {
    color: rgba(255, 255, 255, 0.6);
    font-size: 0.65rem;
}

/* Ping quality colors */
.ping-indicator.good {
    border-color: rgba(0, 255, 100, 0.4);
}

.ping-indicator.good .ping-value {
    color: #00ff64;
}

.ping-indicator.medium {
    border-color: rgba(255, 200, 0, 0.4);
}

.ping-indicator.medium .ping-value {
    color: #ffc800;
}

.ping-indicator.bad {
    border-color: rgba(255, 75, 75, 0.4);
}

.ping-indicator.bad .ping-value {
    color: #ff4b4b;
}

.status-display {
    text-align: center;
    margin: 20px 0;
}

.check-alert {
    color: #ff4b4b;
    font-weight: bold;
    margin-top: 5px;
    animation: pulse 1s infinite;
}

.lan-msg {
    font-size: 0.9em;
    color: #aaa;
    margin-top: 5px;
    font-style: italic;
}

/* Variant Info Box */
.variant-info-box {
    background: linear-gradient(135deg, rgba(0, 210, 255, 0.1), rgba(128, 0, 255, 0.1));
    border: 1px solid rgba(0, 210, 255, 0.3);
    border-radius: 10px;
    padding: 10px 12px;
    margin: 10px 0;
    text-align: left;
}

.variant-info-header {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 5px;
}

#variantInfoName {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--accent);
}

.variant-info-desc {
    font-size: 0.75rem;
    color: #bbb;
    margin: 0;
    line-height: 1.4;
}

/* ANALYSIS - Modern Redesign */
.analysis-box {
    text-align: center;
    margin-bottom: 15px;
    padding: 10px;
    background: linear-gradient(135deg, rgba(0, 210, 255, 0.1), rgba(128, 0, 255, 0.1));
    border-radius: 12px;
    border: 1px solid rgba(0, 210, 255, 0.3);
    backdrop-filter: blur(10px);
}

.analysis-header {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--accent);
    margin-bottom: 8px;
}

.analysis-icon {
    font-size: 1rem;
}

.analysis-move-info {
    background: rgba(0, 0, 0, 0.3);
    padding: 5px 12px;
    border-radius: 15px;
    margin-bottom: 10px;
    font-size: 0.8rem;
    color: #aaa;
}

#moveCounter {
    font-weight: 500;
    color: white;
}

.nav-btns {
    display: flex;
    justify-content: center;
    gap: 4px;
    margin-bottom: 10px;
}

.nav-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 6px 8px;
    min-width: 45px;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.1), rgba(255, 255, 255, 0.05));
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: white;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.nav-btn:hover {
    background: linear-gradient(180deg, var(--accent), rgba(0, 210, 255, 0.7));
    color: black;
    transform: translateY(-1px);
    box-shadow: 0 2px 10px rgba(0, 210, 255, 0.4);
}

.nav-btn:active {
    transform: translateY(0);
}

.nav-btn.nav-main {
    min-width: 55px;
    background: linear-gradient(180deg, rgba(0, 210, 255, 0.3), rgba(0, 210, 255, 0.15));
    border-color: rgba(0, 210, 255, 0.4);
}

.nav-icon {
    font-size: 1rem;
    line-height: 1;
}

.nav-label {
    font-size: 0.55rem;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    opacity: 0.85;
    margin-top: 2px;
}

.btn-exit-analysis {
    width: 100%;
    padding: 7px;
    background: linear-gradient(135deg, #ff4b4b, #c0392b);
    border: none;
    color: white;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.75rem;
    font-weight: 500;
    transition: all 0.2s ease;
}

.btn-exit-analysis:hover {
    background: linear-gradient(135deg, #ff6b6b, #e74c3c);
    box-shadow: 0 2px 10px rgba(255, 75, 75, 0.4);
}

.player-card {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 10px 0;
}

.avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    color: #000;
}

.bg-dark {
    background: #888;
}

.bg-accent {
    background: var(--accent);
}

.input-glass {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid #555;
    color: white;
    padding: 10px;
    width: 100%;
    border-radius: 8px;
    margin-bottom: 10px;
}

.input-glass option {
    background: #222;
}

.btn-primary,
.btn-secondary,
.btn-danger {
    border: none;
    padding: 12px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    margin-bottom: 5px;
}

.btn-primary {
    background: var(--accent);
    color: #000;
    width: 100%;
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    width: 100%;
}

.btn-danger {
    background: #ff4b4b;
    color: #fff;
    width: 100%;
}

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

.btn-group .full {
    width: 100%;
}

.board-container {
    height: 90vh;
    display: flex;
    flex-direction: row;
    justify-content: center;
    align-items: center;
    gap: 15px;
}

.board-frame {
    padding: 20px;
    width: min(85vmin, 750px);
    /* Height is auto to allow dynamic aspect ratio based on board dimensions */
    height: auto;
    /* aspect-ratio is set dynamically by JavaScript based on cols/rows */
    display: flex;
    flex-shrink: 0;
}

.board {
    width: 100%;
    height: 100%;
    /* Height is derived from aspect-ratio set on parent .board-frame */
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    position: relative;
}

.square {
    width: 100%;
    /* Height controlled by grid-template-rows in parent .board */
    /* aspect-ratio removed to allow proper piece alignment */
    position: relative;
}

.light {
    background: var(--sq-light);
}

.dark {
    background: var(--sq-dark);
}

.highlight {
    background: var(--highlight) !important;
}

/* HINT */
.hint-move {
    position: absolute;
    width: 30%;
    height: 30%;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 50%;
    top: 35%;
    left: 35%;
    pointer-events: none;
    z-index: 5;
}

.hint-capture {
    position: absolute;
    width: 100%;
    height: 100%;
    border: 6px solid rgba(0, 0, 0, 0.2);
    border-radius: 50%;
    box-sizing: border-box;
    pointer-events: none;
    z-index: 5;
}

.piece {
    width: 12.5%;
    height: 12.5%;
    position: absolute;
    top: 0;
    left: 0;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center bottom;
    cursor: grab;
    z-index: 10;
    transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.piece.dragging {
    z-index: 100;
    transition: none;
    cursor: grabbing;
    pointer-events: none;
}

/* PROMOTION STYLES */
.promo-options {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin: 20px 0;
}

.promo-btn {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid #555;
    border-radius: 8px;
    padding: 10px;
    cursor: pointer;
    color: white;
    flex: 1;
    transition: 0.2s;
}

.promo-btn:hover {
    background: var(--accent);
    color: black;
}

.promo-btn span {
    font-size: 2rem;
    display: block;
    margin-bottom: 5px;
}

/* Kita akan ganti span dengan gambar SVG di JS nanti */
.promo-btn img {
    width: 40px;
    height: 40px;
    display: block;
    margin: 0 auto 5px auto;
}

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

.modal-overlay.active {
    display: flex;
}

.modal-card {
    width: 400px;
    padding: 30px;
    text-align: center;
}

.tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}

.tab-btn {
    background: transparent;
    border: none;
    color: #aaa;
    padding: 10px;
    cursor: pointer;
    flex: 1;
    border-bottom: 2px solid transparent;
}

.tab-btn.active {
    color: white;
    border-bottom: 2px solid var(--accent);
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

.col-btn {
    padding: 10px;
    border: 1px solid #555;
    background: transparent;
    color: #fff;
    cursor: pointer;
}

.col-btn.selected {
    background: var(--accent);
    color: #000;
}

.color-choice {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin-bottom: 15px;
}

.small-text {
    font-size: 0.8rem;
    margin-bottom: 5px;
    color: #ccc;
}

/* CHAT PANEL - RIGHT SIDE FLOATING */
.chat-panel-right {
    position: fixed;
    right: 20px;
    top: 20px;
    bottom: 20px;
    height: auto;
    width: 420px;
    background: rgba(15, 12, 41, 0.98);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(0, 210, 255, 0.3);
    border-radius: 20px;
    box-shadow: -4px 0 24px rgba(0, 0, 0, 0.5);
    z-index: 500;
    display: flex;
    flex-direction: column;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.3s;
}

.chat-panel-right.hidden {
    transform: translateX(120%);
    opacity: 0;
    pointer-events: none;
}

.chat-float-btn {
    position: fixed;
    right: 20px;
    bottom: 20px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, #00d2ff, #00a2cc);
    border: none;
    font-size: 1.8rem;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(0, 210, 255, 0.4);
    z-index: 499;
    transition: transform 0.3s, box-shadow 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chat-float-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 30px rgba(0, 210, 255, 0.6);
}

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

.chat-float-btn.hidden {
    display: none;
}

/* Unread message badge */
.chat-float-btn .chat-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: linear-gradient(135deg, #ff4b4b, #ff6b6b);
    color: white;
    font-size: 0.75rem;
    font-weight: 700;
    min-width: 22px;
    height: 22px;
    border-radius: 11px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 6px;
    box-shadow: 0 2px 8px rgba(255, 75, 75, 0.5);
    transform: scale(0);
    transition: transform 0.2s ease;
}

.chat-float-btn .chat-badge.visible {
    transform: scale(1);
    animation: badgePop 0.3s ease;
}

/* Pulsing animation when unread */
.chat-float-btn.has-unread {
    animation: chatPulse 1.5s ease-in-out infinite;
}

@keyframes badgePop {
    0% {
        transform: scale(0);
    }

    50% {
        transform: scale(1.2);
    }

    100% {
        transform: scale(1);
    }
}

@keyframes chatPulse {

    0%,
    100% {
        box-shadow: 0 4px 20px rgba(0, 210, 255, 0.4);
    }

    50% {
        box-shadow: 0 4px 30px rgba(255, 75, 75, 0.6), 0 0 0 8px rgba(255, 75, 75, 0.2);
    }
}

.chat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    background: linear-gradient(135deg, rgba(0, 210, 255, 0.15), rgba(0, 162, 204, 0.15));
    border-bottom: 1px solid rgba(0, 210, 255, 0.3);
    border-radius: 20px 20px 0 0;
}

.chat-header h3 {
    font-size: 1.2rem;
    margin: 0;
    color: var(--accent);
    font-weight: 600;
}

.chat-toggle-btn {
    background: transparent;
    border: none;
    color: var(--accent);
    cursor: pointer;
    font-size: 1.2rem;
    padding: 5px 10px;
    transition: transform 0.2s, color 0.2s;
    border-radius: 4px;
}

.chat-toggle-btn:hover {
    transform: scale(1.2);
    color: #ff4b4b;
    background: rgba(255, 75, 75, 0.1);
}

.chat-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.chat-messages::-webkit-scrollbar {
    width: 8px;
}

.chat-messages::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 4px;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, #00d2ff, #00a2cc);
    border-radius: 4px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(180deg, #00e5ff, #00b8e6);
}

.chat-message {
    padding: 10px 14px;
    border-radius: 12px;
    max-width: 80%;
    word-wrap: break-word;
    animation: slideInChat 0.3s ease;
    position: relative;
}

.chat-message.sent {
    background: linear-gradient(135deg, #00d2ff, #00a2cc);
    color: #000;
    align-self: flex-end;
    margin-left: auto;
    border-bottom-right-radius: 4px;
    font-weight: 500;
}

.chat-message.received {
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
    align-self: flex-start;
    border-bottom-left-radius: 4px;
    border-left: 3px solid var(--accent);
}

.chat-message .text {
    font-size: 0.95rem;
    line-height: 1.4;
}

.chat-input-container {
    display: flex;
    gap: 10px;
    padding: 20px;
    background: rgba(0, 0, 0, 0.3);
    border-top: 1px solid rgba(0, 210, 255, 0.2);
    position: relative;
    border-radius: 0 0 20px 20px;
}

.emoji-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.2);
    padding: 10px 14px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1.2rem;
    transition: background 0.2s, transform 0.2s;
}

.emoji-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: scale(1.1);
}

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

/* Emoji Picker Panel */
.emoji-picker {
    position: absolute;
    bottom: 70px;
    left: 10px;
    right: 10px;
    background: rgba(15, 12, 41, 0.98);
    backdrop-filter: blur(20px);
    border: 2px solid rgba(0, 210, 255, 0.5);
    border-radius: 12px;
    padding: 15px;
    box-shadow: 0 -4px 30px rgba(0, 210, 255, 0.3);
    max-height: 300px;
    display: flex;
    flex-direction: column;
    z-index: 1000;
}

.emoji-picker.hidden {
    display: none !important;
}

.emoji-categories {
    display: flex;
    gap: 5px;
    padding: 5px;
    border-bottom: 1px solid rgba(0, 210, 255, 0.2);
    margin-bottom: 10px;
}

.emoji-cat-btn {
    background: transparent;
    border: none;
    padding: 8px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 1.3rem;
    transition: background 0.2s;
    opacity: 0.5;
}

.emoji-cat-btn:hover {
    background: rgba(0, 210, 255, 0.1);
    opacity: 1;
}

.emoji-cat-btn.active {
    background: rgba(0, 210, 255, 0.2);
    opacity: 1;
}

.emoji-grid {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 5px;
    overflow-y: auto;
    max-height: 180px;
    padding: 5px;
}

.emoji-grid::-webkit-scrollbar {
    width: 6px;
}

.emoji-grid::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 3px;
}

.emoji-grid::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, #00d2ff, #00a2cc);
    border-radius: 3px;
}

.emoji-item {
    background: transparent;
    border: none;
    padding: 8px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 1.5rem;
    transition: background 0.2s, transform 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.emoji-item:hover {
    background: rgba(0, 210, 255, 0.2);
    transform: scale(1.2);
}

.emoji-item:active {
    transform: scale(0.9);
}

.sticker-item {
    background: transparent;
    border: none;
    padding: 5px;
    border-radius: 6px;
    cursor: pointer;
    transition: transform 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.sticker-item img {
    width: 50px;
    height: 50px;
    min-width: 50px;
    min-height: 50px;
    object-fit: contain;
    display: block;
}

.sticker-item:hover {
    background: rgba(0, 210, 255, 0.2);
    transform: scale(1.1);
}

.chat-message.sticker-msg {
    background: transparent !important;
    padding: 5px !important;
    border: none !important;
    box-shadow: none !important;
    max-width: 120px !important;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chat-message.sticker-msg img {
    width: 100px;
    height: 100px;
    max-width: 100px;
    max-height: 100px;
    min-width: 80px;
    min-height: 80px;
    object-fit: contain;
    border-radius: 8px;
    border: 2px solid rgba(0, 210, 255, 0.3);
    background: rgba(255, 255, 255, 0.05);
    padding: 5px;
    display: block;
}

.chat-input {
    flex: 1;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 0.95rem;
    transition: border-color 0.2s, background 0.2s;
}

.chat-input::placeholder {
    color: rgba(255, 255, 255, 0.4);
}

.chat-input:focus {
    outline: none;
    border-color: var(--accent);
    background: rgba(255, 255, 255, 0.08);
}

.chat-send-btn {
    background: linear-gradient(135deg, #00d2ff, #00a2cc);
    border: none;
    padding: 12px 18px;
    border-radius: 8px;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    font-size: 1.3rem;
    box-shadow: 0 2px 8px rgba(0, 210, 255, 0.3);
    flex-shrink: 0;
}

.chat-send-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 210, 255, 0.5);
}

.chat-send-btn:active {
    transform: translateY(0);
}

@keyframes slideInChat {
    from {
        opacity: 0;
        transform: translateY(15px);
    }

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

@keyframes pulse {
    0% {
        transform: scale(1);
        opacity: 1;
    }

    50% {
        transform: scale(1.05);
        opacity: 0.8;
    }

    100% {
        transform: scale(1);
        opacity: 1;
    }
}


/* ============ MOBILE RESPONSIVE STYLES ============ */

/* Tablet landscape and smaller desktops */
@media (max-width: 1200px) {
    .app-layout {
        gap: 15px;
        padding: 15px;
    }

    .sidebar {
        width: 280px;
        padding: 20px;
    }

    .board-frame {
        width: min(80vmin, 650px);
        height: auto;
        padding: 15px;
    }

    .app-layout.chat-open {
        padding-right: 380px;
    }

    .chat-panel-right {
        width: 360px;
    }
}

/* Tablet portrait */
@media (max-width: 900px) {
    body {
        overflow-x: hidden;
        overflow-y: auto;
        height: auto;
        min-height: 100vh;
    }

    .app-layout {
        flex-direction: column;
        height: auto;
        min-height: 100vh;
        gap: 15px;
        padding: 10px;
        padding-bottom: 80px;
    }

    .app-layout.chat-open {
        padding-right: 10px;
    }

    .sidebar {
        width: 100%;
        height: auto;
        order: 2;
        padding: 0;
        min-height: auto;
        border-radius: 12px;
        overflow: hidden;
    }

    /* Mobile Menu Header - Visible on mobile */
    .mobile-menu-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 12px 15px;
        background: linear-gradient(135deg, rgba(0, 210, 255, 0.15), rgba(0, 162, 204, 0.1));
        border-bottom: 1px solid rgba(0, 210, 255, 0.2);
        cursor: pointer;
    }

    .mobile-menu-summary {
        display: flex;
        align-items: center;
        gap: 12px;
        flex-wrap: wrap;
    }

    .mobile-brand {
        font-weight: 700;
        font-size: 1rem;
        color: var(--accent);
    }

    .mobile-status {
        font-size: 0.85rem;
        color: #fff;
        background: rgba(255, 255, 255, 0.1);
        padding: 3px 10px;
        border-radius: 12px;
    }

    .mobile-timer {
        font-family: 'Courier New', monospace;
        font-size: 0.9rem;
        font-weight: bold;
        color: #00ffaa;
        background: rgba(0, 255, 170, 0.15);
        padding: 3px 10px;
        border-radius: 8px;
        border: 1px solid rgba(0, 255, 170, 0.3);
    }

    .mobile-timer.hidden {
        display: none;
    }

    /* Mobile Check Indicator */
    .mobile-check {
        font-size: 0.8rem;
        font-weight: bold;
        color: #fff;
        background: linear-gradient(135deg, #ff4444 0%, #cc0000 100%);
        padding: 3px 10px;
        border-radius: 8px;
        border: 1px solid rgba(255, 68, 68, 0.5);
        animation: pulseCheck 1s ease-in-out infinite;
        box-shadow: 0 0 10px rgba(255, 0, 0, 0.5);
    }

    .mobile-check.hidden {
        display: none;
    }

    @keyframes pulseCheck {

        0%,
        100% {
            transform: scale(1);
            box-shadow: 0 0 10px rgba(255, 0, 0, 0.5);
        }

        50% {
            transform: scale(1.05);
            box-shadow: 0 0 20px rgba(255, 0, 0, 0.8);
        }
    }

    .mobile-menu-toggle {
        display: flex;
        align-items: center;
        gap: 6px;
        background: rgba(0, 210, 255, 0.2);
        border: 1px solid rgba(0, 210, 255, 0.4);
        color: var(--accent);
        padding: 8px 14px;
        border-radius: 20px;
        cursor: pointer;
        font-size: 0.85rem;
        font-weight: 600;
        transition: all 0.2s ease;
    }

    .mobile-menu-toggle:hover {
        background: rgba(0, 210, 255, 0.3);
    }

    .mobile-menu-toggle:active {
        transform: scale(0.95);
    }

    .toggle-icon {
        transition: transform 0.3s ease;
    }

    .sidebar.collapsed .toggle-icon {
        transform: rotate(0deg);
    }

    .sidebar.expanded .toggle-icon {
        transform: rotate(180deg);
    }

    /* Sidebar Content - Collapsible */
    .sidebar-content {
        max-height: 0;
        overflow: hidden;
        transition: max-height 0.4s cubic-bezier(0.4, 0, 0.2, 1), padding 0.3s ease;
        padding: 0 15px;
    }

    .sidebar.expanded .sidebar-content {
        max-height: 1000px;
        padding: 15px;
    }

    .sidebar.collapsed .sidebar-content {
        max-height: 0;
        padding: 0 15px;
    }

    /* Hide brand in sidebar-content on mobile since we have mobile header */
    .sidebar .sidebar-content .brand {
        display: none;
    }

    .board-container {
        order: 1;
        width: 100%;
        height: auto;
        flex-direction: column;
        gap: 10px;
    }

    .board-frame {
        width: calc(100vw - 20px);
        /* Height auto to allow dynamic aspect-ratio for non-square boards */
        height: auto;
        max-width: 500px;
        /* Remove max-height to allow proper aspect ratio */
        padding: 10px;
        margin: 0 auto;
    }

    /* Pocket panel untuk Crazyhouse - horizontal compact di mobile */
    .pocket-panel {
        flex-direction: row;
        justify-content: space-around;
        align-items: flex-start;
        min-width: auto;
        max-height: none;
        width: 100%;
        padding: 8px;
        gap: 10px;
    }

    .pocket-section {
        flex-direction: column;
        gap: 4px;
        align-items: center;
        flex: 1;
    }

    .pocket-header {
        flex-direction: row;
        gap: 5px;
    }

    .pocket-label {
        font-size: 0.65rem;
    }

    .pocket-points {
        font-size: 0.7rem;
        padding: 1px 5px;
    }

    .pocket-pieces {
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: center;
        min-height: 30px;
        padding: 3px;
        gap: 4px;
    }

    .pocket-pieces.droppable,
    .pocket-pieces.captured {
        padding: 4px;
        margin-bottom: 3px;
    }

    .pocket-pieces.droppable::before,
    .pocket-pieces.captured::before {
        font-size: 0.5rem;
        margin-bottom: 2px;
    }

    .pocket-piece {
        width: 28px;
        height: 28px;
    }

    .pocket-piece .count {
        font-size: 0.55rem;
        padding: 0 3px;
        min-width: 12px;
    }

    .pocket-divider {
        width: 1px;
        height: auto;
        min-height: 50px;
        margin: 0 5px;
        padding: 0;
    }

    .material-advantage {
        font-size: 0.75rem;
        padding: 1px 5px;
    }

    /* Brand and status */
    .brand h1 {
        font-size: 1.4rem;
    }

    .status-display h2 {
        font-size: 1.1rem;
    }

    /* Player cards - lebih compact */
    .player-card {
        margin: 8px 0;
    }

    .avatar {
        width: 35px;
        height: 35px;
        font-size: 0.8rem;
    }

    .player-timer {
        font-size: 1.1rem;
        padding: 4px 10px;
        min-width: 70px;
    }

    /* Controls */
    .controls {
        margin-top: 10px;
    }

    .controls label {
        font-size: 0.85rem;
    }

    .input-glass {
        padding: 10px;
        font-size: 0.9rem;
    }

    .btn-primary,
    .btn-secondary,
    .btn-danger {
        padding: 12px;
        font-size: 0.9rem;
    }

    .btn-group {
        gap: 8px;
    }

    /* Variant info box */
    .variant-info-box {
        padding: 8px 10px;
        margin: 8px 0;
    }

    #variantInfoName {
        font-size: 0.8rem;
    }

    .variant-info-desc {
        font-size: 0.7rem;
    }

    /* Analysis box */
    .analysis-box {
        padding: 8px;
        margin-bottom: 10px;
    }

    .nav-btns {
        gap: 3px;
    }

    .nav-btn {
        padding: 5px;
        min-width: 40px;
    }

    .nav-icon {
        font-size: 0.9rem;
    }

    .nav-label {
        font-size: 0.5rem;
    }

    /* Chat panel full-screen overlay on mobile */
    .chat-panel-right {
        position: fixed;
        left: 0;
        right: 0;
        top: 0;
        bottom: 0;
        width: 100%;
        max-width: 100vw;
        border-radius: 0;
        z-index: 600;
    }

    .chat-float-btn {
        right: 15px;
        bottom: 80px;
        width: 55px;
        height: 55px;
        font-size: 1.5rem;
        z-index: 550;
    }

    .emoji-picker {
        left: 5px;
        right: 5px;
        bottom: 60px;
        max-height: 250px;
    }

    .emoji-grid {
        grid-template-columns: repeat(7, 1fr);
        max-height: 150px;
    }

    /* Modal styling for mobile */
    .modal-card {
        width: 95vw !important;
        max-width: 400px;
        max-height: 90vh;
        overflow-y: auto;
        padding: 20px;
    }

    .modal-card h2 {
        font-size: 1.3rem;
    }

    .modal-card h3 {
        font-size: 1.1rem;
    }

    /* Tabs */
    .tabs {
        gap: 5px;
    }

    .tab-btn {
        padding: 8px 5px;
        font-size: 0.85rem;
    }

    /* Time control section */
    .time-control-section {
        margin: 10px 0;
        padding: 12px;
    }

    .time-control-section label {
        font-size: 0.9rem;
    }

    /* Color choice buttons */
    .color-choice {
        gap: 8px;
    }

    .col-btn {
        padding: 8px;
        font-size: 0.9rem;
    }

    /* Promotion modal */
    .promo-options {
        gap: 8px;
        flex-wrap: wrap;
    }

    .promo-btn {
        padding: 8px;
        min-width: 60px;
    }

    .promo-btn img {
        width: 35px;
        height: 35px;
    }

    .promo-btn span {
        font-size: 1.6rem;
    }
}

/* Mobile phones - portrait */
@media (max-width: 600px) {
    .app-layout {
        padding: 8px;
        gap: 10px;
        padding-bottom: 70px;
    }

    .sidebar {
        padding: 12px;
        border-radius: 10px;
    }

    .board-frame {
        width: calc(100vw - 16px);
        height: auto;
        max-width: calc(100vw - 16px);
        padding: 8px;
        border-radius: 12px;
    }

    /* Ensure board squares are touch-friendly */
    .square {
        touch-action: none;
    }

    .piece {
        touch-action: none;
        cursor: pointer;
    }

    /* Brand */
    .brand h1 {
        font-size: 1.2rem;
    }

    .badge {
        font-size: 0.7rem;
        padding: 3px 8px;
    }

    /* Status */
    .status-display h2 {
        font-size: 1rem;
    }

    .check-alert {
        font-size: 0.9rem;
    }

    /* Player cards - compact */
    .player-card {
        margin: 6px 0;
    }

    .avatar {
        width: 32px;
        height: 32px;
        font-size: 0.75rem;
    }

    .player-details .name {
        font-size: 0.9rem;
    }

    .player-timer {
        font-size: 1rem;
        padding: 3px 8px;
        min-width: 60px;
    }

    /* Hide some labels to save space */
    .controls label {
        font-size: 0.8rem;
    }

    /* Buttons - touch friendly */
    .btn-primary,
    .btn-secondary,
    .btn-danger {
        padding: 14px;
        font-size: 0.95rem;
        min-height: 48px;
    }

    .input-glass {
        padding: 12px;
        font-size: 1rem;
        min-height: 48px;
    }

    /* Analysis */
    .analysis-box {
        padding: 6px;
    }

    .analysis-header {
        font-size: 0.8rem;
    }

    .analysis-move-info {
        font-size: 0.75rem;
        padding: 4px 10px;
    }

    .nav-btns {
        gap: 2px;
    }

    .nav-btn {
        padding: 6px 4px;
        min-width: 38px;
    }

    .nav-icon {
        font-size: 1rem;
    }

    .nav-label {
        display: none;
    }

    .btn-exit-analysis {
        padding: 8px;
        font-size: 0.8rem;
    }

    /* Variant info */
    .variant-info-box {
        padding: 6px 8px;
        margin: 6px 0;
    }

    #variantInfoName {
        font-size: 0.75rem;
    }

    .variant-info-desc {
        font-size: 0.65rem;
    }

    /* Modal */
    .modal-overlay {
        padding: 10px;
    }

    .modal-card {
        width: calc(100vw - 20px) !important;
        max-width: none;
        padding: 15px;
        border-radius: 12px;
    }

    .modal-card h2 {
        font-size: 1.2rem;
        margin-bottom: 10px;
    }

    .modal-card h3 {
        font-size: 1rem;
    }

    /* Tabs compact */
    .tabs {
        margin-bottom: 15px;
        gap: 3px;
    }

    .tab-btn {
        padding: 10px 8px;
        font-size: 0.8rem;
    }

    /* Time control */
    .time-control-section {
        padding: 10px;
        margin: 8px 0;
    }

    .time-control-section label {
        font-size: 0.85rem;
        margin-bottom: 6px;
    }

    .time-control-section select {
        font-size: 0.95rem;
    }

    .small-text {
        font-size: 0.75rem;
    }

    /* Color choice */
    .color-choice {
        margin-bottom: 12px;
    }

    .col-btn {
        padding: 10px;
        font-size: 0.9rem;
        min-height: 44px;
    }

    /* AI level slider */
    #aiLevel {
        width: 100%;
        height: 30px;
    }

    /* Chat */
    .chat-header {
        padding: 15px;
    }

    .chat-header h3 {
        font-size: 1rem;
    }

    .chat-messages {
        padding: 15px;
        gap: 10px;
    }

    .chat-message {
        padding: 8px 12px;
        font-size: 0.9rem;
    }

    .chat-input-container {
        padding: 12px;
        gap: 8px;
    }

    .chat-input {
        padding: 10px 12px;
        font-size: 0.95rem;
    }

    .emoji-btn {
        padding: 8px 10px;
        font-size: 1.1rem;
    }

    .chat-send-btn {
        padding: 10px 14px;
        font-size: 1.2rem;
    }

    .chat-float-btn {
        right: 10px;
        bottom: 70px;
        width: 50px;
        height: 50px;
        font-size: 1.3rem;
    }

    /* Pocket panel */
    .pocket-panel {
        padding: 8px;
        gap: 12px;
        border-radius: 10px;
    }

    .pocket-piece {
        width: 35px;
        height: 35px;
    }

    .pocket-label {
        font-size: 0.7rem;
    }

    .pocket-points {
        font-size: 0.75rem;
        padding: 2px 6px;
    }

    /* Promotion */
    .promo-options {
        gap: 6px;
    }

    .promo-btn {
        padding: 10px 8px;
        min-width: 55px;
        font-size: 0.8rem;
    }

    .promo-btn img {
        width: 32px;
        height: 32px;
    }

    .promo-btn span {
        font-size: 1.4rem;
    }

    /* AI Thinking panel - compact for mobile */
    .ai-thinking-panel {
        left: 10px;
        bottom: 10px;
        width: auto;
        max-width: 160px;
        border-radius: 10px;
        font-size: 0.75rem;
    }

    .ai-thinking-header {
        padding: 6px 10px;
        font-size: 0.75rem;
    }

    .ai-thinking-header span {
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    /* Hide body entirely on mobile - show only header as indicator */
    .ai-thinking-body {
        display: none;
    }

    /* Make header ultra minimal - just a blinking badge */
    .ai-thinking-header {
        padding: 6px 12px;
        font-size: 0.75rem;
        border-radius: 20px;
        animation: aiBlink 1s ease-in-out infinite;
    }

    .ai-thinking-panel {
        border-radius: 20px;
        max-width: none;
        width: auto;
    }

    .ai-close-btn {
        display: none;
        /* Hide close button on mobile - auto-hides when done */
    }

    @keyframes aiBlink {

        0%,
        100% {
            opacity: 1;
        }

        50% {
            opacity: 0.5;
        }
    }

    /* Toast */
    .toast-container {
        top: 10px;
        left: 10px;
        right: 10px;
        transform: none;
    }

    .toast {
        padding: 10px 16px;
        font-size: 0.85rem;
        border-radius: 20px;
    }
}

/* Very small phones */
@media (max-width: 380px) {
    .app-layout {
        padding: 5px;
    }

    .sidebar {
        padding: 10px;
    }

    .board-frame {
        width: calc(100vw - 10px);
        height: auto;
        padding: 5px;
    }

    .brand h1 {
        font-size: 1.1rem;
    }

    .player-timer {
        font-size: 0.9rem;
        min-width: 55px;
    }

    .tab-btn {
        font-size: 0.75rem;
        padding: 8px 5px;
    }

    .modal-card {
        padding: 12px;
    }

    .btn-primary,
    .btn-secondary,
    .btn-danger {
        padding: 12px;
        font-size: 0.9rem;
    }
}

/* Landscape mode on mobile */
@media (max-height: 500px) and (orientation: landscape) {
    .app-layout {
        flex-direction: row;
        height: 100vh;
        overflow-y: hidden;
        padding: 10px;
        padding-bottom: 10px;
    }

    .sidebar {
        width: 200px;
        height: 100%;
        order: 1;
        overflow-y: auto;
        padding: 10px;
    }

    .board-container {
        order: 2;
        flex: 1;
        height: 100%;
    }

    .board-frame {
        width: min(90vh, 400px);
        height: auto;
        max-width: min(90vh, 400px);
    }

    .brand h1 {
        font-size: 1rem;
    }

    .player-card {
        margin: 5px 0;
    }

    .avatar {
        width: 28px;
        height: 28px;
        font-size: 0.7rem;
    }

    .player-timer {
        font-size: 0.85rem;
        padding: 2px 6px;
    }

    .status-display h2 {
        font-size: 0.9rem;
    }

    .variant-info-box {
        display: none;
    }

    .controls label {
        font-size: 0.75rem;
        margin-bottom: 3px;
    }

    .input-glass {
        padding: 6px;
        font-size: 0.8rem;
        margin-bottom: 5px;
    }

    .btn-group {
        gap: 5px;
    }

    .btn-primary,
    .btn-secondary,
    .btn-danger {
        padding: 8px;
        font-size: 0.8rem;
    }

    /* Modal in landscape */
    .modal-card {
        max-height: 95vh;
        overflow-y: auto;
    }

    .time-control-section {
        padding: 8px;
        margin: 5px 0;
    }

    .chat-float-btn {
        bottom: 10px;
        right: 10px;
        width: 45px;
        height: 45px;
    }
}

/* Touch device improvements */
@media (hover: none) and (pointer: coarse) {

    /* Larger tap targets */
    .btn-primary,
    .btn-secondary,
    .btn-danger,
    .tab-btn,
    .col-btn,
    .nav-btn {
        min-height: 44px;
    }

    .input-glass {
        min-height: 44px;
        font-size: 16px;
        /* Prevents iOS zoom on focus */
    }

    /* Disable hover effects that might be annoying on touch */
    .nav-btn:hover {
        transform: none;
    }

    .promo-btn:hover {
        background: rgba(255, 255, 255, 0.1);
        color: white;
    }

    /* Better active states */
    .btn-primary:active,
    .btn-secondary:active,
    .btn-danger:active {
        transform: scale(0.98);
        opacity: 0.9;
    }

    .nav-btn:active {
        background: linear-gradient(180deg, var(--accent), rgba(0, 210, 255, 0.7));
        color: black;
    }
}

/* ============ TIMER STYLES ============ */
.player-details {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.player-timer {
    font-family: 'Courier New', monospace;
    font-size: 1.4rem;
    font-weight: bold;
    padding: 6px 12px;
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.4);
    color: #00ffaa;
    text-align: center;
    min-width: 80px;
    border: 2px solid rgba(0, 255, 170, 0.3);
    transition: all 0.3s ease;
}

.player-timer.active {
    background: rgba(0, 255, 170, 0.15);
    border-color: #00ffaa;
    box-shadow: 0 0 15px rgba(0, 255, 170, 0.4);
    animation: timerPulse 1s infinite;
}

.player-timer.warning {
    color: #ffc107;
    border-color: #ffc107;
    background: rgba(255, 193, 7, 0.15);
    box-shadow: 0 0 15px rgba(255, 193, 7, 0.4);
}

.player-timer.critical {
    color: #ff4b4b;
    border-color: #ff4b4b;
    background: rgba(255, 75, 75, 0.15);
    animation: timerCritical 0.5s infinite;
}

.player-timer.unlimited {
    color: #aaa;
    font-size: 1.1rem;
}

@keyframes timerPulse {

    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.02);
    }
}

@keyframes timerCritical {

    0%,
    100% {
        opacity: 1;
        transform: scale(1);
    }

    50% {
        opacity: 0.7;
        transform: scale(1.05);
    }
}

/* Time Control Section in Menu */
.time-control-section {
    margin: 15px 0;
    padding: 15px;
    background: rgba(0, 210, 255, 0.1);
    border-radius: 10px;
    border: 1px solid rgba(0, 210, 255, 0.2);
}

.time-control-section label {
    display: block;
    margin-bottom: 8px;
    font-size: 0.95rem;
    color: var(--accent);
}

.time-control-section select {
    font-size: 1rem;
}

/* ============ BOARD COLOR THEMES ============ */

/* Default Theme */
.board.board-default .light {
    background: #e0e0e0;
}

.board.board-default .dark {
    background: #3a7ca5;
}

/* Classic Wood Theme */
.board.board-wood .light {
    background: #f0d9b5;
}

.board.board-wood .dark {
    background: #b58863;
}

/* Green Tournament */
.board.board-green .light {
    background: #eeeed2;
}

.board.board-green .dark {
    background: #769656;
}

/* Blue Ocean */
.board.board-ocean .light {
    background: #dee3e6;
}

.board.board-ocean .dark {
    background: #5f9ea0;
}

/* Purple Royal */
.board.board-purple .light {
    background: #e8d5f0;
}

.board.board-purple .dark {
    background: #7b5e99;
}

/* Pink Candy */
.board.board-pink .light {
    background: #fff0f5;
}

.board.board-pink .dark {
    background: #db7093;
}

/* Orange Sunset */
.board.board-sunset .light {
    background: #fff8dc;
}

.board.board-sunset .dark {
    background: #e07020;
}

/* Brown Classic */
.board.board-brown .light {
    background: #f5deb3;
}

.board.board-brown .dark {
    background: #8b4513;
}

/* Gray Modern */
.board.board-gray .light {
    background: #e8e8e8;
}

.board.board-gray .dark {
    background: #6a6a6a;
}

/* Coral Reef */
.board.board-coral .light {
    background: #ffe4e1;
}

.board.board-coral .dark {
    background: #cd5c5c;
}

/* Teal Nature */
.board.board-teal .light {
    background: #e0f0f0;
}

.board.board-teal .dark {
    background: #008b8b;
}

/* Gold Luxury */
.board.board-gold .light {
    background: #fffacd;
}

.board.board-gold .dark {
    background: #b8860b;
}

/* Wine Elegant */
.board.board-wine .light {
    background: #f5e6e8;
}

.board.board-wine .dark {
    background: #722f37;
}

/* Mint Fresh */
.board.board-mint .light {
    background: #f0fff0;
}

.board.board-mint .dark {
    background: #3cb371;
}

/* Navy Military */
.board.board-navy .light {
    background: #d6e5f3;
}

.board.board-navy .dark {
    background: #1a3a5c;
}

/* Neon Gamer */
.board.board-neon .light {
    background: #1a1a2e;
}

.board.board-neon .dark {
    background: #16213e;
}

.board.board-neon .light {
    box-shadow: inset 0 0 8px rgba(0, 255, 255, 0.3);
}

.board.board-neon .dark {
    box-shadow: inset 0 0 8px rgba(255, 0, 255, 0.3);
}

/* ============ TOAST NOTIFICATION ============ */
.toast-container {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
}

.toast {
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(10px);
    color: white;
    padding: 12px 24px;
    border-radius: 30px;
    font-size: 0.95rem;
    display: flex;
    align-items: center;
    gap: 10px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.1);
    animation: toastSlideIn 0.3s ease, toastFadeOut 0.5s ease 2.5s forwards;
    pointer-events: auto;
}

.toast.info {
    border-left: 4px solid #00d2ff;
}

.toast.success {
    border-left: 4px solid #00ffaa;
}

.toast.warning {
    border-left: 4px solid #ffc107;
}

.toast.error {
    border-left: 4px solid #ff4b4b;
}

@keyframes toastSlideIn {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }

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

@keyframes toastFadeOut {
    from {
        opacity: 1;
    }

    to {
        opacity: 0;
        visibility: hidden;
    }
}

/* Crazyhouse Pocket Panel - Right Side */
.pocket-panel {
    display: flex;
    flex-direction: column;
    background: var(--glass-bg);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    padding: 15px;
    min-width: 80px;
    max-height: 80vh;
    gap: 10px;
}

.pocket-panel.hidden {
    display: none;
}

.pocket-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.pocket-label {
    font-size: 0.75rem;
    color: #aaa;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.pocket-section.self .pocket-label {
    color: var(--accent);
}

.pocket-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    gap: 8px;
}

.pocket-points {
    background: rgba(255, 255, 255, 0.1);
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 0.8rem;
    font-weight: bold;
    color: #fff;
}

.pocket-section.self .pocket-points {
    background: var(--accent);
    color: #000;
}

.pocket-divider {
    height: auto;
    min-height: 1px;
    background: rgba(255, 255, 255, 0.1);
    margin: 8px 0;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 5px 0;
}

.material-advantage {
    font-size: 0.9rem;
    font-weight: bold;
    padding: 2px 8px;
    border-radius: 8px;
}

.material-advantage.positive {
    color: #00ff88;
    background: rgba(0, 255, 136, 0.15);
}

.material-advantage.negative {
    color: #ff4b4b;
    background: rgba(255, 75, 75, 0.15);
}

.material-advantage.neutral {
    color: #888;
}

.pocket-pieces {
    display: flex;
    flex-direction: column;
    gap: 6px;
    align-items: center;
    min-height: 20px;
}

/* Droppable pieces (Crazyhouse/Seirawan) - can be dragged */
.pocket-pieces.droppable {
    border: 1px dashed rgba(0, 210, 255, 0.4);
    border-radius: 8px;
    padding: 5px;
    background: rgba(0, 210, 255, 0.05);
    margin-bottom: 5px;
}

.pocket-pieces.droppable::before {
    content: '🎯 Drop';
    font-size: 0.6rem;
    color: rgba(0, 210, 255, 0.7);
    margin-bottom: 3px;
}

.pocket-pieces.droppable.hidden {
    display: none;
}

/* Captured pieces - just for display */
.pocket-pieces.captured {
    border: 1px solid rgba(255, 75, 75, 0.2);
    border-radius: 8px;
    padding: 5px;
    background: rgba(255, 75, 75, 0.05);
}

.pocket-pieces.captured::before {
    content: '💀 Dimakan';
    font-size: 0.6rem;
    color: rgba(255, 75, 75, 0.7);
    margin-bottom: 3px;
}

.pocket-pieces.captured:empty::before {
    content: '💀 Dimakan';
    opacity: 0.4;
}

.pocket-pieces.captured:empty {
    min-height: 25px;
    opacity: 0.5;
}

.pocket-piece {
    width: 40px;
    height: 40px;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    cursor: grab;
    transition: transform 0.2s;
    position: relative;
}

/* Droppable pieces have cyan glow */
.pocket-pieces.droppable .pocket-piece {
    filter: drop-shadow(0 0 3px rgba(0, 210, 255, 0.5));
}

/* Captured pieces are grayed out slightly */
.pocket-pieces.captured .pocket-piece {
    cursor: default;
    filter: grayscale(0.2);
}

.pocket-pieces.captured .pocket-piece:hover {
    transform: scale(1.05);
}

.pocket-piece:hover {
    transform: scale(1.15);
}

.pocket-piece.dragging {
    cursor: grabbing;
    opacity: 0.7;
    z-index: 100;
}

.pocket-piece .count {
    position: absolute;
    bottom: -2px;
    right: -2px;
    background: var(--accent);
    color: #000;
    font-size: 0.65rem;
    font-weight: bold;
    padding: 1px 4px;
    border-radius: 6px;
    min-width: 14px;
    text-align: center;
}

/* ============ AI THINKING PANEL ============ */
.ai-thinking-panel {
    position: fixed;
    left: 20px;
    bottom: 20px;
    width: 280px;
    background: rgba(15, 12, 41, 0.95);
    backdrop-filter: blur(15px);
    border: 1px solid rgba(0, 210, 255, 0.4);
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
    z-index: 500;
    transition: transform 0.3s ease, opacity 0.3s ease;
    overflow: hidden;
}

.ai-turn .piece {
    pointer-events: none !important;
    opacity: 0.9;
    cursor: wait !important;
    filter: grayscale(0.3);
}

.ai-thinking-panel.hidden {
    transform: translateY(120%);
    opacity: 0;
    pointer-events: none;
}

.ai-thinking-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 15px;
    background: linear-gradient(135deg, rgba(255, 165, 0, 0.2), rgba(255, 200, 0, 0.1));
    border-bottom: 1px solid rgba(255, 165, 0, 0.3);
    font-weight: 600;
    color: #ffa500;
    animation: aiPulse 1.5s ease-in-out infinite;
}

.ai-close-btn {
    background: transparent;
    border: none;
    color: #aaa;
    cursor: pointer;
    font-size: 1rem;
    padding: 2px 6px;
    transition: color 0.2s;
}

.ai-close-btn:hover {
    color: #ff4b4b;
}

.ai-thinking-body {
    padding: 12px 15px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.ai-stat {
    display: flex;
    gap: 8px;
    font-size: 0.9rem;
}

.ai-label {
    color: #aaa;
    min-width: 50px;
}

.ai-value {
    color: #00d2ff;
    font-weight: 600;
    font-family: 'Courier New', monospace;
}

.ai-pv .ai-value {
    font-size: 0.8rem;
    word-break: break-all;
    max-height: 40px;
    overflow: hidden;
    text-overflow: ellipsis;
}

@keyframes aiPulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.6;
    }
}

/* ============ MOBILE POCKET HORIZONTAL LAYOUT ============ */
/* Must be at end to override base styles */
@media (max-width: 900px) {
    .pocket-panel {
        flex-direction: row !important;
        justify-content: space-around !important;
        width: 100% !important;
        padding: 8px !important;
        gap: 8px !important;
    }

    .pocket-section {
        flex-direction: column !important;
        gap: 3px !important;
        align-items: center !important;
        flex: 1 !important;
    }

    .pocket-section .pocket-header {
        flex-direction: row !important;
        gap: 4px !important;
    }

    .pocket-section .pocket-label {
        font-size: 0.6rem !important;
    }

    .pocket-section .pocket-points {
        font-size: 0.65rem !important;
        padding: 1px 4px !important;
    }

    /* Force horizontal row for pieces */
    .pocket-section .pocket-pieces {
        flex-direction: row !important;
        flex-wrap: wrap !important;
        justify-content: center !important;
        gap: 4px !important;
        padding: 4px !important;
        min-height: 28px !important;
    }

    .pocket-section .pocket-pieces.droppable,
    .pocket-section .pocket-pieces.captured {
        margin-bottom: 2px !important;
    }

    .pocket-section .pocket-pieces::before {
        font-size: 0.5rem !important;
    }

    .pocket-section .pocket-piece {
        width: 26px !important;
        height: 26px !important;
    }

    .pocket-section .pocket-piece .count {
        font-size: 0.5rem !important;
        padding: 0 2px !important;
        min-width: 10px !important;
    }

    .pocket-divider {
        width: 1px !important;
        height: auto !important;
        min-height: 40px !important;
        margin: 0 5px !important;
    }

    .material-advantage {
        font-size: 0.7rem !important;
        padding: 1px 4px !important;
    }
}

/* ========== GLOBAL CHAT PANEL ========== */
.global-chat-panel {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 320px;
    max-height: 400px;
    background: rgba(15, 12, 41, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 15px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    z-index: 100;
    backdrop-filter: blur(10px);
}

.global-chat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 15px;
    background: linear-gradient(135deg, rgba(0, 210, 255, 0.2), rgba(78, 205, 196, 0.2));
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    font-weight: 600;
}

.online-badge {
    background: linear-gradient(135deg, #4ecdc4, #00d2ff);
    color: #000;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
}

.player-name-section {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 10px 12px;
    background: rgba(255, 255, 255, 0.03);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.player-name-section label {
    font-size: 0.75rem;
    color: #888;
}

.name-input-wrapper {
    display: flex;
    gap: 6px;
}

.player-name-input {
    flex: 1;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 8px;
    padding: 6px 10px;
    color: #fff;
    font-size: 0.85rem;
    outline: none;
}

.player-name-input:focus {
    border-color: var(--accent);
}

.name-save-btn {
    background: linear-gradient(135deg, #4ecdc4, #00d2ff);
    color: #000;
    border: none;
    border-radius: 8px;
    width: 32px;
    height: 32px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: bold;
    transition: all 0.2s;
}

.name-save-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 2px 10px rgba(0, 210, 255, 0.4);
}

.global-chat-content {
    display: flex;
    flex-direction: column;
    flex: 1;
    overflow: hidden;
}

.online-users-section {
    max-height: 120px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    overflow-y: auto;
}

.online-users-header {
    padding: 8px 12px;
    font-size: 0.8rem;
    color: #aaa;
    background: rgba(255, 255, 255, 0.03);
    position: sticky;
    top: 0;
}

.online-users-list {
    padding: 5px;
}

.no-users {
    padding: 10px;
    text-align: center;
    color: #666;
    font-size: 0.8rem;
}

.online-user-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 10px;
    margin: 3px 0;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    font-size: 0.85rem;
}

.online-user-item .user-name {
    display: flex;
    align-items: center;
    gap: 6px;
}

.online-user-item .status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #4ecdc4;
}

.online-user-item .invite-btn {
    background: linear-gradient(135deg, #4ecdc4, #00d2ff);
    color: #000;
    border: none;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 0.7rem;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s;
}

.online-user-item .invite-btn:hover:not(:disabled) {
    transform: scale(1.05);
    box-shadow: 0 2px 10px rgba(0, 210, 255, 0.4);
}

.online-user-item .invite-btn:disabled {
    background: rgba(255, 165, 0, 0.3);
    color: #ffa500;
    cursor: not-allowed;
    transform: none;
}

/* Status dot colors */
.online-user-item .status-dot.online {
    background: #4ecdc4;
}

.online-user-item .status-dot.playing {
    background: #ffa500;
    animation: statusPulse 1.5s ease-in-out infinite;
}

@keyframes statusPulse {

    0%,
    100% {
        opacity: 1;
        transform: scale(1);
    }

    50% {
        opacity: 0.6;
        transform: scale(0.85);
    }
}

/* User status text */
.user-status-text {
    font-size: 0.65rem;
    padding: 2px 6px;
    border-radius: 8px;
    margin-left: 4px;
}

.online-user-item.online .user-status-text {
    background: rgba(78, 205, 196, 0.2);
    color: #4ecdc4;
}

.online-user-item.playing .user-status-text {
    background: rgba(255, 165, 0, 0.2);
    color: #ffa500;
}

/* Playing user row style */
.online-user-item.playing {
    opacity: 0.7;
}

.global-chat-messages-section {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 150px;
}

.global-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
    max-height: 180px;
}

.global-chat-msg {
    margin-bottom: 8px;
    font-size: 0.85rem;
    line-height: 1.4;
}

.global-chat-msg .msg-name {
    color: #4ecdc4;
    font-weight: 600;
    margin-right: 6px;
}

.global-chat-msg .msg-text {
    color: #ddd;
    word-break: break-word;
}

.global-chat-msg .msg-time {
    color: #666;
    font-size: 0.7rem;
    margin-left: 6px;
}

.global-chat-input-container {
    display: flex;
    gap: 8px;
    padding: 10px;
    background: rgba(255, 255, 255, 0.03);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.global-chat-input {
    flex: 1;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 20px;
    padding: 8px 15px;
    color: #fff;
    font-size: 0.85rem;
    outline: none;
}

.global-chat-input:focus {
    border-color: var(--accent);
}

.global-chat-send-btn {
    background: linear-gradient(135deg, #4ecdc4, #00d2ff);
    border: none;
    border-radius: 50%;
    width: 36px;
    height: 36px;
    cursor: pointer;
    font-size: 1rem;
    transition: all 0.2s;
}

.global-chat-send-btn:hover {
    transform: scale(1.1);
}

/* Invitation details in modal */
.invitation-details {
    background: rgba(255, 255, 255, 0.05);
    padding: 12px;
    border-radius: 10px;
    margin: 10px 0;
}

.invitation-details div {
    margin: 5px 0;
    font-size: 0.9rem;
}

.invitation-details strong {
    color: #4ecdc4;
}

/* Mobile responsive for global chat */
@media (max-width: 768px) {
    .global-chat-panel {
        width: calc(100% - 20px);
        right: 10px;
        bottom: 10px;
        max-height: 50px;
        /* Collapsed by default on mobile */
        overflow: hidden;
        transition: max-height 0.3s ease;
    }

    .global-chat-panel.expanded {
        max-height: 350px;
    }

    .global-chat-header {
        cursor: pointer;
    }

    .global-chat-header::after {
        content: '▲';
        margin-left: 8px;
        font-size: 0.7rem;
        transition: transform 0.3s;
    }

    .global-chat-panel.expanded .global-chat-header::after {
        transform: rotate(180deg);
    }

    .online-users-section {
        max-height: 80px;
    }

    .global-chat-messages {
        max-height: 100px;
    }

    .player-name-section {
        padding: 8px 10px;
    }

    /* AI Thinking indicator - even smaller on very small screens */
    .ai-thinking-panel {
        left: 5px;
        bottom: 5px;
    }

    .ai-thinking-header {
        padding: 4px 10px;
        font-size: 0.7rem;
    }
}

/* ========== OPEN CHALLENGE SYSTEM ========== */
.challenge-create-btn {
    background: linear-gradient(135deg, #ff6b6b, #ffa500);
    border: none;
    border-radius: 50%;
    width: 36px;
    height: 36px;
    min-width: 36px;
    cursor: pointer;
    font-size: 1rem;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.challenge-create-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 2px 15px rgba(255, 107, 107, 0.5);
}

/* Challenge message in chat */
.global-chat-msg.challenge-msg {
    margin-bottom: 12px;
    padding: 0;
}

.challenge-card {
    background: linear-gradient(135deg, rgba(255, 107, 107, 0.15), rgba(255, 165, 0, 0.15));
    border: 1px solid rgba(255, 165, 0, 0.4);
    border-radius: 12px;
    padding: 12px;
    transition: all 0.3s ease;
}

.challenge-card:hover {
    border-color: rgba(255, 165, 0, 0.7);
    box-shadow: 0 4px 20px rgba(255, 165, 0, 0.2);
}

.challenge-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
}

.challenge-icon {
    font-size: 1.2rem;
}

.challenge-creator {
    flex: 1;
    font-weight: 600;
    color: #ffa500;
}

.challenge-info {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 10px;
}

.challenge-info span {
    background: rgba(255, 255, 255, 0.1);
    padding: 4px 10px;
    border-radius: 15px;
    font-size: 0.8rem;
    color: #ddd;
}

.challenge-variant {
    background: linear-gradient(135deg, rgba(78, 205, 196, 0.2), rgba(0, 210, 255, 0.2)) !important;
    color: #4ecdc4 !important;
    font-weight: 600;
}

.challenge-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

.challenge-join-btn {
    background: linear-gradient(135deg, #4ecdc4, #00d2ff);
    color: #000;
    border: none;
    padding: 8px 20px;
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
    animation: challengePulse 2s ease-in-out infinite;
}

.challenge-join-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 15px rgba(0, 210, 255, 0.5);
}

.challenge-cancel-btn {
    background: rgba(255, 75, 75, 0.2);
    color: #ff6b6b;
    border: 1px solid rgba(255, 75, 75, 0.4);
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.challenge-cancel-btn:hover {
    background: rgba(255, 75, 75, 0.4);
    border-color: #ff6b6b;
}

.challenge-taken {
    text-align: center;
    padding: 15px;
    color: #4ecdc4;
    font-weight: 600;
}

.challenge-taken.cancelled {
    color: #ff6b6b;
}

@keyframes challengePulse {

    0%,
    100% {
        box-shadow: 0 0 0 0 rgba(0, 210, 255, 0.4);
    }

    50% {
        box-shadow: 0 0 0 8px rgba(0, 210, 255, 0);
    }
}

/* ========== PWA INSTALL BUTTON ========== */
.modal-header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.modal-header-row h2 {
    margin: 0;
}

.pwa-install-btn {
    background: linear-gradient(135deg, #4ecdc4, #00d2ff);
    color: #000;
    border: none;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    animation: installPulse 2s ease-in-out infinite;
}

.pwa-install-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 15px rgba(0, 210, 255, 0.5);
}

.pwa-install-btn.hidden {
    display: none;
}

@keyframes installPulse {

    0%,
    100% {
        box-shadow: 0 0 0 0 rgba(0, 210, 255, 0.4);
    }

    50% {
        box-shadow: 0 0 0 6px rgba(0, 210, 255, 0);
    }
}

/* PWA Standalone mode adjustments */
@media (display-mode: standalone) {
    body {
        /* Add safe area padding for notched devices */
        padding-top: env(safe-area-inset-top);
        padding-bottom: env(safe-area-inset-bottom);
        padding-left: env(safe-area-inset-left);
        padding-right: env(safe-area-inset-right);
    }

    .pwa-install-btn {
        display: none !important;
    }
}

/* ========== WELCOME MODAL STYLES ========== */
.welcome-modal {
    text-align: center;
    max-width: 400px;
}

.welcome-header {
    margin-bottom: 20px;
}

.welcome-emoji {
    font-size: 4rem;
    display: block;
    margin-bottom: 10px;
    animation: bounce 1s ease-in-out infinite;
}

@keyframes bounce {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-10px);
    }
}

.welcome-text {
    font-size: 1.1rem;
    color: rgba(255, 255, 255, 0.9);
    margin-bottom: 15px;
}

.welcome-hint {
    font-size: 0.85rem;
    color: rgba(255, 255, 255, 0.6);
    margin: 15px 0;
}

.pulse-btn {
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {

    0%,
    100% {
        box-shadow: 0 0 0 0 rgba(0, 210, 255, 0.5);
    }

    50% {
        box-shadow: 0 0 0 10px rgba(0, 210, 255, 0);
    }
}

/* Clickable player card */
.player-card.self {
    cursor: pointer;
    position: relative;
    transition: all 0.2s ease;
}

.player-card.self:hover {
    background: rgba(0, 210, 255, 0.15);
    transform: translateX(5px);
}

.player-card.self .edit-icon {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.9rem;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.player-card.self:hover .edit-icon {
    opacity: 1;
}

/* Modal buttons row */
.modal-buttons {
    display: flex;
    gap: 10px;
    margin-top: 20px;
}

.modal-buttons button {
    flex: 1;
}

/* Subtle username display style */
#selfPlayerName {
    color: var(--accent);
    font-weight: 600;
}