:root {
  --font-mono: "SF Mono", "Fira Code", "Fira Mono", "Roboto Mono", monospace;
  --theme-bg: #f5f4f0;
  --theme-surface: #eceae4;
  --theme-divider: rgba(0, 0, 0, 0.22);
  --theme-cell-border: rgba(0, 0, 0, 0.08);
  --theme-grid-border: rgba(0, 0, 0, 0.28);
  --theme-text-primary: rgba(0, 0, 0, 0.88);
  --theme-text-muted: rgba(0, 0, 0, 0.5);
  --theme-text-hint: rgba(0, 0, 0, 0.3);
  
  --cell-size: 30px;
  --well-width: calc(10 * var(--cell-size));
  --total-well-width: calc(20 * var(--cell-size) + 2px);
  --next-cell-size: 22px;
  --accent-color: #f0ad4e;
  --transition-theme: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease;
}

/* ========================================================
   TEMALAR VE YÜKSEK KONTRAST DÜZENLEMELERİ
   ======================================================== */

/* 1. KLASİK GECE MODU (PM) */
body.pm:not(.theme-gameboy):not(.theme-cyberpunk):not(.theme-matrix) {
  --theme-bg: #18181a;
  --theme-surface: #222226;
  --theme-divider: rgba(255, 255, 255, 0.22);
  --theme-cell-border: rgba(255, 255, 255, 0.08);
  --theme-grid-border: rgba(255, 255, 255, 0.28);
  --theme-text-primary: rgba(255, 255, 255, 0.92);
  --theme-text-muted: rgba(255, 255, 255, 0.5);
  --theme-text-hint: rgba(255, 255, 255, 0.3);
}

body.pm:not(.theme-gameboy):not(.theme-cyberpunk):not(.theme-matrix) .format-btn.active,
body.pm:not(.theme-gameboy):not(.theme-cyberpunk):not(.theme-matrix) .btn-pill.active {
  background: #ffffff !important;
  color: #111111 !important;
  font-weight: bold;
}

/* 2. RETRO GAME BOY (1989 Efsanevi LCD) */
body.theme-gameboy {
  --theme-bg: #8b956d;
  --theme-surface: #9bbc0f;
  --theme-divider: #0f380f;
  --theme-cell-border: rgba(15, 56, 15, 0.22);
  --theme-grid-border: #0f380f;
  --theme-text-primary: #0f380f;
  --theme-text-muted: #1c481c;
  --theme-text-hint: #2f5a2f;
  --accent-color: #0f380f;
}

body.theme-gameboy .grids-container {
  border: 3px solid #0f380f;
  box-shadow: 0 8px 0 rgba(15, 56, 15, 0.25);
}

body.theme-gameboy .cell.filled {
  border: 1px solid #0f380f;
  box-shadow: inset 3px 3px 0 rgba(155, 188, 15, 0.5), inset -3px -3px 0 #0f380f;
}

body.theme-gameboy .format-pill {
  border-color: #0f380f;
}

body.theme-gameboy .format-btn {
  color: #0f380f;
}

body.theme-gameboy .format-btn.active,
body.theme-gameboy .btn-pill.active {
  background: #0f380f !important;
  color: #9bbc0f !important;
  font-weight: bold;
}

body.theme-gameboy .btn-pill {
  border-color: #0f380f;
  color: #0f380f;
}

body.theme-gameboy .btn-test,
body.theme-gameboy .btn-drop {
  border-color: #0f380f;
  color: #0f380f;
}

/* 3. CYBERPUNK NEON (Synthwave) */
body.theme-cyberpunk {
  --theme-bg: #090117;
  --theme-surface: #140728;
  --theme-divider: #ff007f;
  --theme-cell-border: rgba(0, 240, 255, 0.15);
  --theme-grid-border: #7928ca;
  --theme-text-primary: #00f0ff;
  --theme-text-muted: #ff007f;
  --theme-text-hint: rgba(0, 240, 255, 0.5);
  --accent-color: #ff007f;
}

body.theme-cyberpunk .grids-container {
  border: 2px solid #ff007f;
  box-shadow: 0 0 24px rgba(255, 0, 127, 0.25), inset 0 0 12px rgba(121, 40, 202, 0.3);
}

