@import url('https://fonts.googleapis.com/css2?family=Press+Start+2P&family=VT323&display=swap');

:root {
    --bg: #06000c;
    --neon-pink: #ff2979;
    --neon-purple: #b600ff;
    --neon-cyan: #00e5ff;
    --neon-yellow: #ffe600;
    --neon-green: #00ff88;
    --neon-red: #ff1744;
    --pink-glow: rgba(255, 41, 121, 0.6);
    --purple-glow: rgba(182, 0, 255, 0.5);
    --cyan-glow: rgba(0, 229, 255, 0.4);
    --yellow-glow: rgba(255, 230, 0, 0.5);
    --green-glow: rgba(0, 255, 136, 0.4);
    --text-primary: #ffffff;
    --text-dim: rgba(255, 255, 255, 0.45);
    --pixel-font: 'Press Start 2P', monospace;
    --terminal-font: 'VT323', monospace;
}

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

/* ── Giriş Animasyon Sıralaması ─────────────────────────── */
/* Header önce iner */
header.animate__animated {
    animation-duration: 0.5s;
    animation-fill-mode: backwards;
}

/* Board normal açılır, gecikme yok */
#game-view.animate__animated {
    animation-duration: 0.6s;
    animation-fill-mode: backwards;
}

/* Sol panel board açıldıktan sonra kayar */
.side-panel.left.animate__animated {
    animation-duration: 0.6s;
    animation-delay: 0.7s;
    animation-fill-mode: backwards;
}

/* Sağ panel sol panelden kısa süre sonra */
.side-panel.right.animate__animated {
    animation-duration: 0.6s;
    animation-delay: 0.9s;
    animation-fill-mode: backwards;
}

body {
    background: var(--bg);
    color: var(--text-primary);
    font-family: var(--pixel-font);
    height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    overflow: hidden;
    position: relative;
    padding: 0.8rem;
}

/* ── CRT Background ─────────────────────────────────────── */
#quantum-background {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    z-index: -1;
    overflow: hidden;
    background: radial-gradient(ellipse at 50% 40%, #1a0030 0%, #06000c 65%);
}

.geometric-layer {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background-image:
        linear-gradient(rgba(182, 0, 255, 0.07) 1px, transparent 1px),
        linear-gradient(90deg, rgba(182, 0, 255, 0.07) 1px, transparent 1px);
    background-size: 40px 40px;
    animation: grid-scroll 25s linear infinite;
}

@keyframes grid-scroll {
    from { background-position: 0 0; }
    to   { background-position: 40px 40px; }
}

.crt-overlay {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    pointer-events: none;
    background: repeating-linear-gradient(
        0deg,
        transparent,
        transparent 2px,
        rgba(0, 0, 0, 0.13) 2px,
        rgba(0, 0, 0, 0.13) 4px
    );
}

.vignette {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    pointer-events: none;
    background: radial-gradient(ellipse at center, transparent 55%, rgba(0,0,0,0.75) 100%);
}

/* ── Header ─────────────────────────────────────────────── */
header {
    margin-bottom: 0.5vh;
    flex-shrink: 0;
    text-align: center;
}

h1 {
    font-family: var(--pixel-font);
    font-size: clamp(1.4rem, 4.5vw, 3rem);
    font-weight: 400;
    letter-spacing: 6px;
    color: var(--neon-pink);
    text-shadow:
        0 0 8px var(--pink-glow),
        0 0 20px var(--pink-glow),
        0 0 50px rgba(255, 41, 121, 0.25);
    margin-bottom: 1vh;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 14px;
    animation: title-flicker 9s ease-in-out infinite;
}

@keyframes title-flicker {
    0%, 94%, 96%, 98%, 100% { opacity: 1; }
    95%  { opacity: 0.7; }
    97%  { opacity: 0.5; }
    99%  { opacity: 0.9; }
}

#tutorial-btn {
    width: 26px;
    height: 26px;
    background: transparent;
    border: 2px solid var(--neon-pink);
    border-radius: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--pixel-font);
    font-size: 0.55rem;
    cursor: pointer;
    transition: all 0.15s;
    color: var(--neon-pink);
    box-shadow: 0 0 8px var(--pink-glow), inset 0 0 6px rgba(255,41,121,0.1);
    flex-shrink: 0;
    -webkit-text-fill-color: var(--neon-pink);
}

