:root {
  --zemin: #f4f1e8;
  --kagit: #fffdf7;
  --cizgi: #d9d2bf;
  --yazi: #1f2430;
  --soluk: #5b6070;
  --ana: #24518f;
  --ana-yazi: #ffffff;
  --onde: #1d6b45;
  --onde-zemin: #e3f2e8;
  --tehlike: #a42a1f;
  --odak: #c47a00;
  color-scheme: light;
}
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.4;
  color: var(--yazi);
  background: var(--zemin);
  overflow-x: hidden;
}
[hidden] { display: none !important; }
h1, h2 { margin: 0; line-height: 1.2; }
h1 { font-size: 1.25rem; }
h2 { font-size: 1.05rem; }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--odak); outline-offset: 2px; }
.gizli { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.ipucu { color: var(--soluk); font-size: 0.85rem; font-weight: 400; }
svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* Düğmeler */
.dugme {
  min-height: 44px;
  border: 1px solid var(--cizgi);
  border-radius: 10px;
  padding: 0.45rem 0.8rem;
  background: var(--kagit);
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  white-space: nowrap;
}
.dugme:hover { border-color: #b9b09a; }
.dugme:disabled { opacity: 0.45; cursor: default; }
.dugme--ana { background: var(--ana); border-color: var(--ana); color: var(--ana-yazi); }
.dugme--ana:hover { background: #1c4277; }
.dugme--tehlike { color: var(--tehlike); border-color: #e2b4ae; }
.kare { width: 44px; padding: 0; font-size: 1.3rem; }

/* Üst çubuk */
.ust {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  gap: 0.5rem;
  align-items: center;
  padding: 0.5rem 0.75rem;
  background: #ebe5d5;
  border-bottom: 1px solid var(--cizgi);
}
.ust-sol { flex: 1; min-width: 0; }
.ust-sag { display: flex; gap: 0.4rem; }
.tablo-sec { width: 100%; min-height: 44px; border: 1px solid var(--cizgi); border-radius: 10px; padding: 0.3rem 0.5rem; background: var(--kagit); }
.menu {
  position: absolute;
  right: 0.75rem;
  top: calc(100% + 4px);
  width: min(320px, calc(100vw - 1.5rem));
  background: var(--kagit);
  border: 1px solid var(--cizgi);
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
  padding: 0.35rem;
  display: grid;
}
.menu-oge { min-height: 44px; text-align: left; background: none; border: 0; border-radius: 8px; padding: 0.5rem 0.7rem; cursor: pointer; }
.menu-oge:hover { background: var(--zemin); }
.menu-oge--tehlike { color: var(--tehlike); }
.sil-onay { display: flex; flex-wrap: wrap; gap: 0.4rem; align-items: center; padding: 0.5rem; border-top: 1px solid var(--cizgi); }
.sil-onay span { width: 100%; font-weight: 600; }

main { padding: 0.75rem; max-width: 1180px; margin: 0 auto; }

/* Kurulum */
.kurulum { display: grid; gap: 0.75rem; max-width: 640px; margin: 0 auto; }
.kurulum form { display: grid; gap: 0.9rem; }
fieldset { border: 1px solid var(--cizgi); border-radius: 12px; padding: 0.6rem 0.75rem 0.75rem; margin: 0; background: var(--kagit); min-width: 0; }
legend { font-weight: 700; padding: 0 0.3rem; }
.oyun-izgara { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 0.4rem; }
.oyun-sec { position: relative; }
.oyun-sec input { position: absolute; opacity: 0; inset: 0; }
.oyun-sec span {
  display: grid;
  place-items: center;
  min-height: 52px;
  padding: 0.3rem;
  border: 2px solid var(--cizgi);
  border-radius: 10px;
  font-weight: 700;
  text-align: center;
  cursor: pointer;
  background: #fff;
}
.oyun-sec input:checked + span { border-color: var(--ana); background: #e6eef9; color: var(--ana); }
.oyun-sec input:focus-visible + span { outline: 3px solid var(--odak); outline-offset: 2px; }
.kurulum-ayar { display: grid; gap: 0.6rem; }
.kurulum-ayar:empty { display: none; }
.alan { margin: 0; display: grid; gap: 0.25rem; }
.alan label, .alan .etiket { font-weight: 600; }
input[type="text"], input:not([type]), input[type="number"], select {
  min-height: 44px;
  border: 1px solid #c8bfa8;
  border-radius: 8px;
  padding: 0.35rem 0.55rem;
  background: #fff;
  width: 100%;
  min-width: 0;
}
input[type="number"] { -moz-appearance: textfield; appearance: textfield; }
input[type="number"]::-webkit-inner-spin-button, input[type="number"]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.sayac { display: flex; align-items: center; gap: 0.5rem; margin-bottom: 0.6rem; flex-wrap: wrap; }
.sayac output { min-width: 2ch; text-align: center; font-weight: 800; font-size: 1.2rem; }
.ad-alanlari { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 0.5rem; }
.eylemler { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.onay { display: flex; gap: 0.5rem; align-items: center; min-height: 44px; cursor: pointer; }
.onay input { width: 22px; height: 22px; flex: none; }

/* Skor kartları */
.baslik-satir { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0.2rem 0.75rem; margin-bottom: 0.5rem; }
.skorlar { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 0.4rem; }
.skor {
  background: var(--kagit);
  border: 2px solid var(--cizgi);
  border-radius: 12px;
  padding: 0.35rem 0.6rem;
  min-width: 0;
  display: grid;
}
.skor-ad { font-size: 0.85rem; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.skor-toplam { font-size: 1.5rem; font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1.15; }
.skor-not { font-size: 0.75rem; color: var(--soluk); min-height: 1em; }
.skor--onde { border-color: var(--onde); background: var(--onde-zemin); }
.skor--onde .skor-not { color: var(--onde); font-weight: 700; }
.durum-mesaj { margin: 0.5rem 0; font-weight: 600; }
.bitti-kutu { margin: -0.2rem 0 0.6rem; }

/* Form ve tablo yerleşimi */
.izgara { display: grid; gap: 0.75rem; }
@media (min-width: 760px) {
  .izgara { grid-template-columns: minmax(300px, 380px) minmax(0, 1fr); align-items: start; }
  /* Uzun formu kaydırırken eller tablosu görünür kalır; uzun tablo kendi kutusunda kayar */
  .tablo-yan { position: sticky; top: 4.2rem; }
  .tablo-kutu { max-height: calc(100vh - 8rem); overflow: auto; }
}
.el-formu { background: var(--kagit); border: 1px solid var(--cizgi); border-radius: 12px; padding: 0.7rem; display: grid; gap: 0.7rem; min-width: 0; }
.el-formu.duzenleme { border-color: var(--odak); box-shadow: 0 0 0 2px #f3d9a8; }
.form-ust { display: flex; justify-content: space-between; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
.anahtar { display: inline-flex; gap: 0.35rem; align-items: center; font-size: 0.9rem; min-height: 44px; cursor: pointer; }
.anahtar input { width: 20px; height: 20px; }
#form-alanlar { display: grid; gap: 0.7rem; }
.grup { border: 0; padding: 0; margin: 0; background: none; min-width: 0; }
.grup > legend, .grup-baslik { font-weight: 700; font-size: 0.92rem; padding: 0; margin-bottom: 0.3rem; }
.secenekler { display: flex; flex-wrap: wrap; gap: 0.35rem; }
.secenek { position: relative; }
.secenek input { position: absolute; opacity: 0; inset: 0; margin: 0; }
.secenek span {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0.3rem 0.7rem;
  border: 1.5px solid #c8bfa8;
  border-radius: 999px;
  background: #fff;
  cursor: pointer;
  font-size: 0.92rem;
}
.secenek small { margin-left: 0.3rem; color: var(--soluk); }
.secenek input:checked + span { background: var(--ana); border-color: var(--ana); color: #fff; }
.secenek input:checked + span small { color: #dbe6f7; }
.secenek input:focus-visible + span { outline: 3px solid var(--odak); outline-offset: 2px; }
.secenek input:disabled + span { opacity: 0.4; cursor: default; text-decoration: line-through; }
.oyuncu-kutu { border: 1px solid var(--cizgi); border-radius: 10px; padding: 0.5rem; display: grid; gap: 0.45rem; background: #fff; min-width: 0; }
.oyuncu-kutu > legend { font-weight: 700; padding: 0 0.25rem; }
.satirlar { display: grid; gap: 0.45rem; }
.sayi-satir { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; }
.sayi-satir > label { font-weight: 600; font-size: 0.92rem; min-width: 0; }
.adim { display: inline-flex; align-items: center; gap: 0.25rem; flex: none; }
.adim input { width: 3.6rem; text-align: center; font-weight: 700; font-variant-numeric: tabular-nums; }
.adim .dugme { width: 44px; padding: 0; font-size: 1.2rem; }
.elle-izgara { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 0.5rem; }
.toplam-not { font-size: 0.88rem; color: var(--soluk); margin: 0; }
.toplam-not.tamam { color: var(--onde); font-weight: 600; }
.onizleme { background: var(--zemin); border-radius: 10px; padding: 0.5rem 0.6rem; font-size: 0.92rem; }
.onizleme:empty { display: none; }
.onizleme b { font-variant-numeric: tabular-nums; }
.onizleme ul { list-style: none; margin: 0.25rem 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 0.25rem 0.8rem; }
.hatalar { margin: 0; padding-left: 1.1rem; color: var(--tehlike); font-size: 0.9rem; }
.hatalar:empty { display: none; }
.kural { font-size: 0.85rem; color: var(--soluk); margin: 0; }

/* Eller tablosu */
.tablo-yan { min-width: 0; display: grid; gap: 0.4rem; }
.tablo-ust { display: flex; justify-content: space-between; align-items: center; gap: 0.5rem; }
.kucuk-baslik { font-size: 1rem; }
.tablo-kutu { overflow-x: auto; background: var(--kagit); border: 1px solid var(--cizgi); border-radius: 12px; max-width: 100%; }
.eller { border-collapse: collapse; width: 100%; font-variant-numeric: tabular-nums; }
.eller th, .eller td { padding: 0.35rem 0.5rem; border-bottom: 1px solid #ebe5d5; text-align: right; white-space: nowrap; }
.eller thead th { position: sticky; top: 0; background: #ebe5d5; font-size: 0.85rem; z-index: 1; }
.eller th:first-child, .eller td:first-child { text-align: left; position: sticky; left: 0; background: var(--kagit); z-index: 1; }
.eller thead th:first-child { background: #ebe5d5; z-index: 2; }
.eller .not-hucre { text-align: left; color: var(--soluk); font-size: 0.82rem; max-width: 14rem; overflow: hidden; text-overflow: ellipsis; }
.eller .ara { display: block; font-size: 0.72rem; color: var(--soluk); }
.eller tfoot td, .eller tfoot th { font-weight: 800; border-top: 2px solid var(--cizgi); background: #f7f3e8; }
.eller .onde-sutun { background: var(--onde-zemin); }
.eller tfoot .onde-sutun { color: var(--onde); }
.eller .eksi { color: var(--tehlike); }
.eller tr.secili td, .eller tr.secili th { background: #fbecd0; }
.el-no { min-height: 40px; min-width: 52px; border: 1px solid var(--cizgi); background: #fff; border-radius: 8px; font-weight: 700; display: inline-flex; gap: 0.25rem; align-items: center; justify-content: center; cursor: pointer; }
.el-no svg { width: 14px; height: 14px; }
.bos { padding: 1rem; color: var(--soluk); text-align: center; margin: 0; }

@media (max-width: 420px) {
  .dugme { padding: 0.4rem 0.6rem; }
  .ust { padding: 0.4rem 0.5rem; gap: 0.35rem; }
  main { padding: 0.5rem; }
  .skor-toplam { font-size: 1.3rem; }
  .skorlar { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 360px) {
  .ust-sag .dugme { padding: 0.4rem 0.5rem; }
}

@media print {
  body { background: #fff; }
  .ust, .el-formu, #geri-al, .bitti-kutu, .el-no svg { display: none !important; }
  main { padding: 0; max-width: none; }
  .izgara { display: block; }
  .tablo-kutu { overflow: visible; border: 0; max-height: none; }
  .tablo-yan { position: static; }
  .eller th, .eller td { border: 1px solid #999; }
  .eller thead th, .eller th:first-child, .eller td:first-child { position: static; }
  .el-no { border: 0; min-height: 0; min-width: 0; padding: 0; }
  .skor { break-inside: avoid; }
}
