@import url('https://fonts.googleapis.com/css2?family=Nunito:wght@400;700;900&display=swap');

* { box-sizing: border-box; margin: 0; padding: 0; user-select: none; }
body, html { 
    width: 100%; height: 100%; font-family: 'Nunito', sans-serif; 
    background-color: #0f172a; color: #ecf0f1; 
    overflow: hidden; 
    touch-action: none; 
}

/* Orientation Lock Overlay */
#orientation-lock {
    display: none;
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background-color: #0f172a; color: #fff;
    z-index: 99999;
    flex-direction: column; justify-content: center; align-items: center;
    text-align: center; padding: 20px;
}
#orientation-lock h2 { font-size: 2.2rem; color: #e74c3c; margin-bottom: 15px; text-transform: uppercase; letter-spacing: 2px; }
#orientation-lock p { font-size: 1.2rem; color: #bdc3c7; }

/* Triggers the lock on touch devices in landscape, or very short screens */
@media screen and (max-height: 500px) and (orientation: landscape),
       screen and (hover: none) and (pointer: coarse) and (orientation: landscape) {
    #orientation-lock { display: flex; }
    #game-wrapper { display: none !important; }
}

#game-wrapper { display: flex; flex-direction: column; height: 100vh; width: 100vw; }

/* Header */
#csg-header { 
    display: flex; justify-content: space-between; align-items: center; 
    padding: 10px 20px; background: #0f172a; border-bottom: 2px solid #2563eb; 
    min-height: 60px; z-index: 200; position: relative; flex-wrap: wrap; gap: 10px;
}
#csg-branding { display: flex; align-items: center; gap: 10px; }
.logo-shield { background: linear-gradient(135deg, #2563eb, #3b82f6); color: white; font-weight: 900; padding: 4px 8px; border-radius: 6px; font-size: 0.9rem; border: 2px solid #fff; }
#game-title { font-size: 1.3rem; font-weight: bold; color: #fff; }
#csg-navigation { display: flex; gap: 10px; flex-wrap: wrap; }

/* Buttons */
.btn { padding: 10px 16px; border-radius: 6px; border: none; font-weight: bold; cursor: pointer; transition: 0.2s; font-size: 0.9rem; }
.btn:active { transform: scale(0.95); }
.btn.primary { background-color: #2563eb; color: white; }
.btn.primary:hover { background-color: #1d4ed8; }
.btn.secondary { background-color: #334155; color: #fff; border: 1px solid #475569; }

/* Canvas Area */
#main-content { display: flex; flex: 1; position: relative; width: 100%; height: 100%; }
#canvas-container { flex: 1; width: 100%; height: 100%; background: #050510; position: relative; overflow: hidden; }
canvas { display: block; position: absolute; top: 0; left: 0; width: 100%; height: 100%; cursor: crosshair; }

/* HUD */
#hud { position: absolute; top: 0; left: 0; width: 100%; height: 100%; pointer-events: none; display: flex; flex-direction: column; justify-content: space-between; padding: 15px; z-index: 50; }
#hud.hidden { display: none !important; }
.hud-top { display: flex; justify-content: space-between; align-items: flex-start; pointer-events: auto; flex-wrap: wrap; gap: 10px;}
.hud-player-info { background: rgba(15, 23, 42, 0.85); padding: 8px 15px; border-radius: 8px; border: 2px solid #2563eb; display: flex; align-items: center; gap: 10px; font-size: 1rem; font-weight: bold; box-shadow: 0 4px 15px rgba(0,0,0,0.5); }
.hud-score-text { margin-left: 10px; color: #38bdf8; }
.hud-frame-info { background: rgba(15, 23, 42, 0.85); padding: 8px 15px; border-radius: 8px; font-size: 1rem; font-weight: bold; border: 2px solid #475569; }
.player-color-dot { width: 14px; height: 14px; border-radius: 50%; border: 2px solid #fff; }

/* On-Screen Meter */
#meter-container { background: rgba(15, 23, 42, 0.95); padding: 15px; border-radius: 12px; border: 2px solid #38bdf8; width: 100%; max-width: 400px; margin: 0 auto; margin-bottom: 20px; text-align: center; pointer-events: auto; box-shadow: 0 10px 30px rgba(0,0,0,0.7); }
#meter-container.hidden { display: none !important; }
#meter-instruction { color: #fff; margin-bottom: 10px; font-size: 0.9rem; font-weight: bold; text-transform: uppercase; letter-spacing: 1px;}
#meter-track { position: relative; width: 100%; height: 25px; background: #000; border-radius: 15px; border: 2px solid #475569; overflow: hidden; }
#meter-track.hidden { display: none !important; }
#meter-fill { height: 100%; width: 0%; background: linear-gradient(90deg, #10b981, #eab308, #ef4444); transition: width 0.05s linear; }
#meter-cursor { position: absolute; top: -2px; bottom: -2px; width: 6px; background: #fff; left: 50%; transform: translateX(-50%); border-radius: 3px;}
#meter-center-mark { position: absolute; top: 0; bottom: 0; width: 2px; background: rgba(255,255,255,0.2); left: 50%; transform: translateX(-50%); z-index: 0; }

/* Steering Controls */
#steer-controls { position: absolute; top: 50%; left: 0; width: 100%; display: flex; justify-content: space-between; padding: 0 5%; pointer-events: none; z-index: 60; transform: translateY(-50%);}
#steer-controls.hidden { display: none !important; }
.steer-btn { 
    background: transparent; 
    border: none; 
    width: 100px; 
    height: 100px; 
    font-size: 6rem; 
    pointer-events: auto; 
    cursor: pointer; 
    color: rgba(200, 200, 200, 0.3); 
    transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275), color 0.2s;
    outline: none;
    -webkit-tap-highlight-color: transparent;
}
.steer-btn.active { 
    transform: scale(1.2); 
    color: rgba(200, 200, 200, 0.7); 
}

/* Menus & Overlays */
.overlay { position: absolute; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0, 0, 0, 0.85); display: flex; flex-direction: column; justify-content: center; align-items: center; z-index: 100; backdrop-filter: blur(5px); padding: 20px;}
.overlay.hidden { display: none !important; }
.menu-box { background: #0f172a; padding: 30px; border-radius: 16px; border: 2px solid #2563eb; text-align: center; width: 100%; max-width: 500px; max-height: 90vh; overflow-y: auto;}
.menu-box h2 { color: #fff; font-size: 1.8rem; margin-bottom: 20px; text-transform: uppercase; letter-spacing: 2px;}
.pin-style-selector h3 { color: #fff; margin-bottom: 10px; font-size: 1rem; }
.radio-group { display: flex; justify-content: center; gap: 20px; margin-bottom: 20px; color: #fff; font-size: 0.9rem;}
.mode-btn { width: 100%; padding: 15px; background-color: #1e293b; color: white; border: 2px solid #475569; border-radius: 8px; font-size: 1.1rem; cursor: pointer; font-weight: bold; margin-bottom: 12px;}
.mode-btn:hover { background-color: #2563eb; border-color: #38bdf8;}

/* Color Picker */
#color-options { display: grid; grid-template-columns: repeat(4, 1fr); gap: 15px; margin-top: 15px; }
.color-swatch { width: 60px; height: 60px; border-radius: 50%; cursor: pointer; border: none; box-shadow: 0 5px 15px rgba(0,0,0,0.5); margin: 0 auto; outline: none;}
.color-swatch:hover, .color-swatch:active { transform: scale(1.1); border: 3px solid #38bdf8; }

/* Scoreboard */
.modal-content { background: #0f172a; padding: 20px; border-radius: 12px; border: 2px solid #2563eb; width: 100%; max-width: 800px; max-height: 85vh; overflow-y: auto; text-align: center; }
.score-table { width: 100%; border-collapse: collapse; margin-bottom: 20px; background-color: #1e293b; font-size: 0.9rem; border-radius: 8px; overflow: hidden;}
.score-table th, .score-table td { border: 1px solid #334155; text-align: center; padding: 5px; }
.score-table th { background-color: #2563eb; color: white; padding: 10px 5px; }
.frame-boxes { display: flex; justify-content: space-between; width: 100%; border-bottom: 1px solid #334155; padding-bottom: 3px; margin-bottom: 3px;}
.frame-box { flex: 1; text-align: center; border-left: 1px solid #334155; font-weight: bold; color: #94a3b8;}
.frame-box:first-child { border-left: none; }
.frame-score { font-weight: bold; font-size: 1.1rem; color: #fff;}
.player-row-title { background-color: #0f172a; font-weight: bold; padding: 10px; color: #fff; display: flex; align-items: center; gap: 10px; justify-content: flex-start; font-size: 1rem; border: 1px solid #334155; border-bottom: none; border-radius: 8px 8px 0 0;}

/* Mobile Responses */
@media (max-width: 600px) {
    #color-options { grid-template-columns: repeat(3, 1fr); }
    .hud-top { flex-direction: column; align-items: center; width: 100%;}
    #show-score-btn { width: 100%; }
    .score-table th, .score-table td { padding: 2px; font-size: 0.75rem;}
    .steer-btn { font-size: 4.5rem; width: 80px; height: 80px;} 
    #meter-container { max-width: 90%; }
}