#tutorial-btn:hover {
    background: var(--neon-pink);
    -webkit-text-fill-color: #000;
    box-shadow: 0 0 18px var(--pink-glow), 0 0 36px rgba(255,41,121,0.3);
}

/* ── Dashboard ───────────────────────────────────────────── */
.quantum-dashboard {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 2rem;
    background: transparent;
    border: 1px solid var(--neon-purple);
    padding: 0.5rem 2.2rem;
    border-radius: 0;
    margin: 0 auto 1.5vh auto;
    width: fit-content;
    box-shadow: 0 0 14px var(--purple-glow), inset 0 0 14px rgba(182,0,255,0.04);
    position: relative;
}

.quantum-dashboard::before,
.quantum-dashboard::after {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    color: var(--neon-purple);
    font-family: var(--pixel-font);
    font-size: 0.5rem;
    text-shadow: 0 0 8px var(--purple-glow);
}
.quantum-dashboard::before { content: '▶'; left: -1.3rem; }
.quantum-dashboard::after  { content: '◀'; right: -1.3rem; }

.dashboard-item {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.dashboard-label {
    font-family: var(--pixel-font);
    font-size: 0.42rem;
    letter-spacing: 2px;
    color: var(--neon-purple);
    margin-bottom: 0.25rem;
    text-transform: uppercase;
    text-shadow: 0 0 8px var(--purple-glow);
}

#timer,
#difficulty-display {
    font-family: var(--terminal-font);
    font-size: 1.9rem;
    font-weight: 400;
    color: var(--neon-cyan);
    text-shadow: 0 0 10px var(--cyan-glow), 0 0 22px var(--cyan-glow);
    letter-spacing: 3px;
    line-height: 1;
}

.dashboard-divider {
    width: 1px;
    height: 30px;
    background: var(--neon-purple);
    opacity: 0.35;
    box-shadow: 0 0 5px var(--purple-glow);
}

/* ── Main Grid ───────────────────────────────────────────── */
.quantum-container {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: clamp(8px, 2vw, 35px);
    width: 100%;
    max-width: 1400px;
    margin: 0 auto;
    flex: 1;
    min-height: 0;
}

.side-panel {
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 240px;
    justify-content: center;
}

.side-panel.left  { justify-self: end; }
.side-panel.right { justify-self: start; }

/* ── Side Panel Card ─────────────────────────────────────── */
.panel-group {
    background: rgba(182, 0, 255, 0.04);
    border: 1px solid rgba(255, 41, 121, 0.3);
    padding: 1.4rem;
    border-radius: 0;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    position: relative;
    box-shadow: 0 0 18px rgba(182,0,255,0.12), inset 0 0 18px rgba(182,0,255,0.03);
}

/* Corner accents */
.panel-group::before,
.panel-group::after {
    content: '';
    position: absolute;
    width: 10px;
    height: 10px;
    pointer-events: none;
}
.panel-group::before {
    top: -1px; left: -1px;
    border-top: 2px solid var(--neon-pink);
    border-left: 2px solid var(--neon-pink);
    box-shadow: 0 0 6px var(--pink-glow);
}
.panel-group::after {
    bottom: -1px; right: -1px;
    border-bottom: 2px solid var(--neon-pink);
    border-right: 2px solid var(--neon-pink);
    box-shadow: 0 0 6px var(--pink-glow);
}

.panel-label {
    font-family: var(--pixel-font);
    font-size: 0.48rem;
    letter-spacing: 3px;
    color: var(--neon-yellow);
    text-transform: uppercase;
    margin-bottom: 0.3rem;
    display: block;
    text-align: center;
    text-shadow: 0 0 8px var(--yellow-glow);
}

/* ── Game Area ───────────────────────────────────────────── */
#game-view {
    position: relative;
    padding: 10px;
    display: flex;
    justify-content: center;
    flex: 1;
}

/* ── Board ───────────────────────────────────────────────── */
#board {
    display: grid;
    grid-template-columns: repeat(var(--grid-size, 9), var(--cell-size, clamp(30px, 6.2vh, 60px)));
    grid-template-rows:    repeat(var(--grid-size, 9), var(--cell-size, clamp(30px, 6.2vh, 60px)));
    background: rgba(0, 0, 0, 0.65);
    border: 3px solid var(--neon-pink);
    border-radius: 0;
    padding: 6px;
    box-shadow:
        0 0 18px var(--pink-glow),
        0 0 40px rgba(255, 41, 121, 0.2),
        inset 0 0 18px rgba(255, 41, 121, 0.04);
    width: min-content;
    margin: 0 auto;
}

