/* ============================================
   TankTactics-EDU 스타일시트
   다크 테마 + 네온 글로우 + 게임 UI
   ============================================ */

:root {
    /* 컬러 팔레트 */
    --bg-primary: #0a0a1a;
    --bg-secondary: #12122a;
    --bg-panel: rgba(20, 20, 50, 0.9);

    --accent-cyan: #00ffff;
    --accent-magenta: #ff00ff;
    --accent-yellow: #ffff00;
    --accent-green: #00ff88;
    --accent-red: #ff3366;

    --text-primary: #ffffff;
    --text-secondary: #a0a0c0;
    --text-muted: #606080;

    /* 글로우 효과 */
    --glow-cyan: 0 0 20px rgba(0, 255, 255, 0.5);
    --glow-magenta: 0 0 20px rgba(255, 0, 255, 0.5);

    /* 폰트 */
    --font-display: 'Orbitron', sans-serif;
    --font-body: 'Noto Sans KR', sans-serif;

    /* 크기 */
    --sidebar-width: 320px;
    --header-height: 80px;
}

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

body {
    font-family: var(--font-body);
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;

    /* 배경 그라디언트 */
    background:
        radial-gradient(ellipse at 20% 80%, rgba(0, 255, 255, 0.1) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 20%, rgba(255, 0, 255, 0.1) 0%, transparent 50%),
        var(--bg-primary);
}

/* ============================================
   레이아웃 - 스테이지, 디버그, 사이드바
   ============================================ */

#game-wrapper {
    display: grid;
    grid-template-columns: 1fr auto var(--sidebar-width);
    grid-template-areas:
        "main debug sidebar";
    min-height: 100vh;
    gap: 15px;
    padding: 20px;
}

/* ============================================
   헤더 (사이드바 상단)
   ============================================ */

#game-header {
    text-align: center;
    padding: 20px;
    background: var(--bg-panel);
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

#game-header h1 {
    font-family: var(--font-display);
    font-size: 1.3rem;
    font-weight: 900;
    background: linear-gradient(135deg, var(--accent-cyan), var(--accent-magenta));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 8px;
}

@keyframes titlePulse {

    0%,
    100% {
        filter: brightness(1);
    }

    50% {
        filter: brightness(1.2);
    }
}

.subtitle {
    font-size: 0.75rem;
    color: var(--text-secondary);
    letter-spacing: 2px;
    text-transform: uppercase;
}

/* ============================================
   게임 캔버스 영역
   ============================================ */

#game-container {
    grid-area: main;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-secondary);
    border-radius: 16px;
    border: 2px solid rgba(0, 255, 255, 0.2);
    box-shadow:
        inset 0 0 60px rgba(0, 0, 0, 0.5),
        var(--glow-cyan);
    overflow: hidden;
    position: relative;
}

#game-container canvas {
    border-radius: 12px;
}

/* ============================================
   사이드바
   ============================================ */

#sidebar {
    grid-area: sidebar;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.panel {
    background: var(--bg-panel);
    border-radius: 12px;
    padding: 20px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
}

.panel h2 {
    font-family: var(--font-display);
    font-size: 1rem;
    color: var(--accent-cyan);
    margin-bottom: 16px;
    padding-bottom: 8px;
    border-bottom: 1px solid rgba(0, 255, 255, 0.3);
}

.panel.hidden {
    display: none;
}

/* 패널 헤더 (제목 + 버튼) */
.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    padding-bottom: 8px;
    border-bottom: 1px solid rgba(0, 255, 255, 0.3);
}

.panel-header h2 {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
}

/* 작은 버튼 */
.btn-small {
    padding: 4px 10px;
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--accent-cyan);
    background: transparent;
    border: 1px solid var(--accent-cyan);
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-small:hover {
    background: rgba(0, 255, 255, 0.2);
}

/* 맵 선택 */
.map-selector {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 16px 0;
    padding: 10px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 6px;
}

.map-selector label {
    font-size: 0.85rem;
    color: var(--text-secondary);
    white-space: nowrap;
}

.map-selector select {
    flex: 1;
    padding: 8px 12px;
    font-family: var(--font-body);
    font-size: 0.85rem;
    color: #000000;
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    cursor: pointer;
}

.map-selector select:hover {
    border-color: var(--accent-cyan);
}

.map-selector select:focus {
    outline: none;
    border-color: var(--accent-cyan);
    box-shadow: 0 0 0 2px rgba(0, 255, 255, 0.2);
}

