/* // codex: 2026-01-24 主宰模式解释/提示样式与移动端布局优化 */
:root {
    --primary-color: #6c5ce7;
    --secondary-color: #a29bfe;
    --accent-color: #00cec9;
    --bg-color: #f8f9fa;
    --text-color: #2d3436;
    --grid-bg: #dfe6e9;
    --cell-empty: #ffffff;
    --cell-safe: #55efc4;
    --cell-monster: #ff7675;

    /* Path colors for history layering */
    --path-color-1: rgba(116, 185, 255, 0.4);
    --path-color-2: rgba(162, 155, 254, 0.4);
    --path-color-3: rgba(253, 121, 168, 0.4);
    --path-color-4: rgba(250, 177, 160, 0.4);
    --path-color-current: rgba(255, 234, 167, 0.8);

    --border-radius: 12px;
    --cell-size: clamp(28px, 6.2vw, 45px);
    --cell-font-size: clamp(1rem, 3.4vw, 1.5rem);
}

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

body {
    font-family: 'Outfit', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 16px;
}

/* OVERLAY */
.overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.95);
    z-index: 100;
    display: flex;
    justify-content: center;
    align-items: center;
    flex-direction: column;
    backdrop-filter: blur(6px);
}

.overlay.hidden {
    display: none;
}

.overlay-content {
    text-align: center;
    max-width: 600px;
    padding: 2rem;
    background: white;
    border-radius: 16px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
}

.cute-dialog {
    max-width: 420px;
    border: 2px solid #f1f2f6;
    background: linear-gradient(160deg, #ffffff 0%, #fff7fb 100%);
    position: relative;
}

.cute-dialog::before {
    content: '';
    position: absolute;
    inset: -10px;
    border-radius: 20px;
    background: radial-gradient(circle at top left, rgba(162, 155, 254, 0.25), transparent 60%);
    z-index: -1;
}

.cute-dialog-icon {
    font-size: 3rem;
    margin-bottom: 0.5rem;
}

.cute-dialog-message {
    font-size: 1.05rem;
    line-height: 1.6;
    margin: 0.5rem 0 1.2rem;
    white-space: pre-line;
}

.rules-content {
    text-align: left;
}

.rules-text {
    margin: 20px 0;
    line-height: 1.6;
}

.rules-list {
    margin-left: 20px;
    margin-bottom: 15px;
}

.victory-content .victory-icon {
    font-size: 5rem;
    margin-bottom: 1rem;
    animation: bounce 1s infinite;
}

.victory-stats {
    font-size: 1.2rem;
    margin: 20px 0;
    font-weight: bold;
    color: var(--primary-color);
}

.victory-actions {
    display: flex;
    gap: 15px;
    justify-content: center;
}

@keyframes bounce {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-10px);
    }
}

.mode-cards {
    display: flex;
    gap: 20px;
    margin-top: 30px;
    flex-wrap: wrap;
    justify-content: center;
}

.card {
    background: white;
    border: 2px solid #eee;
    padding: 20px;
    border-radius: 12px;
    width: 250px;
    cursor: pointer;
    transition: transform 0.2s, border-color 0.2s;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
}

.card:hover {
    transform: translateY(-5px);
    border-color: var(--primary-color);
}

.card .icon {
    font-size: 3rem;
    margin-bottom: 10px;
}

.lang-toggle-container {
    margin-bottom: 20px;
}

.lang-btn {
    padding: 5px 15px;
    border: 1px solid #ccc;
    background: white;
    cursor: pointer;
}

.lang-btn.active {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

/* GAME UI */
.game-container {
    background: white;
    padding: 2rem;
    border-radius: var(--border-radius);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.1);
    max-width: 980px;
    width: 100%;
    text-align: center;
    position: relative;
    overflow: hidden;
    /* Contains the modal */
}

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

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    gap: 12px;
    flex-wrap: wrap;
}

.grid-wrapper {
    display: flex;
    justify-content: center;
    margin-bottom: 1.5rem;
    overflow-x: auto;
    padding: 10px;
}

.grid-board {
    display: grid;
    gap: 2px;
    background-color: var(--grid-bg);
    padding: 5px;
    border-radius: 8px;
    position: relative;
}

.cell {
    width: var(--cell-size);
    height: var(--cell-size);
    background-color: var(--cell-empty);
    border-radius: 4px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: var(--cell-font-size);
    cursor: pointer;
    user-select: none;
    position: relative;
    /* For overlays */
}

/* Path Layering */
.cell.path-layer-1 {
    background-color: var(--path-color-1);
}

.cell.path-layer-2 {
    background-color: var(--path-color-2);
}

.cell.path-layer-3 {
    background-color: var(--path-color-3);
}

