/* style.css - Zen Ink Brush Snake */

/* Base & Design System */
:root {
    --bg-paper: #f4f1ea;
    --border-paper: #dcd7cd;
    --border-dark: #8c826e;
    --ink-black: #1a1a1a;
    --ink-gray: #555555;
    --ink-light: #a0a0a0;
    --cinnabar-red: #b83b30;
    --jade-green: #3b7a75;
    --gold-ink: #b89c30;
    
    --shadow-soft: 0 10px 30px rgba(140, 130, 110, 0.15);
    --shadow-inset: inset 0 2px 5px rgba(0, 0, 0, 0.05);
}

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

body {
    font-family: 'Noto Serif SC', serif;
    background-color: #e6e2d8;
    color: var(--ink-black);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow-x: hidden;
    position: relative;
    padding: 20px;
}

/* Background Textures */
.paper-texture {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    opacity: 0.12;
    pointer-events: none;
    z-index: 1;
    background-image: 
        radial-gradient(var(--border-dark) 0.5px, transparent 0.5px),
        radial-gradient(var(--border-dark) 0.5px, var(--bg-paper) 0.5px);
    background-size: 20px 20px;
    background-position: 0 0, 10px 10px;
}

/* Calligraphy Text Classes */
.cursive {
    font-family: 'Long Cang', cursive;
}

.title-font {
    font-family: 'ZCOOL XiaoWei', serif;
}

/* Scroll Container representing a traditional Chinese Painting Scroll */
.scroll-wrapper {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    max-width: 1000px;
    z-index: 2;
    padding: 40px 0;
}

/* Wooden rollers on the top and bottom of the scroll */
.scroll-roller {
    width: calc(100% + 40px);
    height: 24px;
    background: linear-gradient(to bottom, #5c4033, #8b5a2b, #5c4033);
    border-radius: 8px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
    position: absolute;
    left: -20px;
    z-index: 5;
}

.scroll-top {
    top: 28px;
}

.scroll-bottom {
    bottom: 28px;
}

.scroll-container {
    background-color: var(--bg-paper);
    width: 100%;
    border-left: 2px solid var(--border-paper);
    border-right: 2px solid var(--border-paper);
    box-shadow: var(--shadow-soft);
    padding: 30px 40px;
    position: relative;
    border-radius: 4px;
    background-image: radial-gradient(#faf8f5 1px, transparent 1px);
    background-size: 24px 24px;
}

/* Header styling */
.game-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-paper);
    padding-bottom: 15px;
    margin-bottom: 25px;
}

.btn-back {
    display: inline-flex;
    align-items: center;
    color: var(--border-dark);
    text-decoration: none;
    font-size: 14px;
    font-weight: 600;
    transition: color 0.3s ease, transform 0.3s ease;
    border: 1px solid var(--border-paper);
    padding: 6px 12px;
    border-radius: 4px;
    background-color: rgba(255, 255, 255, 0.4);
}

.btn-back:hover {
    color: var(--cinnabar-red);
    border-color: var(--cinnabar-red);
    transform: translateX(-4px);
}

.back-arrow {
    margin-right: 5px;
}

.game-title {
    text-align: center;
}

.game-title h1 {
    font-family: 'ZCOOL XiaoWei', serif;
    font-size: 32px;
    font-weight: normal;
    letter-spacing: 4px;
    color: var(--ink-black);
}

.game-title .sub-title {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: var(--border-dark);
    display: block;
    margin-top: 4px;
}

/* Red Seal Stamp */
.zen-stamp {
    width: 46px;
    height: 46px;
    border: 2px solid var(--cinnabar-red);
    color: var(--cinnabar-red);
    font-family: 'ZCOOL XiaoWei', serif;
    font-weight: bold;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 16px;
    line-height: 1;
    transform: rotate(-8deg);
    user-select: none;
    box-shadow: 0 0 2px rgba(184, 59, 48, 0.3);
    border-radius: 3px;
    background-color: rgba(184, 59, 48, 0.03);
}

