/* ========================================
   Grid Savaş Oyunu — Styles
   ======================================== */

/* --- Google Font --- */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;600;700;900&display=swap');

/* --- Reset & Base --- */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    display: flex;
    height: 100vh;
    height: 100dvh;
    background-color: #111827;
    color: white;
    font-family: 'Inter', sans-serif;
    overflow: hidden;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

/* --- Utility Classes --- */
.text-center { text-align: center; }
.font-semibold { font-weight: 600; }
.text-blue-300 { color: #93c5fd; }
.text-blue-400, .text-blue-500 { color: #60a5fa; }
.text-red-300 { color: #fca5a5; }
.text-red-400, .text-red-500 { color: #f87171; }
.text-green-400 { color: #4ade80; }
.text-yellow-400 { color: #facc15; }
.text-gray-400 { color: #9ca3af; }

/* --- Start Menu --- */
#start-menu {
    position: absolute;
    inset: 0;
    background-color: rgba(17, 24, 39, 0.95);
    z-index: 50;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(5px);
    padding: 20px;
}

.start-title {
    font-size: 3rem;
    font-weight: 800;
    margin-bottom: 0.5rem;
    background: linear-gradient(to right, #60a5fa, #ef4444);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-align: center;
}

.start-subtitle {
    color: #9ca3af;
    margin-bottom: 2rem;
    max-width: 28rem;
    text-align: center;
    font-size: 0.95rem;
    line-height: 1.5;
}

.start-form {
    background-color: #1f2937;
    padding: 2rem;
    border-radius: 1rem;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    width: 500px;
    max-width: 95vw;
}

/* --- Tabs --- */
.tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
    width: 500px;
    max-width: 95vw;
}

.tab-btn {
    flex: 1;
    background: rgba(31, 41, 55, 0.7);
    color: #9ca3af;
    border: none;
    padding: 0.75rem;
    border-radius: 0.75rem 0.75rem 0 0;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    font-family: 'Inter', sans-serif;
}

.tab-btn.active {
    background: #1f2937;
    color: white;
    box-shadow: 0 -4px 6px -1px rgba(0, 0, 0, 0.1);
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* --- Dynamic Player List (Local Mode & Lobby) --- */
.players-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.dynamic-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    max-height: 250px;
    overflow-y: auto;
    padding-right: 0.5rem;
}

.player-row, .lobby-player-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    background: #374151;
    padding: 0.5rem 0.75rem;
    border-radius: 0.5rem;
    border: 1px solid #4b5563;
}

.player-row input[type="text"] {
    flex: 1;
    background: transparent;
    border: none;
    color: white;
    font-size: 0.95rem;
    font-weight: 600;
    outline: none;
}

.player-row select {
    background: #1f2937;
    color: white;
    border: 1px solid #4b5563;
    padding: 0.25rem 0.5rem;
    border-radius: 0.25rem;
    outline: none;
}

.remove-btn, .lobby-kick-btn {
    background: rgba(239, 68, 68, 0.2);
    color: #ef4444;
    border: none;
    border-radius: 0.25rem;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s;
}

.remove-btn:hover, .lobby-kick-btn:hover {
    background: rgba(239, 68, 68, 0.4);
}

.lobby-player-icon { font-size: 1.2rem; }
.lobby-player-color { width: 16px; height: 16px; border-radius: 4px; }
.lobby-player-name { flex: 1; font-weight: 600; }

.add-btn {
    background: rgba(55, 65, 81, 0.8);
    color: #d1d5db;
    border: 1px solid #4b5563;
    padding: 0.4rem 0.75rem;
    border-radius: 0.5rem;
    cursor: pointer;
    font-size: 0.8rem;
    transition: all 0.2s;
}
.add-btn:hover { background: #4b5563; color: white; }
.player-add-btns { display: flex; gap: 0.5rem; }

/* --- Forms --- */
.form-group {
    flex: 1;
    margin-bottom: 1rem;
}

.form-label {
    display: block;
    font-weight: 600;
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
}

.form-label.gray { color: #d1d5db; }

.form-input {
    width: 100%;
    background-color: #374151;
    color: white;
    padding: 0.75rem;
    border-radius: 0.5rem;
    border: 1px solid #4b5563;
    outline: none;
    font-family: 'Inter', sans-serif;
    font-size: 0.95rem;
    transition: border-color 0.2s;
}

.form-input:focus { border-color: #60a5fa; }
.form-input.focus-white:focus { border-color: white; }

.start-btn {
    width: 100%;
    background: linear-gradient(to right, #2563eb, #3b82f6);
    color: white;
    font-weight: 700;
    padding: 1rem;
    border-radius: 0.75rem;
    border: none;
    cursor: pointer;
    font-size: 1.1rem;
    box-shadow: 0 10px 15px -3px rgba(37, 99, 235, 0.3);
    transition: all 0.2s;
    font-family: 'Inter', sans-serif;
}

.start-btn:hover {
    background: linear-gradient(to right, #3b82f6, #60a5fa);
    transform: scale(1.02);
}

.start-btn:active { transform: scale(0.98); }
.start-btn.secondary { background: #4b5563; box-shadow: none; }
.start-btn.secondary:hover { background: #6b7280; }

/* --- Game Container --- */
#game-container {
    display: flex;
    flex-direction: row;
    width: 100%;
    height: 100%;
    padding: 20px;
    gap: 20px;
    box-sizing: border-box;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.5s;
}

#game-container.active {
    opacity: 1;
    pointer-events: auto;
}

/* --- Canvas Container --- */
#canvas-container {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: #1f2937;
    border-radius: 12px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    overflow: hidden;
    position: relative;
}

canvas {
    background-color: #374151;
    cursor: crosshair;
    box-shadow: 0 0 20px rgba(0,0,0,0.5);
    image-rendering: pixelated;
    touch-action: none;
}

/* --- Side Menu (Desktop) --- */
#side-menu {
    width: 320px;
    background-color: #1f2937;
    border-radius: 12px;
    padding: 24px;
    display: flex;
    flex-direction: column;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    overflow-y: auto;
}

.panel-section {
    margin-bottom: 24px;
    padding-bottom: 24px;
    border-bottom: 1px solid #374151;
}

.panel-section:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.panel-section.no-border { border-bottom: none; }

.section-title {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 15px;
    color: #f3f4f6;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    text-align: center;
}

/* --- Stat Rows (Dynamic Scoreboard) --- */
#scoreboard-container {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.stat-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 1rem;
    background: #374151;
    padding: 10px 12px;
    border-radius: 8px;
    transition: all 0.3s;
    border: 2px solid transparent;
    opacity: 0.6;
}

.stat-row.eliminated {
    opacity: 0.3;
    text-decoration: line-through;
    filter: grayscale(100%);
}

.stat-row.active-turn {
    opacity: 1;
    transform: scale(1.02);
    box-shadow: 0 0 15px rgba(255, 255, 255, 0.1);
}

.stat-row .player-info {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.color-box {
    width: 16px;
    height: 16px;
    border-radius: 4px;
    display: inline-block;
    flex-shrink: 0;
}

.player-name-label {
    max-width: 140px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.score-value {
    font-weight: 700;
    font-size: 1.3rem;
}

/* --- Selected Area Info --- */
.selected-area-info {
    padding: 0.75rem;
    background: #111827;
    border-radius: 0.5rem;
    border: 1px solid #374151;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.selected-area-info .label { font-size: 0.85rem; color: #9ca3af; }
.selected-area-info .value { font-weight: 700; font-size: 1.125rem; }

/* --- Turn Badge --- */
.turn-badge {
    background-color: #fbbf24;
    color: #78350f;
    font-size: 0.75rem;
    padding: 4px 10px;
    border-radius: 12px;
    font-weight: 700;
    display: inline-block;
    animation: bounce-soft 1s infinite;
}

@keyframes bounce-soft {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-3px); }
}

/* --- Action Panel --- */
#action-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
}

.dice-rules {
    font-size: 0.75rem;
    color: #9ca3af;
    margin-bottom: 0.5rem;
    background: #111827;
    padding: 0.5rem;
    border-radius: 0.375rem;
    width: 100%;
}

#dice-result {
    font-size: 5rem;
    font-weight: bold;
    margin: 15px 0;
    color: #fbbf24;
    text-shadow: 0 0 20px rgba(251, 191, 36, 0.4);
    height: 100px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.dice-animation { animation: roll 0.4s infinite ease-in-out alternate; }
@keyframes roll {
    0% { transform: rotate(-15deg) scale(0.9); }
    100% { transform: rotate(15deg) scale(1.1); }
}

/* --- Buttons --- */
.btn {
    background-color: #2563eb;
    color: white;
    font-weight: bold;
    padding: 14px 24px;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
    width: 100%;
    font-size: 1.1rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-family: 'Inter', sans-serif;
    min-height: 48px;
}
.btn:hover:not(:disabled) { background-color: #1d4ed8; transform: translateY(-2px); box-shadow: 0 4px 12px rgba(37, 99, 235, 0.4); }
.btn:active:not(:disabled) { transform: translateY(0); }
.btn:disabled { background-color: #4b5563; cursor: not-allowed; opacity: 0.5; transform: none; box-shadow: none; }
.btn.secondary { background-color: #374151; padding: 12px 24px; font-size: 0.875rem; }
.btn.secondary:hover:not(:disabled) { background-color: #4b5563; box-shadow: 0 4px 12px rgba(75, 85, 99, 0.4); }
.btn-pulse { animation: pulse-glow 1.5s infinite; }
@keyframes pulse-glow {
    0%, 100% { box-shadow: 0 0 0 0 rgba(37, 99, 235, 0.5); }
    50% { box-shadow: 0 0 0 8px rgba(37, 99, 235, 0); }
}

#status-message {
    margin-top: 20px;
    min-height: 48px;
    font-size: 0.95rem;
    color: #9ca3af;
    line-height: 1.5;
}

/* ========================================
   Mobile HUD (Overlay)
   ======================================== */
#mobile-hud {
    display: none;
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 20;
    flex-direction: column;
    justify-content: space-between;
}

#mobile-hud > * { pointer-events: auto; }

.mobile-top-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    background: rgba(17, 24, 39, 0.85);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid rgba(55, 65, 81, 0.5);
    gap: 8px;
    overflow: hidden;
}

.mobile-player-chip {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    border-radius: 8px;
    background: rgba(55, 65, 81, 0.6);
    border: 2px solid transparent;
    font-size: 0.8rem;
    font-weight: 600;
    opacity: 0.5;
    transition: all 0.3s;
    white-space: nowrap;
    flex-shrink: 0;
}
.mobile-player-chip.active { opacity: 1; transform: scale(1.05); }
.mobile-player-chip.eliminated { opacity: 0.2; text-decoration: line-through; filter: grayscale(100%); }

.mobile-player-chip .chip-color { width: 10px; height: 10px; border-radius: 3px; }
.mobile-player-chip .chip-name { font-size: 0.7rem; max-width: 60px; overflow: hidden; text-overflow: ellipsis; }
.mobile-player-chip .chip-score { font-weight: 700; font-size: 0.9rem; }

.mobile-turn-badge { font-size: 0.65rem; padding: 3px 8px; border-radius: 10px; font-weight: 700; white-space: nowrap; }

.mobile-menu-btn {
    background: rgba(55, 65, 81, 0.6); border: 1px solid #4b5563; color: #9ca3af;
    width: 36px; height: 36px; border-radius: 8px; display: flex; align-items: center; justify-content: center;
}

.mobile-selection-badge {
    position: absolute; right: 12px; bottom: 80px; background: rgba(17, 24, 39, 0.9);
    backdrop-filter: blur(8px); border: 1px solid #374151; border-radius: 10px;
    padding: 6px 12px; display: none; align-items: center; gap: 6px; font-size: 0.8rem;
}
.mobile-selection-badge.visible { display: flex; }

.mobile-bottom-bar {
    display: flex; align-items: center; gap: 10px; padding: 10px 12px;
    background: rgba(17, 24, 39, 0.88); backdrop-filter: blur(12px); border-top: 1px solid rgba(55, 65, 81, 0.5);
}
.mobile-dice { font-size: 2rem; width: 48px; text-align: center; }
.mobile-attack-btn { background: #2563eb; color: white; padding: 10px 16px; border-radius: 8px; border: none; font-weight: 700; }
.mobile-attack-btn:disabled { background: #4b5563; opacity: 0.5; }
.mobile-status { flex: 1; font-size: 0.75rem; color: #9ca3af; line-height: 1.3; }

/* --- Mobile Responsive --- */
@media (max-width: 768px) {
    #start-menu { padding: 16px; }
    .start-title { font-size: 2rem; }
    .start-form { padding: 1.25rem; width: 100%; max-width: 90vw; }
    .tabs { width: 100%; max-width: 90vw; }
    #side-menu { display: none !important; }
    #mobile-hud { display: flex; }
    #game-container { padding: 0; gap: 0; }
    #canvas-container { border-radius: 0; box-shadow: none; }
}
