/* Base Theme & Variables */
:root {
    --bg-color: #050814;
    --grid-bg: rgba(10, 15, 30, 0.7);
    --grid-border: rgba(45, 90, 150, 0.3);

    --primary-glow: #0affd4;
    /* Cyan: default highlight */
    --akira-color: #00bfff;
    /* Deep Sky Blue: Ice/Lock */
    --koto-color: #ff00ff;
    /* Magenta: Observe/Snipe */
    --lux-color: #ffcc00;
    /* Gold/Yellow: Path/Light */
    --enemy-color: #ff2a2a;
    /* Red: Enemy/Danger */
    --prob-color: rgba(255, 42, 42, 0.4);
    /* Probable position */

    --glass-bg: rgba(10, 20, 35, 0.6);
    --glass-border: rgba(0, 255, 212, 0.2);

    --text-main: #e0faff;
    --text-dim: #7da1b8;

    --font-heading: 'Jura', sans-serif;
    --font-body: 'Noto Sans JP', sans-serif;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    user-select: none;
    /* Prevent selection for app feel */
}

body {
    background-color: var(--bg-color);
    color: var(--text-main);
    font-family: var(--font-body);
    height: 100vh;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
    background-image:
        radial-gradient(circle at 50% 50%, rgba(10, 255, 212, 0.05) 0%, transparent 60%),
        linear-gradient(to right, rgba(0, 0, 0, 0.8), transparent 20%, transparent 80%, rgba(0, 0, 0, 0.8));
}

.app-container {
    width: 100vw;
    height: 100vh;
    display: flex;
    flex-direction: column;
    padding: 0.5rem 1rem;
    gap: 0.5rem;
}

/* Glassmorphism utility */
.glass-panel {
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.5);
}

.box-glow {
    box-shadow: 0 0 15px rgba(10, 255, 212, 0.1);
}

/* Header */
.status-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 2rem;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    height: 60px;
}

.logo {
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 1.5rem;
    letter-spacing: 2px;
    color: var(--text-main);
    text-transform: uppercase;
}

.logo span {
    color: var(--primary-glow);
    text-shadow: 0 0 8px var(--primary-glow);
}

.turn-indicator {
    font-family: var(--font-heading);
    font-size: 1.25rem;
    font-weight: 600;
    letter-spacing: 3px;
    color: var(--primary-glow);
    text-shadow: 0 0 10px rgba(10, 255, 212, 0.5);
}

.turn-indicator.enemy-turn {
    color: var(--enemy-color);
    text-shadow: 0 0 10px rgba(255, 42, 42, 0.5);
}

.mission-status {
    font-family: var(--font-heading);
    font-size: 1.1rem;
}

.mission-status .value {
    color: var(--enemy-color);
    font-weight: bold;
    text-shadow: 0 0 5px var(--enemy-color);
}

/* Main Area Layout */
.game-area {
    display: flex;
    flex: 1;
    gap: 1.5rem;
    min-height: 0;
    /* Important for flex child scrolling if needed */
}

/* Sidebars */
.sidebar {
    width: 280px;
    display: flex;
    flex-direction: column;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    padding: 1rem;
    gap: 1rem;
    overflow-y: auto;
    position: relative;
    /* Setup for sticky bottom */
}

.panel-header {
    font-family: var(--font-heading);
    font-size: 0.9rem;
    color: var(--text-dim);
    letter-spacing: 2px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    padding-bottom: 0.5rem;
    text-transform: uppercase;
}

/* Character Cards */
.character-list,
.enemy-list {
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
}

.unit-card {
    background: var(--bg-card);
    border: 1px solid var(--border-dark);
    border-radius: 8px;
    padding: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
}

.unit-card:hover {
    border-color: var(--primary-glow);
    box-shadow: 0 0 10px var(--primary-shadow);
}

.unit-card.active {
    border-color: var(--primary-glow);
    box-shadow: 0 0 15px var(--primary-shadow);
    background: linear-gradient(145deg, var(--bg-dark), #1a2f3a);
}

.unit-layout {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 8px;
}

.unit-icon {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--border-dark);
    background-color: var(--bg-dark);
}

.unit-card.active .unit-icon {
    border-color: var(--primary-glow);
    box-shadow: 0 0 10px var(--primary-shadow);
}

.enemy-unknown {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    background: linear-gradient(135deg, rgba(255, 40, 40, 0.15), rgba(100, 0, 0, 0.3));
    border-color: rgba(255, 40, 40, 0.4);
}

.enemy-icon {
    border-color: #ff4444;
    box-shadow: 0 0 8px rgba(255, 40, 40, 0.3);
}

.unit-details {
    flex: 1;
}

.unit-name {
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 1.1rem;
    letter-spacing: 1px;
    margin-bottom: 0.2rem;
    color: var(--text-light);
}

.unit-role {
    font-size: 0.75rem;
    color: var(--text-dim);
    text-transform: uppercase;
    margin-bottom: 0.5rem;
}

.unit-stats {
    display: flex;
    justify-content: space-between;
    font-size: 0.8rem;
    margin-bottom: 0.5rem;
}

.hp-bar-container {
    width: 100%;
    height: 4px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 2px;
    overflow: hidden;
    margin-bottom: 0.5rem;
}

.hp-bar {
    height: 100%;
    background: #4caf50;
    width: 100%;
    transition: width 0.3s ease;
}