.stamp-inner {
    padding: 4px;
    border: 1px dashed var(--cinnabar-red);
}

/* Main Layout Grid */
.game-layout {
    display: grid;
    grid-template-columns: 320px 1fr;
    gap: 30px;
    align-items: start;
}

/* Paper Cards for Panels */
.paper-card {
    background-color: rgba(255, 255, 255, 0.5);
    border: 1px solid var(--border-paper);
    border-radius: 6px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: 0 4px 12px rgba(140, 130, 110, 0.05);
}

.card-title {
    font-family: 'ZCOOL XiaoWei', serif;
    font-size: 18px;
    color: var(--ink-black);
    border-left: 3px solid var(--border-dark);
    padding-left: 10px;
    margin-bottom: 15px;
    font-weight: normal;
}

/* Ink Energy Bar (Yantai) */
.ink-meter {
    width: 100%;
    height: 24px;
    background-color: #e0dbd0;
    border: 1px solid var(--border-paper);
    border-radius: 12px;
    position: relative;
    overflow: hidden;
    box-shadow: var(--shadow-inset);
}

.ink-fill {
    height: 100%;
    background: linear-gradient(to right, #333333, var(--ink-black));
    border-radius: 12px;
    transition: width 0.1s linear, background 0.3s ease;
}

.ink-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 11px;
    font-weight: 600;
    color: #ffffff;
    mix-blend-mode: difference;
}

.stats-row {
    margin-bottom: 12px;
}

.stats-row.grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    margin-top: 15px;
}

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

.stat-label {
    font-size: 12px;
    color: var(--border-dark);
    margin-bottom: 4px;
}

.stat-val {
    font-size: 32px;
    color: var(--ink-black);
    line-height: 1.1;
}

/* Zen characters list styling */
.zen-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.zen-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px;
    border-radius: 4px;
    border: 1px solid transparent;
    transition: all 0.3s ease;
}

.zen-char {
    width: 32px;
    height: 32px;
    background-color: var(--bg-paper);
    border: 1px solid var(--border-paper);
    border-radius: 4px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-family: 'ZCOOL XiaoWei', serif;
    font-size: 18px;
    font-weight: bold;
    color: var(--ink-black);
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
    transition: all 0.3s ease;
}

.zen-desc strong {
    font-size: 13px;
    color: var(--ink-black);
    display: block;
}

.zen-desc p {
    font-size: 11px;
    color: var(--border-dark);
    margin-top: 2px;
    line-height: 1.3;
}

/* Zen Item Active States */
#zen-jing.active .zen-char {
    background-color: #e6f2ff;
    border-color: #3b88b8;
    color: #3b88b8;
    box-shadow: 0 0 8px rgba(59, 136, 184, 0.4);
}
#zen-liu.active .zen-char {
    background-color: #fff2e6;
    border-color: var(--cinnabar-red);
    color: var(--cinnabar-red);
    box-shadow: 0 0 8px rgba(184, 59, 48, 0.4);
}
#zen-kong.active .zen-char {
    background-color: #eaf6ea;
    border-color: var(--jade-green);
    color: var(--jade-green);
    box-shadow: 0 0 8px rgba(59, 122, 117, 0.4);
}
#zen-run.active .zen-char {
    background-color: #fbf8e6;
    border-color: var(--gold-ink);
    color: var(--gold-ink);
    box-shadow: 0 0 8px rgba(184, 156, 48, 0.4);
}

.zen-item.active {
    background-color: rgba(255, 255, 255, 0.8);
    border-color: var(--border-paper);
}

/* Settings styling */
.control-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.control-row:last-child {
    margin-bottom: 0;
}

.control-row label {
    font-size: 13px;
    color: var(--ink-black);
}

select {
    padding: 6px 12px;
    background-color: var(--bg-paper);
    border: 1px solid var(--border-dark);
    border-radius: 4px;
    color: var(--ink-black);
    font-family: inherit;
    outline: none;
    font-size: 12px;
    cursor: pointer;
}

