/* Cosmic Snake Chaos - Stylesheet */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Orbitron', monospace;
    background: linear-gradient(135deg, #0a0e27 0%, #1a0033 50%, #0a0e27 100%);
    color: #fff;
    overflow: hidden;
    position: relative;
}

/* Game Container */
#game-container {
    width: 100vw;
    height: 100vh;
    position: relative;
}

#game-canvas {
    width: 100%;
    height: 100%;
    cursor: crosshair;
    background: radial-gradient(ellipse at center, #1a1a2e 0%, #0a0a0f 100%);
}

/* Menu Screens */
.menu-screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: rgba(10, 10, 15, 0.95);
    backdrop-filter: blur(10px);
    z-index: 100;
    /* perf: menü izolasyonu */
    contain: layout paint;
}

/* Game Title */
.game-title {
    text-align: center;
    margin-bottom: 40px;
    animation: float 3s ease-in-out infinite;
    width: 100%;
}

.game-title .glow {
    font-size: 4rem;
    font-weight: 900;
    background: linear-gradient(45deg, #ff00ff, #00ffff, #ffff00, #ff00ff);
    background-size: 300% 300%;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    animation: gradient 3s ease infinite;
    display: block;
    text-shadow: 0 0 40px rgba(255, 0, 255, 0.5);
}

.subtitle {
    font-size: 1.2rem;
    color: #00ffcc;
    margin-top: 10px;
    display: block;
    animation: pulse 2s ease infinite;
}

/* Player Setup */
.player-setup {
    background: rgba(30, 30, 50, 0.8);
    padding: 30px;
    border-radius: 20px;
    border: 2px solid #00ffcc;
    box-shadow: 0 0 30px rgba(0, 255, 204, 0.3);
    max-width: 600px;
    width: 90%;
}

#player-name {
    width: 100%;
    padding: 15px;
    font-size: 1.2rem;
    background: rgba(20, 20, 40, 0.9);
    border: 2px solid #00ffcc;
    border-radius: 10px;
    color: #fff;
    margin-bottom: 20px;
    text-align: center;
    font-family: 'Orbitron', monospace;
    transition: border-color 150ms ease, box-shadow 150ms ease;
}

#player-name:focus {
    outline: none;
    border-color: #ff00ff;
    box-shadow: 0 0 20px rgba(255, 0, 255, 0.5);
}

/* Skin Selector */
.skin-selector {
    margin-bottom: 20px;
}

.skin-selector label {
    display: block;
    margin-bottom: 10px;
    color: #00ffcc;
    text-align: center;
}

.skin-options {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
}

.skin-btn {
    padding: 10px;
    background: rgba(40, 40, 60, 0.8);
    border: 2px solid #444;
    border-radius: 10px;
    color: #fff;
    cursor: pointer;
    font-size: 1rem;
    font-family: 'Orbitron', monospace;
    /* perf: all yerine hedefli transition, transform yok */
    transition: filter 120ms ease, box-shadow 120ms ease, border-color 120ms ease, background-color 120ms ease;
}

.skin-btn:hover {
    /* transform: scale(1.1);  kaldırıldı */
    border-color: #00ffcc;
    box-shadow: 0 0 15px rgba(0, 255, 204, 0.5);
    filter: brightness(1.06) saturate(1.04);
}

.skin-btn.selected {
    border-color: #ff00ff;
    background: rgba(255, 0, 255, 0.2);
    animation: glow 1s ease infinite;
}

/* Color Selector in Main Menu */
.color-selector {
    margin: 20px 0;
    padding: 15px;
    background: rgba(60, 20, 80, 0.4);
    border-radius: 15px;
    border: 2px solid #ff00ff;
}

.color-selector label {
    display: block;
    margin-bottom: 10px;
    color: #ff00ff;
    text-align: center;
    font-size: 0.9rem;
}

.color-selector .color-options {
    display: flex;
    justify-content: center;
    gap: 8px;
    flex-wrap: wrap;
}

.color-selector .color-btn {
    width: 35px;
    height: 35px;
    border: 2px solid #666;
    border-radius: 50%;
    cursor: pointer;
    transition: box-shadow 120ms ease, border-color 120ms ease, filter 120ms ease;
}

.color-selector .color-btn:hover {
    /* transform: scale(1.2);  kaldırıldı */
    border-color: #00ffcc;
    box-shadow: 0 0 15px rgba(0, 255, 204, 0.5);
    filter: brightness(1.05);
}

