:root {
    --neon-cyan: #00f3ff;
    --neon-pink: #ff0055;
    --neon-purple: #bc13fe;
    --bg-color: #020408;
    --panel-bg: rgba(2, 6, 12, 0.85);
    --hint-color: #00f3ff;
}

body {
    margin: 0;
    overflow: hidden;
    background-color: var(--bg-color);
    font-family: 'Courier New', Courier, monospace;
    color: var(--neon-cyan);
    touch-action: none;
    -webkit-user-select: none;
    user-select: none;
}

/* --- 背景ボカシレイヤー --- */
#focused-bg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    background-size: cover;
    background-position: center;
    filter: blur(8px) brightness(0.6);
    opacity: 0;
    transition: opacity 1.5s ease;
    pointer-events: none;
}
#focused-bg.active {
    opacity: 1;
}

/* --- UIレイヤー --- */
#ui-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 10;
}

/* --- 情報パネル --- */
#info {
    position: absolute;
    top: 20px;
    left: 20px;
    color: var(--neon-cyan);
    background: var(--panel-bg);
    padding: 15px;
    border: 1px solid var(--neon-cyan);
    box-shadow: 0 0 15px rgba(0, 243, 255, 0.2);
    border-left: 5px solid var(--neon-pink);
    border-radius: 2px;
    font-size: 14px;
    font-weight: bold;
    pointer-events: auto;
    text-transform: uppercase;
    letter-spacing: 1px;
    backdrop-filter: blur(4px);
}

h2 {
    margin: 0 0 10px 0;
    font-size: 18px;
    letter-spacing: 2px;
    color: var(--neon-pink);
    text-shadow: 0 0 8px var(--neon-pink);
}

p {
    margin: 5px 0;
}

/* --- インタラクションヒント --- */
#interaction-hint {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s;
    z-index: 25;
}
#interaction-hint.active {
    opacity: 1;
}

.hint-box {
    border: 2px solid var(--hint-color);
    background: rgba(0, 0, 0, 0.6);
    padding: 15px 30px;
    color: var(--hint-color);
    font-weight: bold;
    font-size: 16px;
    letter-spacing: 2px;
    box-shadow: 0 0 20px var(--hint-color);
    animation: blink 1s infinite alternate;
    position: relative;
}

.hint-box::before,
.hint-box::after {
    content: '';
    position: absolute;
    width: 10px;
    height: 10px;
    border: 2px solid #fff;
    transition: all 0.3s;
}
.hint-box::before { top: -5px; left: -5px; border-right: none; border-bottom: none; }
.hint-box::after  { bottom: -5px; right: -5px; border-left: none; border-top: none; }

@keyframes blink {
    0%   { opacity: 0.8; transform: scale(1);    box-shadow: 0 0 10px var(--hint-color); }
    100% { opacity: 1;   transform: scale(1.05); box-shadow: 0 0 30px var(--hint-color); }
}

.hint-sub {
    font-size: 12px;
    color: #fff;
    margin-top: 5px;
    letter-spacing: 1px;
    text-shadow: 0 0 5px rgba(255, 255, 255, 0.5);
}

/* --- SEO用コンテンツコンテナ --- */
#gallery-source-data {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
}

/* --- メニューボタン --- */
#menu-btn {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 50px;
    height: 50px;
    background: rgba(0, 0, 0, 0.5);
    border: 2px solid var(--neon-cyan);
    border-radius: 50%;
    cursor: pointer;
    pointer-events: auto;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 0 15px rgba(0, 243, 255, 0.4);
    z-index: 20;
    transition: all 0.3s;
}
#menu-btn:hover {
    transform: scale(1.1);
    background: var(--neon-cyan);
    box-shadow: 0 0 25px var(--neon-cyan);
}
#menu-btn span {
    display: block;
    width: 24px;
    height: 2px;
    background: #fff;
    position: relative;
}
#menu-btn span::before,
#menu-btn span::after {
    content: '';
    position: absolute;
    width: 100%;
    height: 100%;
    background: #fff;
    left: 0;
}
#menu-btn span::before { top: -8px; }
#menu-btn span::after  { top: 8px; }
#menu-btn:hover span,
#menu-btn:hover span::before,
#menu-btn:hover span::after {
    background: #000;
}

/* --- サムネイルメニュー --- */
#menu-overlay {
    position: absolute;
    top: 0;
    right: -400px;
    width: 340px;
    max-width: 80vw;
    height: 100%;
    background: rgba(5, 10, 15, 0.95);
    border-left: 2px solid var(--neon-pink);
    box-shadow: -5px 0 30px rgba(255, 0, 85, 0.3);
    backdrop-filter: blur(10px);
    transition: right 0.4s cubic-bezier(0.2, 0.8, 0.2, 1);
    pointer-events: auto;
    display: flex;
    flex-direction: column;
    z-index: 15;
}
#menu-overlay.active {
    right: 0;
}

#menu-header {
    padding: 20px;
    color: var(--neon-pink);
    font-size: 20px;
    border-bottom: 1px solid rgba(255, 0, 85, 0.3);
    display: flex;
    justify-content: space-between;
    align-items: center;
    text-shadow: 0 0 8px rgba(255, 0, 85, 0.6);
    letter-spacing: 2px;
}

#close-btn {
    cursor: pointer;
    font-size: 24px;
    color: #fff;
    padding: 10px;
    transition: color 0.3s;
}
#close-btn:hover { color: var(--neon-cyan); }

#thumb-grid {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    -webkit-overflow-scrolling: touch;
}
#thumb-grid::-webkit-scrollbar       { width: 6px; }
#thumb-grid::-webkit-scrollbar-track  { background: #000; }
#thumb-grid::-webkit-scrollbar-thumb  { background: var(--neon-cyan); border-radius: 3px; }