/* 보조 버튼 */
.btn-secondary {
    width: 100%;
    margin-top: 12px;
    padding: 10px 16px;
    font-family: var(--font-body);
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--accent-green);
    background: rgba(0, 255, 136, 0.1);
    border: 1px solid var(--accent-green);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-secondary:hover {
    background: rgba(0, 255, 136, 0.25);
}

/* 버튼 행 */
.btn-row {
    display: flex;
    gap: 8px;
    margin-top: 12px;
}

.btn-row .btn-pause {
    flex: 1;
    margin-top: 0;
}

/* ============================================
   탱크 선택 UI
   ============================================ */

#tank-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 16px;
    max-height: 300px;
    overflow-y: auto;
}

.tank-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 10px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 1px solid transparent;
}

.tank-item:hover {
    background: rgba(0, 255, 255, 0.1);
    border-color: rgba(0, 255, 255, 0.3);
}

.tank-item.selected {
    background: rgba(0, 255, 255, 0.2);
    border-color: var(--accent-cyan);
    box-shadow: var(--glow-cyan);
}

.tank-item .tank-icon {
    font-size: 1rem;
}

.tank-item .tank-info {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 8px;
}

.tank-item .tank-name {
    font-weight: 600;
    font-size: 0.8rem;
}

.tank-item .tank-level {
    font-size: 0.65rem;
    color: var(--text-muted);
    margin-left: auto;
}

.tank-item .tank-check {
    width: 16px;
    height: 16px;
    border: 1px solid var(--text-muted);
    border-radius: 3px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    font-size: 0.7rem;
}

.tank-item.selected .tank-check {
    background: var(--accent-cyan);
    border-color: var(--accent-cyan);
}

.tank-item.selected .tank-check::after {
    content: '✓';
    color: var(--bg-primary);
    font-weight: bold;
}

/* ============================================
   버튼
   ============================================ */

.btn-primary {
    width: 100%;
    padding: 16px 24px;
    font-family: var(--font-display);
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--bg-primary);
    background: linear-gradient(135deg, var(--accent-cyan), var(--accent-green));
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 8px 30px rgba(0, 255, 255, 0.4);
}

.btn-primary:active:not(:disabled) {
    transform: translateY(0);
}

.btn-primary:disabled {
    background: var(--text-muted);
    cursor: not-allowed;
    opacity: 0.5;
}

.btn-icon {
    font-size: 1.2rem;
}

/* ============================================
   사용법 패널
   ============================================ */

#instructions ul {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

#instructions li {
    padding-left: 20px;
    position: relative;
    color: var(--text-secondary);
    font-size: 0.9rem;
    line-height: 1.5;
}

#instructions li::before {
    content: '▸';
    position: absolute;
    left: 0;
    color: var(--accent-cyan);
}

#instructions code {
    background: rgba(0, 255, 255, 0.1);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Consolas', monospace;
    font-size: 0.85rem;
    color: var(--accent-cyan);
}

/* ============================================
   전투 정보 패널
   ============================================ */

#tank-stats {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.stat-item {
    display: flex;
    align-items: center;
    gap: 12px;
}

.stat-item .tank-color {
    width: 12px;
    height: 12px;
    border-radius: 50%;
}

.stat-item .stat-name {
    flex: 1;
    font-size: 0.9rem;
}

.stat-item .stat-bar {
    width: 100px;
    height: 8px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    overflow: hidden;
}

.stat-item .stat-fill {
    height: 100%;
    background: var(--accent-green);
    transition: width 0.3s ease;
}

/* ============================================
   디버그 섹션
   ============================================ */

#debug-section {
    grid-area: debug;
    width: 280px;
    background: var(--bg-panel);
    border-radius: 12px;
    padding: 16px;
    border: 1px solid rgba(255, 100, 100, 0.3);
    overflow-y: auto;
    max-height: calc(100vh - 40px);
}

#debug-section.hidden {
    display: none;
}

#debug-section h3 {
    font-family: var(--font-display);
    font-size: 0.9rem;
    color: var(--accent-red);
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid rgba(255, 100, 100, 0.3);
}

#debug-content {
    font-size: 0.75rem;
    font-family: 'Consolas', monospace;
    color: var(--text-secondary);
    line-height: 1.5;
}

.debug-tank {
    margin-bottom: 16px;
    padding: 10px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 6px;
    border-left: 3px solid var(--accent-cyan);
}

.debug-tank-name {
    font-weight: bold;
    color: var(--accent-cyan);
    margin-bottom: 6px;
}

.debug-row {
    display: flex;
    justify-content: space-between;
    padding: 2px 0;
}

.debug-label {
    color: var(--text-muted);
}

.debug-value {
    color: var(--text-primary);
}

