/* CSS Variables */
:root {
    --bg-primary: #0a0a1a;
    --bg-secondary: #12122a;
    --accent-gold: #ffd700;
    --accent-orange: #ff8c00;
    --accent-cyan: #00d4ff;
    --accent-purple: #a855f7;
    --accent-green: #22c55e;
    --accent-red: #ef4444;
    --text-primary: #ffffff;
    --text-secondary: rgba(255, 255, 255, 0.7);

    /* Minesweeper specific */
    --cell-hidden: #8b7355;
    --cell-hidden-light: #a08060;
    --cell-revealed: #d4c4a8;
    --cell-revealed-dark: #c4b498;
    --cell-mine: #ef4444;
    --cell-flag: #fbbf24;
    --board-bg: #5c4a32;
    --board-border: #3d2f1e;
}

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

body {
    font-family: 'Noto Sans KR', sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
}

/* Background effects */
.bg-effects {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    overflow: hidden;
    z-index: 0;
}

.bg-orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    opacity: 0.3;
    animation: float 20s infinite ease-in-out;
}

.bg-orb:nth-child(1) {
    width: 400px;
    height: 400px;
    background: var(--accent-purple);
    top: -100px;
    left: -100px;
}

.bg-orb:nth-child(2) {
    width: 300px;
    height: 300px;
    background: var(--accent-cyan);
    bottom: -50px;
    right: -50px;
    animation-delay: -10s;
}

@keyframes float {
    0%, 100% { transform: translate(0, 0) scale(1); }
    33% { transform: translate(30px, -30px) scale(1.1); }
    66% { transform: translate(-20px, 20px) scale(0.9); }
}

/* Container */
.container {
    position: relative;
    z-index: 1;
    max-width: 600px;
    margin: 0 auto;
    padding: 20px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header */
header {
    text-align: center;
    margin-bottom: 20px;
}

.header-top {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    margin-bottom: 10px;
    position: relative;
}

.back-btn {
    position: absolute;
    left: 0;
    display: flex;
    align-items: center;
    gap: 5px;
    color: var(--text-secondary);
    text-decoration: none;
    font-family: 'Jua', sans-serif;
    font-size: 0.9rem;
    transition: color 0.3s;
}

.back-btn:hover {
    color: var(--accent-cyan);
}

.back-btn svg {
    width: 20px;
    height: 20px;
}

header h1 {
    font-family: 'Black Han Sans', sans-serif;
    font-size: 2rem;
    background: linear-gradient(135deg, var(--accent-gold), var(--accent-orange));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.lang-btn {
    position: absolute;
    right: 0;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: var(--text-secondary);
    padding: 5px 12px;
    border-radius: 15px;
    font-family: 'Jua', sans-serif;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.3s;
}

.lang-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    color: var(--text-primary);
}

.subtitle {
    font-family: 'Jua', sans-serif;
    color: var(--text-secondary);
    font-size: 1rem;
}

/* Game Area */
.game-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
}

/* Game Status */
.game-status {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    max-width: 400px;
    padding: 10px 15px;
    background: var(--bg-secondary);
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.status-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}

.status-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.status-value {
    font-family: 'Black Han Sans', sans-serif;
    font-size: 1.3rem;
    color: var(--accent-gold);
}

.difficulty-badge {
    padding: 5px 15px;
    border-radius: 20px;
    font-family: 'Jua', sans-serif;
    font-size: 0.9rem;
    font-weight: bold;
}

