* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}

html, body {
    height: 100%;
    overflow: hidden;
    background: #0f1419;
    color: #fff;
    font-family: 'Inter', system-ui, sans-serif;
    touch-action: none;
}

#app {
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
    width: 100%;
    margin: 0 auto;
}

#scoreboard {
    display: grid;
    grid-template-columns: 1fr 1.4fr 1fr;
    align-items: center;
    padding: 12px 16px;
    background: linear-gradient(180deg, #1a2530 0%, #131b24 100%);
    border-bottom: 2px solid #233140;
    box-shadow: 0 2px 8px rgba(0,0,0,0.4);
}

.team {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.team-name {
    font-size: 12px;
    letter-spacing: 1.5px;
    font-weight: 600;
    opacity: 0.7;
}

.score {
    font-family: 'Bebas Neue', sans-serif;
    font-size: 48px;
    line-height: 1;
    font-weight: 400;
}

.team-red .score, .team-red .team-name { color: #ff5252; }
.team-blue .score, .team-blue .team-name { color: #448aff; }

.match-info {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.turn-indicator {
    font-size: 13px;
    font-weight: 800;
    letter-spacing: 1px;
    padding: 6px 14px;
    border-radius: 20px;
    background: rgba(255, 82, 82, 0.15);
    color: #ff5252;
    transition: all 0.3s;
}

.turn-indicator.blue {
    background: rgba(68, 138, 255, 0.15);
    color: #448aff;
}

.timer {
    font-family: 'Bebas Neue', sans-serif;
    font-size: 22px;
    opacity: 0.6;
    letter-spacing: 2px;
}

#game-container {
    flex: 1;
    min-height: 0;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px;
    background: #0a0e12;
    overflow: hidden;
}

#gameCanvas {
    display: block;
    border-radius: 8px;
    box-shadow: 0 4px 24px rgba(0,0,0,0.6), inset 0 0 0 2px #fff3;
    cursor: pointer;
    touch-action: none;
}

.overlay {
    position: fixed;
    inset: 0;
    background:
        radial-gradient(ellipse at top, rgba(76,175,80,0.18) 0%, transparent 55%),
        radial-gradient(ellipse at bottom, rgba(0,188,212,0.12) 0%, transparent 60%),
        rgba(8, 12, 16, 0.96);
    backdrop-filter: blur(10px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    transition: opacity 0.3s;
    padding: 12px;
}

body.menu #scoreboard,
body.menu #controls { display: none; }

.overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.overlay-content {
    position: relative;
    text-align: center;
    padding: 18px 22px 22px;
    width: 100%;
    max-width: 720px;
    background: linear-gradient(160deg, rgba(28,38,50,0.88) 0%, rgba(18,26,36,0.88) 100%);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 18px;
    box-shadow: 0 18px 50px rgba(0,0,0,0.6), inset 0 1px 0 rgba(255,255,255,0.05);
}

.exit-btn {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 1px solid rgba(255,255,255,0.15);
    background: linear-gradient(135deg, #e53935 0%, #b71c1c 100%);
    color: #fff;
    font-size: 20px;
    font-weight: 700;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(229,57,53,0.4);
    z-index: 5;
    transition: transform 0.12s ease, box-shadow 0.12s ease;
}
.exit-btn:hover { transform: scale(1.06); box-shadow: 0 6px 16px rgba(229,57,53,0.55); }
.exit-btn:active { transform: scale(0.94); }

.ach-menu-btn {
    position: absolute;
    top: 12px;
    left: 12px;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 1px solid rgba(255,255,255,0.15);
    background: linear-gradient(135deg, #ffd54f 0%, #ff8f00 100%);
    color: #1a1a1a;
    font-size: 22px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(255,143,0,0.4);
    z-index: 5;
    transition: transform 0.12s ease, box-shadow 0.12s ease;
    filter: drop-shadow(0 1px 2px rgba(0,0,0,0.25));
}
.ach-menu-btn:hover  { transform: scale(1.06); box-shadow: 0 6px 16px rgba(255,143,0,0.55); }
.ach-menu-btn:active { transform: scale(0.94); }

.brand {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-bottom: 4px;
}
.brand-logo {
    font-size: 28px;
    filter: drop-shadow(0 2px 6px rgba(76,175,80,0.6));
}

.overlay-content h1 {
    font-family: 'Bebas Neue', sans-serif;
    font-size: 38px;
    letter-spacing: 5px;
    background: linear-gradient(135deg, #4caf50 0%, #00bcd4 60%, #448aff 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    line-height: 1;
}

.overlay-content p {
    opacity: 0.65;
    margin-bottom: 16px;
    font-size: 13px;
    letter-spacing: 0.5px;
}

.btn {
    background: linear-gradient(135deg, #4caf50 0%, #2e7d32 100%);
    color: #fff;
    border: none;
    padding: 14px 32px;
    font-size: 16px;
    font-weight: 700;
    letter-spacing: 1px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
    box-shadow: 0 4px 12px rgba(76, 175, 80, 0.3);
}

.btn:hover, .btn:active {
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(76, 175, 80, 0.5);
}

.btn-secondary {
    background: #2a3744;
    box-shadow: 0 2px 6px rgba(0,0,0,0.3);
    padding: 8px 16px;
    font-size: 13px;
}

.hidden { display: none !important; }

.mode-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin-bottom: 14px;
}

.score-limit-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-bottom: 12px;
}
.score-limit-label {
    font-size: 11px;
    letter-spacing: 1.5px;
    opacity: 0.55;
    font-weight: 600;
}
.score-limit-btn {
    padding: 6px 14px;
    border-radius: 8px;
    background: #2a3744;
    color: #fff;
    border: 1px solid rgba(255,255,255,0.06);
    font-family: 'Bebas Neue', sans-serif;
    font-size: 18px;
    letter-spacing: 1px;
    cursor: pointer;
    transition: all 0.15s;
    box-shadow: 0 2px 4px rgba(0,0,0,0.25);
}
.score-limit-btn:hover { background: #344253; }
.score-limit-btn.active {
    background: linear-gradient(135deg, #4caf50 0%, #2e7d32 100%);
    border-color: rgba(255,255,255,0.15);
    box-shadow: 0 2px 8px rgba(76,175,80,0.4);
}

.theme-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-bottom: 12px;
}
.theme-btn {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 2px solid rgba(255,255,255,0.15);
    background: var(--swatch);
    cursor: pointer;
    padding: 0;
    transition: transform 0.15s, box-shadow 0.15s, border-color 0.15s;
    box-shadow: 0 2px 4px rgba(0,0,0,0.4);
}
.theme-btn:hover { transform: scale(1.1); }
.theme-btn.active {
    border-color: #fff;
    transform: scale(1.15);
    box-shadow: 0 0 0 2px rgba(255,255,255,0.2), 0 2px 8px rgba(0,0,0,0.5);
}

#statsBox {
    margin-bottom: 14px;
    background: rgba(255,255,255,0.03);
    border: 1px solid rgba(255,255,255,0.07);
    border-radius: 10px;
    padding: 10px 14px;
}

#matchStatsBox { margin-bottom: 14px; }
.gameover-content { max-width: 560px; }
.gameover-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-top: 6px;
}
.gameover-actions .btn { width: 100%; font-size: 15px; padding: 12px 14px; }
.gameover-actions #rematchBtn2 {
    background: linear-gradient(135deg, #ffa726 0%, #f57c00 100%);
    box-shadow: 0 4px 12px rgba(255,167,38,0.35);
}
.match-stats-box {
    background: linear-gradient(135deg, rgba(76,175,80,0.08) 0%, rgba(33,150,243,0.08) 100%);
    border: 1px solid rgba(255,255,255,0.10);
    border-radius: 12px;
    padding: 12px 14px;
}
.match-stats-title {
    font-family: 'Bebas Neue', sans-serif;
    font-size: 14px;
    letter-spacing: 3px;
    text-align: center;
    opacity: 0.7;
    margin-bottom: 10px;
}
.match-stats-grid {
    display: grid;
    grid-template-columns: 1fr 1.2fr 1fr;
    gap: 6px 10px;
    align-items: center;
}
.ms-team {
    font-family: 'Bebas Neue', sans-serif;
    font-size: 16px;
    letter-spacing: 1px;
    text-align: center;
    padding-bottom: 4px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}
.ms-team.red { color: #ff8a8a; }
.ms-team.blue { color: #82b1ff; }
.ms-label {
    font-size: 11px;
    opacity: 0.6;
    text-align: center;
    letter-spacing: 1px;
    text-transform: uppercase;
}
.ms-val {
    font-family: 'Bebas Neue', sans-serif;
    font-size: 20px;
    text-align: center;
    color: #fff;
    line-height: 1;
}
@media (max-width: 480px) {
    .match-stats-grid { gap: 4px 6px; }
    .ms-val { font-size: 17px; }
    .ms-team { font-size: 14px; }
    .ms-label { font-size: 10px; }
    .match-stats-box { padding: 10px 10px; }
}
.stats-title {
    font-size: 10px;
    letter-spacing: 2px;
    opacity: 0.5;
    margin-bottom: 6px;
    text-align: left;
    text-transform: uppercase;
}
.stat-row {
    display: flex;
    justify-content: space-between;
    font-size: 13px;
    padding: 2px 0;
    opacity: 0.85;
}
.stat-val {
    font-family: 'Bebas Neue', sans-serif;
    letter-spacing: 1px;
    color: #ffeb3b;
    opacity: 0.85;
}

.mode-btn {
    padding: 10px 6px;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.3px;
    background: linear-gradient(160deg, #2a3744 0%, #1c2630 100%);
    box-shadow: 0 2px 6px rgba(0,0,0,0.3), inset 0 1px 0 rgba(255,255,255,0.05);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    border-top: 2px solid transparent;
    transition: transform 0.15s, box-shadow 0.15s, border-color 0.15s;
}
.mode-btn .mode-icon {
    font-size: 22px;
    line-height: 1;
    margin-bottom: 2px;
}
.mode-btn .mode-label {
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0.5px;
}
.mode-btn .mode-desc {
    font-size: 10px;
    opacity: 0.55;
    font-weight: 400;
    letter-spacing: 0.3px;
}

.mode-btn:hover, .mode-btn:active {
    background: linear-gradient(160deg, #344253 0%, #232f3c 100%);
    transform: translateY(-1px);
    box-shadow: 0 4px 10px rgba(0,0,0,0.4), inset 0 1px 0 rgba(255,255,255,0.08);
}

.mode-btn[data-mode="pvp"] { border-top-color: #4caf50; }
.mode-btn[data-mode="bot-easy"] { border-top-color: #8bc34a; }
.mode-btn[data-mode="bot-normal"] { border-top-color: #ffa726; }
.mode-btn[data-mode="bot-hard"] { border-top-color: #ef5350; }
.online-btn {
    border-top-color: #00bcd4 !important;
    background: linear-gradient(160deg, #1f3a4a 0%, #142631 100%);
}
.online-btn:hover, .online-btn:active {
    background: linear-gradient(160deg, #294a5e 0%, #1a3140 100%);
}

.online-modal {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.85);
    backdrop-filter: blur(10px);
    z-index: 100;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    overflow-y: auto;
    padding: 24px 12px;
    -webkit-overflow-scrolling: touch;
}
.online-content {
    background: #1a2530;
    border-radius: 12px;
    padding: 20px;
    max-width: 360px;
    width: 100%;
    text-align: center;
    box-shadow: 0 8px 32px rgba(0,0,0,0.6);
    margin: auto 0;
}
#onlineStatus {
    font-size: 14px;
    margin-bottom: 16px;
    opacity: 0.85;
}
.room-label {
    font-size: 12px;
    opacity: 0.6;
    letter-spacing: 1px;
    margin-bottom: 8px;
}
.room-code {
    font-family: 'Bebas Neue', sans-serif;
    font-size: 48px;
    letter-spacing: 8px;
    color: #00bcd4;
    background: rgba(0,188,212,0.1);
    padding: 12px;
    border-radius: 8px;
    margin-bottom: 8px;
    user-select: all;
}
.room-hint {
    font-size: 12px;
    opacity: 0.6;
    margin-bottom: 16px;
}
#roomInput, #nameInput {
    background: #0f1419;
    border: 2px solid #2a3744;
    color: #fff;
    font-family: 'Bebas Neue', sans-serif;
    font-size: 32px;
    letter-spacing: 6px;
    text-align: center;
    padding: 10px;
    border-radius: 8px;
    width: 100%;
    text-transform: uppercase;
    margin-bottom: 12px;
}
#nameInput {
    font-size: 22px;
    letter-spacing: 3px;
}
#roomInput:focus, #nameInput:focus {
    outline: none;
    border-color: #00bcd4;
}
#nameSection { margin-bottom: 12px; }
#hostStartBox { margin-bottom: 12px; }
#hostStartBtn { width: 100%; }
#joinSubmit {
    width: 100%;
    margin-bottom: 12px;
}
#onlineCancelBtn {
    width: 100%;
    margin-top: 8px;
}

#onlineForm.join-mode {
    display: flex;
    align-items: stretch;
    gap: 6px;
    margin-bottom: 12px;
}
#onlineForm.join-mode #nameSection,
#onlineForm.join-mode #joinInputBox {
    display: contents;
}
#onlineForm.join-mode .room-label { display: none; }
#onlineForm.join-mode #nameInput,
#onlineForm.join-mode #roomInput {
    flex: 1;
    margin-bottom: 0;
    font-size: 16px;
    padding: 10px 4px;
    letter-spacing: 1px;
    min-width: 0;
}
#onlineForm.join-mode #nameInput { letter-spacing: 1px; }
#onlineForm.join-mode #roomInput { letter-spacing: 3px; }
#onlineForm.join-mode #joinSubmit {
    width: auto;
    margin-bottom: 0;
    padding: 10px 14px;
    font-size: 13px;
    flex-shrink: 0;
}

.btn-secondary:hover {
    background: #364554;
    box-shadow: 0 3px 8px rgba(0,0,0,0.4);
}

#controls {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    background: #131b24;
    border-top: 1px solid #233140;
    gap: 12px;
}

.controls-left {
    display: flex;
    gap: 8px;
    align-items: center;
}

#soundBtn {
    padding: 8px 12px;
    font-size: 16px;
    min-width: 44px;
}

.hint {
    font-size: 12px;
    opacity: 0.5;
    text-align: right;
}

@media (max-width: 600px) {
    .score { font-size: 32px; }
    .overlay-content h1 { font-size: 30px; letter-spacing: 3px; }
    .brand-logo { font-size: 22px; }
    .hint { display: none; }
    #scoreboard { padding: 8px 12px; }
    .turn-indicator { font-size: 11px; padding: 4px 10px; }
    .timer { font-size: 18px; }
    #controls { padding: 6px 10px; }
    .btn-secondary { padding: 6px 10px; font-size: 12px; }
}

@media (max-height: 500px) {
    .overlay-content { padding: 10px 14px 12px; max-width: 760px; }
    .overlay-content h1 { font-size: 22px; letter-spacing: 2px; }
    .brand { gap: 6px; margin-bottom: 0; }
    .brand-logo { font-size: 18px; }
    .overlay-content p { margin-bottom: 8px; font-size: 11px; }
    .mode-grid {
        grid-template-columns: repeat(5, 1fr);
        gap: 6px;
        margin-bottom: 8px;
    }
    .mode-btn { padding: 8px 4px; }
    .mode-btn .mode-icon { font-size: 18px; margin-bottom: 0; }
    .mode-btn .mode-label { font-size: 11px; }
    .mode-btn .mode-desc { display: none; }
    #statsBox { padding: 6px 12px; margin-bottom: 0; }
    .stats-title { display: none; }
    #statsBox { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; }
    .stat-row { font-size: 11px; padding: 0; gap: 6px; }
    .stat-row span:first-child { opacity: 0.6; }
}

/* Telefon yatay: saha tam ekran, skor + isimler yan panellerde üstte, controls yan panellerde altta */
@media (orientation: landscape) and (max-height: 600px) {
    #app { position: relative; }

    #scoreboard {
        position: absolute;
        inset: 0;
        background: transparent;
        border: none;
        box-shadow: none;
        padding: 0;
        display: block;
        z-index: 10;
        pointer-events: none;
    }
    .team {
        position: absolute;
        top: 6px;
        flex-direction: column;
        align-items: center;
        gap: 2px;
        background: rgba(15, 20, 25, 0.78);
        backdrop-filter: blur(8px);
        -webkit-backdrop-filter: blur(8px);
        padding: 6px 8px;
        border-radius: 10px;
        pointer-events: auto;
        min-width: 60px;
        border: 1px solid rgba(255,255,255,0.06);
    }
    .team-red { left: 6px; border-left: 3px solid #ff5252; }
    .team-blue { right: 6px; border-right: 3px solid #448aff; }
    .team .team-name { font-size: 9px; letter-spacing: 1px; }
    .team .score { font-size: 24px; }

    .match-info {
        position: absolute;
        top: 6px;
        left: 50%;
        transform: translateX(-50%);
        flex-direction: row;
        gap: 8px;
        align-items: center;
        background: rgba(15, 20, 25, 0.78);
        backdrop-filter: blur(8px);
        -webkit-backdrop-filter: blur(8px);
        padding: 4px 10px;
        border-radius: 10px;
        pointer-events: auto;
        border: 1px solid rgba(255,255,255,0.06);
    }
    .turn-indicator { font-size: 10px; padding: 2px 8px; }
    .timer { font-size: 14px; letter-spacing: 1px; }

    #game-container { padding: 0; background: #0a0e12; }

    /* Controls: yan bantlarda, alt köşelerde, dikey stack */
    #controls {
        position: absolute;
        bottom: 6px;
        left: 6px;
        right: auto;
        background: transparent;
        border: none;
        padding: 0;
        gap: 4px;
        z-index: 10;
        width: auto;
        flex-direction: column;
        align-items: flex-start;
        justify-content: flex-end;
    }
    .controls-left { flex-direction: column; gap: 4px; align-items: stretch; }
    #controls .btn {
        padding: 6px 8px;
        font-size: 12px;
        min-width: 44px;
        background: rgba(15, 20, 25, 0.78);
        backdrop-filter: blur(8px);
        -webkit-backdrop-filter: blur(8px);
        border: 1px solid rgba(255,255,255,0.06);
        box-shadow: none;
    }
    #controls #soundBtn { padding: 6px 8px; font-size: 13px; }
    .hint { display: none; }

    body.menu #scoreboard { display: none; }
}

