* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  background: #05060f;
  color: #fff;
  font-family: "Segoe UI", Arial, sans-serif;
  overflow: hidden;
}

body {
  display: flex;
  align-items: center;
  justify-content: center;
}

#game {
  position: relative;
  width: min(100vw, calc(100vh * 16 / 9));
  aspect-ratio: 16 / 9;
  container-type: inline-size; /* butonlar cqw birimiyle buna göre ölçeklenir */
  box-shadow: 0 0 40px rgba(220, 30, 50, 0.25);
  user-select: none;
  touch-action: none;
}

#canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 16px;
  text-align: center;
  background: rgba(5, 6, 20, 0.72);
}

.overlay.hidden { display: none; }

h1 {
  font-size: clamp(28px, 7vw, 64px);
  letter-spacing: 4px;
  color: #e6232f;
  text-shadow: 3px 3px 0 #1a3fb0, 0 0 20px rgba(230, 35, 47, 0.6);
}

h2 {
  font-size: clamp(26px, 5vw, 48px);
  color: #e6232f;
}

.sub { font-size: clamp(14px, 2.4vw, 22px); color: #c9cff5; }
.score { font-size: clamp(18px, 3vw, 30px); font-weight: bold; }
.best { color: #ffd23f; font-weight: bold; }
.hint { font-size: 13px; color: #9aa0c8; }

button {
  margin-top: 8px;
  padding: 12px 42px;
  font-size: clamp(16px, 2.6vw, 24px);
  font-weight: bold;
  color: #fff;
  background: #e6232f;
  border: 3px solid #1a3fb0;
  border-radius: 10px;
  cursor: pointer;
  transition: transform 0.1s, background 0.2s;
}

button:hover { background: #ff3a46; transform: scale(1.05); }

/* Mobil butonlar: sadece dokunmatik cihazlarda ve oyun sırasında görünür */
/* Boyutlar oyun alanının genişliğine göre ölçeklenir (dik telefonda küçülür) */
.touchBtn {
  display: none;
  position: absolute;
  bottom: 3%;
  width: clamp(40px, 11cqw, 80px);
  height: clamp(40px, 11cqw, 80px);
  margin: 0;
  padding: 0;
  font-size: clamp(18px, 5cqw, 36px);
  border-radius: 50%;
  background: rgba(230, 35, 47, 0.75);
  -webkit-tap-highlight-color: transparent;
}

/* Ağ butonu en sağda ve daha büyük (en çok kullanılan), ağ topu solunda */
#webBtn {
  right: 2.5cqw;
  width: clamp(48px, 13cqw, 92px);
  height: clamp(48px, 13cqw, 92px);
}
#attackBtn {
  right: calc(2.5cqw + clamp(48px, 13cqw, 92px) + 2cqw);
  background: rgba(31, 69, 196, 0.75);
}

@media (pointer: coarse) {
  body.playing .touchBtn { display: block; }
}

/* Ses aç/kapat: masaüstünde sol altta, menü üstünde de görünür */
#muteBtn, #musicBtn {
  position: absolute;
  left: 1.5cqw;
  bottom: 3%;
  z-index: 2;
  width: clamp(28px, 5cqw, 42px);
  height: clamp(28px, 5cqw, 42px);
  margin: 0;
  padding: 0;
  font-size: clamp(13px, 2.2cqw, 20px);
  border-width: 2px;
  border-radius: 50%;
  background: rgba(20, 24, 60, 0.7);
}

#musicBtn { left: calc(1.5cqw + clamp(28px, 5cqw, 42px) + 1cqw); }
#musicBtn.off { opacity: 0.35; text-decoration: line-through; }
#muteBtn:hover, #musicBtn:hover { background: rgba(40, 48, 110, 0.9); }

/* Dokunmatik cihazda kısa yardım, masaüstünde tuş listesi */
.help-touch, .rotate-tip { display: none; }
@media (pointer: coarse) {
  .help-desktop { display: none; }
  .help-touch { display: block; }
  .overlay { gap: clamp(4px, 1.5cqw, 12px); }
  .overlay button { padding: 8px 32px; margin-top: 0; }

  /* Mobilde ses butonları sağ üste, "Rekor" yazısının altına
     (alttaki oyun butonlarıyla karışmasın) */
  #muteBtn, #musicBtn { top: 5.5cqw; bottom: auto; left: auto; }
  #musicBtn { right: 1.5cqw; }
  #muteBtn { right: calc(1.5cqw + clamp(28px, 5cqw, 42px) + 1cqw); }
}
@media (pointer: coarse) and (orientation: portrait) {
  .rotate-tip { display: list-item; color: #ffd23f; }
  h1 { font-size: 5.5vw; } /* sağ üstteki ses butonlarına değmesin */
}

.help {
  list-style: none;
  font-size: clamp(12px, 1.8vw, 16px);
  color: #c9cff5;
  line-height: 1.8;
}

kbd {
  display: inline-block;
  padding: 1px 6px;
  border: 1px solid #6b72a8;
  border-radius: 4px;
  background: #1b1f3d;
  font-size: 0.9em;
}