.difficulty-badge.easy {
    background: linear-gradient(135deg, #22c55e, #16a34a);
    color: white;
}

.difficulty-badge.normal {
    background: linear-gradient(135deg, #f59e0b, #d97706);
    color: white;
}

.difficulty-badge.hard {
    background: linear-gradient(135deg, #ef4444, #dc2626);
    color: white;
}

/* Minesweeper Board */
.minesweeper-board {
    display: grid;
    gap: 2px;
    padding: 8px;
    background: var(--board-bg);
    border-radius: 8px;
    border: 4px solid var(--board-border);
    box-shadow:
        inset 0 2px 4px rgba(0, 0, 0, 0.3),
        0 4px 15px rgba(0, 0, 0, 0.4);
    width: 100%;
    max-width: 400px;
    aspect-ratio: 1;
}

/* Cells */
.cell {
    aspect-ratio: 1;
    overflow: hidden;
    min-width: 0;
    border: 2px solid transparent;
    border-radius: 3px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Black Han Sans', sans-serif;
    font-size: clamp(12px, 3vw, 18px);
    font-weight: bold;
    transition: background 0.1s ease, filter 0.1s ease, box-shadow 0.1s ease;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

/* Hidden cell - 3D raised effect */
.cell.hidden {
    background: linear-gradient(135deg, var(--cell-hidden-light), var(--cell-hidden));
    border: 2px solid;
    border-color: #b8a070 #5c4a32 #5c4a32 #b8a070;
    box-shadow: inset 1px 1px 0 rgba(255, 255, 255, 0.2);
}

.cell.hidden:hover {
    background: linear-gradient(135deg, #b89570, var(--cell-hidden));
    filter: brightness(1.1);
}

.cell.hidden:active {
    border-color: #5c4a32 #b8a070 #b8a070 #5c4a32;
    box-shadow: inset -1px -1px 0 rgba(255, 255, 255, 0.2);
}

/* Revealed cell - flat */
.cell.revealed {
    background: var(--cell-revealed);
    border: 2px solid var(--cell-revealed-dark);
}

/* Alternating revealed cells */
.cell.revealed.alt {
    background: var(--cell-revealed-dark);
}

/* Flagged cell */
.cell.flagged {
    background: linear-gradient(135deg, var(--cell-hidden-light), var(--cell-hidden));
    border: 2px solid;
    border-color: #b8a070 #5c4a32 #5c4a32 #b8a070;
}

.cell.flagged::after {
    content: '🚩';
    font-size: clamp(14px, 4vw, 22px);
}

/* Mine cell */
.cell.mine {
    background: var(--cell-mine);
}

.cell.mine::after {
    content: '💣';
    font-size: clamp(14px, 4vw, 22px);
}

.cell.mine.exploded {
    background: #ff0000;
    animation: explode 0.3s ease-out;
}

.cell.mine.exploded::after {
    content: '💥';
}

/* Wrong flag */
.cell.wrong-flag {
    background: var(--cell-revealed);
}

.cell.wrong-flag::after {
    content: '❌';
    font-size: clamp(14px, 4vw, 22px);
}

@keyframes explode {
    0% { transform: scale(1); }
    50% { transform: scale(1.2); }
    100% { transform: scale(1); }
}

/* Number colors */
.cell.num-1 { color: #0000ff; }
.cell.num-2 { color: #008000; }
.cell.num-3 { color: #ff0000; }
.cell.num-4 { color: #000080; }
.cell.num-5 { color: #800000; }
.cell.num-6 { color: #008080; }
.cell.num-7 { color: #000000; }
.cell.num-8 { color: #808080; }

/* Game Controls */
.game-controls {
    display: flex;
    gap: 10px;
    width: 100%;
    max-width: 400px;
    justify-content: center;
}

.control-btn {
    flex: 1;
    padding: 12px 20px;
    border: none;
    border-radius: 25px;
    font-family: 'Jua', sans-serif;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.control-btn:first-child {
    background: linear-gradient(135deg, var(--accent-cyan), #0099cc);
    color: white;
}

.control-btn:first-child:hover {
    transform: scale(1.05);
    box-shadow: 0 0 20px rgba(0, 212, 255, 0.4);
}

.flag-btn {
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid rgba(255, 255, 255, 0.2);
    color: var(--text-primary);
}

.flag-btn:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: var(--cell-flag);
}

.flag-btn.active {
    background: linear-gradient(135deg, var(--cell-flag), #f59e0b);
    border-color: var(--cell-flag);
    color: #000;
}

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

/* Overlays */
.overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.overlay.show {
    opacity: 1;
    visibility: visible;
}

.overlay-content {
    background: var(--bg-secondary);
    padding: 30px;
    border-radius: 20px;
    text-align: center;
    max-width: 90%;
    width: 350px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    animation: slideUp 0.3s ease;
}

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

.overlay-content h2 {
    font-family: 'Black Han Sans', sans-serif;
    font-size: 2rem;
    margin-bottom: 15px;
    background: linear-gradient(135deg, var(--accent-gold), var(--accent-orange));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.difficulty-label {
    color: var(--text-secondary);
    margin-bottom: 20px;
    font-family: 'Jua', sans-serif;
}

/* Difficulty Buttons */
.difficulty-buttons {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.difficulty-btn {
    padding: 15px 25px;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
}

.difficulty-btn.easy {
    background: linear-gradient(135deg, #22c55e, #16a34a);
    color: white;
}

.difficulty-btn.normal {
    background: linear-gradient(135deg, #f59e0b, #d97706);
    color: white;
}

.difficulty-btn.hard {
    background: linear-gradient(135deg, #ef4444, #dc2626);
    color: white;
}

.difficulty-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.3);
}

.diff-name {
    font-family: 'Black Han Sans', sans-serif;
    font-size: 1.3rem;
}

.diff-info {
    font-size: 0.85rem;
    opacity: 0.9;
}

/* Game Over Content */
.gameover-content h2 {
    font-size: 2.5rem;
}

.gameover-content h2.win {
    background: linear-gradient(135deg, var(--accent-green), #16a34a);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.gameover-content h2.lose {
    background: linear-gradient(135deg, var(--accent-red), #dc2626);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.gameover-message {
    color: var(--text-secondary);
    margin-bottom: 20px;
    font-family: 'Jua', sans-serif;
    font-size: 1.1rem;
}

.gameover-stats {
    display: flex;
    justify-content: center;
    gap: 30px;
    margin-bottom: 25px;
}

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

.stat-label {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.stat-value {
    font-family: 'Black Han Sans', sans-serif;
    font-size: 1.5rem;
    color: var(--accent-gold);
}

.gameover-buttons {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.primary-btn, .secondary-btn {
    padding: 12px 30px;
    border: none;
    border-radius: 25px;
    font-family: 'Jua', sans-serif;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s;
}

.primary-btn {
    background: linear-gradient(135deg, var(--accent-gold), var(--accent-orange));
    color: #000;
}

.primary-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 0 20px rgba(255, 215, 0, 0.4);
}

.secondary-btn {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: var(--text-primary);
}

.secondary-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Game Content Article */
.game-content {
    margin-top: 30px;
    padding: 25px;
    background: var(--bg-secondary);
    border-radius: 15px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.game-content h2 {
    font-family: 'Black Han Sans', sans-serif;
    font-size: 1.5rem;
    color: var(--accent-gold);
    margin-bottom: 15px;
}

.game-content h3 {
    font-family: 'Jua', sans-serif;
    font-size: 1.2rem;
    color: var(--accent-cyan);
    margin: 20px 0 10px;
}

.game-content p {
    color: var(--text-secondary);
    line-height: 1.7;
    margin-bottom: 15px;
}

.tips-list {
    list-style: none;
    padding: 0;
}

.tips-list li {
    color: var(--text-secondary);
    padding: 8px 0 8px 25px;
    position: relative;
    line-height: 1.5;
}

.tips-list li::before {
    content: '💡';
    position: absolute;
    left: 0;
}

/* Footer */
footer {
    margin-top: 30px;
    text-align: center;
    padding: 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

footer p {
    margin-bottom: 10px;
}

footer a {
    color: var(--accent-cyan);
    text-decoration: none;
    transition: color 0.3s;
}

footer a:hover {
    color: var(--accent-gold);
}

.footer-links {
    display: flex;
    justify-content: center;
    gap: 20px;
    font-size: 0.85rem;
}

.footer-links a {
    color: var(--text-secondary);
}

/* Mobile Responsive */
@media (max-width: 600px) {
    .container {
        padding: 15px;
    }

    header h1 {
        font-size: 1.6rem;
    }

    .subtitle {
        font-size: 0.9rem;
    }

    .game-status {
        padding: 8px 12px;
    }

    .status-value {
        font-size: 1.1rem;
    }

    .difficulty-badge {
        padding: 4px 10px;
        font-size: 0.8rem;
    }

    .minesweeper-board {
        max-width: calc(100vw - 30px);
        padding: 5px;
        border-width: 3px;
    }

    .game-controls {
        max-width: calc(100vw - 30px);
    }

    .control-btn {
        padding: 10px 15px;
        font-size: 0.9rem;
    }

    .game-content {
        padding: 20px;
    }

    .game-content, footer {
        display: none;
    }

    .overlay-content {
        padding: 25px 20px;
        width: 95%;
    }
}

/* Resume overlay styles */
.resume-content {
    text-align: center;
}

.saved-info {
    color: var(--text-secondary);
    font-family: 'Jua', sans-serif;
    font-size: 1.1rem;
    margin: 15px 0;
}

.resume-buttons {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 20px;
}

.resume-buttons .primary-btn {
    background: linear-gradient(135deg, var(--accent-cyan), #00a0cc);
}

.resume-buttons .secondary-btn {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

/* Touch device adjustments */
@media (hover: none) {
    .cell.hidden:hover {
        background: linear-gradient(135deg, var(--cell-hidden-light), var(--cell-hidden));
        filter: none;
    }
}

/* Tap-Confirm Selected State */
.cell.selected {
    position: relative;
    z-index: 5;
}

.cell.hidden.selected {
    background: linear-gradient(135deg, #d4a656, #b88c40);
    border-color: var(--accent-gold) !important;
    box-shadow:
        0 0 10px rgba(255, 215, 0, 0.5),
        inset 1px 1px 0 rgba(255, 255, 255, 0.3);
    animation: pulse-cell 0.8s ease-in-out infinite;
}

@keyframes pulse-cell {
    0%, 100% {
        transform: scale(1);
        box-shadow: 0 0 10px rgba(255, 215, 0, 0.5);
    }
    50% {
        transform: scale(1.05);
        box-shadow: 0 0 15px rgba(255, 215, 0, 0.7);
    }
}
