:root {
    --bg-color: #0f0a2e;
    --bg-secondary: #1a1145;
    --text-main: #f0f0ff;
    --text-muted: #9b8ec4;
    --accent-primary: #b44dff;
    --accent-primary-glow: rgba(180, 77, 255, 0.5);
    --accent-secondary: #ff4da6;
    --accent-secondary-glow: rgba(255, 77, 166, 0.5);
    --accent-cyan: #00d4ff;
    --accent-cyan-glow: rgba(0, 212, 255, 0.4);
    --accent-yellow: #ffe44d;
    --glass-bg: rgba(20, 10, 60, 0.6);
    --glass-border: rgba(180, 77, 255, 0.15);
    --glass-blur: 15px;
    --board-cell: rgba(180, 77, 255, 0.08);
    --board-cell-hover: rgba(180, 77, 255, 0.25);
    --font-pixel: 'Press Start 2P', cursive;
    --font-body: 'Montserrat', sans-serif;
}

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

body {
    font-family: var(--font-body);
    color: var(--text-main);
    background-color: var(--bg-color);
    height: 100vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transition: background-image 0.8s ease-in-out, background 0.8s ease-in-out;
    position: relative;
}

/* ===== LANDING ===== */
/* Simple and dark background so text is clear */
body.bg-landing {
    background: 
        radial-gradient(ellipse at center, rgba(120, 50, 255, 0.15) 0%, transparent 60%),
        linear-gradient(180deg, #090514 0%, #11092a 50%, #1a0b38 100%);
}

/* ===== SELECTION & GAME ===== */
body.bg-selection, body.bg-game {
    background: linear-gradient(180deg, #0f0a2e 0%, #150e3a 50%, #1a1145 100%);
}

body.bg-selection {
    box-shadow: inset 0 0 100px rgba(10, 5, 20, 0.5);
}

body.bg-game {
    box-shadow: inset 0 0 150px rgba(0, 0, 0, 0.6);
}

/* ===== Background overlay with stars + glow ===== */
.background-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    pointer-events: none;
    overflow: hidden;
}

/* Animated twinkling stars */
.background-overlay::before {
    content: '';
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background-image:
        radial-gradient(1px 1px at 10% 15%, rgba(255,255,255,0.8), transparent),
        radial-gradient(1px 1px at 20% 35%, rgba(255,255,255,0.6), transparent),
        radial-gradient(2px 2px at 35% 10%, rgba(180,160,255,0.9), transparent),
        radial-gradient(1px 1px at 45% 60%, rgba(255,255,255,0.5), transparent),
        radial-gradient(1.5px 1.5px at 55% 25%, rgba(255,200,255,0.7), transparent),
        radial-gradient(1px 1px at 65% 80%, rgba(255,255,255,0.6), transparent),
        radial-gradient(2px 2px at 75% 45%, rgba(200,180,255,0.8), transparent),
        radial-gradient(1px 1px at 85% 70%, rgba(255,255,255,0.5), transparent),
        radial-gradient(1.5px 1.5px at 90% 15%, rgba(180,220,255,0.7), transparent),
        radial-gradient(1px 1px at 15% 85%, rgba(255,255,255,0.4), transparent),
        radial-gradient(1px 1px at 30% 55%, rgba(255,255,255,0.6), transparent),
        radial-gradient(2px 2px at 50% 40%, rgba(200,150,255,0.7), transparent),
        radial-gradient(1px 1px at 70% 10%, rgba(255,255,255,0.5), transparent),
        radial-gradient(1px 1px at 80% 90%, rgba(255,255,255,0.4), transparent),
        radial-gradient(1.5px 1.5px at 5% 50%, rgba(180,200,255,0.6), transparent),
        radial-gradient(1px 1px at 40% 90%, rgba(255,255,255,0.5), transparent),
        radial-gradient(2px 2px at 60% 5%, rgba(220,180,255,0.8), transparent),
        radial-gradient(1px 1px at 95% 55%, rgba(255,255,255,0.4), transparent);
    animation: twinkle 4s ease-in-out infinite alternate;
}

/* Wavy bottom decoration */
.background-overlay::after {
    content: '';
    position: absolute;
    bottom: -5px;
    left: -5%;
    width: 110%;
    height: 220px;
    background:
        radial-gradient(ellipse at 20% 50%, rgba(100, 50, 220, 0.6) 0%, transparent 70%),
        radial-gradient(ellipse at 80% 60%, rgba(180, 60, 255, 0.4) 0%, transparent 60%);
    border-radius: 50% 50% 0 0;
    filter: blur(30px);
    opacity: 0.7;
}

@keyframes twinkle {
    0%   { opacity: 0.6; }
    50%  { opacity: 1; }
    100% { opacity: 0.7; }
}

/* Glassmorphism utility */
.glass-panel {
    background: var(--glass-bg);
    backdrop-filter: blur(var(--glass-blur));
    -webkit-backdrop-filter: blur(var(--glass-blur));
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    box-shadow: 0 8px 32px 0 rgba(15, 10, 46, 0.5);
}

/* Play button LED animation */
.play-anim {
    animation: led-pulse 0.6s ease-out, play-zoom 0.6s ease-in-out;
}
@keyframes led-pulse {
    0% { box-shadow: 0 0 15px var(--accent-primary), inset 0 0 15px rgba(180, 77, 255, 0.15); }
    50% { box-shadow: 0 0 40px var(--accent-primary-glow), inset 0 0 30px rgba(180, 77, 255, 0.5); }
    100% { box-shadow: 0 0 15px var(--accent-primary), inset 0 0 15px rgba(180, 77, 255, 0.15); }
}
@keyframes play-zoom {
    0% { transform: scale(1) skewX(-10deg); }
    50% { transform: scale(1.15) skewX(-10deg); }
    100% { transform: scale(1) skewX(-10deg); }
}

/* ========== NAVBAR ========== */
.navbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 50px;
    height: 80px;
    z-index: 10;
    position: relative;
}