/* ── Cells ───────────────────────────────────────────────── */
.cell {
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--terminal-font);
    font-size: calc(var(--cell-size, clamp(30px, 6.2vh, 60px)) * 0.72);
    font-weight: 400;
    cursor: pointer;
    border: 1px solid rgba(182, 0, 255, 0.18);
    transition: background 0.12s, box-shadow 0.12s;
    position: relative;
    color: var(--neon-cyan);
    text-shadow: 0 0 7px var(--cyan-glow);
    width:  var(--cell-size, clamp(30px, 6.2vh, 60px));
    height: var(--cell-size, clamp(30px, 6.2vh, 60px));
    background: transparent;
}

.cell.border-right  { border-right:  2px solid var(--neon-pink); }
.cell.border-bottom { border-bottom: 2px solid var(--neon-pink); }

.cell:hover {
    background: rgba(255, 41, 121, 0.08);
}

.cell.selected {
    background: rgba(255, 41, 121, 0.22);
    box-shadow: inset 0 0 14px rgba(255,41,121,0.35);
    z-index: 2;
    color: #fff;
    text-shadow: 0 0 10px #fff;
}

.cell.highlight-house {
    background: rgba(182, 0, 255, 0.07);
}

.cell.highlight-match {
    background: rgba(255, 230, 0, 0.12);
    color: var(--neon-yellow);
    text-shadow: 0 0 8px var(--yellow-glow);
}

.cell.conflict {
    color: var(--neon-red);
    text-shadow: 0 0 10px rgba(255, 23, 68, 0.8);
    background: rgba(255, 0, 0, 0.1);
    animation: conflict-flash 0.4s ease-in-out;
}

@keyframes conflict-flash {
    0%   { background: rgba(255, 0, 0, 0.35); }
    100% { background: rgba(255, 0, 0, 0.1);  }
}

.cell.given {
    color: rgba(255, 255, 255, 0.45);
    background: rgba(0, 0, 0, 0.2);
    text-shadow: none;
    cursor: default;
}

.cell.user-correct {
    color: var(--neon-green);
    text-shadow: 0 0 8px var(--green-glow);
}

/* ── Num Picker ──────────────────────────────────────────── */
.num-picker {
    position: fixed;
    z-index: 500;
    display: grid;
    grid-template-columns: repeat(var(--picker-cols, 3), 1fr);
    gap: 4px;
    background: rgba(6, 0, 12, 0.97);
    border: 1px solid var(--neon-purple);
    padding: 8px;
    box-shadow: 0 0 20px var(--purple-glow);
}

.picker-btn {
    font-family: var(--terminal-font);
    font-size: 1.4rem;
    color: var(--neon-cyan);
    background: transparent;
    border: 1px solid rgba(182, 0, 255, 0.25);
    cursor: pointer;
    padding: 6px 10px;
    min-width: 36px;
    transition: background 0.12s, color 0.12s;
    text-shadow: 0 0 6px var(--cyan-glow);
}

.picker-btn:hover {
    background: var(--neon-purple);
    color: #fff;
    border-color: var(--neon-purple);
}

.picker-del {
    color: var(--neon-red);
    text-shadow: 0 0 6px rgba(255,23,68,0.6);
    grid-column: 1 / -1;
}

.picker-del:hover {
    background: var(--neon-red);
    color: #fff;
}

/* ── Game Over Modal ─────────────────────────────────────── */
.gameover-content {
    background: rgba(6, 0, 12, 0.98);
    border: 2px solid var(--neon-pink);
    padding: 3rem 4rem;
    border-radius: 0;
    text-align: center;
    box-shadow: 0 0 40px var(--pink-glow), 0 0 80px rgba(255,41,121,0.1);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
}

.gameover-title {
    font-family: var(--pixel-font);
    font-size: clamp(1.2rem, 3vw, 2rem);
    color: var(--neon-yellow);
    text-shadow: 0 0 12px var(--yellow-glow), 0 0 30px rgba(255,230,0,0.3);
    letter-spacing: 4px;
    animation: title-flicker 4s ease-in-out infinite;
}