body.theme-cyberpunk .cell.filled {
  border: 1px solid #000;
  box-shadow: inset 2px 2px 0 rgba(255, 255, 255, 0.65), inset -2px -2px 0 rgba(0, 0, 0, 0.6);
}

body.theme-cyberpunk .format-pill {
  border-color: #ff007f;
}

body.theme-cyberpunk .format-btn.active,
body.theme-cyberpunk .btn-pill.active {
  background: #ff007f !important;
  color: #ffffff !important;
  font-weight: bold;
}

body.theme-cyberpunk .btn-pill {
  border-color: rgba(0, 240, 255, 0.4);
  color: #00f0ff;
}

body.theme-cyberpunk .btn-test {
  border-color: #ff007f;
  color: #ff007f;
}

/* 4. MATRIX (Hacker / Fosfor Yeşili) */
body.theme-matrix {
  --theme-bg: #020802;
  --theme-surface: #041404;
  --theme-divider: #00ff41;
  --theme-cell-border: rgba(0, 255, 65, 0.15);
  --theme-grid-border: #006616;
  --theme-text-primary: #00ff41;
  --theme-text-muted: rgba(0, 255, 65, 0.7);
  --theme-text-hint: rgba(0, 255, 65, 0.4);
  --accent-color: #00ff41;
}

body.theme-matrix .grids-container {
  border: 2px solid #00ff41;
  box-shadow: 0 0 20px rgba(0, 255, 65, 0.18);
}

body.theme-matrix .cell.filled {
  border: 1px solid #000;
  box-shadow: inset 2px 2px 0 rgba(180, 255, 180, 0.5), inset -2px -2px 0 rgba(0, 0, 0, 0.7);
}

body.theme-matrix .format-pill {
  border-color: #00ff41;
}

body.theme-matrix .format-btn {
  color: #00ff41;
}

body.theme-matrix .format-btn.active,
body.theme-matrix .btn-pill.active {
  background: #00ff41 !important;
  color: #000000 !important;
  font-weight: bold;
}

body.theme-matrix .btn-pill {
  border-color: #00ff41;
  color: #00ff41;
}

body.theme-matrix .btn-test {
  border-color: #00ff41;
  color: #00ff41;
}

/* ========================================================
   TEMEL DÜZEN
   ======================================================== */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-mono);
  background: var(--theme-bg);
  color: var(--theme-text-primary);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  overflow-x: hidden;
  transition: var(--transition-theme);
  user-select: none;
  padding: 20px 16px;
}

#app-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  width: 100%;
  max-width: 820px;
}

/* Digital Time Header */
.time-header {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.time-display {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  transition: opacity 0.25s ease, transform 0.25s ease, max-height 0.25s ease;
  overflow: hidden;
  max-height: 60px;
}

.time-display.hidden {
  opacity: 0;
  max-height: 0;
  transform: translateY(-8px);
  pointer-events: none;
}

.time-digits {
  font-size: 36px;
  letter-spacing: 0.15em;
  font-weight: 500;
  line-height: 1;
}

.time-ampm-badge {
  font-size: 11px;
  letter-spacing: 0.25em;
  text-transform: uppercase;
  color: var(--theme-text-muted);
  font-weight: bold;
  margin-top: 2px;
}

.time-toggle-btn {
  all: unset;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  margin-top: 2px;
  opacity: 0.5;
  transition: opacity 0.2s, transform 0.2s;
}

.time-toggle-btn:hover {
  opacity: 1;
  transform: scale(1.1);
}

/* Controls Bar */
.controls-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
  margin-bottom: 2px;
}

.format-pill {
  display: flex;
  border-radius: 20px;
  border: 1px solid var(--theme-cell-border);
  overflow: hidden;
}

.format-btn {
  all: unset;
  font-size: 9px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  padding: 5px 11px;
  cursor: pointer;
  color: var(--theme-text-hint);
  transition: background-color 0.25s, color 0.25s;
}

.format-btn.active {
  background: var(--theme-divider);
  color: var(--theme-text-primary);
  font-weight: bold;
}

.btn-pill {
  all: unset;
  cursor: pointer;
  font-size: 10px;
  padding: 5px 12px;
  border-radius: 20px;
  border: 1px solid var(--theme-cell-border);
  color: var(--theme-text-primary);
  letter-spacing: 0.08em;
  transition: background-color 0.2s, transform 0.1s, border-color 0.2s, opacity 0.2s;
}