.nav-links {
    display: flex;
    gap: 30px;
}

.nav-links a {
    color: var(--text-main);
    text-decoration: none;
    font-family: var(--font-pixel);
    font-size: 0.65rem;
    letter-spacing: 1px;
    text-transform: uppercase;
    transition: color 0.3s, text-shadow 0.3s;
}

.nav-links a.hidden-nav {
    display: none;
}

.nav-links a:hover, .nav-links a.active {
    color: var(--accent-primary);
    text-shadow: 0 0 10px var(--accent-primary-glow), 0 0 20px var(--accent-primary-glow);
}

.nav-back-btn {
    font-family: var(--font-pixel);
    font-size: 0.65rem;
    color: var(--text-main);
    text-decoration: none;
    letter-spacing: 1px;
    padding: 8px 20px;
    border: 1px solid rgba(180, 77, 255, 0.3);
    border-radius: 6px;
    background: rgba(180, 77, 255, 0.1);
    transition: all 0.3s;
    cursor: pointer;
}

.nav-back-btn:hover {
    background: rgba(180, 77, 255, 0.3);
    border-color: var(--accent-primary);
    color: var(--accent-primary);
    text-shadow: 0 0 10px var(--accent-primary-glow);
    box-shadow: 0 0 15px rgba(180, 77, 255, 0.2);
}

.nav-back-btn.hidden-nav {
    display: none;
}

/* ========== PAGE SECTIONS ========== */
.page-section {
    flex: 1;
    width: 100%;
    position: absolute;
    top: 80px;
    bottom: 0;
    left: 0;
    opacity: 0;
    transform: perspective(1200px) rotateX(15deg) scale(0.9);
    filter: blur(8px);
    pointer-events: none;
    transition: opacity 0.7s cubic-bezier(0.175, 0.885, 0.32, 1.275), 
                transform 0.7s cubic-bezier(0.175, 0.885, 0.32, 1.275),
                filter 0.5s ease-out;
    display: flex;
}

.page-section.active-page {
    opacity: 1;
    transform: perspective(1200px) rotateX(0deg) scale(1);
    filter: blur(0);
    pointer-events: all;
    z-index: 5;
}

.page-section.hidden {
    display: none;
}

/* ========== LANDING PAGE ========== */
#landing-page {
    justify-content: center;
    align-items: center;
    text-align: center;
}

