/* --- RESET & CORE --- */
* { margin: 0; padding: 0; box-sizing: border-box; }

/* ========================================
   FLASH WARNING SCREEN
   ======================================== */
#flashWarning {
    position: fixed;
    inset: 0;
    z-index: 999999;
    background: #050507;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.5s ease, visibility 0.5s ease;
}

#flashWarning.dismissed {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.fw-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    max-width: 520px;
    padding: 40px;
    gap: 16px;
}

.fw-icon {
    font-size: 3.5rem;
    color: #cc3300;
    line-height: 1;
    margin-bottom: 4px;
    animation: fwPulse 2s ease-in-out infinite;
}

@keyframes fwPulse {
    0%, 100% { opacity: 0.7; transform: scale(1); }
    50% { opacity: 1; transform: scale(1.08); }
}

.fw-title {
    font-family: 'Asimovian', sans-serif;
    font-size: 1.6rem;
    color: #e0e0e0;
    letter-spacing: 0.25em;
}

.fw-line {
    width: 60px;
    height: 1px;
    background: linear-gradient(90deg, transparent, #cc3300, transparent);
    margin: 4px 0;
}

.fw-text {
    font-family: 'Inter', sans-serif;
    font-size: 0.85rem;
    color: #666;
    line-height: 1.7;
}

.fw-text strong {
    color: #999;
    font-weight: 600;
}

.fw-text.secondary {
    color: #555;
    font-style: italic;
    font-size: 0.8rem;
}

.fw-btn {
    margin-top: 12px;
    position: relative;
    background: transparent;
    border: 1px solid #cc3300;
    color: #cc3300;
    font-family: 'Asimovian', sans-serif;
    font-size: 0.9rem;
    letter-spacing: 0.35em;
    padding: 12px 48px;
    cursor: pointer;
    transition: all 0.3s;
}

.fw-btn:hover {
    background: #cc3300;
    color: #050507;
    box-shadow: 0 0 25px rgba(204, 51, 0, 0.3);
}

.fw-btn::before, .fw-btn::after {
    content: '';
    position: absolute;
    width: 8px;
    height: 8px;
}
.fw-btn::before {
    top: -1px; left: -1px;
    border-top: 2px solid #cc3300;
    border-left: 2px solid #cc3300;
}
.fw-btn::after {
    bottom: -1px; right: -1px;
    border-bottom: 2px solid #cc3300;
    border-right: 2px solid #cc3300;
}

:root {
    --bg-color: #2b2510;
    --accent-color: #ffcc00;
    --hud-block: #1a1a1a;
    --page-bg: #0c0c0e;
}

.theme-shadow { --bg-color: #2b2510; --accent-color: #ffcc00; --hud-block: #1a1a1a; }
.theme-wave   { --bg-color: #041e2e; --accent-color: #00b4d8; --hud-block: #071f2b; }
.theme-fire   { --bg-color: #1a0800; --accent-color: #e63b00; --hud-block: #1f0c00; }

body {
    background-color: var(--accent-color);
    transition: background-color 0.5s ease;
    overflow-x: hidden;
}

/* ========================================
   PATTERN BACKGROUND WRAPPER
   (Only appears below the hero header)
   ======================================== */
.cyberpunk-bg-wrap {
    position: relative;
    background: var(--page-bg);
}

.cyberpunk-bg-pattern {
    position: absolute;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    background-image:
        /* fine grid */
        linear-gradient(rgba(255,255,255,0.018) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255,255,255,0.018) 1px, transparent 1px),
        /* large grid */
        linear-gradient(rgba(255,255,255,0.012) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255,255,255,0.012) 1px, transparent 1px),
        /* diagonal hatching */
        repeating-linear-gradient(45deg, transparent, transparent 40px, rgba(255,255,255,0.006) 40px, rgba(255,255,255,0.006) 41px),
        repeating-linear-gradient(-45deg, transparent, transparent 40px, rgba(255,255,255,0.006) 40px, rgba(255,255,255,0.006) 41px),
        /* hex dots */
        radial-gradient(circle, rgba(255,255,255,0.025) 1px, transparent 1px);
    background-size:
        40px 40px,
        40px 40px,
        200px 200px,
        200px 200px,
        56px 56px,
        56px 56px,
        24px 24px;
}

/* accent pulse lines */
.cyberpunk-bg-pattern::before {
    content: '';
    position: absolute;
    inset: 0;
    background:
        repeating-linear-gradient(0deg, transparent, transparent 198px, var(--accent-color) 198px, var(--accent-color) 200px);
    opacity: 0.012;
    animation: patPulse 8s ease-in-out infinite alternate;
}
.cyberpunk-bg-pattern::after {
    content: '';
    position: absolute;
    inset: 0;
    background:
        repeating-linear-gradient(90deg, transparent, transparent 198px, var(--accent-color) 198px, var(--accent-color) 200px);
    opacity: 0.012;
    animation: patPulse 8s ease-in-out infinite alternate-reverse;
}
@keyframes patPulse { 0%{opacity:.01} 100%{opacity:.022} }

/* --- GLITCH OVERLAY --- */
#glitchOverlay {
    position: fixed; inset: 0; z-index: 99999;
    pointer-events: none; opacity: 0;
}
#glitchOverlay.active { animation: glitchFlash 0.4s steps(1) forwards; }

@keyframes glitchFlash {
    0%   { opacity:1; background:#fff; }
    8%   { background:#000; clip-path:inset(0 0 0 0); }
    12%  { background:rgba(255,0,0,.6); clip-path:inset(10% 0 50% 0); transform:translateX(-10px); }
    16%  { background:#fff; clip-path:inset(0 0 0 0); transform:translateX(8px) skewX(3deg); }
    20%  { background:#000; clip-path:inset(30% 0 20% 0); transform:translateX(-6px) skewX(-2deg); }
    24%  { background:rgba(0,255,255,.5); clip-path:inset(60% 0 10% 0); transform:translateX(12px); }
    28%  { background:#fff; clip-path:inset(0 0 0 0); }
    32%  { background:#000; transform:translateX(-8px) skewX(2deg); }
    36%  { background:repeating-linear-gradient(0deg,transparent 0px,transparent 2px,rgba(255,255,255,.4) 2px,rgba(255,255,255,.4) 4px); clip-path:inset(15% 0 40% 0); transform:translateX(5px); }
    40%  { background:rgba(255,0,0,.3); clip-path:inset(0 0 0 0); transform:none; }
    50%  { background:repeating-linear-gradient(0deg,transparent 0px,transparent 3px,rgba(0,255,0,.15) 3px,rgba(0,255,0,.15) 5px); transform:translateX(-3px); }
    65%  { background:transparent; transform:translateX(2px); }
    80%  { background:transparent; transform:none; opacity:.5; }
    100% { opacity:0; transform:none; }
}

body.glitching header, body.glitching #arsenal { animation: glitchShake 0.4s steps(1) forwards; }
body.glitching { animation: glitchInvert 0.4s steps(1) forwards; }

@keyframes glitchInvert {
    0%{filter:none}8%{filter:invert(1) brightness(2)}16%{filter:hue-rotate(90deg) saturate(3) contrast(2)}
    24%{filter:invert(1)}32%{filter:hue-rotate(180deg) saturate(2)}40%{filter:brightness(3) contrast(.5)}
    50%{filter:hue-rotate(270deg) saturate(1.5)}65%{filter:brightness(1.2)}80%{filter:none}100%{filter:none}
}
@keyframes glitchShake {
    0%{transform:translateX(0)}8%{transform:translate(-8px,3px) skewX(2deg) scaleX(1.02)}
    16%{transform:translate(10px,-2px) skewX(-3deg)}24%{transform:translate(-12px,4px) skewX(1.5deg) scaleY(1.01)}
    32%{transform:translate(6px,-3px) skewX(-1deg)}40%{transform:translate(-4px,2px) skewX(2deg)}
    50%{transform:translate(8px,-1px) skewX(-.5deg)}65%{transform:translate(-2px,1px)}
    80%{transform:translate(1px,0)}100%{transform:translate(0)}
}

/* ========================================
   HEADER & HERO (keeps accent bg)
   ======================================== */
header {
    height: 100vh;
    display: flex;
    flex-direction: column;
    position: relative;
    z-index: 2;
}

#title {
    display: flex;
    font-family: 'Asimovian', sans-serif;
    font-size: clamp(1.8rem, 4.2vw, 6rem);
    border-bottom: 1px solid #0a0a0a;
    border-top: 1px solid #0a0a0a;
    width: 100%;
    z-index: 100;
    background: var(--accent-color);
    flex-shrink: 0;
    transition: background 0.5s ease;
    overflow: hidden;
    white-space: nowrap;
    align-items: baseline;
}

#subtitle {
    color: var(--accent-color);
    -webkit-text-stroke: clamp(0.3rem, 0.7vw, 1rem) var(--bg-color);
    transition: -webkit-text-stroke-color 0.5s ease, color 0.5s ease;
}

#hero-content { flex: 1; display: flex; min-height: 0; }

#hero-list {
    display: flex; flex-direction: column; width: 40%;
    border-right: 1px solid black; flex-shrink: 0;
}

.hero-item {
    color: var(--bg-color); border-bottom: 1px solid black;
    flex: 1; display: flex; align-items: center; padding-left: 30px;
    font-family: 'Asimovian', sans-serif; font-size: 2.2rem;
    text-transform: uppercase; transition: color 0.5s ease;
}

/* --- KATANA GALLERY --- */
.katana-gallery { flex: 1; display: flex; flex-direction: column; overflow: hidden; min-width: 0; }

.scroll-container {
    display: flex; overflow-x: scroll; scroll-snap-type: x mandatory;
    width: 100%; flex: 1; min-height: 0;
    scrollbar-width: none; -ms-overflow-style: none;
}
.scroll-container::-webkit-scrollbar { display: none; }

.katana-card {
    flex: 0 0 100%; height: 100%; display: flex;
    justify-content: center; align-items: center;
    scroll-snap-align: center; overflow: hidden;
}
.katana-card img {
    max-width: 80%; max-height: 85%; object-fit: contain;
    filter: drop-shadow(0 10px 40px rgba(0,0,0,.35));
    pointer-events: none; user-select: none;
}

.katana-info { display: flex; align-items: baseline; gap: 12px; padding: 0 10% 8px; flex-shrink: 0; }
.katana-jp { font-size: 1.8rem; color: var(--bg-color); opacity: .4; transition: color .5s ease; }
.katana-en { font-family: 'Asimovian', sans-serif; font-size: 1.1rem; color: var(--bg-color); letter-spacing: .35em; text-transform: uppercase; transition: color .5s ease; }

/* --- HUD SCROLLBAR --- */
.cyberpunk-scroll-hud {
    position: relative; width: 80%; height: 50px;
    margin: 0 auto 20px auto; display: flex;
    justify-content: space-between; align-items: center;
    border-left: 2px solid var(--bg-color); border-right: 2px solid var(--bg-color);
    padding: 0 15px; cursor: pointer; flex-shrink: 0;
    transition: border-color .5s ease;
}
.cyberpunk-scroll-hud::before, .cyberpunk-scroll-hud::after {
    content: ''; position: absolute; width: 12px; height: 12px; transition: border-color .5s ease;
}
.cyberpunk-scroll-hud::before { top: -2px; left: -2px; border-top: 2px solid var(--bg-color); border-left: 2px solid var(--bg-color); }
.cyberpunk-scroll-hud::after  { bottom: -2px; right: -2px; border-bottom: 2px solid var(--bg-color); border-right: 2px solid var(--bg-color); }

.tick-mark { width: 1px; height: 15px; background-color: var(--bg-color); opacity: .3; transition: background-color .5s ease; }

.cyberpunk-thumb-slider {
    position: absolute; left: 15px; width: 70px; height: 30px;
    background-color: var(--hud-block); display: flex;
    justify-content: center; align-items: center; z-index: 10;
    cursor: grab; transition: background-color .5s ease, left .35s cubic-bezier(.4,0,.2,1);
    user-select: none;
}
.cyberpunk-thumb-slider:active { cursor: grabbing; }
.cyberpunk-thumb-slider::after {
    content: '|||'; color: var(--accent-color); font-family: monospace;
    font-weight: bold; letter-spacing: -1px; transition: color .5s ease;
}

/* ========================================
   ARSENAL SECTION
   ======================================== */
#arsenal {
    height: 100vh; display: flex;
    position: relative; z-index: 1;
    --a-accent: #ffcc00;
    border-top: 1px solid #1a1a1a;
}

.arsenal-sidebar {
    width: 120px; display: flex; flex-direction: column;
    border-right: 1px solid #1a1a1a;
    background: rgba(6,6,6,.85); flex-shrink: 0;
}
.arsenal-btn {
    flex: 1; border: none; background: transparent; cursor: pointer;
    padding: 10px; border-bottom: 1px solid #1a1a1a;
    border-left: 3px solid transparent; transition: background .3s, border-color .3s;
    position: relative;
}
.arsenal-btn:hover { background: rgba(17,17,17,.8); }
.arsenal-btn.active { background: rgba(15,15,15,.9); border-left-color: var(--a-accent); }
.arsenal-btn img { width: 100%; height: 100%; object-fit: contain; filter: grayscale(.5) brightness(.7); transition: filter .3s; }
.arsenal-btn:hover img, .arsenal-btn.active img { filter: grayscale(0) brightness(1); }

.arsenal-display {
    flex: 1; display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    position: relative; min-width: 0;
}
.arsenal-header { display: flex; align-items: baseline; gap: 15px; margin-bottom: 20px; }
.arsenal-jp { font-size: 3rem; color: var(--a-accent); opacity: .3; transition: color .4s; }
.arsenal-en { font-family: 'Asimovian', sans-serif; font-size: 1.6rem; color: var(--a-accent); letter-spacing: .4em; transition: color .4s; }

.arsenal-img {
    max-width: 75%; max-height: 75%; object-fit: contain;
    filter: drop-shadow(0 0 40px rgba(255,204,0,.15));
    transition: filter .5s; user-select: none; pointer-events: none;
}

.arsenal-stats {
    width: 340px; display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    border-left: 1px solid #1a1a1a; padding: 30px 20px;
    flex-shrink: 0; gap: 20px; background: rgba(6,6,6,.6);
}
.stats-title { font-family: 'Asimovian', sans-serif; font-size: 1rem; color: var(--a-accent); letter-spacing: .5em; opacity: .6; transition: color .4s; }
#radarChart { display: block; }

.stats-readout { width: 100%; display: flex; flex-direction: column; gap: 8px; }
.readout-item { display: flex; align-items: center; gap: 10px; }
.readout-label { font-family: 'Inter', monospace; font-size: .7rem; font-weight: 600; color: #555; width: 30px; letter-spacing: .1em; }
.readout-bar { flex: 1; height: 3px; background: #1a1a1a; position: relative; overflow: hidden; }
.readout-fill { display: block; height: 100%; width: 0%; background: var(--a-accent); transition: width .6s cubic-bezier(.4,0,.2,1), background .4s; }
.readout-val { font-family: 'Inter', monospace; font-size: .75rem; font-weight: 600; color: var(--a-accent); width: 20px; text-align: right; transition: color .4s; }

/* Corner brackets */
#arsenal::before, #arsenal::after { content: ''; position: absolute; width: 20px; height: 20px; z-index: 5; pointer-events: none; }
#arsenal::before { top: 0; left: 0; border-top: 2px solid #333; border-left: 2px solid #333; }
#arsenal::after  { top: 0; right: 0; border-top: 2px solid #333; border-right: 2px solid #333; }

/* ========================================
   FORGE SECTION — Skill Tree HUD
   ======================================== */
#forge {
    height: 100vh;
    position: relative;
    z-index: 1;
    --forge-accent: var(--accent-color);
    overflow: hidden;
    border-top: 1px solid #1a1a1a;
}

/* --- Forge Overlay (start screen, covers blurred builder) --- */
.forge-overlay {
    position: absolute;
    inset: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(10, 10, 12, 0.75);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
    opacity: 1;
    transition: opacity 0.7s ease, backdrop-filter 0.7s ease;
    pointer-events: all;
}

.forge-overlay-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 20px;
}

.forge-kanji {
    font-size: 8rem;
    color: var(--forge-accent);
    opacity: 0.12;
    line-height: 1;
}

.forge-headline {
    font-family: 'Asimovian', sans-serif;
    font-size: 3.8rem;
    color: #e0e0e0;
    letter-spacing: 0.15em;
}

.forge-sub {
    font-family: 'Inter', sans-serif;
    font-size: 0.95rem;
    color: #555;
    max-width: 420px;
    line-height: 1.5;
}

/* When forge is revealed, overlay fades out */
#forge.state-builder .forge-overlay {
    opacity: 0;
    pointer-events: none;
    backdrop-filter: blur(0px);
    -webkit-backdrop-filter: blur(0px);
}

/* --- Builder (always rendered) --- */
.forge-builder {
    position: absolute;
    inset: 0;
    display: flex;
    z-index: 1;
    filter: blur(14px) brightness(0.35);
    transition: filter 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

#forge.state-builder .forge-builder {
    filter: blur(0px) brightness(1);
}

/* --- LEFT: Vertical Bars Panel --- */
.forge-bars-panel {
    display: flex;
    flex-direction: row;
    align-items: stretch;
    gap: 0;
    padding: 20px 15px 76px 24px;
    flex-shrink: 0;
    height: 100%;
    border-right: 1px solid #1a1a1a;
    background: rgba(5, 5, 7, 0.5);
}

.forge-vbar {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 90px;
    gap: 8px;
    padding: 0 6px;
    height: 100%;
}

/* Value box at top */
.vbar-value-box {
    width: 60px;
    height: 60px;
    border: 1px solid #2a2a2a;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    position: relative;
    background: rgba(15, 15, 15, 0.8);
    transition: border-color 0.3s;
}

/* Corner brackets on value box */
.vbar-value-box::before {
    content: '';
    position: absolute;
    top: -1px; left: -1px;
    width: 8px; height: 8px;
    border-top: 2px solid var(--forge-accent);
    border-left: 2px solid var(--forge-accent);
    opacity: 0.5;
}
.vbar-value-box::after {
    content: '';
    position: absolute;
    bottom: -1px; right: -1px;
    width: 8px; height: 8px;
    border-bottom: 2px solid var(--forge-accent);
    border-right: 2px solid var(--forge-accent);
    opacity: 0.5;
}

.vbar-val {
    font-family: 'Asimovian', sans-serif;
    font-size: 1.8rem;
    color: var(--forge-accent);
    line-height: 1;
}

/* Vertical track */
.vbar-track {
    flex: 1;
    min-height: 0;
    width: 42px;
    position: relative;
    border-top: 2px solid #2a2a2a;
    border-bottom: 2px solid #2a2a2a;
    cursor: pointer;
    background: rgba(10, 10, 10, 0.6);
}

/* Tick marks via bg pattern */
.vbar-ticks {
    position: absolute;
    inset: 0;
    pointer-events: none;
    background: repeating-linear-gradient(
        to top,
        transparent,
        transparent 13px,
        rgba(255,255,255,0.04) 13px,
        rgba(255,255,255,0.04) 14px
    );
}

/* Side brackets on track */
.vbar-track::before {
    content: '';
    position: absolute;
    top: -2px; left: -2px;
    width: 6px; height: 6px;
    border-top: 2px solid #444;
    border-left: 2px solid #444;
}
.vbar-track::after {
    content: '';
    position: absolute;
    bottom: -2px; right: -2px;
    width: 6px; height: 6px;
    border-bottom: 2px solid #444;
    border-right: 2px solid #444;
}

/* Side notch marks on track edges */
.vbar-fill {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 0%;
    background: var(--forge-accent);
    opacity: 0.1;
    pointer-events: none;
    transition: height 0.15s ease;
}

.vbar-thumb {
    position: absolute;
    bottom: 0;
    left: 50%;
    width: 38px;
    height: 18px;
    transform: translateX(-50%);
    background: #1a1a1a;
    border: 1px solid #444;
    cursor: grab;
    z-index: 3;
    user-select: none;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: bottom 0.08s ease;
}
.vbar-thumb:active { cursor: grabbing; }
.vbar-thumb::after {
    content: '═';
    color: var(--forge-accent);
    font-family: monospace;
    font-weight: bold;
    font-size: 0.85rem;
    line-height: 1;
}

/* Labels at bottom */
.vbar-labels {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    flex-shrink: 0;
}

.vbar-jp {
    font-size: 0.85rem;
    color: var(--forge-accent);
    opacity: 0.3;
    writing-mode: horizontal-tb;
}

.vbar-en {
    font-family: 'Asimovian', sans-serif;
    font-size: 0.55rem;
    color: #555;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    writing-mode: vertical-rl;
    text-orientation: mixed;
    height: 70px;
    display: flex;
    align-items: center;
}

/* --- CENTER/RIGHT: Radar Panel --- */
.forge-main-panel {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

#forgeRadar { display: block; }

/* --- CTA Button --- */
.forge-cta {
    position: relative;
    background: transparent;
    border: 2px solid var(--forge-accent);
    color: var(--forge-accent);
    font-family: 'Asimovian', sans-serif;
    font-size: 1rem;
    letter-spacing: 0.3em;
    padding: 14px 50px;
    cursor: pointer;
    transition: all 0.3s;
    z-index: 10;
}
.forge-cta:hover {
    background: var(--forge-accent);
    color: #0a0a0a;
    box-shadow: 0 0 30px rgba(0,255,136,0.25);
}
.forge-cta::before, .forge-cta::after {
    content: ''; position: absolute; width: 10px; height: 10px;
}
.forge-cta::before { top: -2px; left: -2px; border-top: 2px solid var(--forge-accent); border-left: 2px solid var(--forge-accent); }
.forge-cta::after  { bottom: -2px; right: -2px; border-bottom: 2px solid var(--forge-accent); border-right: 2px solid var(--forge-accent); }

.forge-cta.generate { margin-top: 0; }

/* --- BOTTOM HUD BAR --- */
.forge-hud-bar {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 72px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 30px;
    border-top: 1px solid #1a1a1a;
    background: rgba(5, 5, 7, 0.85);
    z-index: 5;
}

.hud-bar-cell {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.hud-bar-label {
    font-family: 'Asimovian', sans-serif;
    font-size: 0.6rem;
    color: #444;
    letter-spacing: 0.4em;
}

.hud-bar-value {
    font-family: 'Asimovian', sans-serif;
    font-size: 2.2rem;
    color: #e0e0e0;
    line-height: 1;
}

.hud-bar-value.accent {
    color: var(--forge-accent);
}

.hud-bar-right {
    text-align: right;
}

/* ========================================
   SCANLINE CRT OVERLAY
   ======================================== */
#scanlines {
    position: fixed; inset: 0; z-index: 99998;
    pointer-events: none;
    background: repeating-linear-gradient(0deg, transparent 0px, transparent 2px, rgba(0,0,0,.035) 2px, rgba(0,0,0,.035) 4px);
}

/* ========================================
   LIGHTSCREEN RESULT MODAL
   ======================================== */
.result-modal {
    position: fixed; inset: 0; z-index: 9999;
    display: flex; align-items: center; justify-content: center;
    opacity: 0; pointer-events: none; transition: opacity .3s;
}
.result-modal.open { opacity: 1; pointer-events: all; }

.modal-backdrop {
    position: absolute; inset: 0;
    background: rgba(0,0,0,.88);
    backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
}
.modal-scanline {
    position: absolute; inset: 0; pointer-events: none; z-index: 6;
    background: repeating-linear-gradient(0deg, transparent 0px, transparent 3px, rgba(0,255,136,.02) 3px, rgba(0,255,136,.02) 6px);
    opacity: 0; transition: opacity .5s .3s;
}
.result-modal.open .modal-scanline { opacity: 1; }

.modal-close {
    position: absolute; top: 25px; right: 35px;
    background: none; border: 1px solid #333;
    color: var(--forge-accent, #00ff88); font-size: 1.3rem;
    width: 44px; height: 44px; cursor: pointer; z-index: 10;
    transition: all .3s; display: flex; align-items: center;
    justify-content: center; font-family: sans-serif;
}
.modal-close:hover {
    background: var(--forge-accent, #00ff88); color: #000;
    border-color: var(--forge-accent); box-shadow: 0 0 20px rgba(0,255,136,.3);
}

.modal-content {
    position: relative; display: flex;
    width: 90%; max-width: 1200px; height: 80vh;
    z-index: 5; border: 1px solid #1a1a1a;
    background: rgba(5,5,5,.6);
}
.result-modal.open .modal-content { animation: lightscreenOn .5s cubic-bezier(.4,0,.2,1) forwards; }

@keyframes lightscreenOn {
    0%   { clip-path: inset(50% 0 50% 0); opacity: 0; }
    40%  { clip-path: inset(2% 0 2% 0); opacity: .6; }
    70%  { clip-path: inset(0 0 0 0); opacity: .85; }
    100% { clip-path: inset(0 0 0 0); opacity: 1; }
}

.modal-content::before, .modal-content::after { content: ''; position: absolute; width: 16px; height: 16px; z-index: 6; }
.modal-content::before { top: -1px; left: -1px; border-top: 2px solid var(--forge-accent, #00ff88); border-left: 2px solid var(--forge-accent, #00ff88); }
.modal-content::after  { bottom: -1px; right: -1px; border-bottom: 2px solid var(--forge-accent, #00ff88); border-right: 2px solid var(--forge-accent, #00ff88); }

.result-modal .result-col { display: flex; flex-direction: column; justify-content: center; padding: 40px 30px; }
.result-modal .result-info { width: 30%; border-right: 1px solid #1a1a1a; gap: 16px; }
.result-modal .result-display { flex: 1; align-items: center; gap: 20px; }
.result-modal .result-stats { width: 30%; border-left: 1px solid #1a1a1a; align-items: center; gap: 20px; }

.result-col { display: flex; flex-direction: column; justify-content: center; padding: 40px 30px; }

.ri-title { font-family: 'Asimovian', sans-serif; font-size: 1.8rem; color: var(--forge-accent); letter-spacing: .2em; }
.ri-jp    { font-size: 3rem; color: var(--forge-accent); opacity: .2; line-height: 1; }
.ri-details { display: flex; flex-direction: column; gap: 10px; }
.ri-row { display: flex; justify-content: space-between; border-bottom: 1px solid #1a1a1a; padding-bottom: 8px; }
.ri-key { font-family: 'Inter', sans-serif; font-size: .65rem; font-weight: 600; color: #444; letter-spacing: .2em; }
.ri-val { font-family: 'Inter', sans-serif; font-size: .75rem; color: #888; }
.ri-desc { font-family: 'Inter', sans-serif; font-size: .8rem; color: #555; line-height: 1.7; }
.forge-cta.again { margin-top: auto; align-self: flex-start; }

.result-display { flex: 1; align-items: center; gap: 20px; }
.result-img { max-width: 55%; max-height: 65%; object-fit: contain; filter: drop-shadow(0 0 40px rgba(0,255,136,.15)); pointer-events: none; user-select: none; }
.result-name { display: flex; align-items: baseline; gap: 15px; }
.rn-jp { font-size: 2.2rem; color: var(--forge-accent); opacity: .35; }
.rn-en { font-family: 'Asimovian', sans-serif; font-size: 1.4rem; color: var(--forge-accent); letter-spacing: .4em; }

.result-stats { width: 30%; border-left: 1px solid #1a1a1a; align-items: center; gap: 20px; }
.rs-title { font-family: 'Asimovian', sans-serif; font-size: .9rem; color: var(--forge-accent); letter-spacing: .5em; opacity: .6; }
#resultRadar { display: block; }

.rs-readouts { width: 100%; display: flex; flex-direction: column; gap: 8px; }
.rs-row { display: flex; align-items: center; gap: 10px; }
.rs-label { font-family: 'Inter', monospace; font-size: .7rem; font-weight: 600; color: #555; width: 30px; letter-spacing: .1em; }
.rs-bar { flex: 1; height: 3px; background: #1a1a1a; position: relative; overflow: hidden; }
.rs-fill { display: block; height: 100%; width: 0%; background: var(--forge-accent); transition: width .6s cubic-bezier(.4,0,.2,1); }
.rs-val { font-family: 'Inter', monospace; font-size: .75rem; font-weight: 600; color: var(--forge-accent); width: 20px; text-align: right; }

/* ========================================
   FOOTER — inline at bottom, inverted text
   ======================================== */
#mainFooter {
    position: relative;
    width: 100%;
    z-index: 1;
    background: rgba(240, 240, 240, 0.03);
    padding: 28px 60px 16px;
    border-top: 1px solid rgba(255,255,255,.05);
}

.footer-accent-line {
    position: absolute; top: -1px; left: 0;
    width: 100%; height: 1px;
    background: linear-gradient(90deg, transparent, var(--accent-color), transparent);
    opacity: .3;
}

.footer-grid { display: grid; grid-template-columns: 1.5fr 1fr 1fr 1.2fr; gap: 40px; margin-bottom: 22px; }
.footer-col { display: flex; flex-direction: column; gap: 5px; }

.footer-logo { font-family: 'Asimovian', sans-serif; font-size: 1.5rem; color: rgba(255,255,255,.8); letter-spacing: .1em; }
.footer-tagline { font-size: .8rem; color: var(--accent-color); opacity: .35; transition: color .5s; }
.footer-desc { font-family: 'Inter', sans-serif; font-size: .72rem; color: rgba(255,255,255,.22); line-height: 1.6; margin-top: 3px; }

.footer-heading { font-family: 'Asimovian', sans-serif; font-size: .68rem; color: rgba(255,255,255,.3); letter-spacing: .3em; margin-bottom: 5px; }
.footer-link { font-family: 'Inter', monospace; font-size: .72rem; color: rgba(255,255,255,.25); text-decoration: none; transition: color .3s; }
.footer-link:hover { color: var(--accent-color); }

.footer-data { font-family: 'Inter', monospace; font-size: .68rem; color: rgba(255,255,255,.18); }
.neon-glow { color: var(--accent-color); text-shadow: 0 0 8px currentColor; transition: color .5s; }

.footer-terminal { font-family: 'Inter', monospace; font-size: .68rem; color: var(--accent-color); opacity: .35; transition: color .5s; }
.blink { animation: cursorBlink 1s steps(1) infinite; }
@keyframes cursorBlink { 0%,50%{opacity:1} 51%,100%{opacity:0} }

.footer-bottom { display: flex; justify-content: space-between; align-items: center; padding-top: 12px; border-top: 1px solid rgba(255,255,255,.03); }
.footer-bottom span { font-family: 'Inter', monospace; font-size: .58rem; color: rgba(255,255,255,.12); letter-spacing: .1em; }
.footer-hash { color: rgba(255,255,255,.06); }

/* ========================================
   RESPONSIVE — TABLET (≤ 1024px)
   ======================================== */
@media (max-width: 1024px) {

    /* --- Hero --- */
    #title { flex-wrap: wrap; justify-content: center; text-align: center; white-space: normal; }

    #hero-content { flex-direction: column; }
    #hero-list {
        width: 100%; flex-direction: row;
        border-right: none;
        flex-shrink: 0;
        flex-wrap: wrap;
    }
    .hero-item {
        border-bottom: 1px solid black; border-right: 1px solid black;
        flex: 1 1 30%; padding: 10px 16px;
        font-size: 1.1rem; white-space: nowrap; justify-content: center;
        box-sizing: border-box;
    }
    .hero-item:nth-child(3) { border-right: none; }
    .hero-item:nth-child(6) { border-right: none; }
    .hero-item:nth-child(n+4) { border-bottom: 1px solid black; }

    /* --- Arsenal --- */
    #arsenal { height: auto; min-height: 100vh; flex-direction: column; }
    .arsenal-sidebar {
        width: 100%; flex-direction: row;
        height: 90px; border-right: none;
        border-bottom: 1px solid #1a1a1a;
        overflow-x: auto; overflow-y: hidden;
        scrollbar-width: none; -ms-overflow-style: none;
    }
    .arsenal-sidebar::-webkit-scrollbar { display: none; }
    .arsenal-btn {
        flex: 0 0 80px; border-bottom: none;
        border-left: none; border-right: 1px solid #1a1a1a;
        border-top: 3px solid transparent;
    }
    .arsenal-btn.active { border-left-color: transparent; border-top-color: var(--a-accent); }
    .arsenal-display { min-height: 400px; padding: 30px 20px; }
    .arsenal-img { max-width: 60%; max-height: 60%; }
    .arsenal-stats {
        width: 100%; border-left: none;
        border-top: 1px solid #1a1a1a;
        padding: 30px 40px;
    }
    #radarChart { max-width: 280px; }

    /* --- Forge --- */
    .forge-headline { font-size: 2.8rem; }
    .forge-kanji { font-size: 5rem; }

    .forge-builder { flex-direction: column; }
    .forge-bars-panel {
        flex-direction: row; height: auto;
        border-right: none; border-bottom: 1px solid #1a1a1a;
        padding: 15px 10px 15px 10px;
        overflow-x: auto; overflow-y: hidden;
        flex-shrink: 0;
    }
    .forge-vbar {
        width: 80px; min-height: 280px;
    }

    .forge-main-panel { flex: 1; min-height: 300px; }
    .forge-hud-bar { padding: 0 20px; }

    /* --- Result Modal --- */
    .modal-content {
        flex-direction: column;
        width: 92%; height: 90vh;
        overflow-y: auto; overflow-x: hidden;
    }
    .result-modal .result-info { width: 100%; border-right: none; border-bottom: 1px solid #1a1a1a; }
    .result-modal .result-display { min-height: 300px; }
    .result-modal .result-stats { width: 100%; border-left: none; border-top: 1px solid #1a1a1a; }

    /* --- Footer --- */
    .footer-grid { grid-template-columns: 1fr 1fr; gap: 25px; }
    #mainFooter { padding: 24px 30px 14px; }
}

/* ========================================
   RESPONSIVE — MOBILE (≤ 768px)
   ======================================== */
@media (max-width: 768px) {

    /* --- Hero --- */
    header { height: 100svh; min-height: 0; }

    .hero-item {
        font-size: 0.85rem; padding: 8px 12px;
    }

    .katana-gallery { min-height: 350px; }
    .katana-card img { max-width: 85%; max-height: 80%; }
    .katana-info { padding: 0 6% 6px; gap: 8px; }
    .katana-jp { font-size: 1.4rem; }
    .katana-en { font-size: 0.85rem; letter-spacing: 0.25em; }

    .cyberpunk-scroll-hud { width: 90%; height: 40px; margin-bottom: 12px; }
    .cyberpunk-thumb-slider { width: 50px; height: 24px; }

    /* --- Arsenal --- */
    #arsenal { min-height: auto; }
    .arsenal-sidebar { height: 75px; }
    .arsenal-btn { flex: 1 1 0; min-width: 0; padding: 8px; }
    .arsenal-display { min-height: 300px; padding: 20px 15px; }
    .arsenal-header { gap: 10px; margin-bottom: 12px; }
    .arsenal-jp { font-size: 2rem; }
    .arsenal-en { font-size: 1.1rem; letter-spacing: 0.25em; }
    .arsenal-img { max-width: 70%; max-height: 55%; }
    .arsenal-stats { padding: 20px 20px; }
    #radarChart { max-width: 220px; }

    /* --- Forge --- */
    #forge { height: auto; min-height: 100vh; }
    .forge-overlay-inner { padding: 0 20px; }
    .forge-headline { font-size: 2rem; letter-spacing: 0.08em; }
    .forge-kanji { font-size: 4rem; }
    .forge-sub { font-size: 0.85rem; max-width: 320px; }
    .forge-cta { font-size: 0.85rem; padding: 12px 35px; letter-spacing: 0.2em; }

    .forge-builder { flex-direction: column; position: relative; }

    .forge-bars-panel {
        flex-direction: row;
        height: auto; min-height: 0;
        border-right: none;
        border-bottom: 1px solid #1a1a1a;
        padding: 12px 8px 12px 8px;
        gap: 0;
        justify-content: center;
        flex-wrap: nowrap;
        overflow-x: auto;
    }

    .forge-vbar {
        width: 65px; min-height: 220px;
        gap: 6px; padding: 0 3px;
    }
    .vbar-value-box { width: 44px; height: 44px; }
    .vbar-val { font-size: 1.3rem; }
    .vbar-track { width: 34px; }
    .vbar-thumb { width: 30px; height: 14px; }
    .vbar-thumb::after { font-size: 0.7rem; }
    .vbar-jp { font-size: 0.7rem; }
    .vbar-en { font-size: 0.45rem; height: 55px; }

    .forge-main-panel { min-height: 250px; padding-bottom: 80px; }
    .forge-hud-bar { height: 64px; padding: 0 15px; }
    .hud-bar-label { font-size: 0.5rem; letter-spacing: 0.25em; }
    .hud-bar-value { font-size: 1.6rem; }

    /* --- Result Modal --- */
    .modal-content {
        width: 96%; height: 92vh;
        flex-direction: column;
        overflow-y: auto;
    }
    .result-modal .result-col { padding: 25px 20px; }
    .result-modal .result-info { width: 100%; }
    .result-modal .result-display { min-height: 250px; }
    .result-modal .result-stats { width: 100%; }
    .ri-title { font-size: 1.4rem; }
    .ri-jp { font-size: 2rem; }
    .ri-desc { font-size: 0.75rem; }
    .result-img { max-width: 65%; max-height: 55%; }
    .rn-jp { font-size: 1.6rem; }
    .rn-en { font-size: 1rem; letter-spacing: 0.25em; }
    .modal-close { top: 12px; right: 14px; width: 36px; height: 36px; font-size: 1rem; }

    /* --- Footer --- */
    .footer-grid { grid-template-columns: 1fr 1fr; gap: 20px; }
    #mainFooter { padding: 20px 20px 12px; }
    .footer-logo { font-size: 1.2rem; }
    .footer-bottom { flex-direction: column; gap: 6px; text-align: center; }

    /* --- Flash Warning --- */
    .fw-content { max-width: 90%; padding: 30px 20px; }
    .fw-title { font-size: 1.2rem; letter-spacing: 0.15em; }
    .fw-icon { font-size: 2.5rem; }
    .fw-text { font-size: 0.8rem; }
    .fw-btn { padding: 10px 36px; font-size: 0.8rem; }
}

/* ========================================
   RESPONSIVE — SMALL MOBILE (≤ 480px)
   ======================================== */
@media (max-width: 480px) {

    /* --- Hero --- */
    #title { font-size: 2.4rem; padding: 8px 0; }
    #subtitle { -webkit-text-stroke-width: 0.3rem; }
    .hero-item { font-size: 0.85rem; padding: 8px 14px; }
    .katana-gallery { min-height: 280px; }
    .katana-card img { max-width: 90%; max-height: 75%; }
    .cyberpunk-scroll-hud { width: 92%; height: 36px; margin-bottom: 10px; padding: 0 10px; }
    .cyberpunk-thumb-slider { width: 40px; height: 20px; left: 10px !important; }
    .cyberpunk-thumb-slider::after { font-size: 0.55rem; }

    /* --- Arsenal --- */
    .arsenal-sidebar { height: 65px; }
    .arsenal-btn { flex: 1 1 0; min-width: 0; padding: 6px; }
    .arsenal-display { min-height: 260px; }
    .arsenal-jp { font-size: 1.5rem; }
    .arsenal-en { font-size: 0.9rem; }
    .arsenal-stats { padding: 16px 14px; }
    #radarChart { max-width: 180px; }
    .readout-label { font-size: 0.6rem; width: 26px; }
    .readout-val { font-size: 0.65rem; width: 18px; }

    /* --- Forge --- */
    .forge-headline { font-size: 1.5rem; }
    .forge-kanji { font-size: 3rem; }
    .forge-sub { font-size: 0.78rem; max-width: 280px; }
    .forge-cta { font-size: 0.75rem; padding: 10px 28px; letter-spacing: 0.15em; }

    .forge-vbar {
        width: 56px; min-height: 180px;
    }
    .vbar-value-box { width: 38px; height: 38px; }
    .vbar-val { font-size: 1.1rem; }
    .vbar-track { width: 28px; }
    .vbar-thumb { width: 24px; height: 12px; }
    .vbar-thumb::after { font-size: 0.6rem; }
    .vbar-jp { font-size: 0.6rem; }
    .vbar-en { font-size: 0.4rem; height: 45px; letter-spacing: 0.08em; }

    .forge-main-panel { min-height: 200px; padding-bottom: 72px; }
    .forge-hud-bar { height: 56px; padding: 0 10px; gap: 8px; }
    .hud-bar-label { font-size: 0.45rem; letter-spacing: 0.15em; }
    .hud-bar-value { font-size: 1.3rem; }

    /* --- Result Modal --- */
    .modal-content { width: 98%; height: 94vh; }
    .result-modal .result-col { padding: 18px 14px; }
    .ri-title { font-size: 1.2rem; }
    .ri-key { font-size: 0.58rem; }
    .ri-val { font-size: 0.68rem; }
    .ri-desc { font-size: 0.7rem; }
    .result-img { max-width: 75%; max-height: 50%; }
    .rn-jp { font-size: 1.3rem; }
    .rn-en { font-size: 0.8rem; }
    .rs-title { font-size: 0.75rem; }
    .rs-label { font-size: 0.6rem; width: 26px; }
    .rs-val { font-size: 0.65rem; width: 18px; }

    /* --- Footer --- */
    .footer-grid { grid-template-columns: 1fr; gap: 16px; }
    #mainFooter { padding: 16px 14px 10px; }
    .footer-logo { font-size: 1rem; }
    .footer-heading { font-size: 0.6rem; }
    .footer-link { font-size: 0.65rem; }
    .footer-data { font-size: 0.6rem; }
    .footer-terminal { font-size: 0.6rem; }
    .footer-bottom span { font-size: 0.5rem; }

    /* --- Flash Warning --- */
    .fw-content { padding: 24px 16px; }
    .fw-title { font-size: 1rem; letter-spacing: 0.1em; }
    .fw-icon { font-size: 2rem; }
    .fw-text { font-size: 0.75rem; }
    .fw-btn { padding: 10px 30px; font-size: 0.75rem; letter-spacing: 0.2em; }
}