:root {
    --bg-color: #050510;
    --panel-bg: rgba(10, 15, 30, 0.6);
    --border-color: rgba(0, 255, 255, 0.3);
    --cyan: #00ffff;
    --magenta: #ff00ff;
    --text-primary: #e0f0ff;
    --cell-bg: rgba(0, 255, 255, 0.05);
    --cell-hover: rgba(0, 255, 255, 0.2);
    --cell-revealed: rgba(5, 10, 20, 0.8);
    --cell-border: rgba(0, 255, 255, 0.2);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    user-select: none;
    -webkit-user-select: none;
}

body {
    background-color: var(--bg-color);
    color: var(--text-primary);
    font-family: 'Rajdhani', sans-serif;
    min-height: 100vh;
    min-height: -webkit-fill-available;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    position: relative;
}

/* Background Cyber Particles */
#particles-container {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    z-index: -1;
    background: radial-gradient(circle at center, #101020 0%, #000000 100%);
    overflow: hidden;
}

.particle {
    position: absolute;
    width: 2px; height: 2px;
    background: var(--cyan);
    box-shadow: 0 0 10px var(--cyan);
    border-radius: 50%;
    animation: float 10s infinite linear;
}

@keyframes float {
    0% { transform: translateY(100vh) scale(0); opacity: 0; }
    50% { opacity: 1; }
    100% { transform: translateY(-10vh) scale(1); opacity: 0; }
}

/* Glassmorphism Panel */
.glass-panel {
    background: var(--panel-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border-color);
    box-shadow: 0 0 20px rgba(0, 255, 255, 0.1), inset 0 0 15px rgba(255, 0, 255, 0.05);
    border-radius: 12px;
}

.game-container {
    padding: 2rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
    max-width: 95vw;
    max-height: 95vh;
    overflow: auto;
}

header h1 {
    font-family: 'Orbitron', sans-serif;
    font-size: 2.5rem;
    letter-spacing: 2px;
    margin: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
}

.title-icon {
    width: 2.4rem;
    height: 2.4rem;
    margin-right: 12px;
    filter: drop-shadow(0 0 6px var(--cyan));
    animation: pulse-bomb 2.5s infinite alternate ease-in-out;
}

@keyframes pulse-bomb {
    0% { transform: scale(1) rotate(0deg); filter: drop-shadow(0 0 4px var(--cyan)); }
    100% { transform: scale(1.08) rotate(3deg); filter: drop-shadow(0 0 10px var(--cyan)) drop-shadow(0 0 4px var(--magenta)); }
}

.spark-glow {
    animation: spark-flicker 0.12s infinite alternate ease-in-out;
}

@keyframes spark-flicker {
    0% { opacity: 0.6; r: 1.2; }
    100% { opacity: 1; r: 2.2; }
}

.version {
    display: block;
    width: 100% !important; /* Force to wrap to a new line in flex container */
    text-align: center;
    font-size: 0.72rem;
    color: var(--magenta);
    text-shadow: 0 0 4px var(--magenta);
    margin-top: 2px;
    font-weight: 700;
    letter-spacing: 2.5px;
}

/* Neon Text */
.neon-text {
    color: #fff;
    text-shadow: 
        0 0 5px #fff,
        0 0 10px #fff,
        0 0 20px var(--cyan),
        0 0 40px var(--cyan),
        0 0 80px var(--cyan);
}

.cyan-glow { color: var(--cyan); text-shadow: 0 0 10px var(--cyan); }
.magenta-glow { color: var(--magenta); text-shadow: 0 0 10px var(--magenta); }

/* Dashboard */
.dashboard {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid var(--cell-border);
    border-radius: 8px;
    padding: 10px 20px;
}

.dash-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 90px; /* Fixed width to prevent adjacent elements from shifting */
    flex-shrink: 0;
}

.dash-box .label {
    font-size: 0.8rem;
    color: #aaa;
    letter-spacing: 1px;
}

.dash-box .value {
    font-family: 'Orbitron', sans-serif;
    font-size: 2rem;
    font-weight: bold;
    font-variant-numeric: tabular-nums; /* Tabular numbers for stable digit widths */
}

/* Buttons */
.neon-button {
    background: transparent;
    color: var(--cyan);
    border: 1px solid var(--cyan);
    padding: 10px 20px;
    font-family: 'Orbitron', sans-serif;
    font-size: 1rem;
    font-weight: bold;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.3s ease;
    text-shadow: 0 0 5px var(--cyan);
    box-shadow: inset 0 0 10px rgba(0,255,255,0.2), 0 0 10px rgba(0,255,255,0.2);
}