.landing-content {
    max-width: 800px;
    padding: 40px;
    background: radial-gradient(circle at center, rgba(180, 77, 255, 0.08) 0%, transparent 70%);
}

.sub-heading {
    font-family: var(--font-pixel);
    font-size: 1.4rem;
    letter-spacing: 8px;
    margin-bottom: -5px;
    color: var(--accent-cyan);
    text-shadow: 0 0 10px var(--accent-cyan-glow), 0 0 30px var(--accent-cyan-glow);
}

.main-heading {
    font-family: var(--font-pixel);
    font-size: 3.8rem;
    font-weight: 400;
    letter-spacing: 4px;
    margin-bottom: 25px;
    background: linear-gradient(180deg, #ff66cc 0%, #b44dff 50%, #6633ff 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    filter: drop-shadow(0 0 15px rgba(180, 77, 255, 0.6));
    line-height: 1.2;
}

.landing-desc {
    font-family: var(--font-body);
    font-size: 0.85rem;
    letter-spacing: 2px;
    margin-bottom: 50px;
    color: var(--text-muted);
    line-height: 1.8;
}

/* Retro Button */
.cyber-btn {
    background: transparent;
    color: #fff;
    border: none;
    padding: 15px 50px;
    font-family: var(--font-pixel);
    font-size: 0.85rem;
    letter-spacing: 2px;
    position: relative;
    cursor: pointer;
    transform: skewX(-10deg);
    transition: all 0.3s;
    outline: none;
}

.cyber-btn.primary-btn {
    background: rgba(180, 77, 255, 0.2);
    border: 2px solid var(--accent-primary);
    box-shadow: 0 0 15px var(--accent-primary-glow), inset 0 0 15px rgba(180, 77, 255, 0.15);
}

.cyber-btn.primary-btn:hover {
    background: var(--accent-primary);
    color: #fff;
    box-shadow: 0 0 30px var(--accent-primary-glow), 0 0 60px rgba(180, 77, 255, 0.3);
    text-shadow: 0 0 10px rgba(255, 255, 255, 0.5);
}

.btn-text {
    display: inline-block;
    transform: skewX(10deg);
}

/* ========== SELECTION PAGE ========== */
#selection-page {
    flex-direction: column;
    padding: 40px 100px;
}

.selection-header {
    margin-bottom: 40px;
}

.selection-header h3 {
    font-family: var(--font-pixel);
    font-size: 0.8rem;
    letter-spacing: 5px;
    color: var(--text-muted);
}

.selection-title {
    font-family: var(--font-pixel);
    font-size: 2.5rem;
    color: var(--accent-primary);
    text-shadow: 0 0 15px var(--accent-primary-glow), 0 0 40px rgba(180, 77, 255, 0.3);
}

.cards-container {
    display: flex;
    gap: 40px;
    height: 500px;
}

.domino-card {
    flex: 1;
    background: var(--glass-bg);
    border: 2px solid var(--glass-border);
    border-radius: 10px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    cursor: pointer;
    transition: transform 0.3s, border-color 0.3s, box-shadow 0.3s;
    position: relative;
}

.domino-card:hover {
    transform: translateY(-10px);
}

.vertical-card:hover {
    border-color: var(--accent-cyan);
    box-shadow: 0 0 30px var(--accent-cyan-glow);
}

.horizontal-card:hover {
    border-color: var(--accent-secondary);
    box-shadow: 0 0 30px var(--accent-secondary-glow);
}

.card-image-placeholder {
    flex: 2;
    background: rgba(15, 10, 46, 0.6);
    display: flex;
    justify-content: center;
    align-items: center;
}

.domino-shape {
    display: flex;
    gap: 4px;
}

.domino-shape.vertical { flex-direction: column; }
.domino-shape.horizontal { flex-direction: row; }

.domino-shape .cell {
    width: 60px;
    height: 60px;
    border-radius: 4px;
    border: 2px solid rgba(255, 255, 255, 0.5);
}

.vertical-card .cell {
    background-color: var(--accent-cyan);
    box-shadow: 0 0 15px var(--accent-cyan-glow);
}

.horizontal-card .cell {
    background-color: var(--accent-secondary);
    box-shadow: 0 0 15px var(--accent-secondary-glow);
}