.btn-pill:hover {
  background-color: var(--theme-cell-border);
}

.btn-pill.active {
  background: var(--theme-divider);
  font-weight: bold;
}

.btn-sound.muted {
  opacity: 0.45;
  text-decoration: line-through;
}

.btn-drop {
  border-color: #3aaa2c;
  color: #3aaa2c;
}

.btn-drop:hover {
  background: rgba(58, 170, 44, 0.15);
}

.btn-theme {
  display: flex;
  align-items: center;
  gap: 5px;
  font-weight: 600;
}

.btn-test {
  border-color: #e07820;
  color: #e07820;
}

.btn-test:hover {
  background: rgba(224, 120, 32, 0.15);
}

.btn-crt {
  border-color: rgba(0, 240, 255, 0.35);
}

.btn-crt.active {
  background: rgba(0, 240, 255, 0.22) !important;
  border-color: #00f0ff !important;
  color: var(--theme-text-primary) !important;
  font-weight: bold;
}

.btn-fullscreen {
  border-color: var(--theme-cell-border);
}

.btn-fullscreen.active {
  background: var(--theme-divider);
  font-weight: bold;
}

/* ========================================================
   SOL ALT SABİT İNFO BUTONU (FLOATING)
   ======================================================== */
.fixed-info-btn {
  position: fixed;
  bottom: 24px;
  left: 24px;
  z-index: 100;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 24px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
  background: var(--theme-surface);
  border: 1.5px solid var(--theme-grid-border);
  color: var(--theme-text-primary);
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
  transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.fixed-info-btn:hover {
  transform: translateY(-2px) scale(1.04);
  border-color: var(--theme-text-primary);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
}

/* ========================================================
   SAĞ ALT İMZA (CREDITS)
   ======================================================== */
.fixed-credits {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 100;
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 8px 16px;
  border-radius: 24px;
  font-size: 10.5px;
  letter-spacing: 0.08em;
  background: var(--theme-surface);
  border: 1.5px solid var(--theme-grid-border);
  color: var(--theme-text-primary);
  opacity: 0.85;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
  transition: transform 0.2s ease, border-color 0.2s ease, opacity 0.2s ease, box-shadow 0.2s ease;
  user-select: none;
}

.fixed-credits span {
  opacity: 0.65;
}

.fixed-credits strong {
  font-weight: 700;
  color: var(--theme-text-primary);
  letter-spacing: 0.06em;
}

.fixed-credits:hover {
  opacity: 1;
  transform: translateY(-2px) scale(1.03);
  border-color: var(--theme-text-primary);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
}

/* ========================================================
   GRID ALANI VE HİZALAMA
   ======================================================== */
.boards-wrapper {
  display: flex;
  align-items: flex-start;
  gap: 28px;
  position: relative;
}

.main-board-column {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: fit-content;
  max-width: 100%;
}

.well-header-bar {
  display: flex;
  width: 100%;
  margin-bottom: 6px;
}

.well-header {
  flex: 1;
  text-align: center;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--theme-text-muted);
}

.grids-container {
  display: flex;
  width: fit-content;
  max-width: 100%;
  border: 2px solid var(--theme-grid-border);
  border-radius: 4px;
  overflow: hidden;
  background: var(--theme-surface);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.08);
  transition: var(--transition-theme);
  box-sizing: content-box;
}

.grid {
  display: grid;
  grid-template-columns: repeat(10, var(--cell-size));
  grid-template-rows: repeat(15, var(--cell-size));
  position: relative;
  width: calc(10 * var(--cell-size));
  height: calc(15 * var(--cell-size));
  flex-shrink: 0;
  box-sizing: content-box;
}

.hours-grid {
  border-right: 2px solid var(--theme-divider);
  box-sizing: content-box;
}

.minutes-grid {
  box-sizing: content-box;
}

.cell {
  width: var(--cell-size);
  height: var(--cell-size);
  border: 0.5px solid var(--theme-cell-border);
  position: relative;
  box-sizing: border-box;
  flex-shrink: 0;
}

