html, body {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: #111;
}
#game {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    touch-action: none;
}
#ui,
#mobileControls,
#leaderboard {
    padding-bottom: env(safe-area-inset-bottom);
}
:root {
        --ui-bg: rgba(0, 0, 0, 0.7);
        --accent: #0f4;
        --sprint: #0cf;
}
#homepage-warning, #portrait-warning {
    display: none; 
    position: fixed; 
    inset: 0; 
    background: #222; 
    z-index: 9999;
    color: white; 
    flex-direction: column; 
    align-items: center; 
    justify-content: center;
    text-align: center; 
    padding: 20px;
}
body { 
    margin: 0; 
    overflow: hidden; 
    background: #111; 
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; 
    touch-action: none; 
    user-select: none; 
    -webkit-user-select: none;
}
#howToPlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.85);
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
}
.howto-box {
    background: #222;
    padding: 25px;
    border-radius: 12px;
    width: 90%;
    max-width: 420px;
    text-align: center;
}
.howto-box h2 {
    margin-top: 0;
    color: #0f4;
}
.howto-box ul {
    text-align: left;
    padding-left: 20px;
}
.howto-box li {
    margin-bottom: 10px;
    font-size: 15px;
}
.howto-buttons {
    margin-top: 20px;
    display: flex;
    justify-content: space-between;
}
.howto-buttons button {
    padding: 10px 18px;
    font-size: 14px;
    border: none;
    border-radius: 6px;
    background: #0f4;
    font-weight: bold;
    cursor: pointer;
}
#personalBestDisplay {
    position: absolute;
    top: 15px;
    left: 15px;
    color: #0f4;
    font-weight: bold;
    font-size: 16px;
    text-align: right;
}
#shareScoreBtn {
    background:#444;
    color:white;
    border: none;
    padding: 8px 16px;
    font-size: 14px;
    font-weight: bold;
    border-radius: 5px;
    cursor: pointer;
    transition: transform 0.1s;
    margin-top: 10px;
}
#shareScoreBtn:hover {
    transform: scale(1.05);
}
#shareModal {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.85);
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
}
.share-box {
    background: #222;
    padding: 25px;
    border-radius: 12px;
    width: 90%;
    max-width: 420px;
    text-align: center;
}
.share-box h2 {
    margin-top: 0;
    color: #0f4;
    margin-bottom: 5px;
}
.share-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 12px;
    margin-bottom: 20px;
}
.share-platform-btn {
    padding: 16px;
    border-radius: 12px;
    border: none;
    background: #0f4;
    color: #000;
    cursor: pointer;
    aspect-ratio: 1 / 1;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    transition: transform 0.1s, box-shadow 0.1s;
}
.share-platform-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 0 15px rgba(0,255,68,0.5);
}
.share-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
}
.share-icon svg {
    width: 24px;
    height: 24px;
}
.share-copy-btn {
    width: 100%;
    padding: 12px;
    border-radius: 8px;
    border: none;
    background: #0f4;
    color: #000;
    font-weight: bold;
    cursor: pointer;
    margin-bottom: 10px;
    transition: transform 0.1s;
}
.share-copy-btn:hover {
    transform: scale(1.02);
}
.share-close-btn {
    width: 100%;
    padding: 10px;
    border-radius: 8px;
    border: none;
    background: #444;
    color: white;
    font-weight: bold;
    cursor: pointer;
    transition: transform 0.1s;
}
.share-close-btn:hover {
    transform: scale(1.02);
}
#gameOver {
    position: relative;
}
canvas { display: block; }
#killFeed {
    position: fixed;
    top: calc(15px + 120px); 
    right: 15px;
    text-align: right;
    pointer-events: none;
    z-index: 100;
}
.kill-msg {
    background: rgba(0, 0, 0, 0.5);
    color: white;
    padding: 5px 10px;
    margin-bottom: 5px;
    border-radius: 4px;
    font-size: 14px;
    animation: fadeOut 4s forwards;
}
@keyframes fadeOut {
    0% { opacity: 1; transform: translateX(0); }
    80% { opacity: 1; }
    100% { opacity: 0; transform: translateX(20px); }
}
#translocatorNotice {
    position: fixed;
    top: calc(15px + 50px); 
    left: 15px;
    pointer-events: none;
    z-index: 100;
}
#sleipnirNotice {
    position: fixed;
    top: calc(15px + 90px); 
    left: 15px;
    pointer-events: none;
    z-index: 100;
}
#eliminatorNotice {
    position: fixed;
    top: calc(15px + 130px); 
    left: 15px;
    pointer-events: none;
    z-index: 100;
}
.translocator-msg {
    background: purple;
    color: rgb(15, 255, 3);
    padding: 6px 12px;
    border-radius: 6px;
    font-weight: 600;
    animation: translocatorFade 4s forwards;
}
.sleipnir-msg {
    background: #FFD700;
    color: black;
    padding: 6px 12px;
    border-radius: 6px;
    font-weight: 600;
    animation: sleipnirFade 4s forwards;
}
.elim-msg {
    background: red;
    color: black;
    padding: 6px 12px;
    border-radius: 6px;
    font-weight: 800;
    letter-spacing: 1px;
    animation: elimFade 4s forwards;
}
@keyframes elimFade {
    0% { opacity: 0; transform: translateX(-30px) scale(0.95); }
    15% { opacity: 1; transform: translateX(0) scale(1); }
    80% { opacity: 1; }
    100% { opacity: 0; transform: translateX(-30px) scale(0.95); }
}
@keyframes translocatorFade {
    0% { opacity: 0; transform: translateX(-20px); }
    15% { opacity: 1; transform: translateX(0); }
    80% { opacity: 1; }
    100% { opacity: 0; transform: translateX(-20px); }
}
@keyframes sleipnirFade {
    0% { opacity: 0; transform: translateX(-20px); }
    15% { opacity: 1; transform: translateX(0); }
    80% { opacity: 1; }
    100% { opacity: 0; transform: translateX(-20px); }
}
#lateSpectatorBanner {
    position: fixed;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.85);
    color: #0f4;
    padding: 10px 18px;
    font-size: 14px;
    border-bottom: 2px solid #0f4;
    z-index: 9999;
    display: none;
    text-align: center;
    pointer-events: none;
}       
#nameScreen, #gameOver {
    position: fixed; 
    inset: 0; 
    background: #222; 
    z-index: 1000;
    display: flex; 
    flex-direction: column; 
    align-items: center; 
    justify-content: center;
}
#nameScreen h1 { 
    color: white; 
    font-size: 56px; 
    margin-bottom: 30px; 
    letter-spacing: 5px; 
}
#nameScreen input[type="text"] { 
    padding: 15px; 
    font-size: 20px; 
    border-radius: 5px; 
    border: none; 
    width: 280px; 
    text-align: center; 
    outline: none;
}
#startBtn{
    margin-top:10px;
    font-size:16px;
    background:#0f4;
    color: black;
}
#winnerList{
    font-size: 24px; 
    text-align: center; 
    color: white;
}
#nameScreen button, #gameOver button:not(#shareScoreBtn) { 
    margin-top: 25px; 
    padding: 15px 50px; 
    font-size: 22px; 
    border: none; 
    cursor: pointer; 
    font-weight: bold; 
    border-radius: 5px; 
    transition: transform 0.1s;
}
#ui, #leaderboard {
    position: fixed; 
    top: 15px; 
    color: white; 
    background: var(--ui-bg); 
    padding: 15px; 
    border-radius: 10px; 
    pointer-events: none; 
    z-index: 10; 
    font-size: 14px;
}
#ui { 
    left: 15px;  
    min-width: 160px; 
}
#leaderboard {
    position: fixed; 
    top: 15px; 
    right: 15px; 
    min-width: 140px;
    text-align: right; 
    pointer-events: auto; 
    background: var(--ui-bg); 
    padding: 15px;
    border-radius: 10px; 
    color: white; 
    font-size: 14px; 
    display: flex;
    flex-direction: column; 
    max-height: 90vh; 
}
#leaderboardTop5 {
    flex-shrink: 0; 
    margin-bottom: 5px;
}
#leaderboardScroll {
    flex: 1 1 auto;  
    overflow-y: auto;
    overscroll-behavior: contain; 
    pointer-events: auto; 
    -webkit-overflow-scrolling: touch; 
}
#leaderboardScroll:focus {
    outline: none;
}
#leaderboardScroll::-webkit-scrollbar {
    width: 6px;
}
#leaderboardScroll::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.3); 
    border-radius: 3px;
}
#leaderboardScroll::-webkit-scrollbar-track {
    background: transparent;
}
.leaderboard-row {
    display: flex; 
    justify-content: space-between;
    align-items: center; 
    gap: 6px;
    padding: 2px 0; 
    font-size: 14px;
}
.lb-rank {
    width: 20px; 
    text-align: right;
    color: #aaa; 
    flex-shrink: 0;
}
.lb-name {
    flex: 1; 
    overflow: hidden;
    text-overflow: ellipsis; 
    white-space: nowrap;
    text-align: right;
}
.lb-score {
    min-width: 28px;
    text-align: right;
    font-weight: bold;
}
.bar-bg { 
    width: 100%; 
    height: 8px; 
    background: #333; 
    border-radius: 4px; 
    overflow: hidden; 
    margin-top: 5px; 
}
#staminaBar { 
    width: 100%; 
    height: 100%; 
    background: var(--sprint); 
    transition: width 0.1s; 
}
#timer { 
    font-size: 22px; 
    font-weight: bold; 
    color: var(--accent); 
    margin-bottom: 8px; 
}
#score {
    color: var(--sprint); 
    margin-top: 15px;
    font-weight: bold; 
    text-shadow: 0 0 10px rgba(0, 204, 255, 0.5);
    font-size: 20px;
}       
#mobileControls {
    display: none; 
    position: fixed; 
    inset: 0; 
    z-index: 500; 
    pointer-events: none;
}
@media (pointer: coarse) { #mobileControls { display: block; } }
.joystick-base {
    position: absolute; 
    bottom: calc(45px + env(safe-area-inset-bottom)); 
    left: 60px; 
    width: 140px; 
    height: 140px; 
    background: rgba(255,255,255,0.1); 
    border-radius: 50%; 
    pointer-events: auto;
}
.joystick-knob {
    position: absolute; 
    top: 45px; 
    left: 45px; 
    width: 50px; 
    height: 50px; 
    background: rgba(255,255,255,0.4); 
    border-radius: 50%;
}
#sprintBtn {
    position: absolute; 
    border-radius: 50%; 
    display: flex; 
    align-items: center; 
    justify-content: center; 
    color: white; 
    font-weight: bold; 
    pointer-events: auto; 
    bottom: 150px; 
    right: 40px; 
    width: 80px; height: 80px; 
    background: rgba(0, 150, 255, 0.6); 
    border: 3px solid rgba(255,255,255,0.2); 
    font-size: 14px;
}
#shootJoystick {
    background: rgba(255, 60, 60, 0.25); 
    border: 3px solid rgba(255, 60, 60, 0.6);
    bottom: 40px; 
    right: 60px; 
    left: auto; 
}
#shootJoystick .joystick-knob {
    background: rgba(255, 80, 80, 0.8);
}       
#minimap-container {
    position: fixed; 
    bottom: 20px; 
    left: 20px; 
    width: 140px; 
    height: 140px; 
    background: rgba(0, 0, 0, 0.6); 
    border: 2px solid #555; 
    border-radius: 8px; 
    overflow: hidden; 
    z-index: 5;
}
#minimap-canvas { display: block; }
#mapToggle {
    display: none; 
    position: fixed; 
    bottom: 170px; 
    left: 20px; 
    padding: 8px 12px; 
    background: var(--ui-bg); 
    color: white; 
    border: 1px solid #555;
    border-radius: 5px; 
    font-size: 10px; 
    pointer-events: auto; 
    z-index: 10;
}
@media (pointer: coarse) { #mapToggle { display: block; } }
#footer {
  position: fixed;
  bottom: 6px;
  left: 50%;
  transform: translateX(-50%);
  font-family: monospace;
  font-size: 12px;
  color: #aaa;
  opacity: 0.85;
  pointer-events: auto;
  z-index: 1000;
  transition: opacity 0.3s;
}
#footer:hover {
  opacity: 1;
}
#footer a {
  color: #4af;
  text-decoration: none;
}
#footer a:hover {
  text-decoration: underline;
}