.gameover-time {
    font-family: var(--terminal-font);
    font-size: 2rem;
    color: var(--neon-cyan);
    text-shadow: 0 0 10px var(--cyan-glow);
    letter-spacing: 3px;
}

/* ── Custom Select ───────────────────────────────────────── */
.quantum-select-wrapper {
    position: relative;
    width: 200px;
    user-select: none;
}

.quantum-select-trigger {
    background: rgba(0, 0, 0, 0.65);
    border: 1px solid var(--neon-purple);
    color: var(--neon-cyan);
    padding: 0.85rem 1.2rem;
    border-radius: 0;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-family: var(--pixel-font);
    font-size: 0.58rem;
    transition: border-color 0.2s, box-shadow 0.2s;
    box-shadow: 0 0 8px rgba(182,0,255,0.2);
}

.quantum-select-trigger:hover {
    border-color: var(--neon-pink);
    box-shadow: 0 0 12px var(--pink-glow);
}

.quantum-select-trigger::after {
    content: '▼';
    font-size: 0.4rem;
    margin-left: 0.5rem;
    transition: transform 0.25s;
    color: var(--neon-pink);
}

.quantum-select-wrapper.open .quantum-select-trigger::after { transform: rotate(180deg); }

.quantum-options {
    position: absolute;
    bottom: 115%;
    left: 0; right: 0;
    background: rgba(6, 0, 12, 0.98);
    border: 1px solid var(--neon-purple);
    border-radius: 0;
    overflow: hidden;
    z-index: 100;
    opacity: 0;
    visibility: hidden;
    transform: translateY(6px);
    transition: all 0.2s;
    box-shadow: 0 0 20px var(--purple-glow);
}

.quantum-select-wrapper.open .quantum-options {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.quantum-option {
    padding: 0.8rem 1.2rem;
    cursor: pointer;
    transition: 0.15s;
    font-family: var(--pixel-font);
    font-size: 0.55rem;
    color: var(--text-dim);
    border-bottom: 1px solid rgba(182,0,255,0.12);
}

.quantum-option:last-child { border-bottom: none; }

.quantum-option:hover {
    background: var(--neon-pink);
    color: #000;
}

.quantum-option.selected {
    color: var(--neon-yellow);
    text-shadow: 0 0 7px var(--yellow-glow);
}

#difficulty-selector { display: none; }

/* ── Primary Button ──────────────────────────────────────── */
.btn-quantum {
    background: transparent;
    color: var(--neon-green);
    border: 2px solid var(--neon-green);
    padding: 1rem 2rem;
    border-radius: 0;
    font-family: var(--pixel-font);
    font-size: 0.72rem;
    cursor: pointer;
    transition: all 0.18s;
    text-transform: uppercase;
    letter-spacing: 2px;
    text-shadow: 0 0 8px var(--green-glow);
    box-shadow: 0 0 10px rgba(0,255,136,0.18), inset 0 0 10px rgba(0,255,136,0.04);
}

.btn-quantum:hover {
    background: var(--neon-green);
    color: #000;
    text-shadow: none;
    box-shadow: 0 0 22px rgba(0,255,136,0.6), 0 0 44px rgba(0,255,136,0.25);
    transform: translateY(-1px);
}

.btn-quantum:active {
    transform: translateY(1px);
    box-shadow: none;
}

/* ── Right Panel ─────────────────────────────────────────── */
.side-panel.right {
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1rem;
}

.quick-actions {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.7rem;
    width: fit-content;
}

.btn-round-premium {
    width: 68px;
    height: 68px;
    border-radius: 0;
    background: rgba(0, 0, 0, 0.65);
    border: 2px solid var(--neon-purple);
    color: var(--neon-cyan);
    font-size: 1.3rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.18s;
    box-shadow: 0 0 8px rgba(182,0,255,0.25);
    position: relative;
    padding: 0;
}

.btn-round-premium.undo:hover {
    background: rgba(255, 23, 68, 0.15);
    border-color: var(--neon-red);
    box-shadow: 0 0 16px rgba(255,23,68,0.55);
    color: var(--neon-red);
    transform: scale(1.1);
}

.btn-round-premium.redo:hover {
    background: rgba(0, 229, 255, 0.12);
    border-color: var(--neon-cyan);
    box-shadow: 0 0 16px var(--cyan-glow);
    color: #fff;
    transform: scale(1.1);
}

.btn-round-premium.hint:hover {
    background: rgba(255, 230, 0, 0.12);
    border-color: var(--neon-yellow);
    box-shadow: 0 0 16px var(--yellow-glow);
    color: var(--neon-yellow);
    transform: scale(1.1);
}

#hint-count {
    font-family: var(--pixel-font);
    font-size: 0.38rem;
    position: absolute;
    bottom: 5px;
    color: var(--text-dim);
}