/* 디버그 체크박스 */
#debug-toggle {
    padding: 12px 20px;
}

.debug-checkbox {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.debug-checkbox input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--accent-red);
    cursor: pointer;
}

/* 일시정지 버튼 */
.btn-pause {
    width: 100%;
    margin-top: 12px;
    padding: 10px 16px;
    font-family: var(--font-body);
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.btn-pause:hover:not(:disabled) {
    background: rgba(255, 200, 0, 0.2);
    border-color: var(--accent-yellow);
}

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

.btn-pause.paused {
    background: rgba(0, 255, 136, 0.2);
    border-color: var(--accent-green);
}

/* 컨트롤 그리드 (2열 레이아웃: 버튼 | 체크박스) */
.control-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-top: 12px;
}

.control-col {
    display: flex;
    flex-direction: column;
    gap: 8px;
    justify-content: center;
    /* Center content vertically */
}

.panel-divider {
    border: 0;
    height: 1px;
    background: rgba(255, 255, 255, 0.1);
    margin: 16px 0;
}

.btn-secondary-action {
    background: rgba(100, 100, 100, 0.2);
    border: 1px solid rgba(150, 150, 150, 0.3);
    color: var(--text-secondary);
}

.btn-secondary-action:hover {
    background: rgba(150, 150, 150, 0.3);
    color: var(--text-primary);
}

/* 컨트롤 버튼 (세로 배치용) */
.btn-control {
    width: 100%;
    padding: 8px 12px;
    font-family: var(--font-body);
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.btn-control:hover:not(:disabled) {
    background: rgba(255, 200, 0, 0.2);
    border-color: var(--accent-yellow);
}

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

.btn-control.paused {
    background: rgba(0, 255, 136, 0.2);
    border-color: var(--accent-green);
}

/* ============================================
   스크롤바 스타일링
   ============================================ */

::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-secondary);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: var(--text-muted);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--accent-cyan);
}

/* ============================================
   반응형 디자인
   ============================================ */

@media (max-width: 1024px) {
    #game-wrapper {
        grid-template-columns: 1fr;
        grid-template-areas:
            "header"
            "main"
            "sidebar";
    }

    #sidebar {
        flex-direction: row;
        flex-wrap: wrap;
    }

    .panel {
        flex: 1;
        min-width: 280px;
    }
}

@media (max-width: 600px) {
    #game-header h1 {
        font-size: 1.5rem;
    }

    .subtitle {
        font-size: 0.8rem;
        letter-spacing: 1px;
    }

    #game-wrapper {
        padding: 10px;
        gap: 10px;
    }
}

/* ============================================
   플랫폼 UI (로그인, 대시보드)
   ============================================ */
.platform-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    z-index: 9999;
    display: flex;
    justify-content: center;
    align-items: center;
}

.hidden,
.platform-overlay.hidden,
.modal-box.hidden,
.dashboard-box.hidden {
    display: none !important;
}

.modal-box {
    background: var(--bg-panel);
    padding: 2rem;
    border-radius: 10px;
    border: 1px solid var(--accent-cyan);
    box-shadow: var(--glow-cyan);
    width: 400px;
    text-align: center;
}

.modal-box h2 {
    color: var(--accent-cyan);
    margin-bottom: 1.5rem;
}

.modal-box .input-group {
    margin-bottom: 1rem;
    text-align: left;
}

.modal-box label {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.modal-box input {
    width: 100%;
    padding: 0.8rem;
    background: var(--bg-dark);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    border-radius: 4px;
    font-size: 1rem;
}

.modal-box button {
    margin-top: 1rem;
    width: 100%;
    padding: 0.8rem;
    cursor: pointer;
    font-weight: bold;
    border: none;
    border-radius: 4px;
}

.btn-primary {
    background: var(--accent-cyan);
    color: #000;
}

.btn-primary:hover {
    background: #00cccc;
}

.btn-secondary {
    background: transparent;
    color: var(--text-muted);
    border: 1px solid var(--border-color) !important;
    margin-top: 0.5rem;
}

.btn-secondary:hover {
    color: var(--text-primary);
    border-color: var(--text-primary) !important;
}

.error-msg {
    color: #ff3366;
    font-size: 0.9rem;
    margin-top: 1rem;
    min-height: 1.2em;
}

/* 대시보드 */
.dashboard-box {
    width: 95%;
    height: 95%;
    background: var(--bg-panel);
    border-radius: 10px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.5);
}

