/* ========== Base Styles ========== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    /* 主色调 */
    --bg-cream: #f5f3eb;
    --bg-cream-light: #faf8f2;
    --text-dark: #1a1a1a;
    --text-light: #666666;
    --text-muted: #999999;
    --accent-blue: #5a9cbf;

    /* 底部积水 - 柔和蓝色 */
    --water-deep: rgba(120, 180, 208, 0.7);
    --water-mid: rgba(140, 195, 220, 0.5);
    --water-light: rgba(170, 210, 235, 0.35);
    --water-highlight: rgba(255, 255, 255, 0.5);

    /* 阴影 */
    --shadow-soft: rgba(0, 0, 0, 0.06);
    --shadow-medium: rgba(0, 0, 0, 0.1);
}

body {
    font-family: 'LXGW WenKai', serif;
    background-color: var(--bg-cream);
    color: var(--text-dark);
    min-height: 100vh;
    overflow: hidden;
    position: relative;
    font-size: 14px;
    line-height: 1.6;
}

/* 米色纸纹叠加 */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: url('data:image/svg+xml,<svg viewBox="0 0 200 200" xmlns="http://www.w3.org/2000/svg"><filter id="noise"><feTurbulence type="fractalNoise" baseFrequency="0.65" numOctaves="3" stitchTiles="stitch"/></filter><rect width="100%" height="100%" filter="url(%23noise)"/></svg>');
    opacity: 0.04;
    pointer-events: none;
    z-index: 1;
}

/* ========== Canvas Layers ========== */
#water-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 2;
}

#rain-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 100;
}

/* ========== Header ========== */
.header {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    padding: 30px;
    display: flex;
    justify-content: center;
    z-index: 50;
    pointer-events: none;
}

.logo {
    font-family: 'Courier New', 'Cutive Mono', monospace;
    font-size: 12px;
    letter-spacing: 4px;
    text-transform: uppercase;
    font-weight: 400;
    color: var(--text-dark);
    opacity: 0.6;
    transition: opacity 0.3s ease;
    pointer-events: auto;
}

.logo:hover {
    opacity: 1;
}

/* ========== Island Container ========== */
.island-container {
    position: relative;
    z-index: 10;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 80px 20px 150px;
}

.island-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    grid-template-rows: repeat(3, 1fr);
    gap: 0;
    width: 350px;
    height: 210px;
    background: var(--bg-cream);
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: 12px;
    position: relative;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.03);
    overflow: hidden;
}

