:root {
  --bg: #0c1f22;
  --panel: #10302f;
  --ink: #f3ead3;
  --glow: #ffb84d;
  --muted: #8fb3a6;
  --tehlike: #ff6f91;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Trebuchet MS", system-ui, sans-serif;
}

body {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: env(safe-area-inset-top, 0px) 0 env(safe-area-inset-bottom, 0px);
}

#wrap {
  position: relative;
  width: min(100vw, 480px, calc((100vh - 24px) * .75));
  aspect-ratio: 3 / 4;
  touch-action: none;
}

canvas {
  width: 100%;
  height: 100%;
  display: block;
  border-radius: 18px;
  background: var(--panel);
}

/* ---------- oyun menüsüne dönüş ---------- */
.geri {
  position: absolute;
  top: 10px;
  left: 10px;
  z-index: 5;
  padding: 6px 12px;
  border-radius: 999px;
  border: 2px solid var(--muted);
  background: rgba(12, 31, 34, .72);
  color: var(--ink);
  font: inherit;
  font-size: 13px;
  text-decoration: none;
  line-height: 1.2;
}
.geri:hover, .geri:focus-visible { border-color: var(--glow); color: var(--glow); }

/* Alt yolda başlık "← Oyunlar" bağlantısının altına insin */
.alt-yol #ov { padding-top: 46px; }

/* ---------- kaplama ---------- */
#ov {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 18px;
  overflow: auto;
  text-align: center;
  background: rgba(12, 31, 34, .86);
  border-radius: 18px;
  backdrop-filter: blur(2px);
}
#ov > :first-child { margin-top: auto; }
#ov > :last-child { margin-bottom: auto; }

#ov h1 {
  margin: 0;
  font-size: clamp(26px, 7vw, 38px);
  color: var(--glow);
  text-shadow: 0 0 18px rgba(255, 184, 77, .35);
}
#ov p { margin: 0; max-width: 32ch; line-height: 1.5; }
#ov small { color: var(--muted); }

.cevrimici {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: #7ee2a8;
}
.cevrimici::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #7ee2a8;
  box-shadow: 0 0 8px #7ee2a8;
}

/* ---------- düğmeler ---------- */
button {
  font: inherit;
  font-weight: 700;
  background: var(--glow);
  color: #2a1b05;
  border: 0;
  border-radius: 999px;
  padding: 12px 28px;
  cursor: pointer;
  transition: transform .12s ease, filter .12s ease;
}
button:hover { filter: brightness(1.06); }
button:active { transform: scale(.97); }
button:focus-visible { outline: 3px solid var(--ink); outline-offset: 3px; }
button:disabled { opacity: .5; cursor: default; }

button.ikinci {
  background: transparent;
  color: var(--ink);
  border: 2px solid var(--muted);
  padding: 10px 20px;
}

.sira { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }

.yuvarlak {
  position: absolute;
  top: 8.4%;
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: rgba(12, 31, 34, .55);
  color: var(--ink);
  border: 2px solid var(--muted);
  font-size: 13px;
  letter-spacing: 1px;
}
#menu { left: 50%; transform: translateX(-50%); }
#ses { right: 10px; font-size: 17px; letter-spacing: 0; }
#ses.kapali { opacity: .42; text-decoration: line-through; }

/* ---------- takma ad ---------- */
#nick {
  font: inherit;
  text-align: center;
  padding: 10px 14px;
  border-radius: 999px;
  border: 2px solid var(--muted);
  background: #0a1a20;
  color: var(--ink);
  width: min(220px, 80%);
  box-sizing: border-box;
}
#nick::placeholder { color: var(--muted); opacity: .8; }
#nick:focus-visible { outline: 3px solid var(--glow); outline-offset: 2px; }
#nick.hata { border-color: var(--tehlike); }

/* ---------- rehber ---------- */
#rehber {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 6px;
  text-align: left;
  font-size: 13px;
}
#rehber li { display: flex; align-items: center; gap: 10px; }

.nk {
  flex: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  color: #10302f;
}
.nk-f { background: #ffb84d; }
.nk-g { background: #ffe066; }
.nk-w { background: #c8442f; color: #f3ead3; }
.nk-p { background: #ff6f91; }
.nk-m { background: #5ec8ff; }
.nk-s { background: #b48cff; }

/* ---------- skor tablosu ---------- */
#skorPanel {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  width: 100%;
}

.sekmeler { display: flex; gap: 6px; }
.sek {
  padding: 6px 14px;
  font-size: 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, .06);
  color: var(--muted);
  border: 1px solid transparent;
}
.sek.aktif {
  background: rgba(255, 184, 77, .18);
  color: var(--glow);
  border-color: rgba(255, 184, 77, .5);
}

#tablo {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 4px;
  font-size: 13px;
  width: min(300px, 94%);
}
#tablo li {
  display: grid;
  grid-template-columns: 24px 1fr auto;
  gap: 8px;
  padding: 5px 10px;
  border-radius: 8px;
  background: rgba(255, 255, 255, .05);
}
#tablo li.ben {
  background: rgba(255, 184, 77, .22);
  box-shadow: inset 0 0 0 1px rgba(255, 184, 77, .4);
}
#tablo li.not {
  display: block;
  text-align: center;
  color: var(--muted);
  background: none;
  font-size: 12px;
  line-height: 1.5;
  padding: 10px 4px;
}
#tablo b { color: var(--glow); font-variant-numeric: tabular-nums; }
#tablo .ad { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: left; }
#tablo .puan { font-variant-numeric: tabular-nums; font-weight: 700; }

/* ---------- durum ---------- */
.durum { min-height: 1.2em; font-size: 12px; }
.durum.kotu { color: var(--tehlike); }
.ipucu { font-size: 11px; opacity: .8; }

.hide { display: none !important; }

@media (prefers-reduced-motion: reduce) {
  button { transition: none; }
}