.cell.filled {
  border: 1px solid rgba(0, 0, 0, 0.3);
  box-shadow: inset 2.5px 2.5px 0 rgba(255, 255, 255, 0.5),
              inset -2.5px -2.5px 0 rgba(0, 0, 0, 0.35);
}

body.pm .cell.filled {
  border: 1px solid rgba(0, 0, 0, 0.5);
  box-shadow: inset 2.5px 2.5px 0 rgba(255, 255, 255, 0.55),
              inset -2.5px -2.5px 0 rgba(0, 0, 0, 0.45);
}

.cell.ghost {
  border: 2px dashed var(--theme-text-primary) !important;
  background-color: transparent !important;
  opacity: 0.45;
  animation: ghostPulse 1.2s infinite alternate ease-in-out;
}

@keyframes ghostPulse {
  0% { opacity: 0.25; }
  100% { opacity: 0.7; }
}

.cell.falling {
  border: 1px solid rgba(0, 0, 0, 0.4) !important;
  box-shadow: inset 3px 3px 0 rgba(255, 255, 255, 0.7),
              inset -3px -3px 0 rgba(0, 0, 0, 0.4),
              0 6px 12px rgba(0, 0, 0, 0.3);
  z-index: 5;
}

.cell.falling.uncolored-falling,
.demo-cell.filled.uncolored-falling {
  border: 1px solid var(--theme-cell-border) !important;
  box-shadow: inset 2px 2px 0 rgba(255, 255, 255, 0.45),
              inset -2px -2px 0 rgba(0, 0, 0, 0.35),
              0 4px 10px rgba(0, 0, 0, 0.25) !important;
  opacity: 0.95;
}

/* NEXT Preview Box */
.next-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 160px;
}

.next-title {
  font-size: 11px;
  letter-spacing: 0.16em;
  margin-bottom: 6px;
  font-weight: 700;
  color: var(--theme-text-muted);
}

.next-grid {
  display: grid;
  grid-template-columns: repeat(6, var(--next-cell-size, 22px));
  grid-template-rows: repeat(5, var(--next-cell-size, 22px));
  background: var(--theme-surface);
  padding: 10px;
  border-radius: 4px;
  border: 2px solid var(--theme-grid-border);
  gap: 1.5px;
}

.next-cell {
  width: var(--next-cell-size, 22px);
  height: var(--next-cell-size, 22px);
  border-radius: 2px;
}

.next-cell.has-block {
  box-shadow: inset 1.5px 1.5px 0 rgba(255, 255, 255, 0.45),
              inset -1.5px -1.5px 0 rgba(0, 0, 0, 0.3);
}

.next-footer {
  margin-top: 8px;
  font-size: 10px;
  opacity: 0.6;
}

.status-badge {
  margin-top: 8px;
  font-size: 9px;
  letter-spacing: 0.1em;
  padding: 3px 10px;
  border-radius: 12px;
  border: 1px solid var(--theme-cell-border);
  color: var(--theme-text-muted);
}

.status-badge.falling-active {
  color: #3aaa2c;
  border-color: #3aaa2c;
  font-weight: bold;
}

/* Legend */
.legend-bar {
  display: flex;
  width: 100%;
  font-size: 10px;
  letter-spacing: 1px;
  text-align: center;
  border-top: 1px solid var(--theme-divider);
  padding-top: 10px;
  margin-top: 8px;
}

.legend-col {
  flex: 1;
}

.legend-col strong {
  display: block;
  font-size: 10px;
  margin-bottom: 2px;
  opacity: 0.8;
}

.legend-col span {
  opacity: 0.5;
  font-size: 9px;
}

/* ========================================================
   POP-UP BİLGİ VE İNTERAKTİF TEST PENCERESİ (MODAL)
   ======================================================== */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
  padding: 16px;
}

.modal-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.modal-card {
  background: var(--theme-surface);
  border: 2px solid var(--theme-grid-border);
  border-radius: 8px;
  width: 100%;
  max-width: 640px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.4);
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  color: var(--theme-text-primary);
  transform: translateY(12px) scale(0.98);
  transition: transform 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.modal-overlay.open .modal-card {
  transform: translateY(0) scale(1);
}

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

.modal-title {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.12em;
}

.modal-close-btn {
  all: unset;
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  padding: 4px 8px;
  border-radius: 4px;
  opacity: 0.6;
  transition: opacity 0.2s, background-color 0.2s;
}