.hp-bar.low {
    background: #ff9800;
}

.hp-bar.critical {
    background: #f44336;
}

/* Skills Section */
.skills-container {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    margin-top: 0.5rem;
}

.skill-btn {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: var(--text-main);
    padding: 0.4rem 0.6rem;
    font-size: 0.8rem;
    border-radius: 4px;
    cursor: pointer;
    font-family: inherit;
    text-align: left;
    transition: all 0.2s;
    display: flex;
    justify-content: space-between;
}

.skill-btn:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--primary-glow);
}

.skill-btn.active {
    background: rgba(10, 255, 212, 0.2);
    border-color: var(--primary-glow);
    box-shadow: 0 0 10px rgba(10, 255, 212, 0.3);
}

.skill-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* Board Area */
.board-container {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    padding: 1rem;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    perspective: 1000px;
    /* For 3D rotation if needed */
}

.game-board {
    display: grid;
    /* Grid size defined in JS, e.g., grid-template-columns: repeat(8, 60px); */
    gap: 2px;
    padding: 10px;
    background: rgba(0, 0, 0, 0.5);
    border: 2px solid var(--glass-border);
    border-radius: 12px;
    box-shadow: 0 0 30px rgba(0, 0, 0, 0.8), inset 0 0 20px rgba(10, 255, 212, 0.05);
    /* transform: rotateX(20deg); Optional: isometric feel */
    transition: transform 0.3s ease;
}

/* Generic Button Styles */
.btn {
    font-family: var(--font-heading);
    font-weight: 600;
    letter-spacing: 1px;
    padding: 0.8rem 1.2rem;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.2s ease;
    text-transform: uppercase;
}

.btn-warning {
    background: transparent;
    border: 1px solid var(--enemy-color);
    color: var(--text-main);
    width: 100%;
}

.btn-warning:hover {
    background: rgba(255, 42, 42, 0.2);
    box-shadow: 0 0 15px rgba(255, 42, 42, 0.4);
}

.btn-primary {
    background: rgba(10, 255, 212, 0.1);
    border: 1px solid var(--primary-glow);
    color: var(--text-main);
}

.btn-primary:hover {
    background: rgba(10, 255, 212, 0.3);
    box-shadow: 0 0 15px rgba(10, 255, 212, 0.6);
}

.btn-secondary {
    background: transparent;
    border: 1px solid var(--text-dim);
    color: var(--text-dim);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-main);
}

.turn-controls {
    margin-top: auto;
    padding-top: 1rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    position: sticky;
    bottom: 0;
    background: var(--glass-bg);
    /* Ensure it covers anything scrolling beneath */
    z-index: 10;
    padding-bottom: 0.5rem;
}

/* Individual Grid Cells */
.cell {
    width: 60px;
    height: 60px;
    background: rgba(20, 30, 50, 0.8);
    border: 1px solid var(--grid-border);
    border-radius: 4px;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s, transform 0.1s;
}

.cell:hover {
    background: rgba(40, 60, 90, 0.9);
    border-color: var(--primary-glow);
    z-index: 10;
}

/* Path overlay (Lux's path) */
.cell.path-lux::before {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(circle, rgba(255, 204, 0, 0.4) 0%, transparent 70%);
    animation: pulse 2s infinite alternate;
    pointer-events: none;
}

/* Movement Highlight */
.cell.highlight-move {
    background: rgba(10, 255, 212, 0.15);
    border-color: var(--primary-glow);
}

.cell.highlight-move::after {
    content: '';
    width: 8px;
    height: 8px;
    background: var(--primary-glow);
    border-radius: 50%;
    box-shadow: 0 0 8px var(--primary-glow);
}

/* Attack Highlight */
.cell.highlight-attack {
    background: rgba(255, 42, 42, 0.15);
    border-color: var(--enemy-color);
}

.cell.highlight-attack::after {
    content: '';
    width: 12px;
    height: 12px;
    border: 2px solid var(--enemy-color);
    transform: rotate(45deg);
    box-shadow: 0 0 8px var(--enemy-color);
}

/* Skill Highlights */
.cell.highlight-akira {
    background: rgba(0, 191, 255, 0.15);
    border-color: var(--akira-color);
}

.cell.highlight-koto {
    background: rgba(255, 0, 255, 0.15);
    border-color: var(--koto-color);
}

/* Entities on board */
.entity-token {
    width: 80%;
    height: 80%;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 1.2rem;
    position: relative;
    z-index: 2;
    transition: all 0.3s ease;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
}

.entity-token.has-icon {
    background: none;
    border: none;
    box-shadow: none;
}

.board-icon {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--text-light);
    box-shadow: 0 0 10px var(--primary-shadow);
    position: relative;
    z-index: 10;
    /* Keep image above ::before and ::after pseudo elements */
}

/* AKIRA: Ice/Crystal aesthetic */
.entity-token.akira {
    background: linear-gradient(135deg, rgba(0, 191, 255, 0.8), rgba(0, 50, 150, 0.9));
    border: 2px solid var(--akira-color);
    box-shadow: 0 0 15px var(--akira-color), inset 0 0 10px rgba(255, 255, 255, 0.5);
    border-radius: 8px;
    /* Not perfectly round, like a crystal structure */
    transform: rotate(45deg);
}

.entity-token.akira span,
.entity-token.akira .board-icon {
    transform: rotate(-45deg);
    color: white;
}