/* ── Modal ───────────────────────────────────────────────── */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.92);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 3000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s, visibility 0.3s;
}

.modal-backdrop:not(.hidden) { opacity: 1; visibility: visible; }

/* Tutorial overlay: display:none kalkınca animation ile gecikmeli açılır */
#tutorial-overlay:not(.hidden) {
    animation: tutorial-fadein 1s ease 1.5s both;
}

@keyframes tutorial-fadein {
    from { opacity: 0; visibility: hidden; }
    to   { opacity: 1; visibility: visible; }
}

.tutorial-content {
    background: rgba(6, 0, 12, 0.98);
    border: 2px solid var(--neon-pink);
    padding: 2rem;
    border-radius: 0;
    max-width: 800px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    text-align: center;
    position: relative;
    box-shadow: 0 0 40px var(--pink-glow), 0 0 80px rgba(255,41,121,0.1);
    scrollbar-width: thin;
    scrollbar-color: var(--neon-pink) transparent;
}

.tutorial-content h2 {
    font-family: var(--pixel-font);
    font-size: clamp(1.3rem, 3vw, 2rem);
    color: var(--neon-yellow);
    text-shadow: 0 0 10px var(--yellow-glow);
    margin-bottom: 1rem;
    letter-spacing: 4px;
}

.tutorial-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
    margin: 1.5rem 0;
    text-align: left;
}

.mod-item {
    background: rgba(182, 0, 255, 0.05);
    border: 1px solid rgba(255, 41, 121, 0.3);
    padding: 1.2rem;
    border-radius: 0;
}

.mod-item h3 {
    font-family: var(--pixel-font);
    font-size: 1rem;
    color: var(--neon-cyan);
    text-shadow: 0 0 8px var(--cyan-glow);
    margin-bottom: 0.8rem;
    line-height: 1.9;
}

.mod-item p {
    font-family: var(--terminal-font);
    font-size: 1.8rem;
    color: var(--text-dim);
    line-height: 1.5;
}

#close-tut-x {
    position: absolute;
    top: 1rem;
    right: 1.5rem;
    font-size: 1.4rem;
    color: var(--neon-pink);
    cursor: pointer;
    text-shadow: 0 0 8px var(--pink-glow);
    font-family: var(--pixel-font);
    transition: text-shadow 0.2s, transform 0.2s;
}

#close-tut-x:hover {
    text-shadow: 0 0 18px var(--pink-glow);
    transform: scale(1.15);
}

/* ── Loading Spinner ─────────────────────────────────────── */
.spinner {
    width: 46px;
    height: 46px;
    border: 3px solid rgba(255, 41, 121, 0.18);
    border-top: 3px solid var(--neon-pink);
    border-radius: 0;
    animation: spin 0.75s linear infinite;
    box-shadow: 0 0 14px var(--pink-glow);
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to   { transform: rotate(360deg); }
}

/* ── Footer ──────────────────────────────────────────────── */
.quantum-footer {
    padding: 0.4rem 0;
    text-align: center;
    width: 100%;
    margin-top: 0.8vh;
    flex-shrink: 0;
    z-index: 10;
}

.quantum-footer p {
    font-family: var(--pixel-font);
    letter-spacing: 4px;
    text-transform: uppercase;
    font-size: 0.8rem;
    color: var(--text-dim);
}

.quantum-footer span {
    color: var(--neon-pink);
    text-shadow: 0 0 8px var(--pink-glow);
}

.hidden { display: none !important; }

/* ── Responsive ──────────────────────────────────────────── */
@media (max-width: 900px) {
    .quantum-container {
        grid-template-columns: 1fr;
        grid-template-rows: auto auto auto;
        gap: 1vh;
        overflow: hidden;
        justify-items: center;
    }
    .side-panel {
        width: 100%;
        max-width: 450px;
        justify-self: center;
    }
    .panel-group {
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: center;
        padding: 0.8rem;
        gap: 0.5rem;
    }
}

@media (max-width: 768px) {
    .tutorial-grid { grid-template-columns: 1fr; }
}
