:root {
    --bg-dark: #1b1b1b;
    --bg-light: #262421;
    --primary: #7fa650;
    --primary-hover: #8cb558;
    --primary-shadow: #5b7a37;
    --secondary: #36383c;
    --secondary-hover: #414448;
    --secondary-shadow: #212325;
    --text-main: #f8fafc;
    --text-muted: #9ca3af;
    --accent-success: #10b981;
    --accent-error: #ef4444;
    --glass-bg: #262421;
    --glass-border: #3b3936;
}

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

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-dark);
    color: var(--text-main);
    min-height: 100vh;
    overflow-x: hidden;
    position: relative;
}

/* Dynamic background */
.background-animation {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: -1;
    background: linear-gradient(-45deg, #ff0050, #9b59b6, #00f2fe, #1b1b1b);
    background-size: 400% 400%;
    animation: gradientBG 15s ease infinite;
}

@keyframes gradientBG {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
}

header {
    text-align: center;
    margin-bottom: 3rem;
}

header h1 {
    font-size: 2.75rem;
    font-weight: 800;
    color: #fff;
    letter-spacing: -0.5px;
    margin-bottom: 0.5rem;
}

header p {
    color: var(--text-muted);
    font-size: 1.1rem;
}

.app-layout {
    display: grid;
    grid-template-columns: 350px 1fr;
    gap: 2rem;
    align-items: start;
}

.glass-panel {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    padding: 2rem;
    box-shadow: 0 4px 6px rgba(0,0,0,0.3);
}

.input-group {
    margin-bottom: 1.5rem;
}

.input-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: var(--text-muted);
}

.input-group input {
    width: 100%;
    padding: 0.75rem 1rem;
    border-radius: 8px;
    border: 1px solid var(--glass-border);
    background: rgba(15, 23, 42, 0.6);
    color: var(--text-main);
    font-size: 1rem;
    font-family: inherit;
    transition: border-color 0.3s;
}

.input-group input:focus {
    outline: none;
    border-color: var(--primary);
}

button {
    width: 100%;
    padding: 1rem;
    border-radius: 6px;
    border: none;
    font-family: inherit;
    font-size: 1rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    cursor: pointer;
    transition: background-color 0.15s ease, transform 0.1s ease, box-shadow 0.1s ease;
    margin-bottom: 0.5rem;
}

.primary-btn {
    background-color: var(--primary);
    color: white;
    box-shadow: 0 4px 0 var(--primary-shadow);
}

.primary-btn:hover {
    background-color: var(--primary-hover);
}

.primary-btn:active {
    transform: translateY(4px);
    box-shadow: 0 0px 0 var(--primary-shadow);
}

.secondary-btn {
    background-color: var(--secondary);
    color: white;
    box-shadow: 0 4px 0 var(--secondary-shadow);
}

.secondary-btn:hover {
    background-color: var(--secondary-hover);
}

.secondary-btn:active {
    transform: translateY(4px);
    box-shadow: 0 0px 0 var(--secondary-shadow);
}

.hidden {
    display: none !important;
}

.status-container {
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--glass-border);
}

.progress-bar {
    width: 100%;
    height: 6px;
    background: rgba(255,255,255,0.1);
    border-radius: 3px;
    margin-top: 0.5rem;
    overflow: hidden;
}

.progress {
    height: 100%;
    background: var(--primary);
    width: 0%;
    transition: width 0.3s;
}

.puzzle-info {
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--glass-border);
    animation: fadeIn 0.5s;
}

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

.puzzle-info h2 {
    font-size: 1.25rem;
    margin-bottom: 0.5rem;
}

.instruction {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 1rem;
    padding: 0.75rem;
    border-radius: 8px;
    background: rgba(255,255,255,0.05);
}

.instruction.success {
    color: var(--accent-success);
    background: rgba(16, 185, 129, 0.1);
}

.instruction.error {
    color: var(--accent-error);
    background: rgba(239, 68, 68, 0.1);
}

.eval-text {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-bottom: 1.5rem;
}

.puzzle-controls {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-top: 1rem;
}

/* Engine Controls */
.engine-controls {
    margin-bottom: 1rem;
    padding: 1rem;
    background: #1e1e1e;
    border: 1px solid var(--glass-border);
    border-radius: 6px;
}

.toggle-container {
    display: flex;
    align-items: center;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--text-muted);
}

.toggle-container input {
    margin-right: 0.75rem;
    width: 1.25rem;
    height: 1.25rem;
    cursor: pointer;
}

.engine-output {
    margin-top: 0.75rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem;
    background: rgba(15, 23, 42, 0.6);
    border-radius: 6px;
    font-family: monospace;
}