.dash-header {
    padding: 1rem 2rem;
    background: var(--bg-dark);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.dash-header h3 {
    color: var(--accent-cyan);
    margin: 0;
}

.user-info {
    display: flex;
    gap: 1rem;
    align-items: center;
    color: var(--text-muted);
}

.btn-sm {
    padding: 0.4rem 0.8rem;
    font-size: 0.8rem;
    background: var(--bg-danger);
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
}

.dash-content {
    flex: 1;
    display: flex;
    overflow: hidden;
    position: relative;
}

/* 메인 콘텐츠 영역 (스크롤 가능) */
#dashboard-main {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    height: 100%;
}

.sidebar {
    width: 250px;
    background: var(--bg-dark);
    border-right: 1px solid var(--border-color);
    padding: 1rem;
    display: flex;
    flex-direction: column;
}

.sidebar h4 {
    color: var(--text-muted);
    margin-bottom: 1rem;
    font-size: 0.9rem;
    text-transform: uppercase;
}

.sidebar ul {
    flex: 1;
    overflow-y: auto;
    list-style: none;
    margin-bottom: 1rem;
    padding: 0;
}

.sidebar li {
    padding: 0.8rem;
    cursor: pointer;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-muted);
    transition: all 0.2s;
    border-radius: 4px;
    margin-bottom: 4px;
}

.sidebar li:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
}

.sidebar li.active {
    background: var(--bg-primary);
    color: white;
    border-left: 3px solid var(--accent-cyan);
}

.sidebar li .version {
    font-size: 0.7rem;
    float: right;
    opacity: 0.7;
    border: 1px solid #555;
    padding: 1px 4px;
    border-radius: 3px;
}

.btn-full {
    width: 100%;
    padding: 0.8rem;
    background: var(--bg-primary);
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
}

.btn-full:hover {
    background: #4a5a7a;
}

.editor-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: #1e1e1e;
}

.editor-toolbar {
    padding: 0.8rem 1rem;
    background: var(--bg-dark);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.editor-toolbar input {
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-size: 1.2rem;
    font-weight: bold;
    outline: none;
    width: 300px;
}

.editor-toolbar input:focus {
    border-bottom: 1px solid var(--accent-cyan);
}

.actions {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

#save-status {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-right: 1rem;
}

.actions button {
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-weight: bold;
}

#btn-save-strat {
    background: var(--accent-cyan);
    color: black;
}

#btn-save-strat:disabled {
    background: #555;
    color: #888;
    cursor: not-allowed;
}

#btn-publish-strat {
    background: var(--bg-primary);
    color: white;
}

#btn-publish-strat.published {
    background: #00ff88;
    color: black;
}

#code-editor {
    flex: 1;
    background: #1e1e1e;
    color: #d4d4d4;
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 14px;
    border: none;
    resize: none;
    line-height: 1.6;
    outline: none;
}

/* 분할 레이아웃 & 레퍼런스 패널 */
.editor-main-split {
    flex: 1;
    display: flex;
    overflow: hidden;
    height: 100%;
}

.code-section {
    flex: 1 1 60%;
    min-width: 0;
    /* Allow shrinking below content size */
    display: flex;
    flex-direction: column;
}

#code-editor {
    width: 100%;
    height: 100%;
    border-radius: 0;
    /* 분할 화면이므로 라운드 제거 */
}

.reference-panel {
    flex: 1 1 40%;
    min-width: 0;
    /* Allow shrinking below content size */
    background: #18191a;
    border-left: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    color: #e4e6eb;
}

.reference-panel h4 {
    padding: 1rem;
    background: #242526;
    margin: 0;
    font-size: 0.9rem;
    color: var(--accent-cyan);
    border-bottom: 1px solid #3e4042;
}

.ref-content {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    font-size: 0.85rem;
}

.ref-content details {
    margin-bottom: 0.8rem;
    background: #242526;
    border-radius: 6px;
    padding: 0.5rem;
}

.ref-content summary {
    cursor: pointer;
    font-weight: bold;
    color: #b0b3b8;
}

.ref-content ul {
    margin: 0.5rem 0 0 1.2rem;
    padding: 0;
    list-style: disc;
}

.ref-content li {
    margin-bottom: 0.3rem;
    color: #e4e6eb;
}

.ref-content code {
    background: #3a3b3c;
    padding: 2px 4px;
    border-radius: 4px;
    color: #ffd700;
}

.tip-box {
    margin-top: 1rem;
    background: rgba(255, 215, 0, 0.1);
    border: 1px solid #ffd700;
    padding: 0.8rem;
    border-radius: 6px;
    color: #ffd700;
}

.tip-box pre {
    background: #000;
    padding: 0.5rem;
    border-radius: 4px;
    margin-top: 0.5rem;
    font-family: monospace;
    white-space: pre-wrap;
}