/* Custom Switch Toggle */
.toggle-container {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 22px;
}

.toggle-container input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #e0dbd0;
    transition: .3s;
    border-radius: 11px;
    border: 1px solid var(--border-paper);
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 14px;
    width: 14px;
    left: 3px;
    bottom: 3px;
    background-color: var(--border-dark);
    transition: .3s;
    border-radius: 50%;
}

input:checked + .toggle-slider {
    background-color: var(--jade-green);
}

input:checked + .toggle-slider:before {
    transform: translateX(22px);
    background-color: #ffffff;
}

/* Center Panel - Board Canvas */
.game-center {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.canvas-wrapper {
    position: relative;
    background-color: #faf7f2;
    border: 8px double var(--border-dark);
    padding: 5px;
    box-shadow: 0 15px 35px rgba(100, 90, 70, 0.2);
    border-radius: 4px;
    overflow: hidden;
}

/* Classical Corner Decorative Borders */
.canvas-corner {
    position: absolute;
    width: 16px;
    height: 16px;
    border: 2px solid var(--cinnabar-red);
    pointer-events: none;
}

.top-left { top: 5px; left: 5px; border-right: none; border-bottom: none; }
.top-right { top: 5px; right: 5px; border-left: none; border-bottom: none; }
.bottom-left { bottom: 5px; left: 5px; border-right: none; border-top: none; }
.bottom-right { bottom: 5px; right: 5px; border-left: none; border-top: none; }

/* Apply SVG Filter to the Canvas for bleeding liquid effect */
#game-canvas {
    display: block;
    background-color: transparent;
    cursor: crosshair;
    max-width: 100%;
    height: auto;
    filter: url(#ink-bleed); /* The magic filter */
}

/* Screen Overlays */
.screen-overlay {
    position: absolute;
    top: 5px;
    left: 5px;
    right: 5px;
    bottom: 5px;
    background-color: rgba(244, 241, 234, 0.95);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10;
    transition: opacity 0.4s ease, visibility 0.4s ease;
    backdrop-filter: blur(2px);
}

.screen-overlay.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.overlay-content {
    text-align: center;
    max-width: 480px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.seal-logo {
    width: 64px;
    height: 64px;
    border: 3px double var(--ink-black);
    font-family: 'ZCOOL XiaoWei', serif;
    font-size: 32px;
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 15px;
    user-select: none;
    border-radius: 50%;
}

.seal-logo.red {
    border-color: var(--cinnabar-red);
    color: var(--cinnabar-red);
}

.overlay-content h2 {
    font-size: 38px;
    margin-bottom: 10px;
    font-weight: normal;
}

.game-intro {
    font-size: 13px;
    line-height: 1.6;
    color: var(--ink-gray);
    margin-bottom: 20px;
}

.tutorial-box {
    background-color: rgba(255, 255, 255, 0.4);
    border: 1px dashed var(--border-dark);
    padding: 12px;
    border-radius: 4px;
    font-size: 11px;
    text-align: left;
    margin-bottom: 25px;
    line-height: 1.5;
}

.tutorial-box p {
    margin-bottom: 8px;
}

.tutorial-box p:last-child {
    margin-bottom: 0;
}

.tutorial-box code {
    background-color: #eae5d8;
    padding: 1px 4px;
    border-radius: 3px;
    font-family: monospace;
    font-weight: bold;
}

/* Antique Ink Button */
.btn-ink {
    background-color: var(--ink-black);
    color: var(--bg-paper);
    border: 1px solid var(--ink-black);
    font-family: 'ZCOOL XiaoWei', serif;
    font-size: 16px;
    padding: 10px 28px;
    border-radius: 4px;
    cursor: pointer;
    letter-spacing: 2px;
    transition: all 0.3s ease;
    box-shadow: 0 4px 10px rgba(0,0,0,0.15);
}

.btn-ink:hover {
    background-color: transparent;
    color: var(--ink-black);
    box-shadow: 0 4px 15px rgba(0,0,0,0.05);
}

/* Stats Report for Game Over */
.stats-report {
    background-color: rgba(255, 255, 255, 0.4);
    border: 1px solid var(--border-paper);
    padding: 15px 30px;
    border-radius: 4px;
    margin-bottom: 25px;
    width: 100%;
}

.stats-report p {
    display: flex;
    justify-content: space-between;
    font-size: 14px;
    margin-bottom: 8px;
    color: var(--ink-gray);
}

.stats-report p:last-child {
    margin-bottom: 0;
}

.stat-highlight {
    font-weight: bold;
    color: var(--ink-black);
}

.stat-highlight.cursive {
    font-size: 24px;
    line-height: 1;
}

/* Mobile Virtual D-pad / Joystick Container */
.mobile-controls {
    display: none;
    flex-direction: column;
    align-items: center;
    margin-top: 25px;
    width: 100%;
}

.joystick-boundary {
    width: 140px;
    height: 140px;
    background-color: rgba(255, 255, 255, 0.6);
    border: 2px solid var(--border-dark);
    border-radius: 50%;
    position: relative;
    touch-action: none;
    box-shadow: var(--shadow-inset), 0 4px 10px rgba(0,0,0,0.05);
    display: flex;
    justify-content: center;
    align-items: center;
}

.joystick-yin-yang {
    position: absolute;
    width: 100px;
    height: 100px;
    opacity: 0.05;
    background: radial-gradient(circle, #000 50%, transparent 50%), linear-gradient(to right, #000 50%, #fff 50%);
    border-radius: 50%;
    pointer-events: none;
}

.joystick-yin-yang::before, .joystick-yin-yang::after {
    content: '';
    position: absolute;
    width: 50px;
    height: 50px;
    left: 25px;
    border-radius: 50%;
}
.joystick-yin-yang::before {
    top: 0;
    background: #000;
}
.joystick-yin-yang::after {
    bottom: 0;
    background: #fff;
}

.joystick-center-dot {
    width: 16px;
    height: 16px;
    background-color: var(--border-dark);
    border-radius: 50%;
    opacity: 0.3;
    pointer-events: none;
}

.joystick-handle {
    width: 50px;
    height: 50px;
    background-color: var(--bg-paper);
    border: 3px double var(--ink-black);
    border-radius: 50%;
    position: absolute;
    top: 45px;
    left: 45px;
    cursor: grab;
    z-index: 2;
    box-shadow: 0 4px 10px rgba(0,0,0,0.1);
    transition: transform 0.05s ease;
}

.joystick-handle::after {
    content: '';
    position: absolute;
    top: 19px;
    left: 19px;
    width: 6px;
    height: 6px;
    background-color: var(--cinnabar-red);
    border-radius: 50%;
}

.mobile-tip {
    font-size: 11px;
    color: var(--border-dark);
    margin-top: 10px;
    text-align: center;
}

/* Responsiveness */
@media (max-width: 900px) {
    body {
        padding: 10px;
    }
    
    .scroll-wrapper {
        padding: 20px 0;
    }
    
    .scroll-roller {
        width: calc(100% + 20px);
        left: -10px;
    }
    
    .scroll-top { top: 8px; }
    .scroll-bottom { bottom: 8px; }
    
    .scroll-container {
        padding: 20px 20px;
    }
    
    .game-layout {
        grid-template-columns: 1fr;
        gap: 20px;
    }
    
    .panel-left {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 15px;
    }
    
    .paper-card {
        margin-bottom: 0;
    }
    
    .zen-card {
        grid-row: span 2;
    }
    
    .mobile-controls {
        display: flex;
    }
}

@media (max-width: 600px) {
    .panel-left {
        grid-template-columns: 1fr;
    }
    
    .zen-card {
        grid-row: auto;
    }
    
    .game-title h1 {
        font-size: 26px;
    }
    
    .scroll-container {
        padding: 15px 15px;
    }
}
