* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

body {
    background: linear-gradient(145deg, #1a1a2e 0%, #16213e 100%);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    font-family: 'Noto Sans KR', 'Malgun Gothic', sans-serif;
}

.game-container {
    width: 100%;
    max-width: 500px;
    height: 100vh;
    background: rgba(0, 0, 0, 0.3);
    overflow: hidden;
    position: relative;
}

@media (min-width: 501px) {
    .game-container {
        height: 700px;
        border-radius: 40px;
    }
}

.screen {
    position: absolute;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
    transition: opacity 0.3s;
    opacity: 0;
    visibility: hidden;
    overflow-y: auto;
}

.screen.active {
    opacity: 1;
    visibility: visible;
}

.background-layer {
    position: absolute;
    width: 100%;
    height: 100%;
    background-size: cover;
    background-position: center;
    z-index: -1;
}

/* ========== 메인 메뉴 ========== */
.main-menu {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    padding: 20px;
}

.game-title {
    text-align: center;
    color: gold;
    font-size: 1.6rem;
    margin-bottom: 10px;
    text-shadow: 2px 2px 4px black;
}

.game-sub {
    text-align: center;
    color: #aaa;
    font-size: 0.7rem;
    margin-bottom: 50px;
}

.menu-buttons {
    display: flex;
    flex-direction: column;
    gap: 15px;
    width: 80%;
}

.menu-btn {
    background: linear-gradient(45deg, #d4af37, #ff8c00);
    border: none;
    padding: 15px;
    font-size: 1.1rem;
    font-weight: bold;
    border-radius: 50px;
    cursor: pointer;
    transition: 0.1s;
    color: #1a1a2e;
}

.menu-btn:active {
    transform: scale(0.96);
}

/* ========== 대시보드 (공고문 스타일) ========== */
.dashboard-header {
    text-align: center;
    padding: 15px;
    background: rgba(210, 180, 140, 0.95);
    color: #8B4513;
    border-bottom: 3px solid #8B4513;
    position: relative;
}

.dashboard-header h1 {
    font-size: 1.2rem;
    font-family: 'Times New Roman', serif;
    letter-spacing: 2px;
}

.dashboard-header p {
    font-size: 0.6rem;
    color: #5a2d0c;
}

.dashboard-combo {
    font-size: 0.5rem;  /* 기존 0.7rem 또는 0.65rem에서 축소 */
    color: #c0392b;
    margin-top: 3px;
}

.dashboard-close-btn {
    position: absolute;
    top: 10px;
    right: 15px;
    background: #8B4513;
    color: white;
    border: none;
    padding: 5px 10px;
    border-radius: 20px;
    cursor: pointer;
    font-size: 0.7rem;
}

.dashboard-content {
    padding: 15px;
    background: rgba(245, 245, 220, 0.95);
    min-height: calc(100% - 80px);
    overflow-y: auto;
}

.generals-grid-dashboard {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 10px;
}

.dashboard-card {
    background: rgba(200, 180, 140, 0.5);
    border: 2px solid #8B4513;
    border-radius: 8px;
    text-align: center;
    padding: 8px 5px;
    transition: all 0.2s;
}

.dashboard-card.cleared {
    background: #2c2c3e;
    border-color: #8B0000;
}

.dashboard-card.cleared .dashboard-name {
    color: #ff6666;
    text-decoration: line-through;
}

.dashboard-card.current {
    background: #ffd700;
    border-color: #ff4500;
    box-shadow: 0 0 10px gold;
}

.dashboard-card img {
    width: 50px;
    height: 50px;
    border-radius: 8px;
    margin-bottom: 5px;
}

.dashboard-name {
    font-size: 0.6rem;
    font-weight: bold;
    color: #3d2b1f;
}

.dashboard-status {
    font-size: 0.5rem;
    color: #5a2d0c;
    margin-top: 3px;
}

.dashboard-card.cleared .dashboard-status {
    color: #ff8888;
}

/* ========== 장수 선택 ========== */
.select-header {
    text-align: center;
    padding: 15px;
    background: rgba(0, 0, 0, 0.8);
    color: gold;
    border-bottom: 1px solid gold;
}

.select-header h1 {
    font-size: 1.2rem;
}

.select-header p {
    font-size: 0.6rem;
    color: #aaa;
}

.character-selector {
    padding: 15px;
}

.select-area {
    background: rgba(0, 0, 0, 0.7);
    border-radius: 20px;
    padding: 15px;
    border: 1px solid gold;
}

.select-area h2 {
    color: #ffd966;
    font-size: 0.9rem;
    margin-bottom: 10px;
    border-left: 3px solid gold;
    padding-left: 10px;
}

.char-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    max-height: 300px;
    overflow-y: auto;
    margin-bottom: 15px;
}

.char-card {
    background: #2c2c3e;
    border-radius: 12px;
    padding: 8px;
    text-align: center;
    cursor: pointer;
    border: 2px solid transparent;
    width: 85px;
    transition: 0.1s;
}

.char-card.selected {
    border-color: gold;
    background: #3d3d5e;
    box-shadow: 0 0 10px gold;
}

.char-card img {
    width: 55px;
    height: 55px;
    border-radius: 10px;
}

.char-card .char-name {
    font-weight: bold;
    color: white;
    font-size: 0.7rem;
    margin-top: 3px;
}

.char-card .char-stats {
    font-size: 0.55rem;
    color: #aaa;
}

.char-card .char-combo {
    font-size: 0.55rem;
    color: gold;
    margin-top: 3px;
}

.weapon-select, .horse-select {
    margin-top: 10px;
    display: flex;
    gap: 8px;
    align-items: center;
    color: white;
    font-size: 0.7rem;
}

select {
    background: #1e1e2a;
    color: white;
    padding: 6px;
    border-radius: 20px;
    border: 1px solid gold;
    flex: 1;
}

.confirm-btn {
    background: linear-gradient(45deg, #27ae60, #2ecc71);
    border: none;
    padding: 12px;
    font-size: 1rem;
    font-weight: bold;
    border-radius: 30px;
    cursor: pointer;
    width: 100%;
    margin-top: 15px;
}

/* ========== 세이브 목록 ========== */
.save-list-container {
    padding: 15px;
    height: calc(100% - 120px);
    overflow-y: auto;
}

.save-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.save-item {
    background: #2c2c3e;
    border-radius: 15px;
    padding: 12px;
    border: 1px solid gold;
}

.save-info {
    margin-bottom: 8px;
}

.save-name {
    font-weight: bold;
    color: gold;
    font-size: 0.9rem;
}

.save-detail {
    font-size: 0.65rem;
    color: #aaa;
}

.save-buttons {
    display: flex;
    gap: 10px;
}

.save-load-btn, .save-delete-btn {
    background: #3498db;
    border: none;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.7rem;
    cursor: pointer;
    color: white;
}

.save-delete-btn {
    background: #c0392b;
}

.save-input-area {
    padding: 15px;
    display: flex;
    gap: 10px;
    border-top: 1px solid gold;
}

.save-name-input {
    flex: 1;
    background: #1e1e2a;
    border: 1px solid gold;
    border-radius: 25px;
    padding: 10px;
    color: white;
    font-size: 0.8rem;
}

.save-btn {
    background: #27ae60;
    border: none;
    padding: 10px 15px;
    border-radius: 25px;
    font-weight: bold;
    cursor: pointer;
}

.back-btn {
    background: #555;
    border: none;
    padding: 10px;
    margin: 10px 15px;
    border-radius: 25px;
    font-weight: bold;
    cursor: pointer;
    width: calc(100% - 30px);
}

/* ========== 게임 화면 ========== */
.game-header {
    position: absolute;
    top: 5px;
    left: 0;
    right: 0;
    display: flex;
    justify-content: space-between;
    padding: 5px 10px;
    font-size: 0.6rem;
    color: gold;
    background: rgba(0,0,0,0.5);
    z-index: 15;
}

/* 게임 화면 VS 표시줄 */
.battle-display {
    position: absolute;
    top: 30px;
    left: 0;
    right: 0;
    text-align: center;
    z-index: 12;
    background: rgba(0,0,0,0.5);
    padding: 5px;
}

.vs-container {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 15px;
}

.vs-player, .vs-enemy {
    text-align: center;
}

.vs-player img, .vs-enemy img {
    width: 45px;
    height: 45px;
    border-radius: 10px;
    border: 1px solid gold;
}

.vs-name {
    font-size: 0.6rem;
    color: #ffd966;
    margin-top: 2px;
}

.vs-text {
    font-size: 1rem;
    font-weight: bold;
    color: crimson;
}

.stats-container {
    display: flex;
    gap: 8px;
    padding: 8px;
    background: rgba(0, 0, 0, 0.7);
    position: absolute;
    top: 80px;
    left: 0;
    right: 0;
    z-index: 10;
}

.stat-bar {
    flex: 1;
    background: rgba(0, 0, 0, 0.6);
    border-radius: 12px;
    padding: 5px 8px;
    border: 1px solid rgba(255, 215, 0, 0.3);
}

.char-name {
    font-weight: bold;
    font-size: 0.75rem;
    text-align: center;
    color: #ffd966;
}

.stat-row {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 0.55rem;
    margin: 3px 0;
}

.bar-bg {
    flex: 1;
    background: #2c2c3e;
    height: 6px;
    border-radius: 10px;
    overflow: hidden;
}

.bar-fill {
    height: 100%;
    transition: width 0.2s;
}

.player-stats .bar-fill { background: #e74c3c; }
.enemy-stats .bar-fill { background: #3498db; }

.small-stats {
    display: flex;
    justify-content: space-around;
    gap: 6px;
    font-size: 0.5rem;
    margin-top: 4px;
    color: #ccc;
}

.combo-status-area {
    position: absolute;
    top: 145px;
    left: 10px;
    right: 10px;
    text-align: center;
    z-index: 15;
}

.combo-status {
    background: rgba(0,0,0,0.7);
    padding: 4px 8px;
    border-radius: 20px;
    font-size: 0.6rem;
    color: gold;
    display: inline-block;
}

.combo-status.active {
    background: linear-gradient(45deg, #ff6600, #ffcc00);
    color: #1a1a2e;
    animation: pulse 0.5s infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

.combo-progress-bar {
    height: 3px;
    background: #333;
    border-radius: 2px;
    margin-top: 5px;
    overflow: hidden;
}

.combo-progress-fill {
    width: 0%;
    height: 100%;
    background: linear-gradient(90deg, #ff6600, #ffcc00);
    transition: width 0.1s;
}

.combo-notice {
    font-size: 0.55rem;
    color: #aaa;
    margin-top: 3px;
}

.action-log {
    position: absolute;
    top: 180px;
    left: 8px;
    right: 8px;
    background: rgba(0,0,0,0.7);
    border-radius: 12px;
    padding: 6px;
    z-index: 10;
}

.log-messages {
    height: 55px;
    overflow-y: auto;
    font-size: 0.6rem;
    color: #ffd966;
}

.arena {
    position: absolute;
    bottom: 280px;
    left: 0;
    right: 0;
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    padding: 0 20px;
}

.character-area {
    width: 45%;
    text-align: center;
    transition: transform 0.2s ease;
}

.character-sprite img {
    width: 100px;
    height: 100px;
    object-fit: contain;
    transition: all 0.1s;
}

.enemy-sprite img {
    transform: scaleX(-1);
}

.horse-icon {
    font-size: 1.2rem;
    margin-top: -8px;
}

/* 화살표 컨테이너 */
.arrow-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 15;
    overflow: hidden;
}

.arrow {
    position: absolute;
    width: 30px;
    height: 30px;
    background: url('images/arrow.png') no-repeat center;
    background-size: contain;
    animation: arrowRain 0.8s ease-out forwards;
}

@keyframes arrowRain {
    0% { opacity: 1; transform: translate(0, 0) rotate(130deg); }
    100% { opacity: 0; transform: translate(var(--tx, 100px), var(--ty, 200px)) rotate(180deg); }
}

/* 번개 컨테이너 */
.thunder-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 100;
    display: flex;
    justify-content: center;
    align-items: center;
}

.thunder-bolt {
    position: absolute;
    width: 200px;
    height: 200px;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    animation: thunderBoltAnim 0.5s ease-out forwards;
}

@keyframes thunderBoltAnim {
    0% { opacity: 0; transform: translate(-50%, -50%) scale(0.8); }
    20% { opacity: 1; transform: translate(-50%, -50%) scale(1.2); }
    40% { opacity: 0.8; transform: translate(-50%, -50%) scale(1); }
    100% { opacity: 0; transform: translate(-50%, -50%) scale(1.5); }
}

.combo-slots {
    position: absolute;
    bottom: 220px;
    left: 20px;
    right: 20px;
    display: flex;
    gap: 8px;
    justify-content: center;
    z-index: 20;
}

.combo-slot {
    width: 50px;
    height: 50px;
    border: 2px dashed gold;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1rem;
    font-weight: bold;
    background: rgba(0,0,0,0.7);
}

.combo-slot.filled {
    border: 2px solid gold;
    background: #3d3d5e;
    box-shadow: 0 0 5px gold;
}

.action-buttons {
    position: absolute;
    bottom: 100px;
    left: 10px;
    right: 10px;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
    z-index: 20;
}

.action-btn {
    background: #2c2c3e;
    border: 1px solid gold;
    color: white;
    padding: 10px 4px;
    border-radius: 25px;
    font-size: 0.7rem;
    font-weight: bold;
    cursor: pointer;
    transition: 0.05s linear;
}

.action-btn:active {
    transform: scale(0.94);
    background: linear-gradient(135deg, #d4af37, #ff8c00);
    color: #1a1a2e;
}

.touch-guide {
    position: absolute;
    bottom: 15px;
    left: 10px;
    right: 10px;
    text-align: center;
    font-size: 0.5rem;
    color: rgba(255,255,255,0.4);
    z-index: 20;
}

/* ========== 결과 화면 ========== */
.result-box {
    background: rgba(0,0,0,0.9);
    margin: 10% 20px;
    padding: 20px;
    border-radius: 30px;
    text-align: center;
    border: 2px solid gold;
}

.result-header h2 {
    font-size: 1.6rem;
    margin-bottom: 15px;
    color: gold;
}

.result-battle-display {
    margin: 15px 0;
}

.result-vs-container {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 20px;
    padding: 15px;
    background: rgba(0,0,0,0.5);
    border-radius: 20px;
}

.result-vs-player, .result-vs-enemy {
    text-align: center;
}

.result-vs-player img, .result-vs-enemy img {
    width: 80px;
    height: 80px;
    border-radius: 15px;
    border: 2px solid gold;
}

.result-vs-name {
    font-size: 0.8rem;
    color: gold;
    margin-top: 5px;
    font-weight: bold;
}

.result-vs-text {
    font-size: 1.8rem;
    font-weight: bold;
    color: crimson;
    text-shadow: 2px 2px 4px black;
}

.result-box p {
    color: #ddd;
    margin-bottom: 20px;
}

.result-buttons {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 12px;
    margin-top: 20px;
}

.result-btn {
    padding: 10px 20px;
    border: none;
    border-radius: 30px;
    font-weight: bold;
    font-size: 0.85rem;
    cursor: pointer;
    transition: 0.1s;
    min-width: 90px;
}

.result-btn:active {
    transform: scale(0.96);
}

.save-result {
    background: #3498db;
    color: white;
}

.rematch-result {
    background: #e67e22;
    color: white;
}

.next-result {
    background: #27ae60;
    color: white;
}

.home-result {
    background: #e74c3c;
    color: white;
}

/* 애니메이션 */
.special-scale {
    animation: specialScale 0.3s ease-in-out forwards;
}
@keyframes specialScale {
    0% { transform: scale(1); }
    50% { transform: scale(1.4); filter: drop-shadow(0 0 10px gold); }
    100% { transform: scale(1); }
}

.screen-flash {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: white;
    pointer-events: none;
    z-index: 200;
    animation: flashAnim 0.3s ease-out forwards;
}
@keyframes flashAnim {
    0% { opacity: 0.8; }
    100% { opacity: 0; }
}

.special-effect-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 100;
}

.special-slice {
    position: absolute;
    width: 40px;
    height: 40px;
    background-size: contain;
    animation: sliceFly 0.8s ease-out forwards;
}
@keyframes sliceFly {
    0% { opacity: 1; transform: translate(0,0) scale(1); }
    100% { opacity: 0; transform: translate(var(--tx,200px), var(--ty,-200px)) scale(0.5); }
}

/* 반응형 */
@media (min-width: 400px) {
    .action-buttons { grid-template-columns: repeat(4, 1fr); }
}

@media (max-width: 450px) {
    .generals-grid-dashboard {
        gap: 6px;
    }
    .dashboard-card img {
        width: 40px;
        height: 40px;
    }
    .dashboard-name {
        font-size: 0.5rem;
    }
    .result-vs-player img, .result-vs-enemy img {
        width: 60px;
        height: 60px;
    }
    .result-vs-text {
        font-size: 1.2rem;
    }
    .result-btn {
        padding: 8px 12px;
        font-size: 0.7rem;
        min-width: 70px;
    }
}