/* ===== Başarımlar ===== */
.achievement-toast {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translate(-50%, -120%);
    z-index: 10000;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 18px;
    background: linear-gradient(135deg, #ffd54f 0%, #ff8f00 100%);
    color: #1a1a1a;
    border-radius: 14px;
    box-shadow: 0 12px 28px rgba(0,0,0,0.45), inset 0 1px 0 rgba(255,255,255,0.5);
    font-family: 'Inter', sans-serif;
    min-width: 240px;
    max-width: 90vw;
    transition: transform 0.45s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.3s;
    opacity: 0;
    pointer-events: none;
}
.achievement-toast.visible {
    transform: translate(-50%, 0);
    opacity: 1;
}
.ach-toast-icon {
    font-size: 32px;
    line-height: 1;
    flex-shrink: 0;
    filter: drop-shadow(0 2px 3px rgba(0,0,0,0.25));
}
.ach-toast-body { display: flex; flex-direction: column; gap: 2px; }
.ach-toast-label {
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 1.5px;
    color: rgba(0,0,0,0.55);
}
.ach-toast-title {
    font-size: 16px;
    font-weight: 800;
    color: #1a1a1a;
}

/* Başarımlar modalı */
.ach-modal-content {
    max-width: 520px;
    max-height: 88vh;
    display: flex;
    flex-direction: column;
    padding: 20px 18px 16px;
}
.ach-modal-title {
    text-align: center;
    margin: 4px 0 12px;
    font-family: 'Bebas Neue', sans-serif;
    letter-spacing: 4px;
    font-size: 28px;
    color: #fff;
}
.ach-summary {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 12px;
    margin-bottom: 12px;
    background: rgba(255,255,255,0.06);
    border-radius: 10px;
    font-family: 'Inter', sans-serif;
    font-size: 12px;
    color: #cfd8dc;
}
.ach-count { font-weight: 800; color: #ffd54f; font-size: 14px; }
.ach-list {
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding-right: 4px;
}
.ach-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: 10px;
    background: rgba(255,255,255,0.04);
    border: 1px solid rgba(255,255,255,0.06);
    transition: background 0.15s;
}
.ach-row.ach-unlocked {
    background: linear-gradient(90deg, rgba(255,213,79,0.18), rgba(255,143,0,0.08));
    border-color: rgba(255,213,79,0.35);
}
.ach-row.ach-locked .ach-text { opacity: 0.55; }
.ach-icon {
    font-size: 26px;
    width: 40px;
    text-align: center;
    flex-shrink: 0;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.4));
}
.ach-text { flex: 1; min-width: 0; font-family: 'Inter', sans-serif; }
.ach-title { font-weight: 800; font-size: 14px; color: #fff; margin-bottom: 2px; }
.ach-desc  { font-size: 11px; color: #b0bec5; }

@media (max-width: 600px) {
    .achievement-toast { top: 12px; padding: 10px 14px; min-width: 200px; }
    .ach-toast-icon { font-size: 26px; }
    .ach-toast-title { font-size: 14px; }
    .ach-modal-content { padding: 14px 12px 12px; }
    .ach-modal-title { font-size: 22px; letter-spacing: 3px; }
    .ach-row { padding: 8px 10px; }
    .ach-title { font-size: 13px; }
    .ach-desc { font-size: 10px; }
}