/* ========== Island Cell ========== */
.island-cell {
    background: var(--bg-cream);
    border: 0.5px solid rgba(0, 0, 0, 0.06);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.island-cell:hover {
    background: rgba(0, 0, 0, 0.03);
    transform: scale(1.05);
    z-index: 5;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.island-cell.occupied {
    background: rgba(26, 26, 26, 0.02);
}

/* 彩色小圆点 */
.island-cell.occupied::after {
    content: '';
    position: absolute;
    bottom: 8px;
    left: 50%;
    transform: translateX(-50%);
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--cell-color, var(--accent-blue));
    opacity: 0.9;
}

.cell-number {
    font-family: 'Courier New', 'Cutive Mono', monospace;
    font-size: 12px;
    color: var(--text-dark);
    opacity: 0.5;
    font-weight: 400;
    letter-spacing: 1px;
}

.cell-name {
    font-family: 'Courier New', 'Cutive Mono', monospace;
    font-size: 9px;
    color: var(--text-muted);
    margin-top: 3px;
    text-align: center;
    max-width: 90%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ========== Tagline ========== */
.tagline {
    margin-top: 30px;
    font-family: 'Courier New', 'Cutive Mono', monospace;
    font-size: 10px;
    color: var(--text-muted);
    letter-spacing: 3px;
    text-transform: lowercase;
    opacity: 0.6;
    transition: opacity 0.3s ease, color 0.3s ease;
}

.tagline:hover {
    opacity: 1;
    color: var(--accent-blue);
}

/* ========== Modal (卡片化设计) ========== */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(26, 26, 26, 0.4);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-overlay.active {
    display: flex;
}

.modal {
    background: var(--bg-cream-light);
    border-radius: 16px;
    box-shadow:
        0 25px 50px rgba(0, 0, 0, 0.15),
        0 10px 25px rgba(0, 0, 0, 0.1),
        inset 0 1px 0 rgba(255, 255, 255, 0.6);
    padding: 36px 32px 32px;
    max-width: 360px;
    width: 90%;
    position: relative;
    border: none;
}

.modal h2 {
    font-family: 'Courier New', 'Cutive Mono', monospace;
    font-size: 13px;
    font-weight: 400;
    letter-spacing: 3px;
    text-transform: uppercase;
    margin-bottom: 4px;
    color: var(--text-dark);
}

.modal-subtitle {
    font-family: 'Courier New', 'Cutive Mono', monospace;
    font-size: 10px;
    color: var(--text-muted);
    letter-spacing: 1px;
    margin-bottom: 28px;
}

.modal-close {
    position: absolute;
    top: 16px;
    right: 16px;
    background: none;
    border: none;
    width: 28px;
    height: 28px;
    font-size: 18px;
    cursor: pointer;
    color: var(--text-muted);
    border-radius: 50%;
    transition: background 0.2s ease, color 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-close:hover {
    background: rgba(0, 0, 0, 0.06);
    color: var(--text-dark);
}

.form-group {
    margin-bottom: 18px;
}

.form-group label {
    display: block;
    font-family: 'Courier New', 'Cutive Mono', monospace;
    font-size: 9px;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    margin-bottom: 8px;
    color: var(--text-muted);
}

.form-group input {
    width: 100%;
    padding: 14px 16px;
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.7);
    font-family: 'Courier New', 'Cutive Mono', monospace;
    font-size: 13px;
    color: var(--text-dark);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.form-group input:focus {
    outline: none;
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 3px rgba(90, 156, 191, 0.15);
}

.form-group input::placeholder {
    color: var(--text-muted);
    opacity: 0.6;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.form-error {
    color: #e74c3c;
    font-family: 'Courier New', 'Cutive Mono', monospace;
    font-size: 10px;
    margin-bottom: 14px;
    min-height: 14px;
    letter-spacing: 0.5px;
}

.btn-submit {
    width: 100%;
    padding: 14px 20px;
    background: var(--text-dark);
    color: var(--bg-cream-light);
    border: none;
    border-radius: 8px;
    font-family: 'Courier New', 'Cutive Mono', monospace;
    font-size: 11px;
    letter-spacing: 2px;
    text-transform: uppercase;
    cursor: pointer;
    transition: opacity 0.2s ease, transform 0.1s ease;
    margin-top: 8px;
}

.btn-submit:hover {
    opacity: 0.85;
}

.btn-submit:active {
    transform: scale(0.98);
}

/* ========== Responsive ========== */
@media (max-width: 500px) {
    .island-grid {
        width: 280px;
        height: 168px;
    }

    .cell-number {
        font-size: 10px;
    }

    .cell-name {
        font-size: 8px;
    }

    .form-row {
        grid-template-columns: 1fr;
    }

    .modal {
        padding: 30px 25px;
    }
}

/* ========== Keyboard Focus Styles ========== */
.island-cell:focus {
    outline: 2px solid var(--accent-blue);
    outline-offset: -2px;
}

.island-cell:focus:not(:focus-visible) {
    outline: none;
}

/* ========== Island Viewer Overlay (水墨溶解效果) ========== */
.island-viewer-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 500;
    display: none;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.island-viewer-overlay.active {
    display: flex;
}

/* 溶解效果 Canvas */
#dissolve-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
}

/* 背景淡入 */
.island-viewer-overlay::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(245, 243, 235, 0.85);
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
    opacity: 0;
    transition: opacity 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.island-viewer-overlay.active::before {
    opacity: 1;
}

/* 岛屿展示容器 */
.island-viewer {
    position: relative;
    z-index: 10;
    display: flex;
    flex-direction: column;
    align-items: center;
    opacity: 0;
    transform: scale(0.8) translateY(20px);
    transition: all 0.8s cubic-bezier(0.34, 1.56, 0.64, 1);
    transition-delay: 0.2s;
}

.island-viewer-overlay.active .island-viewer {
    opacity: 1;
    transform: scale(1) translateY(0);
}

.island-viewer-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: pointer;
    transition: transform 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.island-viewer-content:hover {
    transform: translateY(-8px) scale(1.02);
}

/* 岛屿图片 */
.island-viewer-img {
    width: 150px;
    height: 150px;
    object-fit: contain;
    filter: drop-shadow(0 12px 24px rgba(0, 0, 0, 0.12));
    animation: float-gentle 4s ease-in-out infinite;
}

@keyframes float-gentle {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-10px);
    }
}

/* 岛屿元信息 */
.island-viewer-meta {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-top: 20px;
    gap: 4px;
    opacity: 0;
    transform: translateY(10px);
    animation: fade-in-up 0.6s ease forwards;
    animation-delay: 0.5s;
}

@keyframes fade-in-up {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.viewer-num {
    font-family: 'Courier New', 'Cutive Mono', monospace;
    font-size: 12px;
    color: var(--text-dark);
    opacity: 0.5;
    letter-spacing: 4px;
    text-transform: uppercase;
}

.viewer-name {
    font-family: 'Courier New', 'Cutive Mono', monospace;
    font-size: 12px;
    color: var(--text-dark);
    letter-spacing: 2px;
    opacity: 0.7;
}

/* 点击提示 */
.island-viewer::after {
    content: '点击岛屿访问 · 点击其他区域返回';
    position: absolute;
    bottom: -60px;
    font-family: 'Courier New', 'Cutive Mono', monospace;
    font-size: 10px;
    color: var(--text-muted);
    letter-spacing: 1px;
    white-space: nowrap;
    opacity: 0;
    animation: fade-in 0.6s ease forwards;
    animation-delay: 0.8s;
}

@keyframes fade-in {
    to {
        opacity: 0.6;
    }
}

/* 退出动画 */
.island-viewer-overlay.closing::before {
    opacity: 0;
    transition: opacity 0.4s ease;
}

.island-viewer-overlay.closing .island-viewer {
    opacity: 0;
    transform: scale(0.9) translateY(-10px);
    transition: all 0.3s ease;
    transition-delay: 0;
}

/* ========== 水墨扩散效果的格子状态 ========== */
.island-cell.dissolving {
    animation: cell-dissolve 0.6s ease forwards;
}

@keyframes cell-dissolve {
    0% {
        opacity: 1;
        filter: blur(0);
        transform: scale(1);
    }

    50% {
        opacity: 0.6;
        filter: blur(2px);
        transform: scale(1.05);
    }

    100% {
        opacity: 0;
        filter: blur(8px);
        transform: scale(1.1);
    }
}

/* 响应式 */
@media (max-width: 500px) {
    .island-viewer-img {
        width: 120px;
        height: 120px;
    }

    .viewer-num,
    .viewer-name {
        font-size: 11px;
    }

    .island-viewer::after {
        font-size: 9px;
        bottom: -40px;
    }
}