.color-selector .color-btn.selected {
    border-color: #00ffcc;
    box-shadow: 0 0 20px rgba(0, 255, 204, 0.8);
    /* transform: scale(1.1);  kaldırıldı */
}

.color-selector .color-btn-default {
    background: linear-gradient(45deg, #ff0000, #00ff00, #0000ff);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
}

/* Room Controls */
.room-controls {
    margin: 20px 0;
    padding: 15px;
    background: rgba(40, 20, 60, 0.6);
    border-radius: 15px;
    border: 2px solid #ff00ff;
}

.room-controls h3 {
    text-align: center;
    color: #ff00ff;
    margin-bottom: 15px;
    font-size: 1.1rem;
}

.room-buttons {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin-bottom: 15px;
}

.room-btn {
    padding: 10px 20px;
    background: rgba(255, 0, 255, 0.2);
    border: 2px solid #ff00ff;
    color: #fff;
    border-radius: 10px;
    cursor: pointer;
    font-family: 'Orbitron', monospace;
    transition: background-color 120ms ease, border-color 120ms ease, box-shadow 120ms ease, filter 120ms ease;
}

.room-btn:hover {
    background: rgba(255, 0, 255, 0.35);
    /* transform: scale(1.05);  kaldırıldı */
    filter: brightness(1.04);
}

#room-info {
    display: none;
    text-align: center;
    padding: 10px;
    background: rgba(0, 255, 204, 0.1);
    border: 2px solid #00ffcc;
    border-radius: 10px;
    margin-bottom: 10px;
}

#room-code-display {
    font-size: 2rem;
    font-weight: bold;
    color: #00ffcc;
    margin: 10px 0;
    letter-spacing: 5px;
}

#room-link-input {
    width: 100%;
    padding: 8px;
    margin: 5px 0;
    background: rgba(0,0,0,0.5);
    border: 1px solid #00ffcc;
    color: #fff;
    border-radius: 5px;
    font-family: 'Orbitron', monospace;
    text-align: center;
}

.copy-btn {
    padding: 8px 15px;
    background: #00ffcc;
    color: #000;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-family: 'Orbitron', monospace;
    margin: 5px;
    transition: background-color 120ms ease, box-shadow 120ms ease, filter 120ms ease;
}

.copy-btn:hover {
    background: #00ff99;
    /* transform: scale(1.05);  kaldırıldı */
    filter: brightness(1.03);
}

#join-room-section {
    text-align: center;
    margin-top: 10px;
}

#room-code-input {
    padding: 10px;
    width: 150px;
    background: rgba(20, 20, 40, 0.9);
    border: 2px solid #00ffcc;
    color: #fff;
    border-radius: 10px;
    font-family: 'Orbitron', monospace;
    text-align: center;
    text-transform: uppercase;
    letter-spacing: 2px;
}

#join-room-btn {
    padding: 10px 20px;
    margin-left: 10px;
    background: rgba(0, 255, 204, 0.2);
    border: 2px solid #00ffcc;
    color: #fff;
    border-radius: 10px;
    cursor: pointer;
    font-family: 'Orbitron', monospace;
    transition: background-color 120ms ease, border-color 120ms ease, filter 120ms ease;
}

#join-room-btn:hover {
    background: rgba(0, 255, 204, 0.35);
    /* transform: scale(1.05);  kaldırıldı */
    filter: brightness(1.03);
}

/* Game Instructions */
.instructions {
    margin: 20px 0;
    padding: 15px;
    background: rgba(20, 40, 60, 0.6);
    border-radius: 15px;
    border: 2px solid #00ffcc;
}

.instructions h3 {
    text-align: center;
    color: #00ffcc;
    margin-bottom: 15px;
    font-size: 1.1rem;
}

.instruction-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
}

.instruction-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 8px;
}

.instruction-icon {
    font-size: 1.5rem;
}