/* KOTO: Observation/Atom aesthetic */
.entity-token.koto {
    background: radial-gradient(circle, rgba(255, 0, 255, 0.8) 0%, rgba(50, 0, 100, 0.9) 100%);
    border: 2px solid var(--koto-color);
    box-shadow: 0 0 15px var(--koto-color);
}

.entity-token.koto::before {
    content: '';
    position: absolute;
    width: 50px;
    height: 50px;
    border: 1px dotted var(--koto-color);
    border-radius: 50%;
    animation: rotate 4s linear infinite;
}

/* LUX: Light/Energy aesthetic */
.entity-token.lux {
    background: transparent;
    border: 2px solid var(--lux-color);
    box-shadow: 0 0 20px var(--lux-color);
    clip-path: polygon(50% 0%, 100% 50%, 50% 100%, 0% 50%);
    /* Diamond */
}

.entity-token.lux::after {
    content: '';
    position: absolute;
    width: 20px;
    height: 20px;
    background: var(--lux-color);
    border-radius: 50%;
    box-shadow: 0 0 15px var(--lux-color);
    animation: pulse 1s alternate infinite;
}

/* Enemies: Glitchy/Uncertain aesthetic */
.entity-token.enemy {
    background: rgba(255, 42, 42, 0.5);
    /* Make it slightly more transparent so the dark portrait stands out */
    border: 2px solid var(--enemy-color);
    box-shadow: 0 0 15px var(--enemy-color);
    clip-path: polygon(20% 0%, 80% 0%, 100% 20%, 100% 80%, 80% 100%, 20% 100%, 0% 80%, 0% 20%);
    /* Octagon */
}

/* Ensure enemy icons are rendered correctly within the token */
.entity-token.enemy .board-icon {
    width: 90%;
    height: 90%;
    object-fit: contain;
    /* Don't crop the face */
    mix-blend-mode: luminosity;
    /* Style the monochrome AI face to blend with the red background */
}

/* Probability Shadow of Enemy */
.entity-token.enemy.probability {
    background: transparent;
    border: 2px dashed var(--enemy-color);
    box-shadow: none;
    opacity: 0.6;
    animation: jitter 0.5s infinite;
}

.entity-token.enemy.probability::before {
    content: '?';
    color: var(--enemy-color);
    font-size: 1.5rem;
    font-weight: bold;
    text-shadow: 0 0 5px var(--enemy-color);
}

/* Enemy Intent (Arrow/Highlight) */
.intent-line {
    position: absolute;
    background: var(--enemy-color);
    height: 2px;
    transform-origin: left center;
    z-index: 4;
    opacity: 0.5;
    pointer-events: none;
}

.intent-line::after {
    content: '';
    position: absolute;
    right: 0;
    top: -4px;
    border-top: 5px solid transparent;
    border-bottom: 5px solid transparent;
    border-left: 10px solid var(--enemy-color);
}

/* Status Effects on Tokens */
.status-frozen {
    border-color: #fff !important;
    box-shadow: 0 0 10px #fff !important;
}

.status-frozen::after {
    content: '❄';
    position: absolute;
    top: -10px;
    right: -10px;
    font-size: 14px;
    text-shadow: 0 0 5px white;
}

/* Animations */
@keyframes pulse {
    0% {
        transform: scale(1);
        opacity: 0.8;
    }

    100% {
        transform: scale(1.1);
        opacity: 1;
    }
}

