/* 101 Defter - Mobil Skor Defteri Stilleri */

:root {
  /* Açık Tema Değişkenleri */
  --bg-page: #f4f5f2;
  --surface-main: #ffffff;
  --surface-sub: #eef2ec;
  --text-main: #171a16;
  --text-muted: #687067;
  --border-color: #dfe4dc;
  --accent-green: #176b3a;
  --accent-surface: #e1f4e8;
  --accent-text: #ffffff;
  --danger-color: #c92a2a;
  --danger-surface: #ffe3e3;
  --shadow-subtle: 0 2px 8px rgba(0, 0, 0, 0.05);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-pill: 9999px;
  --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --app-max-width: 460px;
}

[data-theme="dark"] {
  /* Koyu Tema Değişkenleri */
  --bg-page: #111310;
  --surface-main: #1b1e19;
  --surface-sub: #262b24;
  --text-main: #f1f5ef;
  --text-muted: #aeb7ab;
  --border-color: #353b32;
  --accent-green: #75dd9d;
  --accent-surface: #1d3827;
  --accent-text: #111310;
  --danger-color: #ff8787;
  --danger-surface: #3b1919;
  --shadow-subtle: 0 2px 10px rgba(0, 0, 0, 0.35);
}

/* Sıfırlama ve Temel Yapı */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  width: 100%;
  min-height: 100%;
  background-color: var(--bg-page);
  color: var(--text-main);
  font-family: var(--font-family);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

body {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  min-height: 100vh;
}

/* Ana Uygulama Kapsayıcısı */
#app-container {
  width: 100%;
  max-width: var(--app-max-width);
  min-height: 100vh;
  background-color: var(--bg-page);
  position: relative;
  display: flex;
  flex-direction: column;
}

@media (min-width: 480px) {
  #app-container {
    border-left: 1px solid var(--border-color);
    border-right: 1px solid var(--border-color);
    min-height: 100vh;
    box-shadow: var(--shadow-subtle);
  }
}

/* Ekran Yönetimi */
.screen {
  display: none;
  flex-direction: column;
  width: 100%;
  min-height: 100vh;
  padding-bottom: 24px;
}

.screen.active {
  display: flex;
}

/* Üst Bar (Header) */
.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 60px;
  padding: 0 16px;
  background-color: var(--bg-page);
  border-bottom: 1px solid var(--border-color);
  position: relative;
  z-index: 10;
  width: 100%;
}

.top-bar.sticky-top {
  position: sticky;
  top: 0;
  background-color: var(--bg-page);
}

.top-bar-left, .top-bar-right {
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.top-bar-center {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  pointer-events: none;
}

.brand-title {
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--text-main);
  line-height: 1.2;
}

.brand-subtitle {
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--text-muted);
  line-height: 1.2;
}

/* İkon Butonlar */
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-main);
  cursor: pointer;
  touch-action: manipulation;
  transition: background-color 0.15s ease, border-color 0.15s ease;
}

.icon-btn:hover {
  background-color: var(--surface-sub);
}

.icon-btn:active {
  transform: scale(0.96);
}

.icon-btn:focus-visible {
  outline: 2px solid var(--accent-green);
  outline-offset: 2px;
}

.icon {
  width: 20px;
  height: 20px;
  stroke-width: 2;
}

.icon-mini {
  width: 15px;
  height: 15px;
}

/* Tema Değiştirme Butonu */
.theme-toggle-btn .icon-sun {
  display: none;
}

.theme-toggle-btn .icon-moon {
  display: block;
}

[data-theme="dark"] .theme-toggle-btn .icon-sun {
  display: block;
}

[data-theme="dark"] .theme-toggle-btn .icon-moon {
  display: none;
}

/* Buton Stilleri */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 48px;
  min-height: 48px;
  padding: 0 20px;
  font-size: 0.98rem;
  font-weight: 600;
  font-family: inherit;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  white-space: nowrap;
  touch-action: manipulation;
  transition: background-color 0.15s ease, transform 0.1s ease, border-color 0.15s ease, opacity 0.15s ease;
}

.btn:active {
  transform: scale(0.98);
}

.btn:focus-visible {
  outline: 2px solid var(--accent-green);
  outline-offset: 2px;
}

.btn-primary {
  background-color: var(--accent-green);
  color: var(--accent-text);
  border-color: transparent;
}

.btn-primary:hover {
  opacity: 0.93;
}

.btn-secondary {
  background-color: var(--surface-main);
  color: var(--text-main);
  border-color: var(--border-color);
}

.btn-secondary:hover {
  background-color: var(--surface-sub);
}

.btn-danger {
  background-color: var(--danger-color);
  color: #ffffff;
}

.btn-danger:hover {
  opacity: 0.92;
}

.btn-full {
  width: 100%;
}

.btn-icon {
  width: 18px;
  height: 18px;
}

/* 1. EKRAN: KURULUM İÇERİĞİ */
.setup-content {
  padding: 20px 16px 32px 16px;
  display: flex;
  flex-direction: column;
  flex: 1;
}

.setup-heading-group {
  margin-bottom: 24px;
}

.setup-title {
  font-size: 1.45rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-main);
  margin-bottom: 6px;
}