.neon-button:hover {
    background: var(--cyan);
    color: #000;
    box-shadow: 0 0 20px var(--cyan);
}

.difficulty-selector {
    display: flex;
    gap: 10px;
}

.diff-btn {
    background: rgba(0, 0, 0, 0.5);
    color: #fff;
    border: 1px solid var(--border-color);
    padding: 5px 15px;
    font-family: 'Rajdhani', sans-serif;
    font-size: 1rem;
    font-weight: bold;
    cursor: pointer;
    transition: 0.3s;
    border-radius: 4px;
}

.diff-btn:hover {
    border-color: var(--magenta);
    box-shadow: 0 0 10px var(--magenta);
}

.diff-btn.active {
    background: rgba(255, 0, 255, 0.2);
    border-color: var(--magenta);
    box-shadow: 0 0 15px var(--magenta);
    color: var(--magenta);
}

/* Grid Wrapper & Grid */
.grid-wrapper {
    background: rgba(0, 0, 0, 0.6);
    padding: 10px;
    border-radius: 8px;
    border: 1px solid var(--cell-border);
}

.grid {
    display: grid;
    gap: 2px;
}

/* Cells */
.cell {
    width: 35px;
    height: 35px;
    background: var(--cell-bg);
    border: 1px solid var(--cell-border);
    border-radius: 4px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.2rem;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.15s ease;
    perspective: 1000px;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.cell:hover:not(.revealed) {
    background: var(--cell-hover);
    box-shadow: 0 0 10px var(--cyan);
}

.cell.revealed {
    background: var(--cell-revealed);
    border-color: rgba(255, 255, 255, 0.05);
    cursor: default;
    box-shadow: inset 0 0 10px rgba(0,0,0,0.8);
    animation: flipIn 0.4s ease-out forwards;
}

@keyframes flipIn {
    0% { transform: rotateY(90deg); opacity: 0; }
    100% { transform: rotateY(0); opacity: 1; }
}

.cell.mine {
    background: rgba(255, 0, 0, 0.2) !important;
    border-color: #ff0000;
    box-shadow: 0 0 15px #ff0000, inset 0 0 10px #ff0000;
    color: #ff0000;
    font-size: 1.5rem;
    animation: explode 0.5s ease-out;
}

@keyframes explode {
    0% { transform: scale(1); background: #fff; }
    50% { transform: scale(1.5); }
    100% { transform: scale(1); }
}

.cell.flag {
    color: var(--magenta);
    text-shadow: 0 0 10px var(--magenta);
    animation: pop 0.2s ease-out;
}

@keyframes pop {
    0% { transform: scale(0.5); }
    100% { transform: scale(1); }
}

/* Number Colors */
.n-1 { color: #00ffff; text-shadow: 0 0 5px #00ffff; }
.n-2 { color: #00ff00; text-shadow: 0 0 5px #00ff00; }
.n-3 { color: #ff3333; text-shadow: 0 0 5px #ff3333; }
.n-4 { color: #9933ff; text-shadow: 0 0 5px #9933ff; }
.n-5 { color: #ffff00; text-shadow: 0 0 5px #ffff00; }
.n-6 { color: #ff9900; text-shadow: 0 0 5px #ff9900; }
.n-7 { color: #ff00ff; text-shadow: 0 0 5px #ff00ff; }
.n-8 { color: #ffffff; text-shadow: 0 0 10px #ffffff; }

/* Modal */
.modal {
    position: fixed;
    top: 0; left: 0; width: 100vw; height: 100vh;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
    opacity: 1;
    transition: opacity 0.3s;
}

.modal.hidden {
    opacity: 0;
    pointer-events: none;
}

.hidden:not(.modal) {
    display: none !important;
}

.modal-content {
    padding: 3rem;
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: 20px;
    transform: scale(1);
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.modal.hidden .modal-content {
    transform: scale(0.8);
}

.modal h2 {
    font-family: 'Orbitron', sans-serif;
    font-size: 2.5rem;
    margin: 0;
}

.modal p {
    font-size: 1.2rem;
    color: #ccc;
}

.win-text {
    color: #00ff00 !important;
    text-shadow: 0 0 10px #00ff00, 0 0 40px #00ff00 !important;
}

/* Adjust sizes for smaller screens */
@media (max-width: 800px) {
    body {
        overflow: auto;
        align-items: flex-start;
        padding: 0.5rem 0;
    }
    .game-container {
        padding: 1rem;
        gap: 0.8rem;
        max-height: none;
        width: calc(100vw - 1rem);
    }
    .glass-panel {
        backdrop-filter: blur(4px);
        -webkit-backdrop-filter: blur(4px);
    }
    .cell { width: 30px; height: 30px; font-size: 0.9rem; }
    header h1 { font-size: 1.5rem; }
    .dash-box .value { font-size: 1.5rem; }
    .neon-button { font-size: 0.8rem; padding: 8px 12px; }
    .diff-btn { font-size: 0.8rem; padding: 5px 10px; }
    .grid-wrapper { overflow-x: auto; max-width: calc(100vw - 2rem); }
}

/* Mobile Touch Guide Styling */
.mobile-guide {
    margin-top: 0.5rem;
    padding: 0.8rem 1.2rem;
    border-radius: 8px;
    background: rgba(0, 255, 255, 0.03);
    border: 1px dashed rgba(0, 255, 255, 0.2);
    font-family: 'Rajdhani', sans-serif;
    color: var(--text-primary);
    font-size: 0.9rem;
    text-align: left;
    width: 100%;
    box-sizing: border-box;
    max-width: 340px;
    box-shadow: 0 0 10px rgba(0, 255, 255, 0.02);
}

.guide-title {
    font-weight: 700;
    color: var(--cyan);
    margin-bottom: 0.4rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-family: 'Orbitron', sans-serif;
    text-shadow: 0 0 5px var(--cyan);
    font-size: 0.9rem;
}

.guide-item {
    margin-bottom: 0.2rem;
    line-height: 1.4;
    font-weight: 500;
}

.guide-item:last-child {
    margin-bottom: 0;
}

/* Small Buttons */
.small-btn {
    font-size: 0.8rem !important;
    padding: 6px 12px !important;
    height: auto !important;
}

/* Record Form in Win Modal */
#record-form-container {
    margin-top: 1.2rem;
    margin-bottom: 1rem;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.6rem;
}

.record-input-title {
    font-size: 0.85rem;
    color: var(--cyan);
    font-family: 'Orbitron', sans-serif;
    letter-spacing: 1px;
    text-shadow: 0 0 5px var(--cyan);
}

.input-wrapper {
    display: flex;
    gap: 8px;
    width: 100%;
    justify-content: center;
}

#player-name {
    background: rgba(0, 255, 255, 0.05);
    border: 1px solid rgba(0, 255, 255, 0.3);
    border-radius: 4px;
    color: #fff;
    padding: 6px 12px;
    font-family: 'Rajdhani', sans-serif;
    font-weight: bold;
    font-size: 1rem;
    width: 140px;
    text-align: center;
    outline: none;
    transition: all 0.3s ease;
}

#player-name:focus {
    border-color: var(--cyan);
    box-shadow: 0 0 10px rgba(0, 255, 255, 0.3);
    background: rgba(0, 255, 255, 0.1);
}

/* Ranking Modal Specifics */
.ranking-content {
    width: 90vw;
    max-width: 500px;
    padding: 2rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
}

.title-center {
    text-align: center;
    font-family: 'Orbitron', sans-serif;
    letter-spacing: 1px;
    font-size: 1.8rem !important; /* 2 sizes smaller than default 2.5rem */
}

.ranking-tabs {
    display: flex;
    gap: 10px;
    width: 100%;
    justify-content: center;
}

.rank-tab-btn {
    background: transparent;
    color: #888;
    border: 1px solid #444;
    padding: 6px 12px;
    font-family: 'Rajdhani', sans-serif;
    font-weight: bold;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.rank-tab-btn:hover {
    color: #fff;
    border-color: #888;
}

.rank-tab-btn.active {
    color: var(--magenta);
    border-color: var(--magenta);
    box-shadow: 0 0 10px rgba(255, 0, 255, 0.2);
    text-shadow: 0 0 5px var(--magenta);
}

.rankings-table-wrapper {
    width: 100%;
    max-height: 250px;
    overflow-y: auto;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: rgba(0, 0, 0, 0.3);
}

.rankings-table {
    width: 100%;
    border-collapse: collapse;
    font-family: 'Rajdhani', sans-serif;
    color: var(--text-primary);
}

.rankings-table th, .rankings-table td {
    padding: 10px;
    text-align: center;
    border-bottom: 1px solid rgba(0, 255, 255, 0.1);
}

.rankings-table th {
    font-family: 'Orbitron', sans-serif;
    font-size: 0.85rem;
    color: var(--cyan);
    background: rgba(0, 255, 255, 0.05);
    letter-spacing: 1px;
    position: sticky;
    top: 0;
}

.rankings-table tr:hover td {
    background: rgba(0, 255, 255, 0.03);
}

.rankings-table tr.highlight td {
    color: var(--magenta);
    font-weight: bold;
    text-shadow: 0 0 5px var(--magenta);
}
