/* ============================================================
   AirFortress Mobile v18 - CSS (웹뷰 터치 수정)
   ============================================================ */

* {
    box-sizing: border-box;
    -webkit-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
}

body {
    text-align: center;
    font-family: 'Segoe UI', sans-serif;
    margin: 0;
    background: #1a1a2e;
    display: flex;
    flex-direction: column;
    align-items: center;
    min-height: 100vh;
    overflow: hidden;
    touch-action: manipulation;
}

.main-title {
    color: #fff;
    margin: 10px 0 5px;
    font-size: 1.4rem;
}

/* ====== 메시지 ====== */
#status-message {
    position: fixed;
    top: 80px;
    left: 50%;
    transform: translateX(-50%);
    color: #fff;
    font-size: 20px;
    font-weight: bold;
    text-shadow: 0 0 20px rgba(0,0,0,0.8);
    z-index: 100;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s;
}
#status-message.show { opacity: 1; }

/* ====== 게임 래퍼 ====== */
#game-wrapper {
    width: 100%;
    max-width: 800px;
    margin: 0 auto;
    position: relative;
}

canvas {
    border: 2px solid #444;
    display: block;
    width: 100%;
    height: auto;
    aspect-ratio: 800 / 500;
    background: #0a0a1a;
    touch-action: none;
}

#windDisplay {
    font-size: 18px;
    font-weight: bold;
    margin: 5px;
    color: #fff;
}

/* ====== 컨트롤 ====== */
.controls {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    grid-template-rows: repeat(2, 1fr);
    gap: 10px;
    width: 100%;
    max-width: 800px;
    padding: 10px 10px 5px 10px;
    box-sizing: border-box;
    margin-top: 10px;
}

.controls button {
    font-size: 24px;
    padding: 15px 10px;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    background-color: #007BFF;
    color: white;
    transition: background-color 0.1s ease;
    touch-action: none;
    -webkit-touch-callout: none;
}
.controls button:active { background-color: #0056b3; }
.controls button.disabled {
    background-color: #6c757d;
    cursor: not-allowed;
    opacity: 0.7;
}

#useSpecialBtn {
    grid-column: 6 / 7;
    grid-row: 1 / 3;
    font-size: 28px;
    background-color: #dc3545;
}
#useSpecialBtn.disabled { background-color: #6c757d; }

#moveLeftBtn { grid-column: 1 / 2; grid-row: 1 / 3; font-size: 28px; }
#moveRightBtn { grid-column: 2 / 3; grid-row: 1 / 3; font-size: 28px; }
#leftBtn { grid-column: 3 / 4; grid-row: 1 / 2; }
#rightBtn { grid-column: 3 / 4; grid-row: 2 / 3; }
#upBtn { grid-column: 4 / 5; grid-row: 1 / 2; }
#downBtn { grid-column: 4 / 5; grid-row: 2 / 3; }
#fireBtn {
    grid-column: 5 / 6;
    grid-row: 1 / 3;
    font-size: 28px;
    background-color: #28a745;
}

/* ====== 특수 능력 바 ====== */
#special-ability-bar {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 5px;
    background-color: rgba(0, 0, 0, 0.3);
    padding: 5px;
    border-radius: 10px;
    width: 100%;
    max-width: 800px;
    box-sizing: border-box;
    margin-bottom: 10px;
}

.special-icon {
    width: 100%;
    height: auto;
    aspect-ratio: 1 / 1;
    border: 2px solid #555;
    border-radius: 5px;
    transition: all 0.2s;
    box-sizing: border-box;
    cursor: pointer;
    background: #111a2a;
    object-fit: contain;
    padding: 4px;
    touch-action: none;
}
.special-icon.unavailable {
    filter: grayscale(100%);
    opacity: 0.3;
    pointer-events: none;
}
.special-icon.selected {
    border-color: #ffcc00;
    box-shadow: 0 0 16px rgba(255,204,0,0.3);
}
.special-icon.armed {
    border-color: #ff4444;
    box-shadow: 0 0 16px rgba(255,68,68,0.3);
}

/* ====== 탄 선택 바 ====== */
.ammo-game-bar {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    justify-content: center;
    margin: 5px 0;
    padding: 5px;
    background: rgba(0,0,0,0.3);
    border-radius: 8px;
}