.setup-description {
  font-size: 0.92rem;
  color: var(--text-muted);
}

.setup-section {
  margin-bottom: 24px;
}

.section-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  margin-bottom: 10px;
}

/* Segmented Control */
.segmented-control {
  display: flex;
  background-color: var(--surface-sub);
  padding: 4px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  gap: 4px;
  width: 100%;
}

.segment-btn {
  flex: 1;
  height: 42px;
  border: none;
  background: transparent;
  color: var(--text-main);
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s ease;
  touch-action: manipulation;
}

.segment-btn.active {
  background-color: var(--accent-green);
  color: var(--accent-text);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1);
}

.segment-btn:focus-visible {
  outline: 2px solid var(--accent-green);
  outline-offset: 1px;
}

/* 2x2 Oyuncu Grid */
.players-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 16px;
}

.input-field-group {
  display: flex;
  flex-direction: column;
}

.player-input {
  width: 100%;
  height: 48px;
  padding: 0 14px;
  font-family: inherit;
  font-size: 16px; /* 16px mobil zoom engellemek için */
  background-color: var(--surface-main);
  color: var(--text-main);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.player-input:focus {
  outline: none;
  border-color: var(--accent-green);
  box-shadow: 0 0 0 2px var(--accent-surface);
}

.player-input.input-error {
  border-color: var(--danger-color);
  box-shadow: 0 0 0 2px var(--danger-surface);
}

.player-input::placeholder {
  color: var(--text-muted);
  opacity: 0.7;
}

/* Eşli Bilgi Kartı */
.paired-info-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 12px 14px;
  background-color: var(--accent-surface);
  border: 1px solid var(--accent-green);
  border-radius: var(--radius-md);
  margin-bottom: 16px;
}

.paired-info-card.hidden {
  display: none;
}

.paired-row {
  display: flex;
  align-items: baseline;
  gap: 6px;
  font-size: 0.88rem;
}

.paired-tag {
  font-weight: 700;
  color: var(--accent-green);
  flex-shrink: 0;
}

.paired-names {
  color: var(--text-main);
  font-weight: 500;
  word-break: break-word;
}

/* Doğrulama Mesajı */
.validation-message {
  font-size: 0.85rem;
  color: var(--danger-color);
  margin-top: 4px;
  min-height: 20px;
  display: none;
}

.validation-message.active {
  display: block;
}

/* Kurulum Alt Buton Sarmalayıcı */
.setup-action-wrapper {
  margin-top: auto;
  padding-top: 20px;
}

/* 2. EKRAN: OYUN */
.auto-save-indicator {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 16px;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-muted);
  background-color: var(--bg-page);
}

.game-content {
  padding: 4px 12px 24px 12px;
  display: flex;
  flex-direction: column;
  flex: 1;
}

/* Tablo Kapsayıcısı */
.table-outer-wrapper {
  width: 100%;
  background-color: var(--surface-main);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  margin-bottom: 18px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.02);
}

.scores-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  table-layout: fixed;
  text-align: center;
}

/* Sütun Genişlikleri */
.scores-table col.col-round {
  width: 13%;
}

.scores-table col.col-player {
  width: 21.75%;
}

/* Tablo Başlıkları (Sticky Header) */
.scores-table thead {
  position: static;
}

.scores-table thead tr {
  position: static;
}

.scores-table thead th {
  position: sticky;
  top: 0;
  z-index: 10;
  background-color: var(--surface-sub);
  color: var(--text-main);
  font-size: 0.82rem;
  font-weight: 600;
  padding: 10px 4px;
  border-bottom: 1px solid var(--border-color);
  vertical-align: middle;
  word-break: break-word;
  line-height: 1.2;
}

.scores-table thead tr th:first-child {
  border-top-left-radius: calc(var(--radius-md) - 1px);
}

.scores-table thead tr th:last-child {
  border-top-right-radius: calc(var(--radius-md) - 1px);
}

.scores-table th.th-round {
  width: 13%;
  font-weight: 700;
  color: var(--text-muted);
}

/* Eşli Takım Ayırıcı Dikey Çizgisi */
.scores-table th.pair-divider-right,
.scores-table td.pair-divider-right {
  border-right: 1.5px solid var(--border-color);
}

/* Tablo Gövde Hücreleri */
.scores-table tbody {
  margin: 0;
  padding: 0;
  transform: none;
}

.scores-table tbody tr {
  margin: 0;
  padding: 0;
  transform: none;
}

.scores-table tbody tr td {
  border-bottom: 1px solid var(--border-color);
  padding: 6px 2px;
  vertical-align: middle;
  height: 52px;
}

.scores-table td.cell-round {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
  background-color: var(--surface-sub);
  border-right: 1px solid var(--border-color);
  white-space: nowrap;
}

/* Skor Giriş Inputları */
.score-input-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  padding: 2px;
}

.score-input {
  width: 90%;
  max-width: 62px;
  height: 40px;
  text-align: center;
  font-family: inherit;
  font-size: 16px;
  font-weight: 600;
  color: var(--text-main);
  background-color: var(--surface-main);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 0 2px;
  -webkit-appearance: none;
  -moz-appearance: textfield;
  transition: border-color 0.15s ease, background-color 0.15s ease;
}