/* Play Button (ENTER THE CHAOS) */
.play-button {
    padding: 15px 40px;
    font-size: 1.3rem;
    font-weight: 700;
    background: linear-gradient(45deg, #ff00ff, #00ffcc);
    border: none;
    border-radius: 50px;
    color: #fff;
    cursor: pointer;
    text-transform: uppercase;
    letter-spacing: 2px;
    margin: 10px auto;
    display: block;
    font-family: 'Orbitron', monospace;
    /* perf: hedefli transition + GPU katmanı */
    transition: transform 120ms ease-out, filter 120ms ease-out, box-shadow 120ms ease-out;
    will-change: transform;
    backface-visibility: hidden;
    transform: translateZ(0);
}

.play-button:hover {
    /* transform: scale(1.1) rotate(2deg);  -> rotate kaldırıldı, scale küçültüldü */
    transform: scale(1.03);
    box-shadow: 0 10px 40px rgba(255, 0, 255, 0.5);
}

/* HUD */
/* HUD köşe boşluğu ver */
#hud{
  position: fixed;          /* viewport'a sabitle */
  inset: 0;
  padding: clamp(12px,1.5vw,20px);   /* her kenardan boşluk */
  pointer-events: none;
}

/* Top bar artık absolute olmasın */
.top-bar{
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  justify-content: flex-start; /* sağ tarafa da eleman koyacaksan space-between yap */
  pointer-events: all;
}

/* Kart kendi içinde */
.score-display{
  /* mevcut stilin kalsın; margin vermek istersen: */
  /* margin: 0; */
}


/* Mobilde biraz daha yaklaştır */
@media (max-width: 768px){
  .top-bar{
    top: 14px;
    left: 14px;
  }
}


.score-display {
    background: rgba(20, 20, 40, 0.9);
    padding: 10px 20px;
    border-radius: 12px;
    border: 2px solid #00ffcc;
    display: flex;
    align-items: center;
    gap: 10px;
    width: auto;        /* >>> barın boyunu içeriğe göre ayarla */
    max-width: 280px;   /* >>> çok uzamasın diye sabit sınır */
}


.boost-indicator {
    padding: 5px 10px;
    background: rgba(255, 0, 0, 0.2);
    border-radius: 10px;
    font-size: 0.9rem;
    animation: pulse 1s ease infinite;
}

.boost-indicator.ready {
    background: rgba(0, 255, 0, 0.2);
    color: #00ff00;
}

/* Leaderboard */
.leaderboard {
    position: absolute;
    top: 80px;
    right: 20px;
    background: rgba(20, 20, 40, 0.9);
    padding: 20px;
    border-radius: 15px;
    border: 2px solid #00ffcc;
    min-width: 250px;
    max-width: 300px;
    pointer-events: all;
}

.leaderboard h3 {
    text-align: center;
    margin-bottom: 15px;
    color: #00ffcc;
    font-size: 1.1rem;
}

#leaderboard-list {
    list-style: none;
}

#leaderboard-list li {
    padding: 8px;
    margin: 5px 0;
    background: rgba(30, 30, 50, 0.6);
    border-radius: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

#leaderboard-list li.current-player {
    animation: glow 2s ease infinite;
}

/* Loading Overlay */
.loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(10, 10, 15, 0.98);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
}

.loading-spinner {
    width: 80px;
    height: 80px;
    border: 5px solid rgba(0, 255, 204, 0.3);
    border-top-color: #00ffcc;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

/* Death Screen */
.death-title {
    font-size: 3rem;
    color: #ff0000;
    text-shadow: 0 0 20px rgba(255, 0, 0, 0.8);
    margin-bottom: 30px;
    animation: shake 0.5s ease infinite;
}

.death-stats {
    background: rgba(30, 30, 50, 0.9);
    padding: 30px;
    border-radius: 20px;
    border: 2px solid #ff0000;
    margin-bottom: 20px;
}

.death-stats p {
    font-size: 1.2rem;
    margin: 10px 0;
}

/* Animations */
@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-20px); }
}

@keyframes gradient {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

@keyframes glow {
    0%, 100% { box-shadow: 0 0 10px rgba(255, 0, 255, 0.5); }
    50% { box-shadow: 0 0 30px rgba(255, 0, 255, 0.8); }
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-10px); }
    75% { transform: translateX(10px); }
}

/* Reduced Motion & Mobile Tweaks */
@media (prefers-reduced-motion: reduce) {
    * { animation: none !important; transition: none !important; }
}

@media (hover: none) {
    .menu-screen * { transition: none !important; }
}

@media (max-width: 768px) {
    .game-title .glow { 
        font-size: 2.5rem; 
    }
    
    .skin-options { 
        grid-template-columns: repeat(2, 1fr); 
    }
    
    .instruction-grid {
        grid-template-columns: 1fr;
    }
    
    .leaderboard {
        top: 60px;
        right: 10px;
        min-width: 200px;
        padding: 15px;
    }

    /* mobilde blur biraz düşür */
    .menu-screen { backdrop-filter: blur(6px); }
}