.modal-close-btn:hover {
  opacity: 1;
  background-color: var(--theme-divider);
}

.info-guide-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.guide-card {
  border: 1px solid var(--theme-cell-border);
  border-radius: 6px;
  padding: 12px;
  background: rgba(0, 0, 0, 0.03);
}

body.pm .guide-card {
  background: rgba(255, 255, 255, 0.03);
}

.guide-card h4 {
  font-size: 11px;
  letter-spacing: 0.1em;
  margin-bottom: 6px;
  opacity: 0.9;
}

.guide-card p {
  font-size: 10px;
  line-height: 1.5;
  opacity: 0.7;
}

.demo-section {
  border-top: 1px solid var(--theme-divider);
  padding-top: 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}

.demo-title {
  font-size: 11px;
  letter-spacing: 0.14em;
  font-weight: bold;
  opacity: 0.8;
}

.demo-display-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 18px;
  font-weight: bold;
  letter-spacing: 0.1em;
}

.demo-grid-wrapper {
  display: flex;
  border: 1.5px solid var(--theme-grid-border);
  border-radius: 4px;
  overflow: hidden;
  background: var(--theme-surface);
}

.demo-grid {
  display: grid;
  grid-template-columns: repeat(10, 14px);
  grid-template-rows: repeat(15, 14px);
  width: 140px;
  height: 210px;
}

.demo-hours-grid {
  border-right: 1.5px solid var(--theme-divider);
}

.demo-cell {
  width: 14px;
  height: 14px;
  border: 0.5px solid var(--theme-cell-border);
}

.demo-cell.filled {
  border: 0.5px solid rgba(0, 0, 0, 0.3);
  box-shadow: inset 1px 1px 0 rgba(255, 255, 255, 0.4);
}

.demo-cell.ghost {
  border: 1px dashed var(--theme-text-primary) !important;
  background-color: transparent !important;
  opacity: 0.55;
}

.demo-actions-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  width: 100%;
  max-width: 380px;
  margin: 2px 0;
  flex-wrap: wrap;
}

.demo-actions-bar .btn-pill {
  font-size: 9.5px;
  padding: 6px 14px;
}