@keyframes rotate {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

@keyframes jitter {
    0% {
        transform: translate(0, 0);
    }

    25% {
        transform: translate(1px, -1px);
    }

    50% {
        transform: translate(-1px, 0);
    }

    75% {
        transform: translate(0, 1px);
    }

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

/* Setup Modals */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(5px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 11000;
}

.modal.hidden {
    display: none;
}

.modal-content {
    padding: 3rem;
    text-align: center;
    max-width: 500px;
}

.modal-content h2 {
    font-family: var(--font-heading);
    font-size: 2.5rem;
    margin-bottom: 1rem;
    color: var(--primary-glow);
}

.modal-content p {
    margin-bottom: 2rem;
    font-size: 1.2rem;
}

/* Floating combat text */
.floating-text {
    position: absolute;
    color: white;
    font-weight: 900;
    font-size: 2.5rem;
    text-shadow: 2px 2px 0 #000, -2px -2px 0 #000, 2px -2px 0 #000, -2px 2px 0 #000, 0 0 15px rgba(0, 0, 0, 0.8);
    pointer-events: auto;
    cursor: pointer;
    z-index: 3000;
    text-align: center;
    white-space: nowrap;
    animation: floatUp 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

.floating-text.damage {
    color: #ff3333;
    text-shadow: 2px 2px 0 #000, -2px -2px 0 #000, 2px -2px 0 #000, -2px 2px 0 #000, 0 0 20px #ff0000;
}

.floating-text.heal {
    color: #33ff33;
}

.floating-text.miss {
    color: #ffffff;
    font-size: 2rem;
    font-style: italic;
    color: rgba(255, 255, 255, 0.8);
}

.floating-text.warning {
    color: #ffaa00;
    font-size: 2.2rem;
}

@keyframes floatUp {
    0% {
        transform: translate(-50%, 20px) scale(0.5);
        opacity: 0;
    }

    100% {
        transform: translate(-50%, 0) scale(1.2);
        opacity: 1;
    }
}

/* Screen Shake Effect */
.board-shake {
    animation: shake 0.4s cubic-bezier(.36, .07, .19, .97) both;
}

@keyframes shake {
    0% {
        transform: translate(1px, 1px) rotate(0deg);
    }

    10% {
        transform: translate(-2px, -3px) rotate(-1deg);
    }

    20% {
        transform: translate(-4px, 0px) rotate(1deg);
    }

    30% {
        transform: translate(4px, 3px) rotate(0deg);
    }

    40% {
        transform: translate(2px, -2px) rotate(1deg);
    }

    50% {
        transform: translate(-2px, 3px) rotate(-1deg);
    }

    60% {
        transform: translate(-4px, 2px) rotate(0deg);
    }

    70% {
        transform: translate(4px, 2px) rotate(-1deg);
    }

    80% {
        transform: translate(-2px, -2px) rotate(1deg);
    }

    90% {
        transform: translate(2px, 3px) rotate(0deg);
    }

    100% {
        transform: translate(0, 0) rotate(0deg);
    }
}

/* Cell Impact Flashes */
.cell-flash-damage {
    animation: flashRed 0.5s ease-out;
}

.cell-flash-heal {
    animation: flashGreen 0.5s ease-out;
}

.cell-flash-miss {
    animation: flashWhite 0.5s ease-out;
}

@keyframes flashRed {
    0% {
        background-color: rgba(255, 0, 0, 0.8);
        box-shadow: 0 0 30px red inset;
    }

    100% {
        background-color: transparent;
        box-shadow: none;
    }
}

@keyframes flashGreen {
    0% {
        background-color: rgba(0, 255, 255, 0.8);
        box-shadow: 0 0 30px cyan inset;
    }

    100% {
        background-color: transparent;
        box-shadow: none;
    }
}

@keyframes flashWhite {
    0% {
        background-color: rgba(255, 255, 255, 0.5);
        box-shadow: 0 0 30px white inset;
    }

    100% {
        background-color: transparent;
        box-shadow: none;
    }
}

/* Action Overlay (Bottom Middle) */
.action-overlay {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.8);
    padding: 10px;
    border-radius: 8px;
    border: 1px solid var(--primary-glow);
    z-index: 100;
    pointer-events: auto;
    /* Only buttons should be clickable, let events pass through the gap mostly */
}

.action-actions {
    display: flex;
    gap: 10px;
}

.hidden {
    display: none !important;
}

/* ----------------------------------
   Cut-in Animation (Skill usage)
----------------------------------- */
.cutin-overlay {
    position: fixed;
    top: 50%;
    left: 0;
    width: 100%;
    height: 300px;
    transform: translateY(-50%);
    z-index: 2000;
    pointer-events: none;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    overflow: visible;
    /* Changed from hidden so tall images don't get cut off */
    opacity: 0;
    transition: opacity 0.3s ease;
}

.cutin-overlay::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, rgba(10, 255, 212, 0.2) 0%, rgba(0, 0, 0, 0.8) 40%, rgba(0, 0, 0, 0.8) 100%);
    border-top: 2px solid var(--primary-glow);
    border-bottom: 2px solid var(--primary-glow);
    box-shadow: 0 0 30px var(--primary-shadow);
    transform: translateX(-100%);
    transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.cutin-portrait {
    height: 400px;
    /* Fixed height instead of percentage to ensure it escapes the container uniformly */
    object-fit: contain;
    transform: translateX(-50vw) scale(1.2);
    transition: transform 0.5s cubic-bezier(0.175, 0.885, 0.32, 1);
    filter: drop-shadow(0 0 20px var(--primary-glow));
    z-index: 2;
    margin-top: 0;
    /* Reset margin */
    margin-bottom: 50px;
    /* Lift it slightly */
    margin-left: 10%;
    position: relative;
    /* Ensure it layers correctly over the visible overflow */
}

.cutin-skill-text {
    font-family: 'Jura', sans-serif;
    font-size: 4rem;
    font-weight: 700;
    color: #fff;
    text-transform: uppercase;
    letter-spacing: 15px;
    text-shadow: 0 0 20px var(--primary-glow), 0 0 40px var(--primary-glow);
    margin-left: 50px;
    transform: translateX(50vw);
    transition: transform 0.6s cubic-bezier(0.175, 0.885, 0.32, 1);
    z-index: 3;
    font-style: italic;
}

.cutin-overlay.active {
    opacity: 1;
    /* Removed pointer-events: auto so it doesn't trap clicks while fading */
}

.cutin-overlay.active::before {
    transform: translateX(0);
}

.cutin-overlay.active .cutin-portrait {
    transform: translateX(0) scale(1);
}

.cutin-overlay.active .cutin-skill-text {
    transform: translateX(0);
}

/* ========== Dialogue Bar ========== */
.dialogue-bar {
    display: none;
    align-items: center;
    gap: 12px;
    padding: 12px 20px;
    margin: 0 calc(280px + 1.5rem);
    background: linear-gradient(135deg, rgba(10, 20, 40, 0.95), rgba(20, 30, 60, 0.92));
    border: 1px solid rgba(10, 255, 212, 0.25);
    border-radius: 8px;
    backdrop-filter: blur(8px);
    box-shadow: 0 0 20px rgba(10, 255, 212, 0.08), inset 0 1px 0 rgba(255, 255, 255, 0.05);
    transition: opacity 0.3s ease;
    min-height: 56px;
    position: relative;
    z-index: 50;
    cursor: pointer;
    flex-shrink: 0;
}

.dialogue-bar:hover {
    border-color: rgba(10, 255, 212, 0.5);
    box-shadow: 0 0 25px rgba(10, 255, 212, 0.15);
}

.dialogue-icon {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid rgba(10, 255, 212, 0.6);
    flex-shrink: 0;
    box-shadow: 0 0 15px rgba(10, 255, 212, 0.3);
    animation: icon-pulse 1.5s ease-in-out infinite;
}

@keyframes icon-pulse {

    0%,
    100% {
        transform: scale(1);
        box-shadow: 0 0 15px rgba(10, 255, 212, 0.3);
    }

    50% {
        transform: scale(1.1);
        box-shadow: 0 0 25px rgba(10, 255, 212, 0.6);
    }
}

.dialogue-content {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
    flex: 1;
}

.dialogue-name {
    font-family: var(--font-heading);
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 2px;
    text-transform: uppercase;
}

.dialogue-text {
    font-family: var(--font-body);
    font-size: 1.05rem;
    color: rgba(255, 255, 255, 0.9);
    line-height: 1.5;
    letter-spacing: 0.3px;
}

.dialogue-prompt {
    font-size: 1.2rem;
    color: rgba(10, 255, 212, 0.8);
    flex-shrink: 0;
    animation: bounce-prompt 0.8s ease-in-out infinite;
    align-self: center;
    text-shadow: 0 0 8px rgba(10, 255, 212, 0.4);
    padding: 4px 8px;
}

@keyframes bounce-prompt {

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

    50% {
        transform: translateY(-6px);
        opacity: 1;
    }
}

/* ========== Enemy Reveal Overlay ========== */
.enemy-reveal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 5000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.enemy-reveal-overlay.active {
    opacity: 1;
}

.enemy-reveal-overlay.fade-out {
    opacity: 0;
    transition: opacity 0.5s ease;
}

.enemy-reveal-bg {
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, rgba(255, 20, 20, 0.15), rgba(100, 0, 0, 0.4));
    transition: left 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.enemy-reveal-overlay.active .enemy-reveal-bg {
    left: 0;
}

.enemy-reveal-portrait {
    max-height: 80vh;
    max-width: 45vw;
    object-fit: contain;
    filter: drop-shadow(0 0 40px rgba(255, 40, 40, 0.6));
    transform: translateX(-80vw) scale(1.1);
    transition: transform 0.5s cubic-bezier(0.175, 0.885, 0.32, 1);
    z-index: 2;
    position: relative;
}

.enemy-reveal-overlay.active .enemy-reveal-portrait {
    transform: translateX(-5vw) scale(1);
}

.enemy-reveal-info {
    position: absolute;
    right: 10%;
    text-align: right;
    z-index: 3;
    transform: translateX(50vw);
    transition: transform 0.5s cubic-bezier(0.175, 0.885, 0.32, 1) 0.15s;
}

.enemy-reveal-overlay.active .enemy-reveal-info {
    transform: translateX(0);
}

.enemy-reveal-label {
    font-family: var(--font-heading);
    font-size: 1rem;
    color: #ff4444;
    letter-spacing: 6px;
    text-transform: uppercase;
    margin-bottom: 8px;
    text-shadow: 0 0 15px rgba(255, 40, 40, 0.5);
}

.enemy-reveal-name {
    font-family: var(--font-heading);
    font-size: 4rem;
    font-weight: 700;
    color: #fff;
    letter-spacing: 10px;
    text-shadow: 0 0 30px rgba(255, 40, 40, 0.6), 0 0 60px rgba(255, 40, 40, 0.3);
    line-height: 1;
    margin-bottom: 12px;
}

.enemy-reveal-role {
    font-family: var(--font-body);
    font-size: 1.2rem;
    color: rgba(255, 180, 180, 0.8);
    letter-spacing: 3px;
}

/* ========== Tutorial Detail Styles ========== */
.tutorial-content .btn-close {
    position: absolute;
    top: 12px;
    right: 16px;
    font-size: 2rem;
    color: #0affd4;
    background: rgba(10, 255, 212, 0.1);
    border: 2px solid rgba(10, 255, 212, 0.4);
    border-radius: 50%;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    z-index: 10;
    line-height: 1;
}

.tutorial-content .btn-close:hover {
    background: rgba(10, 255, 212, 0.25);
    box-shadow: 0 0 15px rgba(10, 255, 212, 0.4);
    transform: scale(1.1);
}

.tutorial-content {
    max-height: 85vh;
    overflow-y: auto;
    max-width: 700px;
    text-align: left;
}

.tutorial-content h3 {
    color: #0affd4;
    margin-bottom: 12px;
    font-size: 1.3rem;
}

.tutorial-content p {
    line-height: 1.7;
    margin-bottom: 10px;
    font-size: 0.95rem;
}

.tut-highlight {
    background: rgba(10, 255, 212, 0.08);
    border-left: 3px solid #0affd4;
    padding: 12px 16px;
    margin: 12px 0;
    border-radius: 0 8px 8px 0;
    font-size: 0.92rem;
    line-height: 1.6;
}

.tut-layout-guide {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.tut-section {
    background: rgba(255, 255, 255, 0.04);
    padding: 10px 14px;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.tut-section strong {
    color: #0affd4;
    font-size: 0.95rem;
}

.tut-section p {
    margin: 6px 0 0;
    font-size: 0.88rem;
}

.tut-steps {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.tut-step {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    background: rgba(255, 255, 255, 0.03);
    padding: 10px 14px;
    border-radius: 8px;
}

.tut-step-num {
    font-size: 1.4rem;
    font-weight: 700;
    color: #0affd4;
    flex-shrink: 0;
    width: 30px;
    text-align: center;
}

.tut-step-text {
    font-size: 0.92rem;
    line-height: 1.5;
}

.tut-step-text strong {
    color: #fff;
}

.tut-char-detail {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 14px;
    padding: 12px;
    background: rgba(255, 255, 255, 0.04);
    border-radius: 12px;
}

.tut-char-icon {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid #0affd4;
    box-shadow: 0 0 15px rgba(10, 255, 212, 0.3);
    flex-shrink: 0;
}

.tut-char-name {
    font-family: var(--font-heading);
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: 2px;
}

.tut-char-role {
    color: rgba(255, 255, 255, 0.6);
    font-size: 0.85rem;
    margin-top: 2px;
}

.tut-ability {
    background: rgba(255, 255, 255, 0.04);
    border-left: 3px solid #0affd4;
    padding: 12px 16px;
    margin: 10px 0;
    border-radius: 0 8px 8px 0;
    font-size: 0.92rem;
    line-height: 1.6;
}

.tut-ability ul {
    margin: 8px 0 8px 16px;
    padding: 0;
}

.tut-ability li {
    margin-bottom: 4px;
}

.tut-enemy-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.tut-enemy-row {
    display: flex;
    align-items: center;
    gap: 14px;
    background: rgba(255, 40, 40, 0.06);
    padding: 12px;
    border-radius: 10px;
    border: 1px solid rgba(255, 40, 40, 0.15);
}

.tut-enemy-icon {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid rgba(255, 40, 40, 0.5);
    flex-shrink: 0;
}

.tut-enemy-stats {
    display: block;
    color: rgba(255, 180, 180, 0.7);
    font-size: 0.8rem;
    margin-top: 2px;
}

.tut-enemy-row p {
    margin: 4px 0 0;
    font-size: 0.85rem;
    color: rgba(255, 255, 255, 0.7);
}

/* ========== Title Screen ========== */
.title-screen {
    position: fixed;
    inset: 0;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(ellipse at 30% 20%, rgba(10, 255, 212, 0.08) 0%, transparent 50%),
        radial-gradient(ellipse at 70% 80%, rgba(204, 102, 255, 0.06) 0%, transparent 50%),
        linear-gradient(135deg, #0a0a1a 0%, #0d1b2a 40%, #1a0a2e 100%);
    overflow: hidden;
    transition: opacity 0.6s ease, transform 0.6s ease;
}

.title-screen.fade-out {
    opacity: 0;
    transform: scale(1.05);
    pointer-events: none;
}

.title-particles {
    position: absolute;
    inset: 0;
    pointer-events: none;
}

.title-particle {
    position: absolute;
    width: 3px;
    height: 3px;
    background: #0affd4;
    border-radius: 50%;
    opacity: 0;
    animation: titleParticleFloat 6s infinite;
}

@keyframes titleParticleFloat {
    0% {
        opacity: 0;
        transform: translateY(100vh) scale(0);
    }

    10% {
        opacity: 0.8;
    }

    90% {
        opacity: 0.3;
    }

    100% {
        opacity: 0;
        transform: translateY(-10vh) scale(1);
    }
}

.title-content {
    text-align: center;
    z-index: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 28px;
    padding: 20px;
}

.title-sub-label {
    font-family: var(--font-heading);
    font-size: 0.75rem;
    letter-spacing: 8px;
    color: rgba(10, 255, 212, 0.5);
    text-transform: uppercase;
}

.title-main {
    font-family: var(--font-heading);
    font-size: 4.5rem;
    font-weight: 700;
    letter-spacing: 10px;
    color: #fff;
    text-shadow:
        0 0 20px rgba(10, 255, 212, 0.5),
        0 0 60px rgba(10, 255, 212, 0.2),
        0 0 120px rgba(10, 255, 212, 0.1);
    margin: 0;
    line-height: 1;
    animation: titleGlow 3s ease-in-out infinite alternate;
}

.title-accent {
    color: #0affd4;
    text-shadow:
        0 0 30px rgba(10, 255, 212, 0.8),
        0 0 80px rgba(10, 255, 212, 0.4);
}

@keyframes titleGlow {
    0% {
        text-shadow: 0 0 20px rgba(10, 255, 212, 0.3), 0 0 60px rgba(10, 255, 212, 0.1);
    }

    100% {
        text-shadow: 0 0 30px rgba(10, 255, 212, 0.6), 0 0 80px rgba(10, 255, 212, 0.3), 0 0 140px rgba(10, 255, 212, 0.1);
    }
}

.title-tagline {
    font-family: var(--font-body);
    font-size: 0.95rem;
    color: rgba(255, 255, 255, 0.5);
    letter-spacing: 4px;
    margin-top: 8px;
}

.title-characters {
    display: flex;
    gap: 32px;
    justify-content: center;
    margin: 8px 0;
}

.title-char {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.title-char span {
    font-family: var(--font-heading);
    font-size: 0.8rem;
    letter-spacing: 3px;
    font-weight: 700;
}

.title-char-img {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid #0affd4;
    box-shadow: 0 0 20px rgba(10, 255, 212, 0.3);
    transition: all 0.3s ease;
}

.title-char:hover .title-char-img {
    transform: scale(1.12);
    box-shadow: 0 0 30px rgba(10, 255, 212, 0.6);
}

.title-difficulty {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
}

.title-diff-label {
    font-family: var(--font-heading);
    font-size: 0.7rem;
    letter-spacing: 6px;
    color: rgba(255, 255, 255, 0.4);
}

.title-diff-buttons {
    display: flex;
    gap: 16px;
}

.title-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 16px 32px;
    border: 2px solid rgba(255, 255, 255, 0.15);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.03);
    cursor: pointer;
    transition: all 0.3s ease;
    min-width: 110px;
}

.title-btn:hover {
    transform: translateY(-4px);
    background: rgba(255, 255, 255, 0.08);
}

.title-btn-rank {
    font-family: var(--font-heading);
    font-size: 0.7rem;
    letter-spacing: 4px;
    color: rgba(255, 255, 255, 0.5);
}

.title-btn-name {
    font-family: var(--font-body);
    font-size: 1.3rem;
    font-weight: 700;
    color: #fff;
}

/* Easy - green */
.title-btn-easy {
    border-color: rgba(0, 255, 136, 0.3);
}

.title-btn-easy:hover {
    border-color: rgba(0, 255, 136, 0.7);
    box-shadow: 0 0 25px rgba(0, 255, 136, 0.3), inset 0 0 25px rgba(0, 255, 136, 0.05);
}

.title-btn-easy .title-btn-name {
    color: #00ff88;
}

/* Normal - cyan */
.title-btn-normal {
    border-color: rgba(10, 255, 212, 0.3);
}

.title-btn-normal:hover {
    border-color: rgba(10, 255, 212, 0.7);
    box-shadow: 0 0 25px rgba(10, 255, 212, 0.3), inset 0 0 25px rgba(10, 255, 212, 0.05);
}

.title-btn-normal .title-btn-name {
    color: #0affd4;
}

/* Hard - red/orange */
.title-btn-hard {
    border-color: rgba(255, 80, 50, 0.3);
}

.title-btn-hard:hover {
    border-color: rgba(255, 80, 50, 0.7);
    box-shadow: 0 0 25px rgba(255, 80, 50, 0.3), inset 0 0 25px rgba(255, 80, 50, 0.05);
}

.title-btn-hard .title-btn-name {
    color: #ff5032;
}

.title-tutorial-btn {
    font-family: var(--font-body);
    font-size: 0.9rem;
    color: rgba(255, 255, 255, 0.6);
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 8px;
    padding: 10px 28px;
    cursor: pointer;
    transition: all 0.3s ease;
    letter-spacing: 2px;
}

.title-tutorial-btn:hover {
    color: #0affd4;
    border-color: rgba(10, 255, 212, 0.5);
    background: rgba(10, 255, 212, 0.05);
}

.title-footer {
    font-family: var(--font-heading);
    font-size: 0.65rem;
    color: rgba(255, 255, 255, 0.15);
    letter-spacing: 4px;
    margin-top: 8px;
}

/* ===================================================================
   RESPONSIVE: TABLET (768px - 1023px)
   =================================================================== */
@media (max-width: 1023px) {
    .status-bar {
        padding: 0.5rem 1rem;
        height: 50px;
    }

    .logo {
        font-size: 1.2rem;
    }

    .turn-indicator {
        font-size: 1rem;
        letter-spacing: 1px;
    }

    .mission-status {
        font-size: 0.9rem;
    }

    .sidebar {
        width: 220px;
        padding: 0.8rem;
    }

    .unit-icon {
        width: 48px;
        height: 48px;
    }

    .unit-name {
        font-size: 0.95rem;
    }

    .board-container {
        padding: 0.5rem;
    }

    .cell {
        width: 50px;
        height: 50px;
    }

    .entity-token {
        width: 36px;
        height: 36px;
    }

    .board-icon {
        width: 32px;
        height: 32px;
    }

    .dialogue-bar {
        margin: 0 calc(220px + 1.5rem);
        padding: 10px 16px;
    }

    .dialogue-icon {
        width: 56px;
        height: 56px;
    }

    /* Title Screen tablet */
    .title-main {
        font-size: 3.5rem;
        letter-spacing: 6px;
    }
}

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

    /* === Body & Container === */
    body {
        overflow: auto;
        height: auto;
        min-height: 100vh;
        align-items: flex-start;
    }

    .app-container {
        height: auto;
        min-height: 100vh;
        padding: 0.3rem;
        gap: 0.3rem;
    }

    /* === Header === */
    .status-bar {
        padding: 0.4rem 0.6rem;
        height: auto;
        min-height: 40px;
        flex-wrap: wrap;
        gap: 4px;
    }

    .logo {
        font-size: 0.9rem;
        letter-spacing: 1px;
    }

    .turn-indicator {
        font-size: 0.8rem;
        letter-spacing: 1px;
        order: -1;
        width: 100%;
        text-align: center;
    }

    .mission-status {
        font-size: 0.75rem;
        display: flex;
        align-items: center;
        gap: 4px;
        flex-wrap: wrap;
    }

    .mission-status .btn-small {
        padding: 2px 6px;
        font-size: 0.7rem;
    }

    #difficulty-select {
        font-size: 0.7rem;
        padding: 2px 4px;
    }

    /* === Game Area: 縦積み === */
    .game-area {
        flex-direction: column;
        gap: 0.4rem;
    }

    /* === Board === */
    .board-container {
        padding: 0.3rem;
        order: 0;
    }

    .game-board {
        padding: 4px;
        gap: 1px;
    }

    .cell {
        width: calc((100vw - 40px) / 8);
        height: calc((100vw - 40px) / 8);
    }

    .entity-token {
        width: calc((100vw - 40px) / 8 * 0.7);
        height: calc((100vw - 40px) / 8 * 0.7);
    }

    .board-icon {
        width: calc((100vw - 40px) / 8 * 0.55);
        height: calc((100vw - 40px) / 8 * 0.55);
    }

    /* === Sidebars: 横幅100% === */
    .sidebar {
        width: 100%;
        padding: 0.5rem;
        gap: 0.4rem;
        order: 1;
    }

    .sidebar.right-sidebar {
        order: 2;
    }

    .panel-header {
        font-size: 0.75rem;
        padding-bottom: 0.3rem;
    }

    /* キャラカード: 横スクロール */
    .character-list {
        flex-direction: row;
        overflow-x: auto;
        gap: 0.5rem;
        padding-bottom: 4px;
        -webkit-overflow-scrolling: touch;
    }

    .character-list .unit-card {
        min-width: 200px;
        flex-shrink: 0;
    }

    /* 敵リスト: 横スクロール */
    .enemy-list {
        flex-direction: row;
        overflow-x: auto;
        gap: 0.5rem;
        padding-bottom: 4px;
        -webkit-overflow-scrolling: touch;
    }

    .enemy-list .unit-card {
        min-width: 180px;
        flex-shrink: 0;
    }

    .unit-card {
        padding: 8px;
    }

    .unit-icon {
        width: 40px;
        height: 40px;
    }

    .unit-name {
        font-size: 0.85rem;
    }

    .unit-role {
        font-size: 0.65rem;
        margin-bottom: 0.3rem;
    }

    .unit-stats {
        font-size: 0.7rem;
    }

    .skill-btn {
        padding: 0.5rem 0.6rem;
        font-size: 0.75rem;
        min-height: 36px;
    }

    /* ターン終了ボタン */
    .turn-controls {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        padding: 0.5rem;
        background: rgba(10, 20, 35, 0.95);
        border-top: 1px solid var(--glass-border);
        z-index: 100;
    }

    /* 確定・キャンセルボタン */
    .action-confirm {
        position: fixed;
        bottom: 50px;
        left: 0;
        right: 0;
        padding: 0.4rem;
        background: rgba(10, 20, 35, 0.95);
        border-top: 1px solid var(--glass-border);
        z-index: 100;
        display: flex;
        gap: 0.5rem;
    }

    .action-confirm .btn {
        flex: 1;
        padding: 0.7rem;
        font-size: 0.85rem;
    }

    /* === Dialogue Bar === */
    .dialogue-bar {
        margin: 0;
        padding: 8px 12px;
        gap: 8px;
        min-height: 48px;
    }

    .dialogue-icon {
        width: 40px;
        height: 40px;
    }

    .dialogue-name {
        font-size: 0.7rem;
    }

    .dialogue-text {
        font-size: 0.8rem;
    }

    .dialogue-prompt {
        font-size: 0.8rem;
    }

    /* === Floating Text === */
    .floating-text {
        font-size: 0.7rem;
    }

    /* === Modals === */
    .modal-content {
        width: 95vw;
        max-height: 90vh;
        padding: 1rem;
    }

    .tutorial-content {
        max-width: 95vw;
        max-height: 85vh;
    }

    .tut-char-icon {
        width: 56px;
        height: 56px;
    }

    .tut-enemy-icon {
        width: 44px;
        height: 44px;
    }

    /* === Title Screen === */
    .title-content {
        gap: 16px;
        padding: 12px;
    }

    .title-sub-label {
        font-size: 0.55rem;
        letter-spacing: 4px;
    }

    .title-main {
        font-size: 2rem;
        letter-spacing: 4px;
    }

    .title-tagline {
        font-size: 0.7rem;
        letter-spacing: 2px;
    }

    .title-characters {
        gap: 16px;
    }

    .title-char-img {
        width: 56px;
        height: 56px;
    }

    .title-char span {
        font-size: 0.65rem;
    }

    .title-diff-buttons {
        flex-direction: column;
        gap: 10px;
        width: 100%;
    }

    .title-btn {
        padding: 14px 24px;
        min-width: unset;
        width: 100%;
    }

    .title-tutorial-btn {
        font-size: 0.8rem;
        padding: 10px 20px;
    }

    /* === Cut-in === */
    .cutin-overlay .cutin-portrait {
        max-height: 50vh;
    }

    .cutin-overlay .cutin-name {
        font-size: 1.5rem;
    }

    /* === Enemy Reveal === */
    .enemy-reveal-portrait {
        max-height: 40vh;
    }

    .enemy-reveal-name {
        font-size: 1.5rem;
    }

    /* ボトム固定コントロール分のパディング */
    .app-container {
        padding-bottom: 60px;
    }
}