.card-info {
    flex: 1;
    padding: 30px;
    background: linear-gradient(to top, rgba(15, 10, 46, 0.9), transparent);
}

.card-info h4 {
    font-family: var(--font-pixel);
    font-size: 1rem;
    margin-bottom: 10px;
    color: var(--text-main);
}

.card-info p {
    font-family: var(--font-body);
    color: var(--text-muted);
    font-size: 0.85rem;
}

.selection-back {
    margin-top: 30px;
    text-align: center;
}

.selection-back .cyber-btn {
    font-size: 0.7rem;
    padding: 12px 35px;
}

/* ========== GAME PAGE ========== */
.game-container {
    padding: 20px 50px;
    gap: 30px;
    position: static;
    height: calc(100vh - 80px);
}

.center-section {
    flex: 1.5;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
}

.turn-indicator {
    padding: 10px 30px;
    font-family: var(--font-pixel);
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 2px;
    margin-bottom: 20px;
    color: var(--text-main);
    text-align: center;
    transition: color 0.3s, text-shadow 0.3s;
}

.turn-indicator.human-turn {
    color: var(--accent-cyan);
    text-shadow: 0 0 10px var(--accent-cyan-glow);
}

.turn-indicator.ai-turn {
    color: var(--accent-secondary);
    text-shadow: 0 0 10px var(--accent-secondary-glow);
}

.board-container { padding: 20px; }

.board {
    display: grid;
    grid-template-columns: repeat(6, 60px);
    grid-template-rows: repeat(6, 60px);
    gap: 4px;
}

.cell {
    background-color: var(--board-cell);
    border: 1px solid rgba(180, 77, 255, 0.15);
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.2s, box-shadow 0.2s;
}

.cell.valid-hover-cyan {
    background-color: var(--board-cell-hover);
    box-shadow: inset 0 0 10px var(--accent-cyan-glow);
}

.cell.valid-hover-orange {
    background-color: rgba(255, 77, 166, 0.2);
    box-shadow: inset 0 0 10px var(--accent-secondary-glow);
}

/* Placed Dominoes */
.cell.cyan {
    background-color: var(--accent-cyan);
    box-shadow: 0 0 10px var(--accent-cyan-glow);
    border: 1px solid rgba(255, 255, 255, 0.5);
}

.cell.orange {
    background-color: var(--accent-secondary);
    box-shadow: 0 0 10px var(--accent-secondary-glow);
    border: 1px solid rgba(255, 255, 255, 0.5);
}

.game-status {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(15, 10, 46, 0.92);
    border: 2px solid var(--accent-primary);
    padding: 30px 50px;
    border-radius: 15px;
    text-align: center;
    z-index: 20;
    box-shadow: 0 0 30px var(--accent-primary-glow);
}

.game-status.hidden { display: none; }

#status-text {
    font-family: var(--font-pixel);
    font-size: 1.5rem;
    color: var(--accent-primary);
    text-shadow: 0 0 15px var(--accent-primary-glow);
}

.game-status.ai-win {
    border-color: var(--accent-secondary);
    box-shadow: 0 0 30px var(--accent-secondary-glow);
}

.game-status.ai-win #status-text {
    color: var(--accent-secondary);
    text-shadow: 0 0 15px var(--accent-secondary-glow);
}

/* ========== RIGHT SECTION ========== */
.right-section {
    flex: 1.2;
    display: flex;
    flex-direction: column;
}

.info-panel {
    padding: 30px;
    height: 100%;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.info-panel::-webkit-scrollbar { width: 6px; }
.info-panel::-webkit-scrollbar-track { background: rgba(15, 10, 46, 0.5); }
.info-panel::-webkit-scrollbar-thumb {
    background: var(--accent-primary);
    border-radius: 3px;
}

.info-panel h2 {
    font-family: var(--font-pixel);
    font-size: 0.85rem;
    margin-bottom: 8px;
    color: var(--accent-primary);
    text-shadow: 0 0 8px var(--accent-primary-glow);
}

.timestamp {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 20px;
    border-bottom: 1px solid rgba(180, 77, 255, 0.15);
    padding-bottom: 10px;
}

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

.description {
    font-size: 0.9rem;
    line-height: 1.6;
    color: #b8a8d8;
    margin-bottom: 25px;
}

.settings-group {
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.settings-group label {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-muted);
}

.cyber-select {
    background: rgba(15, 10, 46, 0.7);
    color: white;
    border: 1px solid var(--accent-primary);
    padding: 8px 12px;
    border-radius: 4px;
    font-family: var(--font-body);
    outline: none;
    cursor: pointer;
}

.cyber-slider {
    flex: 1;
    margin: 0 15px;
    accent-color: var(--accent-primary);
}

.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    margin-bottom: 25px;
}