.demo-sliders-box {
  width: 100%;
  max-width: 380px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.demo-slider-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.demo-slider-row span:first-child {
  font-size: 9px;
  width: 50px;
  opacity: 0.7;
}

.demo-slider-row input {
  flex: 1;
  accent-color: var(--accent-color);
  cursor: pointer;
}

.demo-slider-row span:last-child {
  font-size: 11px;
  width: 25px;
  text-align: right;
  font-weight: bold;
}

.modal-footer-credits {
  margin-top: 6px;
  padding-top: 14px;
  border-top: 1px solid var(--theme-divider);
  text-align: center;
  font-size: 11px;
  letter-spacing: 0.12em;
  opacity: 0.82;
  user-select: none;
}

.modal-footer-credits strong {
  font-weight: 700;
  color: var(--theme-text-primary);
  letter-spacing: 0.08em;
}

/* ========================================================
   CRT SCANLINE & RETRO TÜPLÜ TV EFEKTİ
   ======================================================== */
body.crt-mode {
  position: relative;
  text-shadow: 0 0 2px currentColor;
}

/* CRT Scanline Çizgileri */
body.crt-mode::after {
  content: " ";
  display: block;
  position: fixed;
  top: 0; left: 0; bottom: 0; right: 0;
  background: linear-gradient(rgba(18, 16, 16, 0) 50%, rgba(0, 0, 0, 0.28) 50%),
              linear-gradient(90deg, rgba(255, 0, 0, 0.04), rgba(0, 255, 0, 0.02), rgba(0, 0, 255, 0.04));
  background-size: 100% 3px, 6px 100%;
  z-index: 9999;
  pointer-events: none;
  opacity: 0.88;
}

/* CRT Tüp Kenar Gölgelenmesi (Vignette) */
body.crt-mode::before {
  content: " ";
  display: block;
  position: fixed;
  top: 0; left: 0; bottom: 0; right: 0;
  background: radial-gradient(circle at center, transparent 60%, rgba(0, 0, 0, 0.6) 100%);
  z-index: 9998;
  pointer-events: none;
}

body.crt-mode .cell.filled {
  box-shadow: inset 1.5px 1.5px 0 rgba(255, 255, 255, 0.5),
              inset -1.5px -1.5px 0 rgba(0, 0, 0, 0.4),
              0 0 8px currentColor;
}

body.crt-mode.theme-matrix {
  filter: drop-shadow(0 0 3px #00ff41);
}

body.crt-mode.theme-cyberpunk {
  filter: drop-shadow(0 0 3px #ff007f);
}

/* ========================================================
   RESPONSIVE: MOBİL, TABLET VE MASA SAATİ (DESK CLOCK) DÜZENİ
   ======================================================== */

/* Tablet & Küçük Ekranlar (<= 1024px) */
@media (max-width: 1024px) {
  :root {
    --cell-size: 26px;
    --next-cell-size: 20px;
  }
}

/* Telefonlar ve Dikey Tabletler (<= 768px) */
@media (max-width: 768px) {
  :root {
    --cell-size: min(18px, calc((100vw - 36px) / 20));
    --next-cell-size: 15px;
  }

  body {
    padding: 12px 6px;
    justify-content: center;
  }

  #app-container {
    gap: 10px;
  }

  .time-digits {
    font-size: 28px;
  }

  .controls-bar {
    gap: 5px;
    margin-bottom: 2px;
  }

  .btn-pill,
  .format-btn {
    font-size: 8.5px;
    padding: 4px 7px;
  }

  .boards-wrapper {
    flex-direction: column;
    align-items: center;
    gap: 12px;
  }

  .next-container {
    flex-direction: row;
    width: 100%;
    max-width: 360px;
    gap: 8px;
    align-items: center;
    justify-content: space-between;
    padding: 6px 12px;
    background: var(--theme-surface);
    border: 1px solid var(--theme-grid-border);
    border-radius: 8px;
    box-sizing: border-box;
  }

  .next-title {
    margin-bottom: 0;
    font-size: 9.5px;
    letter-spacing: 0.1em;
    white-space: nowrap;
  }

  .next-grid {
    flex-shrink: 0;
  }

  .next-footer {
    margin-top: 0;
    font-size: 9.5px;
    white-space: nowrap;
  }

  .status-badge {
    margin-top: 0;
    font-size: 8.5px;
    padding: 3px 8px;
    white-space: nowrap;
    flex-shrink: 0;
  }

  .fixed-info-btn {
    bottom: 12px;
    left: 12px;
    padding: 6px 12px;
    font-size: 9.5px;
  }

  .fixed-credits {
    bottom: 12px;
    right: 12px;
    padding: 6px 12px;
    font-size: 8.5px;
    letter-spacing: 0.06em;
  }

  .modal-card {
    padding: 16px;
  }

  .info-guide-grid {
    grid-template-columns: 1fr;
    gap: 10px;
  }
}

@media (max-width: 480px) {
  .fixed-credits span {
    display: none;
  }
  .fixed-credits strong::before {
    content: "by ";
    font-weight: 400;
    opacity: 0.7;
  }
}

/* Çok Küçük Telefonlar (<= 375px) */
@media (max-width: 375px) {
  :root {
    --cell-size: 13.5px;
    --next-cell-size: 14px;
  }

  .time-digits {
    font-size: 24px;
  }

  .controls-bar {
    gap: 4px;
  }
}

/* Yatay Telefon Modu (Landscape Desk Clock / Screensaver) */
@media (max-height: 540px) and (orientation: landscape) {
  :root {
    --cell-size: min(20px, calc((100vh - 44px) / 15), calc((100vw - 220px) / 20));
    --next-cell-size: 13.5px;
  }

  body {
    padding: 4px 10px;
    justify-content: center;
  }

  #app-container {
    gap: 4px;
  }

  .time-header {
    display: none; /* Saat zaten Tetris bloklarıyla okunuyor */
  }

  .controls-bar {
    gap: 4px;
    margin-bottom: 2px;
  }

  .btn-pill,
  .format-btn {
    font-size: 7.5px;
    padding: 2px 5px;
  }

  .boards-wrapper {
    flex-direction: row;
    gap: 14px;
  }

  .fixed-info-btn {
    bottom: 6px;
    left: 6px;
    padding: 4px 8px;
    font-size: 8px;
  }

  .fixed-credits {
    bottom: 6px;
    right: 6px;
    padding: 4px 8px;
    font-size: 8px;
  }
}

/* ========================================================
   FULLSCREEN SCREENSAVER / DİJİTAL SAAT MODU
   ======================================================== */

/* Çıkış butonu normalde gizli */
.fullscreen-exit-btn {
  display: none;
}

/* Fullscreen aktifken SADECE kuyular ve sıradaki kutusu görünür;
   Dijital saat, üst kontrol butonları, alt açıklama ve info butonu gizlenir */
body.fullscreen-active .time-header,
:fullscreen .time-header,
:-webkit-full-screen .time-header,
body.fullscreen-active .controls-bar,
:fullscreen .controls-bar,
:-webkit-full-screen .controls-bar,
body.fullscreen-active .legend-bar,
:fullscreen .legend-bar,
:-webkit-full-screen .legend-bar,
body.fullscreen-active .fixed-info-btn,
:fullscreen .fixed-info-btn,
:-webkit-full-screen .fixed-info-btn,
body.fullscreen-active .fixed-credits,
:fullscreen .fixed-credits,
:-webkit-full-screen .fixed-credits {
  display: none !important;
}

/* Fullscreen genel gövde ve container hizalaması */
body.fullscreen-active,
:fullscreen body,
:-webkit-full-screen body {
  padding: max(10px, env(safe-area-inset-top, 10px)) max(12px, env(safe-area-inset-right, 12px)) max(10px, env(safe-area-inset-bottom, 10px)) max(12px, env(safe-area-inset-left, 12px)) !important;
  margin: 0 !important;
  width: 100vw !important;
  height: 100vh !important;
  height: 100dvh !important;
  min-height: 100vh !important;
  min-height: 100dvh !important;
  overflow: hidden !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
}

body.fullscreen-active #app-container,
:fullscreen #app-container,
:-webkit-full-screen #app-container {
  max-width: none !important;
  width: auto !important;
  height: auto !important;
  padding: 0 !important;
  margin: auto !important;
  gap: 0 !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
}