/* Sayı spinner oklarını gizle */
.score-input::-webkit-outer-spin-button,
.score-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.score-input:focus {
  outline: none;
  border-color: var(--accent-green);
  background-color: var(--surface-sub);
}

/* Genel Satırı (TFoot) */
.scores-table tfoot tr.genel-row td {
  background-color: var(--surface-sub);
  border-top: 2px solid var(--border-color);
  padding: 10px 4px;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-main);
  vertical-align: middle;
}

.scores-table tfoot tr.genel-row td:first-child {
  border-bottom-left-radius: calc(var(--radius-md) - 1px);
}

.scores-table tfoot tr.genel-row td:last-child {
  border-bottom-right-radius: calc(var(--radius-md) - 1px);
}

.scores-table tfoot td.cell-genel-label {
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--text-muted);
  border-right: 1px solid var(--border-color);
  text-align: center;
  vertical-align: middle;
}

.scores-table tfoot td.cell-genel-label .icon-equal {
  display: inline-block;
  vertical-align: middle;
  width: 18px;
  height: 18px;
  color: var(--text-muted);
}

.scores-table tfoot td.winner-score-highlight {
  color: var(--accent-green);
  font-weight: 800;
}

/* Oyun Butonları */
.game-actions-bar {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  width: 100%;
}

/* 3. EKRAN: OYUN SONUCU */
.result-content {
  padding: 16px 12px 28px 12px;
  display: flex;
  flex-direction: column;
  flex: 1;
}

/* Kazanan Kartı */
.winner-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px;
  background-color: var(--accent-surface);
  border: 1px solid var(--accent-green);
  border-radius: var(--radius-md);
  margin-bottom: 20px;
}

.winner-icon-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  border-radius: var(--radius-pill);
  background-color: var(--surface-main);
  color: var(--accent-green);
  flex-shrink: 0;
  border: 1px solid var(--border-color);
}

.winner-trophy-icon {
  width: 26px;
  height: 26px;
}

.winner-details {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.winner-badge-label {
  font-size: 0.76rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--accent-green);
}

.winner-name {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-main);
  word-break: break-word;
  line-height: 1.25;
}

.winner-score {
  font-size: 0.88rem;
  color: var(--text-muted);
}

.winner-score strong {
  color: var(--text-main);
}

/* Sonuç Tablosu Salt Okunur Değerler */
.result-table td.cell-score-readonly {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-main);
}

.result-table td.cell-empty {
  color: var(--text-muted);
  opacity: 0.6;
}

/* Sonuç Butonları */
.result-actions-wrapper {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 10px;
}

/* HAMBURGER DRAWER */
.drawer-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background-color: rgba(0, 0, 0, 0.45);
  z-index: 99;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease, visibility 0.2s ease;
}

.drawer-backdrop.active {
  opacity: 1;
  visibility: visible;
}

.drawer-panel {
  position: fixed;
  top: 0;
  left: 0;
  right: auto;
  width: 280px;
  max-width: 80vw;
  height: 100vh;
  background-color: var(--surface-main);
  border-right: 1px solid var(--border-color);
  border-left: none;
  z-index: 100;
  transform: translateX(-100%);
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  display: flex;
  flex-direction: column;
  padding: 16px;
  box-shadow: 4px 0 16px rgba(0, 0, 0, 0.15);
}

.drawer-panel.active {
  transform: translateX(0);
}

.drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border-color);
  margin-bottom: 16px;
}

.drawer-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-main);
}

.drawer-nav {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.drawer-nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  height: 48px;
  padding: 0 14px;
  border-radius: var(--radius-md);
  border: none;
  background: transparent;
  color: var(--text-main);
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  text-align: left;
  transition: background-color 0.15s ease;
  touch-action: manipulation;
}

.drawer-nav-item:hover {
  background-color: var(--surface-sub);
}

.drawer-nav-item:active {
  transform: scale(0.98);
}

.drawer-nav-item.text-danger {
  color: var(--danger-color);
}

.drawer-nav-item.text-danger:hover {
  background-color: var(--danger-surface);
}

/* MODAL DİYALOGLARI */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background-color: rgba(0, 0, 0, 0.5);
  z-index: 110;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease, visibility 0.2s ease;
}

.modal-overlay.active {
  opacity: 1;
  visibility: visible;
}

.modal-card {
  width: 100%;
  max-width: 360px;
  background-color: var(--surface-main);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.2);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: scale(0.95);
  transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-overlay.active .modal-card {
  transform: scale(1);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px 12px 18px;
  border-bottom: 1px solid var(--border-color);
}

.modal-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-main);
}

.modal-body {
  padding: 16px 18px;
}

.modal-text {
  font-size: 0.95rem;
  color: var(--text-main);
  line-height: 1.45;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 12px 18px 16px 18px;
  background-color: var(--surface-sub);
  border-top: 1px solid var(--border-color);
}

.edit-players-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.field-caption {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 4px;
}

/* Erişilebilirlik ve Yardımcı Sınıflar */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