.cell.path-layer-4 {
    background-color: var(--path-color-4);
}

/* Current path overrides history */
.cell.path-current {
    background-color: var(--path-color-current);
    border: 2px solid #ffeaa7;
}

.cell.monster-revealed {
    background-color: var(--cell-monster) !important;
}

/* Snail & Monster Icons */
.cell.snail::after {
    content: '🐌';
    position: absolute;
    font-size: clamp(1rem, 3vw, 1.2rem);
}

.cell.monster-revealed::after {
    content: '👹';
    position: absolute;
    font-size: clamp(1rem, 3vw, 1.2rem);
}

.primary-btn {
    background-color: var(--primary-color);
    color: white;
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: bold;
}

.secondary-btn {
    background-color: #b2bec3;
    color: white;
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
}

.small-btn {
    padding: 5px 10px;
    font-size: 0.9rem;
}

.hidden {
    display: none !important;
}

.debug-panel {
    width: min(900px, 100%);
    border: 1px solid #eef0f3;
    border-radius: 12px;
    padding: 10px;
    background: linear-gradient(160deg, #ffffff 0%, #f8f9ff 100%);
    box-shadow: 0 6px 14px rgba(0, 0, 0, 0.06);
    margin: 12px auto 0;
}

.debug-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 8px;
}

.debug-title {
    font-weight: 700;
    color: var(--primary-color);
}

.debug-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.debug-textarea {
    width: 100%;
    min-height: 160px;
    max-height: 40vh;
    resize: vertical;
    padding: 10px 12px;
    border-radius: 10px;
    border: 1px solid #e6e8ef;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
    font-size: 12px;
    line-height: 1.45;
    background: #0b1020;
    color: #e9ecff;
    outline: none;
}

.speed-control {
    width: min(900px, 100%);
    border: 1px solid #eef0f3;
    border-radius: 12px;
    padding: 10px 12px;
    background: #ffffff;
    margin: 10px auto 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.speed-label {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 600;
    font-size: 0.95rem;
}

#ai-speed-value {
    color: var(--primary-color);
    font-variant-numeric: tabular-nums;
}

#input-ai-speed {
    width: 100%;
    accent-color: var(--primary-color);
}

.mastermind-hint {
    width: min(900px, 100%);
    margin: 10px auto 0;
    padding: 10px 12px;
    border-radius: 12px;
    background: rgba(162, 155, 254, 0.18);
    border: 1px solid rgba(162, 155, 254, 0.35);
    color: #2d3436;
    text-align: center;
    font-weight: 600;
    line-height: 1.4;
}

.explain-content {
    width: min(94vw, 760px);
    max-width: 760px;
    text-align: center;
}

.explain-body {
    margin-top: 10px;
}

.explain-board-wrapper {
    position: relative;
    display: inline-block;
    margin: 8px auto 0;
}

.explain-board {
    --cell-size: clamp(24px, 7vw, 40px);
    border-radius: 10px;
}

.board-annotation {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.explain-text {
    margin-top: 12px;
    white-space: pre-line;
    text-align: left;
    font-size: 0.98rem;
    line-height: 1.55;
}

.explain-step {
    font-weight: 800;
    color: var(--primary-color);
    font-variant-numeric: tabular-nums;
}

.explain-footer {
    display: flex;
    gap: 10px;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
    margin-top: 12px;
}

.cell.monster-revealed[data-monster-id]::before {
    content: attr(data-monster-id);
    position: absolute;
    top: 3px;
    left: 6px;
    font-size: 11px;
    font-weight: 800;
    color: rgba(255, 255, 255, 0.92);
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
}

@media (max-width: 720px) {
    .debug-textarea {
        min-height: 140px;
        font-size: 11px;
    }

    .speed-label {
        font-size: 0.9rem;
    }

    .explain-text {
        font-size: 0.92rem;
    }
}

@media (max-width: 900px) {
    .game-container {
        padding: 1.5rem;
    }

    .overlay-content {
        width: min(92vw, 560px);
    }

    .mode-cards {
        gap: 16px;
    }
}

@media (max-width: 720px) {
    :root {
        --cell-size: clamp(24px, 8vw, 38px);
        --cell-font-size: clamp(0.9rem, 4vw, 1.3rem);
    }

    header {
        flex-direction: column;
        align-items: center;
    }

    .stats-panel {
        width: 100%;
        display: flex;
        justify-content: center;
        gap: 16px;
        flex-wrap: wrap;
    }
}

@media (max-width: 540px) {
    .game-container {
        padding: 1.2rem;
    }

    .grid-wrapper {
        padding: 6px;
    }

    .controls-area {
        display: flex;
        flex-direction: column;
        gap: 12px;
        align-items: center;
    }

    .mode-cards .card {
        width: 100%;
    }
}