body.fullscreen-active .boards-wrapper,
:fullscreen .boards-wrapper,
:-webkit-full-screen .boards-wrapper {
  margin: auto !important;
  align-items: center !important;
  gap: clamp(52px, 5.5vw, 84px) !important;
}

/* Fullscreen gerçek ekran koruyucu (screensaver) ölçeği:
   Ekranın %65 - %70'ini dolduran, ferah ve odanın her yerinden okunan retro kompozisyon */
body.fullscreen-active,
:fullscreen,
:-webkit-full-screen {
  --cell-size: min(clamp(28px, 4.2vh, 46px), calc((100vw - 340px) / 22), calc((100vh - 120px) / 16));
  --next-cell-size: calc(var(--cell-size) * 0.72);
}

body.fullscreen-active .well-header,
:fullscreen .well-header,
:-webkit-full-screen .well-header {
  font-size: 12.5px !important;
  letter-spacing: 0.22em !important;
  margin-bottom: 8px !important;
}

body.fullscreen-active .next-title,
:fullscreen .next-title,
:-webkit-full-screen .next-title {
  font-size: 12.5px !important;
  letter-spacing: 0.22em !important;
  margin-bottom: 8px !important;
}

body.fullscreen-active .next-footer,
:fullscreen .next-footer,
:-webkit-full-screen .next-footer {
  font-size: 11px !important;
  margin-top: 10px !important;
}

body.fullscreen-active .status-badge,
:fullscreen .status-badge,
:-webkit-full-screen .status-badge {
  font-size: 9.5px !important;
  padding: 4px 12px !important;
  margin-top: 8px !important;
}