.ammo-btn {
    padding: 4px 10px;
    font-size: 12px;
    border-radius: 6px;
    border: 2px solid #334;
    background: #111a2a;
    color: #8899bb;
    cursor: pointer;
    transition: all 0.2s;
    touch-action: none;
}
.ammo-btn:hover { border-color: #556; }
.ammo-btn.selected { border-color: #007bff; background: #007bff; color: #fff; }
.ammo-btn.primary { border-color: #ffcc00; background: #ffcc00; color: #222; }
.ammo-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.ammo-btn .ammo-icon { font-size: 18px; display: block; }
.ammo-btn .ammo-name { font-size: 10px; }
.ammo-btn .ammo-count { font-size: 9px; color: #667; }
.ammo-btn.primary .ammo-count { color: #333; }

/* ====== 메뉴 ====== */
#menu-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 50px 20px;
    width: 100%;
    box-sizing: border-box;
}
#menu {
    background: rgba(255,255,255,0.95);
    padding: 20px;
    border-radius: 15px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.1);
    width: 90%;
    max-width: 400px;
}
#menu h2 { color: #333; }

#tank-selection-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 50px 20px;
    width: 100%;
    box-sizing: border-box;
}
#tank-selection-ui {
    background: rgba(255,255,255,0.95);
    padding: 20px;
    border-radius: 15px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.1);
    width: 90%;
    max-width: 500px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}
.hidden { display: none !important; }

.player-selection {
    border: 1px solid #ccc;
    padding: 15px;
    border-radius: 10px;
}
.player-selection h3 { margin-top: 0; color: #333; }
.player-selection select {
    font-size: 16px;
    padding: 8px;
    width: 100%;
    margin-bottom: 10px;
}

.selection-details {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-top: 10px;
}
.tank-preview-img {
    width: 60px;
    height: 60px;
    border: 1px solid #ddd;
    border-radius: 5px;
    object-fit: contain;
}

.stats-display { flex-grow: 1; }
.stat-item {
    display: flex;
    align-items: center;
    margin-bottom: 5px;
    font-size: 13px;
}
.stat-name {
    width: 40px;
    text-align: right;
    margin-right: 5px;
    font-weight: bold;
    color: #333;
}
.stat-bar-container {
    flex-grow: 1;
    height: 14px;
    background-color: #e9ecef;
    border-radius: 7px;
    overflow: hidden;
    border: 1px solid #ccc;
}
.stat-bar {
    height: 100%;
    background-color: #007bff;
    border-radius: 7px;
    transition: width 0.3s ease-in-out;
}

/* ====== 탄 선택 (탱크 선택 화면) ====== */
#ammo-select-container {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    justify-content: center;
    margin: 10px 0;
}
#ammo-select-container .ammo-btn {
    padding: 6px 10px;
    font-size: 12px;
    border-radius: 6px;
    border: 2px solid #ccc;
    cursor: pointer;
    background: #f0f0f0;
    transition: all 0.2s;
    min-width: 50px;
    color: #333;
    touch-action: none;
}
#ammo-select-container .ammo-btn.selected {
    border-color: #007bff;
    background: #007bff;
    color: white;
}
#ammo-select-container .ammo-btn.primary {
    border-color: #ffcc00;
    background: #ffcc00;
    color: #333;
}
#ammo-select-container .ammo-btn .ammo-icon { font-size: 20px; display: block; }
#ammo-select-container .ammo-btn .ammo-name { font-size: 10px; color: #333; }

.menu-btn {
    font-size: 18px;
    padding: 12px 30px;
    margin: 8px;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    background-color: #007BFF;
    color: white;
    transition: background-color 0.2s;
    touch-action: none;
}
.menu-btn:hover { background-color: #0056b3; }

/* ====== 게임 오버 ====== */
.game-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
}
.game-overlay-text {
    font-size: 48px;
    font-weight: bold;
    text-shadow: 0 0 20px rgba(0,0,0,0.8);
}

/* ====== 반응형 ====== */
@media (max-width: 500px) {
    .controls button { font-size: 18px; padding: 10px 6px; }
    .ammo-btn { font-size: 10px; padding: 3px 6px; }
    .special-icon { padding: 2px; }
    .main-title { font-size: 1.1rem; }
}