.engine-score {
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--primary);
}

.engine-depth {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.highlight {
    box-shadow: inset 0 0 3px 3px rgba(255, 255, 0, 0.7) !important;
}

.board-container-wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 400px;
}

.board-container {
    width: 100%;
    max-width: 600px;
}

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

.modal-content {
    width: 100%;
    max-width: 400px;
    background: var(--bg-dark);
}

@media (max-width: 900px) {
    .app-layout {
        grid-template-columns: 1fr;
    }
}

/* GGTok Mode Overlay */
#ggtok-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    pointer-events: none;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

#ggtok-overlay.hidden {
    display: none !important;
}

.ggtok-header {
    display: flex;
    padding: 20px;
    gap: 15px;
    align-items: center;
}

.live-badge {
    background: rgba(0,0,0,0.5);
    padding: 8px 15px;
    border-radius: 20px;
    font-weight: bold;
    font-size: 1.2rem;
    color: white;
    display: flex;
    align-items: center;
    gap: 8px;
}

.live-badge .blink {
    color: #ff0050;
    animation: blink-animation 1s steps(5, start) infinite;
}

@keyframes blink-animation {
    to { visibility: hidden; }
}

.view-count, .heart-count, .level-badge {
    background: rgba(0,0,0,0.5);
    padding: 8px 15px;
    border-radius: 20px;
    font-weight: bold;
    color: white;
    display: flex;
    align-items: center;
}

.level-badge {
    color: #f1c40f;
    box-shadow: 0 0 10px rgba(241, 196, 15, 0.4);
}

.xp-bar-container {
    background: rgba(0,0,0,0.5);
    width: 150px;
    height: 20px;
    border-radius: 10px;
    position: relative;
    overflow: hidden;
    margin-left: 10px;
    border: 1px solid rgba(255,255,255,0.2);
}

.xp-bar-fill {
    background: linear-gradient(90deg, #00f2fe, #4facfe);
    height: 100%;
    width: 0%;
    transition: width 0.5s ease-out;
}

.xp-text {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 0.75rem;
    font-weight: bold;
    color: white;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.8);
}

.floating-xp {
    position: absolute;
    color: #00f2fe;
    font-weight: bold;
    font-size: 1.5rem;
    text-shadow: 0 2px 5px rgba(0,0,0,0.8);
    pointer-events: none;
    animation: floatXpUp 2s ease-out forwards;
    z-index: 10000;
}

@keyframes floatXpUp {
    0% { transform: translateY(0) scale(1); opacity: 1; }
    100% { transform: translateY(-50px) scale(1.5); opacity: 0; }
}

.ggtok-sidebar {
    position: absolute;
    left: 20px;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.sidebar-icon {
    display: flex;
    flex-direction: column;
    align-items: center;
    color: white;
    font-size: 1.8rem;
    text-shadow: 0 2px 4px rgba(0,0,0,0.5);
}

.sidebar-icon span {
    font-size: 0.8rem;
    margin-top: 5px;
    font-weight: bold;
}

.ggtok-chat-container {
    position: absolute;
    bottom: 20px;
    left: 100px;
    width: 300px;
    height: 250px;
    overflow: hidden;
    mask-image: linear-gradient(to top, rgba(0,0,0,1) 70%, rgba(0,0,0,0) 100%);
    -webkit-mask-image: linear-gradient(to top, rgba(0,0,0,1) 70%, rgba(0,0,0,0) 100%);
}

.ggtok-chat {
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    gap: 8px;
    position: absolute;
    bottom: 0;
    width: 100%;
}

.ggtok-msg {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    animation: slideInUp 0.3s ease-out;
    background: rgba(0,0,0,0.4);
    padding: 6px 10px;
    border-radius: 12px;
    color: white;
    font-size: 0.95rem;
}

.ggtok-user {
    font-weight: bold;
    color: #00f2fe;
}

.ggtok-gift {
    color: #ff0050;
    font-weight: bold;
}

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

.ggtok-animations {
    position: absolute;
    bottom: 50px;
    right: 80px;
    width: 100px;
    height: 300px;
}

.floating-heart {
    position: absolute;
    bottom: 0;
    font-size: 2rem;
    animation: floatUp 3s ease-in forwards;
    opacity: 0;
}

@keyframes floatUp {
    0% { transform: translateY(0) scale(0.5); opacity: 1; }
    50% { transform: translateY(-150px) scale(1.2) translateX(20px); opacity: 0.8; }
    100% { transform: translateY(-300px) scale(1) translateX(-20px); opacity: 0; }
}