/* Telefonlar ve Dikey Ekranlar (Mobil Tam Ekran) */
@media (orientation: portrait) and (max-width: 768px) {
  body.fullscreen-active,
  :fullscreen,
  :-webkit-full-screen {
    --cell-size: min(17.5px, calc((100vw - 36px) / 20));
    --next-cell-size: 14px;
  }
  body.fullscreen-active .boards-wrapper,
  :fullscreen .boards-wrapper,
  :-webkit-full-screen .boards-wrapper {
    flex-direction: column !important;
    gap: 14px !important;
    align-items: center !important;
  }
  body.fullscreen-active .next-container,
  :fullscreen .next-container,
  :-webkit-full-screen .next-container {
    width: 100% !important;
    max-width: 340px !important;
    justify-content: space-between !important;
    padding: 6px 12px !important;
    gap: 8px !important;
    box-sizing: border-box !important;
  }
  body.fullscreen-active .next-title,
  :fullscreen .next-title,
  :-webkit-full-screen .next-title {
    font-size: 9.5px !important;
    letter-spacing: 0.1em !important;
    margin-bottom: 0 !important;
    white-space: nowrap !important;
  }
  body.fullscreen-active .next-grid,
  :fullscreen .next-grid,
  :-webkit-full-screen .next-grid {
    --next-cell-size: 14px !important;
    flex-shrink: 0 !important;
  }
  body.fullscreen-active .next-footer,
  :fullscreen .next-footer,
  :-webkit-full-screen .next-footer {
    font-size: 9.5px !important;
    margin-top: 0 !important;
    white-space: nowrap !important;
  }
  body.fullscreen-active .status-badge,
  :fullscreen .status-badge,
  :-webkit-full-screen .status-badge {
    font-size: 8.5px !important;
    padding: 3px 8px !important;
    margin-top: 0 !important;
    white-space: nowrap !important;
    flex-shrink: 0 !important;
  }
}

/* Telefonlar Yatay Çevrildiğinde (Gerçek Başucu / Masa Saati Modu) */
@media (orientation: landscape) and (max-height: 540px) {
  body.fullscreen-active,
  :fullscreen,
  :-webkit-full-screen {
    --cell-size: min(20px, calc((100vh - 44px) / 15), calc((100vw - 220px) / 20));
    --next-cell-size: 13.5px;
  }
  body.fullscreen-active .boards-wrapper,
  :fullscreen .boards-wrapper,
  :-webkit-full-screen .boards-wrapper {
    flex-direction: row !important;
    gap: 20px !important;
    align-items: center !important;
  }
  body.fullscreen-active .next-container,
  :fullscreen .next-container,
  :-webkit-full-screen .next-container {
    flex-direction: column !important;
    width: 120px !important;
    padding: 8px !important;
    background: var(--theme-surface) !important;
    border: 1px solid var(--theme-grid-border) !important;
    border-radius: 8px !important;
    gap: 6px !important;
    align-items: center !important;
  }
  body.fullscreen-active .next-title,
  :fullscreen .next-title,
  :-webkit-full-screen .next-title {
    font-size: 9.5px !important;
    margin-bottom: 0 !important;
  }
  body.fullscreen-active .next-footer,
  :fullscreen .next-footer,
  :-webkit-full-screen .next-footer {
    font-size: 9px !important;
    margin-top: 2px !important;
  }
  body.fullscreen-active .status-badge,
  :fullscreen .status-badge,
  :-webkit-full-screen .status-badge {
    font-size: 8px !important;
    padding: 2px 7px !important;
    margin-top: 0 !important;
  }
}

/* Fullscreen yüzen çıkış butonu (fare oynatıldığında / dokunulduğunda belirir) */
body.fullscreen-active .fullscreen-exit-btn,
:fullscreen .fullscreen-exit-btn,
:-webkit-full-screen .fullscreen-exit-btn {
  display: inline-flex !important;
  align-items: center;
  gap: 6px;
  position: fixed;
  top: max(16px, env(safe-area-inset-top, 16px));
  right: max(16px, env(safe-area-inset-right, 16px));
  z-index: 10001;
  background: rgba(18, 18, 22, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.22);
  color: var(--theme-text, #ffffff);
  border-radius: 6px;
  padding: 7px 14px;
  font-family: inherit;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.35s ease, background-color 0.2s ease, transform 0.2s ease;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.5);
}

body.fullscreen-active.mouse-active .fullscreen-exit-btn,
:fullscreen.mouse-active .fullscreen-exit-btn {
  opacity: 0.85;
  pointer-events: auto;
}

body.fullscreen-active .fullscreen-exit-btn:hover {
  opacity: 1;
  background: rgba(30, 30, 36, 0.95);
  transform: translateY(-1px);
}