.stat-box {
    background: rgba(180, 77, 255, 0.06);
    border: 1px solid rgba(180, 77, 255, 0.15);
    padding: 15px;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
}

.stat-label {
    font-family: var(--font-pixel);
    font-size: 0.5rem;
    color: var(--text-muted);
    text-transform: uppercase;
    margin-bottom: 8px;
    letter-spacing: 1px;
}

.stat-value {
    font-family: var(--font-pixel);
    font-size: 1rem;
    font-weight: 400;
    color: var(--accent-primary);
    text-shadow: 0 0 8px var(--accent-primary-glow);
}

/* ========== TREE VISUALIZER ========== */
.tree-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 250px;
    border-top: 1px solid rgba(180, 77, 255, 0.15);
    padding-top: 20px;
}

.tree-container h3 {
    font-family: var(--font-pixel);
    font-size: 0.55rem;
    margin-bottom: 10px;
    color: var(--text-muted);
    letter-spacing: 1px;
}

.tree-scroll {
    flex: 1;
    background: rgba(15, 10, 46, 0.5);
    border: 1px solid rgba(180, 77, 255, 0.1);
    border-radius: 8px;
    padding: 15px;
    overflow: auto;
    position: relative;
}

.tree-placeholder {
    color: var(--text-muted);
    text-align: center;
    margin-top: 50px;
    font-style: italic;
}

.tree-ul {
    padding-top: 20px;
    position: relative;
    transition: all 0.5s;
    display: flex;
    justify-content: center;
    gap: 20px;
    padding-left: 0;
}

.tree-li {
    float: left;
    text-align: center;
    list-style-type: none;
    position: relative;
    padding: 20px 5px 0 5px;
    transition: all 0.5s;
}

.tree-li::before, .tree-li::after {
    content: '';
    position: absolute;
    top: 0;
    right: 50%;
    border-top: 1px solid rgba(180, 77, 255, 0.4);
    width: 50%;
    height: 20px;
}

.tree-li::after {
    right: auto;
    left: 50%;
    border-left: 1px solid rgba(180, 77, 255, 0.4);
}

.tree-li:only-child::after, .tree-li:only-child::before { display: none; }
.tree-li:only-child { padding-top: 0; }

.tree-li:first-child::before, .tree-li:last-child::after { border: 0 none; }

.tree-li:last-child::before {
    border-right: 1px solid rgba(180, 77, 255, 0.4);
    border-radius: 0 5px 0 0;
}

.tree-li:first-child::after {
    border-radius: 5px 0 0 0;
}

.tree-ul::before {
    content: '';
    position: absolute;
    top: 0;
    left: 50%;
    border-left: 1px solid rgba(180, 77, 255, 0.4);
    width: 0;
    height: 20px;
}

.tree-node {
    border: 1px solid rgba(180, 77, 255, 0.4);
    padding: 5px 10px;
    text-decoration: none;
    color: #fff;
    font-family: var(--font-pixel);
    font-size: 0.6rem;
    display: inline-block;
    border-radius: 4px;
    background: rgba(15, 10, 46, 0.85);
    transition: all 0.5s;
}

.tree-node .score {
    font-weight: bold;
    color: var(--accent-primary);
}

.tree-node.pruned {
    border-color: var(--accent-secondary);
    background: rgba(255, 77, 166, 0.15);
}

.tree-node.pruned .score {
    color: var(--accent-secondary);
    text-decoration: line-through;
}

.tree-node.best-path {
    border-color: var(--accent-yellow);
    box-shadow: 0 0 10px rgba(255, 228, 77, 0.4);
}

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