.thumb-item {
    aspect-ratio: 4/3;
    background: #000;
    border: 1px solid #333;
    cursor: pointer;
    transition: all 0.3s;
    position: relative;
    overflow: hidden;
}
.thumb-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    opacity: 0.6;
    transition: opacity 0.3s;
    filter: grayscale(80%);
}
.thumb-item:hover {
    border-color: var(--neon-cyan);
    box-shadow: 0 0 15px var(--neon-cyan);
    transform: translateY(-2px);
    z-index: 1;
}
.thumb-item:hover img {
    opacity: 1;
    filter: grayscale(0%);
}

.thumb-number {
    position: absolute;
    bottom: 0;
    right: 0;
    background: var(--neon-cyan);
    color: #000;
    font-size: 10px;
    padding: 2px 6px;
    font-weight: bold;
}

/* --- レイアウト切り替えコントロール --- */
#layout-controls {
    position: absolute;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 15px;
    z-index: 20;
    pointer-events: auto;
    background: rgba(0, 5, 10, 0.7);
    padding: 10px 20px;
    border-radius: 40px;
    border: 1px solid rgba(0, 243, 255, 0.3);
    backdrop-filter: blur(5px);
}

.layout-btn {
    width: 44px;
    height: 44px;
    background: rgba(0, 0, 0, 0.6);
    border: 1px solid var(--neon-cyan);
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    color: var(--neon-cyan);
    position: relative;
}
.layout-btn:hover {
    transform: scale(1.15);
    background: rgba(0, 243, 255, 0.2);
    box-shadow: 0 0 15px var(--neon-cyan);
    color: #fff;
    border-color: #fff;
}
.layout-btn.active {
    background: var(--neon-cyan);
    color: #000;
    border-color: #fff;
    transform: scale(1.2);
    box-shadow: 0 0 25px var(--neon-cyan);
}
.layout-btn svg {
    width: 20px;
    height: 20px;
    fill: currentColor;
}

/* ツールチップ */
.layout-btn::after {
    content: attr(data-label);
    position: absolute;
    top: -30px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--neon-pink);
    color: #fff;
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 9px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
    white-space: nowrap;
    box-shadow: 0 0 10px var(--neon-pink);
    font-weight: bold;
    letter-spacing: 1px;
}
.layout-btn:hover::after { opacity: 1; }

/* --- ポップアップモーダル --- */
#modal {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 30;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
    backdrop-filter: blur(8px);
}
#modal.active { opacity: 1; pointer-events: auto; }

#modal-content {
    width: 90%;
    max-width: 800px;
    height: 85vh;
    background: rgba(5, 10, 15, 0.95);
    border: 1px solid var(--neon-cyan);
    padding: 0;
    border-radius: 4px;
    box-shadow: 0 0 60px rgba(0, 243, 255, 0.2);
    transform: scale(0.95);
    transition: transform 0.3s;
    position: relative;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
#modal.active #modal-content { transform: scale(1); }

#modal-image-container {
    flex-shrink: 0;
    width: 100%;
    height: 60%;
    background: #000;
    display: flex;
    justify-content: center;
    align-items: center;
    border-bottom: 1px solid var(--neon-cyan);
    position: relative;
}

#modal-image {
    max-width: 100%;
    max-height: 100%;
    display: block;
    object-fit: contain;
}

#modal-text-container {
    flex: 1;
    padding: 30px;
    overflow-y: auto;
    background: linear-gradient(to bottom, rgba(10, 20, 30, 1), rgba(5, 10, 15, 1));
    color: #ddd;
    position: relative;
}

/* 走査線エフェクト */
#modal-text-container::before {
    content: "";
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: repeating-linear-gradient(
        0deg,
        transparent,
        transparent 2px,
        rgba(0, 243, 255, 0.03) 3px
    );
    pointer-events: none;
}

#modal-title {
    font-size: 24px;
    font-weight: bold;
    color: var(--neon-cyan);
    margin-bottom: 15px;
    border-bottom: 2px solid var(--neon-pink);
    display: inline-block;
    padding-bottom: 5px;
    text-shadow: 0 0 8px rgba(0, 243, 255, 0.6);
    letter-spacing: 2px;
}

#modal-desc {
    font-size: 15px;
    line-height: 1.8;
    white-space: pre-wrap;
    color: #ccc;
    font-family: sans-serif;
}

/* --- YouTubeボタン --- */
#modal-youtube-link {
    display: inline-block;
    margin-top: 20px;
    padding: 10px 20px;
    background: rgba(255, 0, 0, 0.1);
    border: 1px solid #ff0000;
    color: #ff0000;
    text-decoration: none;
    font-weight: bold;
    border-radius: 4px;
    transition: all 0.3s;
    text-shadow: 0 0 5px #ff0000;
    box-shadow: 0 0 10px rgba(255, 0, 0, 0.1);
    font-family: 'Courier New', Courier, monospace;
    letter-spacing: 1px;
}
#modal-youtube-link:hover {
    background: rgba(255, 0, 0, 0.8);
    color: #fff;
    box-shadow: 0 0 20px #ff0000;
}

#modal-close {
    position: absolute;
    top: 20px;
    right: 20px;
    color: #fff;
    font-size: 24px;
    cursor: pointer;
    background: rgba(0, 0, 0, 0.6);
    border: 1px solid var(--neon-pink);
    width: 44px;
    height: 44px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    transition: all 0.3s;
}
#modal-close:hover {
    background: var(--neon-pink);
    box-shadow: 0 0 15px var(--neon-pink);
    transform: rotate(90deg);
}

canvas { display: block; }
