/* --- CORE CSS --- */
:root {
  --font-main: 'Montserrat', sans-serif;
  --font-hand: 'Patrick Hand', cursive;
  /* Asya ve diÃ¯Â¿Â½er diller iÃ¯Â¿Â½in sistem fontu yedekleri */
  --font-fallback: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;

  --bg: #111827;
  --panel: #1f2937;
  --card: #374151;
  --text: #f3f4f6;
  --muted: #9ca3af;
  --border: #4b5563;
  --accent: #60a5fa;
  --accent-hover: #3b82f6;

  /* Defaults if JS completely fails */
  --battle-cell-size: 30px;
  --mini-cell-size: 18px;
  --cell-size: 40px;

  --ok: #34d399;
  --danger: #f87171;
  --warn: #fbbf24;
  --miss-bg: #ff9800;
  --miss-txt: #5c2802;

  --radius: 8px;
  --sidebar-width: auto;
  --sidebar-bg: rgba(31, 41, 55, 0.4);
}

body.theme-light {
  --bg: #f3f4f6;
  --panel: #ffffff;
  --card: #e5e7eb;
  --text: #111827;
  --muted: #6b7280;
  --border: #d1d5db;
  --accent: #2563eb;
  --accent-hover: #3b82f6;
  --ok: #10b981;
  --danger: #ef4444;
  --miss-bg: #ffcc80;
  --miss-txt: #c0392b;
}

body.theme-hand {
  --font-main: 'Patrick Hand', cursive;
  --bg: #e8eaf6;
  --panel: #c5cae9;
  --card: #ffffff;
  --text: #1a237e;
  --muted: #5c6bc0;
  --border: #7986cb;
  --accent: #304ffe;
  --accent-hover: #3949ab;
  --ok: #00c853;
  --danger: #d50000;
  --warn: #ff6f00;
  --miss-bg: #bbdefb;
  --miss-txt: #0d47a1;
  --radius: 3px;
  --sidebar-bg: rgba(197, 202, 233, 0.6);
}

/* Base */
* {
  box-sizing: border-box;
  user-select: none;
  -webkit-user-select: none;
}

input,
textarea,
[contenteditable] {
  user-select: text;
  -webkit-user-select: text;
}

html,
body {
  height: 100%;
  margin: 0;
  padding: 0;
  overflow: visible !important;
}

body[data-lang="ru"] {
  font-family: 'Montserrat', 'Helvetica', sans-serif;
}

body[data-lang="zh"],
body[data-lang="ja"] {
  font-family: "Noto Sans SC", "Heiti SC", "Microsoft YaHei", sans-serif;
}

body[data-lang="hi"] {
  font-family: "Poppins", "Arial", sans-serif;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-main);
  display: flex;
  flex-direction: column;
}

/* Buttons & Inputs */
.btn,
.select {
  height: clamp(28px, 4vw, 36px);
  padding: 0 clamp(6px, 1vw, 12px);
  border-radius: var(--radius);
  background: var(--card);
  color: var(--text);
  border: 1px solid var(--border);
  cursor: pointer;
  font-size: clamp(11px, 1.3vw, 15px);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  font-weight: 600;
  text-align: center;
  font-family: inherit;
  white-space: nowrap;
}

.btn:hover {
  background: var(--border);
  border-color: var(--accent);
}

.btn:disabled,
.select:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

.btn--ok {
  background: var(--ok);
  color: white;
  border: none;
}
.btn--ok:hover {
  background: #10b981; /* Slightly darker green than --ok (emerald-500) */
  border: none;
}

.btn--danger {
  background: var(--danger);
  color: white;
  border: none;
}

.btn--info {
  background: var(--accent);
  color: white;
  border: none;
}

.select {
  outline: none;
}

/* Topbar & Layout */
.topbar {
  height: clamp(60px, 9vw, 84px);
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: flex-end !important;
  justify-content: space-between;
  padding: 0 clamp(8px, 1.5vw, 16px) 0;
  flex-shrink: 0;
  z-index: 50;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

.topbar > * {
  margin-top: auto;
  margin-bottom: 4px;
}

/* Topbar buttons: 50% larger */
.topbar .btn,
.topbar .select {
  height: clamp(42px, 6vw, 54px);
  font-size: clamp(17px, 2vw, 23px);
  padding: 0 clamp(10px, 1.5vw, 18px);
}

/* Topbar title text: 50% larger */
.topbar h3 {
  font-size: clamp(18px, 2.1vw, 24px) !important;
  margin: 0;
}

.bar-group {
  display: flex;
  gap: clamp(4px, 0.8vw, 8px);
  align-items: center;
}

.dropdown {
  position: relative;
  display: inline-block;
}

.layout {
  display: grid;
  grid-template-columns: minmax(auto, max-content) 1fr;
  height: calc(100% - 84px);
  overflow: hidden;
}

/* Sidebar & Main */
.sidebar {
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  padding: clamp(6px, 1vw, 10px);
  display: flex;
  flex-direction: column;
  gap: clamp(4px, 0.8vw, 8px);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  height: 100%;
  width: max-content;
  min-width: 180px;
  max-width: 320px;
}

.sidebar h3 {
  font-size: clamp(12px, 1.4vw, 16px);
  margin: 0;
}

.main-area {
  background: transparent !important;
  padding: clamp(5px, 1vw, 10px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  width: 100%;
  height: 100%;
}

.modal-box {
  background: var(--card);
  padding: 20px;
  border-radius: 12px;
  box-shadow: 0 0 20px rgba(0, 0, 0, 0.6);
  border: 1px solid var(--border);
  position: relative;
  max-width: 90%;
  width: 400px;
  max-height: 85vh;
  overflow-y: auto;
}

.board-card {
  background: var(--card);
  padding: clamp(6px, 1vw, 10px);
  border-radius: 12px;
  border: 1px solid var(--border);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  max-width: 99%;
  max-height: 99%;
  width: auto;
  height: auto;
  position: relative;
}

#battleCard {
  width: 100% !important;
  height: 100% !important;
  max-width: none;
  max-height: none;
  padding: 10px;
  justify-content: flex-start;
  background: transparent !important;
  box-shadow: none;
  border: none;
}

.card-header {
  display: flex;
  width: 100%;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  padding: clamp(6px, 1vw, 10px);
  margin-bottom: 5px;
  flex-shrink: 0;
  background: var(--sidebar-bg);
  border-radius: 6px;
}

.card-header h2 {
  font-size: clamp(14px, 2vw, 22px);
}

/* Grid & Cells */
.grid {
  display: grid;
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
}

.cell {
  /* FIX: Fluid Width for 1fr Grid */
  width: auto;
  height: auto;
  aspect-ratio: 1;
  min-width: 0;
  /* Allow shrinking below content size */
  background: var(--card);
  position: relative;
  cursor: pointer;
  display: grid;
  place-items: center;
  font-weight: bold;
  font-size: calc(100% * 0.45);
  /* fallback size */
  font-size: clamp(8px, 1.5vw, 16px);
  /* Responsive font */
}

.cell:hover {
  background: var(--panel);
}

.cell.head {
  background: transparent;
  color: #9ca3af !important;
  border: none;
  cursor: default;
  /* FIX: Allow shrinking */
  width: auto !important;
  height: auto !important;
  min-width: 0 !important;
  min-height: 0 !important;
  aspect-ratio: 1;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  font-size: calc(var(--cell-size) * 0.4) !important;
  font-weight: 700 !important;
  flex-shrink: 0 !important;
  z-index: 10 !important;
  opacity: 1 !important;
}
.battle-grid {
  gap: 1px !important;
}

.battle-grid .cell.head {
  width: var(--battle-cell-size) !important;
  height: var(--battle-cell-size) !important;
  font-size: calc(var(--battle-cell-size) * 0.35) !important;
}

.battle-grid .cell {
  width: var(--battle-cell-size) !important;
  height: var(--battle-cell-size) !important;
  font-size: calc(var(--battle-cell-size) * 0.5) !important;
}

.battle-grid .cell.hit-prime {
  background: var(--ok) !important;
  color: var(--panel);
  border: 2px solid white;
}

.battle-grid .cell.hit-mine {
  background: var(--danger) !important;
  color: white;
}

.cell-content {
  position: absolute;
  inset: 1px;
  border-radius: 3px;
  display: grid;
  place-items: center;
  pointer-events: none;
  background: var(--accent);
  color: var(--panel);
}

.cell-content.mine {
  background: var(--danger);
  color: white;
}

.cell-content.ghost-ok {
  background: var(--ok);
  opacity: 0.6;
}

.cell-content.ghost-bad {
  background: var(--danger);
  opacity: 0.6;
}

.cell.miss {
  background: var(--miss-bg) !important;
  color: var(--miss-txt) !important;
  font-family: 'Segoe UI Light', sans-serif;
  font-weight: 300;
  font-size: 130% !important;
  line-height: 1;
}

body.theme-hand .cell.miss {
  font-family: 'Patrick Hand', cursive;
  font-weight: bold;
}

/* STAGE 2 Ã¯Â¿Â½ZEL */
.mini-grid-wrap {
  display: flex;
  justify-content: center;
  margin: 0;
  padding: 0;
}

.stage2-box {
  background: var(--sidebar-bg);
  border-radius: 6px;
  padding: 10px;
  margin-bottom: 15px;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.grid.mini {
  grid-template-columns: repeat(var(--cols), 1fr);
  width: 95%;
  max-width: 100%;
  margin: 0 auto;
}

.grid.mini .cell {
  width: auto;
  height: auto;
  aspect-ratio: 1;
  font-size: clamp(8px, 1.5vw, 14px);
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(255, 255, 255, 0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
  font-weight: bold;
  text-shadow: 1px 1px 0 #000;
}

.grid.mini .cell.miss {
  font-size: calc(var(--mini-cell-size)*0.8) !important;
  font-weight: bold;
  line-height: 1 !important;
  padding: 0;
  margin: 0;
}

.grid.mini .cell.revealed {
  background: var(--accent);
  color: var(--bg);
}

.grid.mini .cell.revealed.mine {
  background: var(--danger);
  color: white;
}

.grid.mini .cell.hit-prime {
  background: var(--ok) !important;
  color: var(--panel);
  border: 1px solid white;
}

.grid.mini .cell.hit-mine {
  background: #7f1d1d !important;
  opacity: 0.7;
}

.grid.mini .cell.ai-shot {
  border: 2px solid #ffeb3b !important;
  z-index: 2;
}

.info-area {
  background: var(--sidebar-bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px;
  flex: 1;
  overflow-y: auto;
  min-height: 100px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 14px;
}

.info-line {
  padding-bottom: 3px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.info-line.ai {
  color: var(--warn);
}

body.theme-hand .info-line.ai {
  color: #d35400;
  font-weight: bold;
}

body.theme-hand .score-table {
  color: var(--text);
  font-weight: bold;
}

.score-table {
  width: 100%;
  text-align: center;
  border-collapse: collapse;
  margin-bottom: 5px;
}

.score-table td {
  padding: 3px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

/* Strips */
.strips-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  width: 100%;
}

.strip-item {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 3px;
  cursor: pointer;
  display: flex;
  gap: 2px;
  align-items: center;
  width: fit-content;
}

.strip-item:hover {
  border-color: var(--accent);
}

.strip-item.selected {
  border: 2px solid var(--accent);
  background: rgba(96, 165, 250, 0.1);
}

.chip {
  width: clamp(18px, 2.5vw, 26px);
  height: clamp(18px, 2.5vw, 26px);
  border-radius: 4px;
  display: grid;
  place-items: center;
  font-size: clamp(10px, 1.3vw, 14px);
  font-weight: 700;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--border);
  flex-shrink: 0;
}

.chip.mine {
  background: rgba(239, 68, 68, 0.3);
  color: #ffcece;
  border-color: var(--danger);
}

.chip.dot {
  border: none;
  background: transparent;
  color: var(--muted);
  opacity: 0.3;
}

.board-footer-info {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: clamp(10px, 2vw, 20px);
  width: 100%;
  padding: clamp(4px, 0.8vw, 8px) clamp(6px, 1vw, 10px);
  margin-top: 5px;
  font-size: clamp(9px, 1.1vw, 12px);
}

.footer-hint {
  color: var(--muted);
}

.footer-legend {
  display: flex;
  gap: clamp(8px, 1.2vw, 15px);
}

/* Smooth page reload transition */
body {
  transition: opacity 0.25s ease;
}
body.page-fading {
  opacity: 0 !important;
  pointer-events: none;
}

/* STAGE 0: SHELL */
#stage0 {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end; /* Push everything to bottom */
  width: 100%;
  min-height: 100vh;
  min-height: 100dvh; /* Better mobile viewport support */
  background: radial-gradient(circle at center, #374151, #111827) !important;
  color: #f3f4f6 !important;
  padding: 20px 0 0 0; /* No bottom padding */
  z-index: 200;
  position: relative;
  overflow-y: auto;
  overflow-x: hidden;
}

.shell-logo img {
  width: 180px;
  height: auto;
  filter: drop-shadow(0 0 20px rgba(96, 165, 250, 0.5));
  margin-bottom: 10px;
}

.shell-logo {
  text-align: center;
  margin-bottom: auto; /* Push everything below it to the bottom */
  margin-top: 30px;
}

.shell-menu {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 300px;
  z-index: 10;
}

@media screen and (orientation: landscape) and (max-height: 600px) {
  #stage0 {
    justify-content: flex-start; padding-top: 25px;
  }
  #stage0 .shell-menu {
    gap: 6px !important;
    margin-top: 10px !important;
  }
  
  #stage0 .shell-btn {
    height: 40px !important;
    font-size: 13px !important;
  }
  
  #stage0 .cat-animation {
    top: -115px !important;
    right: -80px !important;
    width: 220px !important;
    height: 220px !important;
  }
  
  #stage0 lottie-player.cat-animation {
    width: 220px !important;
    height: 220px !important;
  }
  
  /* Readjust Cat Eyes for 220px size */
  #stage0 #eyeLeft {
    top: -8px !important;
    right: 53px !important;
    transform: scale(0.6) !important;
  }
  
  #stage0 #eyeRight {
    top: -8px !important;
    right: 43px !important;
    transform: scale(0.6) !important;
  }
  
  .shell-logo {
    transform: scale(0.6);
    transform-origin: top center;
    margin-top: -30px !important;
    margin-bottom: -50px !important;
  }
}

.shell-btn {
  height: 55px;
  background: #1f2937;
  color: #fff;
  border: 2px solid #374151;
  border-radius: 50px;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  padding-left: 25px;
  transition: all 0.3s;
  box-shadow: 0 0 10px var(--accent), 0 0 20px rgba(96, 165, 250, 0.3);
  text-shadow: 0 0 5px rgba(255, 255, 255, 0.5);
  border-color: #60a5fa;
}

.shell-btn:hover {
  background: #374151;
  border-color: #60a5fa;
  transform: translateY(-2px);
  box-shadow: 0 8px 15px rgba(96, 165, 250, 0.2);
}

.shell-btn span.icon {
  font-size: 22px;
  margin-right: 15px;
  width: 30px;
  text-align: center;
}

.shell-divider {
  width: 300px;
  height: 1px;
  background: rgba(255, 255, 255, 0.1);
  margin: 6px 0;
  flex-shrink: 0;
}

.shell-profile {
  width: 300px;
  background: rgba(255, 255, 255, 0.05);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 16px;
  padding: 10px 20px;
  display: flex;
  align-items: center;
  gap: 15px;
  margin-bottom: 20px;
  flex-shrink: 0;
  opacity: 0;
  transition: opacity 0.3s ease;
}

#shellProfile .rank-badge {
  transform: scale(0.65);
  transform-origin: center;
  margin: -15px -10px; /* offset the physical space taken by scaled badge */
}

@media screen and (orientation: landscape) and (max-height: 600px) {
  .shell-profile {
    transform: scale(0.5); transform-origin: top center; margin-top: -35px !important;
    margin-bottom: -30px !important;
  }
  .shell-bottom-nav {
    margin-bottom: 20px !important;
  }
}

.shell-bottom-nav {
  width: 300px;
  background: rgba(31, 41, 55, 0.6);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 50px;
  height: 50px;
  display: flex;
  justify-content: space-around;
  align-items: center;
  margin-bottom: 50px;
  flex-shrink: 0;
}

.nav-item {
  font-size: 22px;
  color: #9ca3af;
  cursor: pointer;
}

/* Nav tooltip hover ghost text */
.nav-tooltip {
  position: relative;
}

.nav-tooltip::after {
  content: attr(data-tip);
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%) translateY(4px);
  background: rgba(15, 23, 42, 0.85);
  color: rgba(255, 255, 255, 0.7);
  font-size: 11px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 6px;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.25s ease, transform 0.25s ease;
  backdrop-filter: blur(6px);
  border: 1px solid rgba(255, 255, 255, 0.08);
  letter-spacing: 0.3px;
}

.nav-tooltip:hover::after {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* INLINE SCREENS & PHYSICAL GAME CONTAINER */
.inline-screen,
.phys-container {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 9000;
  background: rgba(17, 24, 39, 0.3);
  
  flex-direction: column;
}

#themeContainer {
  background: transparent !important;
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
}

.inline-screen.show {
  display: flex !important;
  opacity: 1 !important;
  visibility: visible !important;
  transition: opacity 0.3s ease;
}

.inline-screen.screen-exit-anim {
  animation: screenFadeOut 0.25s ease forwards !important;
}

@keyframes screenFadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}
@keyframes screenFadeOut {
  from { opacity: 1; }
  to   { opacity: 0; }
}

.inline-content {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  min-height: 0;
  padding: 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.lang-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  width: 100%;
  max-width: 300px;
}

#physGameArea {
  display: flex;
  width: 100%;
  height: calc(100% - 84px);
}

.phys-left {
  width: 50%;
  height: 100%;
  border-right: 2px solid var(--border);
  padding: 10px;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}

.phys-right {
  width: 50%;
  height: 100%;
  padding: 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  background: var(--panel);
  overflow-y: auto;
}

.phys-header-box {
  display: flex;
  width: 100%;
  margin-bottom: 10px;
  border-bottom: 2px solid var(--border);
  padding-bottom: 10px;
  align-items: center;
}

.p-score-box {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.p-name {
  font-weight: bold;
  color: var(--muted);
  margin-bottom: 5px;
}

.big-score {
  font-size: 40px;
  font-weight: 900;
  color: var(--ok);
  line-height: 1;
}

.status-text {
  font-size: 13px;
  color: var(--warn);
  min-height: 50px;
  font-weight: bold;
}

.phys-table-container {
  flex: 1;
  overflow-y: auto;
  width: 100%;
}

.phys-table {
  width: 100%;
  border-collapse: collapse;
}

.phys-table th {
  background: #111827;
  position: sticky;
  top: 0;
  padding: 10px;
  color: var(--accent);
  border-bottom: 2px solid var(--accent);
}

.phys-table td {
  padding: 5px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  text-align: center;
}



.phys-table input {
  width: 100%;
  text-align: center;
  font-weight: bold;
  background: transparent;
  border: none;
  color: inherit;
  font-size: 18px;
  text-transform: uppercase;
}

.phys-table input:focus {
  background: rgba(255, 255, 255, 0.1);
  outline: none;
}

.phys-table input.invalid {
  color: var(--danger);
  text-decoration: line-through;
}

/* x2 Toggle Button for Physical Game */
.btn-dbl {
  width: 28px;
  height: 24px;
  padding: 0;
  font-size: 10px;
  font-weight: bold;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--card);
  color: var(--muted);
  cursor: pointer;
  transition: all 0.2s;
}

.btn-dbl:hover {
  border-color: var(--warn);
  color: var(--warn);
}

.btn-dbl.active {
  background: var(--warn) !important;
  color: #000 !important;
  border-color: var(--warn);
}

.p1-dbl,
.p2-dbl {
  padding: 2px !important;
  width: 35px !important;
}

/* THEME STORE & EXTRAS */
.theme-content {
  padding: 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  overflow-y: auto;
  height: calc(100% - 84px);
}

.theme-grid {
  display: flex;
  gap: 15px;
  flex-wrap: wrap;
  justify-content: center;
  width: 100%;
}

.theme-btn {
  width: 140px;
  height: 80px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  font-weight: bold;
  cursor: pointer;
  border: 2px solid var(--border);
  background: linear-gradient(135deg, var(--card), var(--panel));
  color: var(--text);
}

.theme-btn:hover {
  border-color: var(--accent);
  transform: scale(1.05);
}

/* CUSTOM MODALS */
.custom-modal-overlay,
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 99999;
  display: none;
  place-items: center;
  
  overflow-y: auto;
  animation: overlayFadeIn 0.25s ease both;
}

@keyframes overlayFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes modalScaleFadeIn {
  from { opacity: 0; transform: scale(0.92); }
  to { opacity: 1; transform: scale(1); }
}

.modal-fade-out {
  animation: overlayFadeOut 0.25s ease forwards !important;
}
@keyframes overlayFadeOut {
  from { opacity: 1; }
  to { opacity: 0; }
}

.show-modal {
  display: grid !important;
}

.custom-modal,
.modal-box {
  background: var(--panel);
  border: 1px solid var(--border);
  padding: 25px;
  border-radius: 16px;
  width: 90%;
  max-width: 420px;
  max-height: 90vh;
  overflow-y: auto;
  text-align: center;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.7);
  color: var(--text);
  box-sizing: border-box;
  animation: modalScaleFadeIn 0.3s cubic-bezier(0.16, 1, 0.3, 1) both;
}

/* Landscape modal compact */
@media screen and (orientation: landscape) and (max-height: 500px) {
  .custom-modal,
  .modal-box {
    padding: 8px 12px;
    max-height: 95vh;
    border-radius: 10px;
  }
  .custom-modal h2,
  .modal-box h2 {
    font-size: 14px;
    margin-bottom: 5px;
    margin-top: 0;
  }
  #mpChooseMode > div:first-child {
    padding: 8px !important;
    margin-bottom: 8px !important;
  }
  #mpChooseMode > div:first-child > div:first-child {
    margin-bottom: 5px !important;
    gap: 5px !important;
  }
  #mpChooseMode label {
    font-size: 10px !important;
  }
  #mpChooseMode select {
    padding: 4px !important;
    margin-top: 2px !important;
  }
  #mpGameValue {
    font-size: 14px !important;
  }
  #mpCreateBtn {
    margin-bottom: 5px !important;
    padding: 8px !important;
    font-size: 12px !important;
  }
  #mpChooseMode > div:nth-child(3) {
    margin: 5px 0 !important;
    font-size: 10px !important;
  }
  #mpJoinCode {
    padding: 6px !important;
    font-size: 16px !important;
    letter-spacing: 2px !important;
  }
  #mpChooseMode > button:last-child {
    margin-top: 5px !important;
    padding: 8px !important;
    font-size: 12px !important;
  }
  .modal-box > button.btn--danger {
    margin-top: 10px !important;
    padding: 8px !important;
    font-size: 12px !important;
  }
}

.modal-btns {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin-top: 20px;
}

.dropdown-content {
  display: none;
  position: absolute;
  top: 100%;
  right: 0;
  left: auto;
  background-color: #1f2937 !important;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  flex-direction: column;
  z-index: 100;
  min-width: 200px;
  white-space: nowrap;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
}

.dropdown-content.show {
  display: flex;
}

.drop-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  white-space: nowrap;
}

.drop-row span {
  flex-shrink: 0;
  margin-right: 10px;
}

body.theme-light .dropdown-content,
body.theme-light .mobile-dropdown-content {
  background-color: #ffffff !important;
}

/* ANIMATIONS */
.show-anim {
  display: flex !important;
  animation: fadeContainer 4s forwards;
}

@keyframes fadeContainer {
  0% {
    opacity: 1;
  }

  85% {
    opacity: 1;
  }

  100% {
    opacity: 0;
  }
}

.last-move {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 50;
  border: 3px solid white;
  animation: blinkAnim 0.8s infinite;
}

.last-move-bonus {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 50;
  border: 3px dashed var(--warn);
  animation: dashAnim 0.6s infinite;
}

@keyframes blinkAnim {
  0% {
    border-color: white;
  }

  50% {
    border-color: transparent;
  }

  100% {
    border-color: white;
  }
}

@keyframes dashAnim {
  0% {
    border-color: var(--warn);
  }

  50% {
    border-color: transparent;
  }

  100% {
    border-color: var(--warn);
  }
}

#streakAnimOverlay {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 10000;
  pointer-events: none;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

#streakAnimOverlay img {
  max-width: 80vw;
  max-height: 80vh;
  width: auto;
  height: auto;
  filter: drop-shadow(0 0 20px rgba(0, 0, 0, 0.8));
  display: block;
}

/* --- ARKA PLANLAR (BACKGROUNDS) --- */

/* Arka plan seÃ¯Â¿Â½ildiÃ¯Â¿Â½inde main-area resimle kaplanÃ¯Â¿Â½r */
body.bg-space .main-area {
  background: url('space1.png') no-repeat center center !important;
  background-size: cover !important;
}

body.bg-forest .main-area {
  background: url('forest1.png') no-repeat center center !important;
  background-size: cover !important;
}

body.bg-stary .main-area {
  background: url('stary1.png') no-repeat center center !important;
  background-size: cover !important;
}

/* Arka plan resimli olduÃ¯Â¿Â½unda panonun okunabilirliÃ¯Â¿Â½ini artÃ¯Â¿Â½rmak iÃ¯Â¿Â½in kartÃ¯Â¿Â½n arkasÃ¯Â¿Â½nÃ¯Â¿Â½ biraz karartalÃ¯Â¿Â½m */
body.bg-space .board-card,
body.bg-forest .board-card,
body.bg-stary .board-card {
  background: rgba(30, 40, 55, 0.85);
  /* Hafif Ã¯Â¿Â½effaf koyu zemin */
  backdrop-filter: blur(5px);
  /* Arkadaki resmi bulanÃ¯Â¿Â½klaÃ¯Â¿Â½tÃ¯Â¿Â½rÃ¯Â¿Â½r */
  border: 1px solid rgba(255, 255, 255, 0.2);
}

/* --- THEME STORE PREVIEW --- */
.theme-divider {
  width: 100%;
  height: 1px;
  background: var(--border);
  margin: 15px 0;
}

.theme-preview-box {
  width: 100%;
  height: 450px;
  /* Adjust based on content */
  background: transparent;
  /* Changed from rgba(0,0,0,0.2) per user request to be clear */
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-top: 10px;
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  pointer-events: none;
  /* Make it non-interactive */
}

.theme-preview-content {
  transform: scale(0.65);
  transform-origin: center top;
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  gap: 20px;
  padding-top: 20px;
}


/* --- THEME ROW LAYOUT --- */
.theme-content-row-layout {
  display: flex;
  flex-direction: column;
  gap: 20px;
  width: 100%;
}

.theme-row-group {
  display: flex;
  flex-direction: row;
  /* Horizontal layout */
  align-items: center;
  justify-content: space-between;
  width: 100%;
  border: 1px solid var(--border);
  padding: 10px;
  border-radius: var(--radius);
  background: rgba(0, 0, 0, 0.2);
}

.theme-label-col {
  width: 120px;
  min-width: 120px;
  font-weight: bold;
  font-size: 1.1em;
  color: var(--accent);
  text-align: left;
  border-right: 1px solid var(--border);
  margin-right: 15px;
  padding-right: 10px;
  display: flex;
  align-items: center;
}

.theme-options-col {
  display: flex;
  flex: 1;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-start;
  align-items: center;
}

.theme-btn.small {
  padding: 8px 16px;
  font-size: 0.9em;
  min-width: 90px;
}

.theme-preview-container {
  margin-top: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px;
  background: transparent;
  /* Changed from rgba(0,0,0,0.1) */
}

.preview-header {
  width: 100%;
  text-align: center;
  margin-bottom: 10px;
  font-weight: bold;
  color: var(--text-muted);
}


/* --- VISUAL TWEAKS --- */
.theme-btn.small {
  padding: 6px 12px !important;
  /* Smaller padding */
  font-size: 0.8em !important;
  /* Smaller font */
  min-width: 80px !important;
  /* Smaller width */
  height: auto !important;
}

.theme-btn.small span {
  font-size: 16px !important;
  /* Smaller icon */
}


/* --- THEME PREVIEW SCALING --- */
.theme-preview-wrapper {
  transform: scale(0.6);
  /* Scale down to fit */
  transform-origin: top center;
  width: 1000px;
  /* Match cloned width */
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-top: 20px;
}



/* --- GLOBAL BACKGROUNDS FINAL OVERRIDE --- */
body.bg-space,
body.bg-forest,
body.bg-sunrise {
  background-repeat: no-repeat !important;
  background-position: center center !important;
  background-size: cover !important;
  background-attachment: fixed !important;

  --bg: transparent !important;
  --panel: rgba(31, 41, 55, 0.85) !important;
  --card: rgba(55, 65, 81, 0.85) !important;
  --border: rgba(255, 255, 255, 0.2) !important;
}

/* space.png removed Ã¢â‚¬â€ space background uses initSkyBackground canvas + gradient */

body.bg-forest {
  background-image: url('forest.png') !important;
}

body.bg-stary {
  background-image: url('stary.png') !important;
}

/* Sunrise handles its own background via .landscape, so no image here */

/* Remove old specific restrictions if they exist */
body.bg-space .main-area,
body.bg-forest .main-area,
body.bg-stary .main-area,
body.bg-sunrise .main-area {
  background: none !important;
}



/* --- SHOOTING STAR BACKGROUND --- */
body.bg-space {
  background: radial-gradient(ellipse at bottom, #1b2735 0%, #090a0f 100%);
  min-height: 100vh;
  /* overflow:hidden removed Ã¢â‚¬â€ sky bg uses position:fixed, not overflow clipping */
}

.night {
  position: absolute;
  /* Changed to absolute to overlay/underlay */
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  transform: rotateZ(45deg);
  z-index: -1;
  /* Ensure behind content */
  pointer-events: none;
}

.shooting_star {
  position: absolute;
  left: 50%;
  top: 50%;
  height: 2px;
  background: linear-gradient(-45deg, rgba(95, 145, 255, 1), rgba(0, 0, 255, 0));
  border-radius: 999px;
  filter: drop-shadow(0 0 6px rgba(105, 155, 255, 1));
  animation: tail 3000ms ease-in-out infinite, shooting 3000ms ease-in-out infinite;
}

.shooting_star::before {
  content: '';
  position: absolute;
  top: calc(50% - 1px);
  right: 0;
  height: 2px;
  background: linear-gradient(-45deg, rgba(0, 0, 255, 0), rgba(95, 145, 255, 1), rgba(0, 0, 255, 0));
  transform: translateX(50%) rotateZ(45deg);
  border-radius: 100%;
  animation: shining 3000ms ease-in-out infinite;
}

.shooting_star::after {
  content: '';
  position: absolute;
  top: calc(50% - 1px);
  right: 0;
  height: 2px;
  background: linear-gradient(-45deg, rgba(0, 0, 255, 0), rgba(95, 145, 255, 1), rgba(0, 0, 255, 0));
  transform: translateX(50%) rotateZ(-45deg);
  /* Corrected from SCSS logic error comment */
  border-radius: 100%;
  animation: shining 3000ms ease-in-out infinite;
}

@keyframes tail {
  0% {
    width: 0;
  }

  30% {
    width: 100px;
  }

  100% {
    width: 0;
  }
}

@keyframes shining {
  0% {
    width: 0;
  }

  50% {
    width: 30px;
  }

  100% {
    width: 0;
  }
}

@keyframes shooting {
  0% {
    transform: translateX(0);
  }

  100% {
    transform: translateX(300px);
  }
}

@keyframes sky {
  0% {
    transform: rotate(45deg);
  }

  100% {
    transform: rotate(45 + 360deg);
  }
}


/* --- SHOOTING STAR DELAY FIX --- */
.shooting_star {
  animation-delay: var(--star-delay) !important;
}

.shooting_star::before,
.shooting_star::after {
  animation-delay: var(--star-delay) !important;
}


/* --- SUNRISE BACKGROUND --- */
:root {
  --v1: #be91c6;
  --v2: #8a65cc;
  --v3: #5e30d9;
  --transparentv3: #5e30d900;
  --v4: #3b1895;
  --s1: #fea798;
  --s2: #ff846e;
  --cloud: #fea798;
}

.landscape {
  position: fixed !important;
  /* Force background behavior */
  top: 0;
  left: 0;
  width: 100%;
  height: 100vh;
  background-image: linear-gradient(var(--v1), var(--s1), var(--v1));
  z-index: -1 !important;
  /* Behind content */
  overflow: hidden;
  pointer-events: none;
}

.landscape *,
.landscape *:before,
.landscape *:after {
  position: absolute;
}

.front {
  z-index: 1;
  bottom: 0;
  /* Stays at bottom but elements inside might need adjustment */
  left: 0;
  right: 0;
}

.mountain {
  border-radius: 180% 80% 0% 0%/60vmin 60vmin 0% 0%;
  width: 40vmin;
  height: 30vmin;
  bottom: 25%;
  /* Lowered from 50% to 25% (Horizon at 75%) */
  left: -10vmin;
  background: var(--s1);
  background-image: linear-gradient(var(--v1), var(--v2) 30%, var(--v3));
  box-shadow: inset -10px 0 10px -10px var(--s1);
}

.mountain:before {
  content: '';
  bottom: 0;
  width: inherit;
  height: inherit;
  background: inherit;
  border-radius: inherit;
  transform-origin: bottom center;
  transform: scaleX(1) scaleY(-0.6);
  filter: blur(3px);
}

.mountain-2 {
  left: 5vmin;
  height: 15vmin;
  width: 40vmin;
  box-shadow: inset -15px 0 10px -14px var(--s1);
  border-radius: 120% 50% 0% 0%/25vmin 25vmin 0% 0%;
  background-image: linear-gradient(var(--v3), var(--v4));
}

.mountain-3 {
  border-radius: 80% 0% 0 0/100% 100% 0 0;
  right: -85vmin;
  width: 100vmin;
  left: auto;
  height: 12vmin;
  color: var(--v3);
  background-image: linear-gradient(var(--s1), var(--v4));
  box-shadow: inset 15px 0 10px -10px var(--s1);
}

.mountain-3:after {
  content: '';
  border-radius: 60% 0 0 0/100% 0 0 0;
  background: inherit;
  width: 100%;
  height: 0;
  bottom: 0;
  right: 20%;
}

.lotus {
  width: 10vmin;
  height: 5vmin;
  background: conic-gradient(var(--v3) 0deg 40deg,
      var(--transparentv3) 50deg 70deg,
      var(--v3) 80deg);
  border-radius: 50%;
}

.lotus-1 {
  bottom: 10vmin;
  right: 5vmin;
  width: 20vmin;
}

.lotus-2 {
  bottom: 20vmin;
  right: 15vmin;
  height: 3vmin;
  transform: skew(-10deg);
  opacity: 0.5;
  mix-blend-mode: multiply;
}

.lotus-3 {
  bottom: 10vmin;
  right: 35vmin;
  transform: rotate(180deg) skew(-20deg);
  opacity: 0.8;
  width: 15vmin;
}

.cloud {
  width: 80vmin;
  height: 6vmin;
  background: currentcolor;
  color: var(--cloud);
  top: 24vmin;
  left: 20vmin;
  border-radius: 50%;
  box-shadow: 30vmin 0.5vmin 0 -1vmin currentcolor,
    -25vmin 0 0 -0.6vmin currentcolor;
  opacity: 0.3;
  transform: translate3d(-150vmin, 0, 0);
  animation: clouds 120s infinite;
  animation-delay: -10s;
}

@keyframes clouds {
  50% {
    transform: translate3d(0, 0, 0);
  }

  100% {
    transform: translate3d(150vmin, 0, 0);
  }
}

.cloud-1 {
  left: 60vmin;
  top: 15vmin;
  opacity: 0.2;
  filter: blur(1px);
  animation-delay: 0;
  animation-duration: 100s;
}

.water {
  top: 75%;
  /* Lowered from 50% to 75% */
  bottom: 0;
  left: 0;
  right: 0;
  background: linear-gradient(#fea79855, var(--v2));
  overflow: hidden;
  box-shadow: inset 0 1px 4px -3px white;
}

.stone {
  bottom: -5vh;
  /* This is relative to container, seems ok */
  left: 0;
  height: 20vmin;
  width: 40vmin;
  background: var(--v4);
  box-shadow: inset 0 0 20px -5px rgba(0, 0, 0, 0.2);
  border-radius: 0% 200% 0 0/0% 200%;
}

.stone:after {
  content: '';
  background: var(--v3);
  width: 100%;
  height: 100%;
  right: -15%;
  border-radius: inherit;
  z-index: -1;
  transform: scaleX(1.3) skew(10deg);
  box-shadow: inset 0 0 20px -5px rgba(0, 0, 0, 0.4);
}

.grass {
  height: 40vmin;
  width: 10vmin;
  border-radius: 0 60% 0 0/0 100% 0 0;
  bottom: 0;
  border-right: 5px solid var(--v4);
  box-shadow: 1px 0 0 var(--s1);
  filter: drop-shadow(-0.5vmin 6vmin 0 var(--s2)) drop-shadow(-4.5vmin 10vmin 0 var(--v3));
}

.grass-1 {
  left: 14vmin;
  bottom: -2vmin;
  transform: scaleX(-1);
  box-shadow: 2px 0 0 var(--v4);
  border-color: var(--v3);
  filter: drop-shadow(-1vmin 5vmin 0 var(--v3)) drop-shadow(-80vmin 5vmin 0 var(--v4));
}

.grass-2 {
  right: 0;
  left: auto;
  height: 20vmin;
  bottom: -2vmin;
  transform: scaleX(-1);
}

.sun {
  background: white;
  border-radius: 50%;
  width: 20vmin;
  height: 20vmin;
  left: 28%;
  /* MOVED LEFT - Approx gap between strips and board */
  top: 100%;
  transform: translate3d(0, 0, 0);
  animation: rise 20s infinite;
  box-shadow: 0 0 10px white;
}

.reed {
  height: 40vmin;
  width: 0.5vmin;
  bottom: 0;
  left: 10vmin;
  color: var(--v4);
  background: currentColor;
  transform-origin: bottom center;
  transform: rotate(4deg);
  box-shadow: inset -1px 0 0 var(--s2), -6vmin 3vmin 0 0, 80vmin 0 0 0;
  animation: verticalise 20s infinite;
}

.reed-1 {
  color: var(--s2);
  left: 15vmin;
  height: 50vmin;
  bottom: -5vmin;
  transform: rotate(-2deg);
  animation: verticalise-1 20s infinite;
  box-shadow: inset -1px 0 0 var(--s1), 6vmin 13vmin 0 0 var(--s1),
    80vmin 10vmin 0 0 var(--v3);
}

.reed:after {
  content: '';
  width: 1.5vmin;
  height: 10vmin;
  background: currentcolor;
  border-radius: 0.75vmin;
  top: 0;
  left: -0.5vmin;
  box-shadow: inherit;
}

@keyframes verticalise {

  0%,
  10% {
    transform: rotate(4deg);
  }

  30%,
  70% {
    transform: rotate(0);
  }
}

@keyframes verticalise-1 {

  0%,
  10% {
    transform: rotate(-2deg);
  }

  45%,
  70% {
    transform: rotate(0) translateY(-6vmin);
  }
}

@keyframes rise {
  100% {
    transform: translate3d(0, -100vh, 20vmin);
  }
}

@keyframes rise-reflection {
  30% {
    opacity: 0;
    transform: translate3d(0, 5vmin, 0);
  }

  100% {
    opacity: 0;
    transform: translate3d(0, 80vmin, 0);
  }
}

.sun-container {
  overflow: hidden;
  width: 100%;
  height: 75%;
  /* Increased from 50% to match new horizon */
}

.sun-container-1:after {
  content: '';
  left: 0;
  right: 0;
  top: 0;
  bottom: 0;
  background: radial-gradient(circle at 60% 100%, var(--s2), transparent);
  animation: fade 20s infinite;
  mix-blend-mode: color-burn;
}

@keyframes fade {
  10% {
    opacity: 1;
  }

  30%,
  70% {
    opacity: 0;
  }
}

.sun-container-reflection {
  top: 75%;
  /* Lowered from 50% to 75% */
  background: radial-gradient(circle at 60% 0%, var(--s2), transparent);
}

.sun-container-reflection .sun {
  background: linear-gradient(white, rgba(255, 255, 255, 0));
  box-shadow: none;
  filter: blur(5px);
  opacity: 1;
  top: 0;
  transform: translate3d(0, -20vmin, 0);
  animation-name: rise-reflection;
}

.light {
  height: 0.5vmin;
  width: 20vmin;
  background: white;
  left: 20%;
  right: 0;
  margin: auto;
  top: calc(50% + 1vmin);
  /* Ideally re-center to 75% but let's test */
  animation: light 20s infinite;
  opacity: 0;
  transform: scaleX(0.1) translate3d(0%, 0, 0);
  border-radius: 0.25vh;
  filter: blur(1px);
}

@keyframes light {
  5% {
    opacity: 1;
    transform: scaleX(1);
  }

  10% {
    opacity: 0.6;
    transform: scaleX(1) translate3d(5%, 0, 0);
  }

  15% {
    opacity: 0.6;
    transform: scaleX(1) translate3d(-5%, 0, 0);
  }

  20% {
    opacity: 0;
    transform: scaleX(0.1) translate3d(0, 0, 0);
  }
}

.light-1 {
  top: calc(50% + 2vmin);
  animation-delay: 0.5s;
}

.light-2 {
  top: calc(50% + 3vmin);
  width: 18vmin;
  animation-delay: 1s;
}

.light-3 {
  top: calc(50% + 4vmin);
  width: 18vmin;
  animation-delay: 1.5s;
}

.light-4 {
  top: calc(50% + 5vmin);
  width: 16vmin;
  animation-delay: 2s;
}

.light-5 {
  top: calc(50% + 8vmin);
  width: 14vmin;
  animation-delay: 2.5s;
}

.light-6 {
  top: calc(50% + 9vmin);
  width: 10vmin;
  animation-delay: 3s;
}

.light-7 {
  top: calc(50% + 7vmin);
  width: 12vmin;
  animation-delay: 3.5s;
}

.splash {
  width: 8vmin;
  height: 3vmin;
  border: 2px solid var(--s1);
  box-shadow: 0 0 2px var(--s1);
  border-radius: 50%;
  bottom: 5vmin;
  left: 70%;
  animation: splash 9s infinite;
  transform: scale(0);
}

.splash-stone {
  bottom: 15vh;
  left: -3vmin;
  height: 10vmin;
  width: 30vmin;
}

.splash-4 {
  bottom: 5vmin;
  left: auto;
  bottom: 15vmin;
  right: -2vmin;
}

@keyframes splash {

  50%,
  100% {
    transform: scale(1);
    opacity: 0;
  }
}

.delay-1 {
  animation-delay: 1s;
}

.delay-2 {
  animation-delay: 2s;
}

.delay-3 {
  animation-delay: 3s;
}

.delay-4 {
  animation-delay: 4s;
}

.delay-5 {
  animation-delay: 5s;
}

/* Stage 2 Transparency Force Fix */
#stage2 .main-area,
#stage2 #battleCard {
  background: transparent !important;
  box-shadow: none !important;
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
  box-shadow: none !important;
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
  border: none !important;
}

/* Ensure Grid ITSELF is transparent in Stage 2 */
#stage2 .grid {
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
  justify-content: center !important;
}

#stage2 .main-area:before,
#stage2 .main-area:after,
#stage2 #battleCard:before,
#stage2 #battleCard:after {
  display: none !important;
  content: none !important;
  background: transparent !important;
}

#stage2 .card-header {
  background: var(--sidebar-bg) !important;
  border-radius: 6px;
  padding: 10px;
}

/* Battle Grid Special */
.battle-grid .cell {
  /* background: transparent !important; */
  /* Make cells transparent to reveal forest */
  border: 1px solid rgba(255, 255, 255, 0.1);
  /* Add light border to define grid */
}




.delay-6 {
  animation-delay: 6s;
}

/* --- FALLING LEAVES (FOREST) --- */
.falling-leaves {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 100%;
  max-width: 100%;
  height: 100%;
  transform: translate(-50%, 0);
  z-index: 10;
  pointer-events: none;
  overflow: hidden;
}

.leaf-scene {
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  width: 100%;
  transform-style: preserve-3d;
}

.leaf-scene div {
  position: absolute;
  top: 0;
  left: 0;
  width: 20px;
  height: 20px;
  background: url('leaf.svg') no-repeat;
  background-size: 100%;
  transform-style: preserve-3d;
  backface-visibility: visible;
}

/* --- NEW CSS LEAF BACKGROUND --- */
.leaf-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    overflow: hidden;
    z-index: 1;
}

.css-leaf {
    position: absolute;
    top: -50px;
    width: 25px;
    height: 25px;
    background: url('leaf.svg') no-repeat center/contain;
    animation: fall linear infinite;
    will-change: transform;
    left: var(--start-x);
    animation-duration: var(--dur);
    animation-delay: var(--delay);
}

@keyframes fall {
    0% {
        transform: translate3d(0, 0, 0) rotate3d(1, 1, 1, 0deg) scale(var(--scale));
        opacity: 0;
    }
    5% {
        opacity: 1;
    }
    25% {
        transform: translate3d(var(--swing), 25vh, 50px) rotate3d(1, 1, 0, 90deg) scale(var(--scale));
    }
    50% {
        transform: translate3d(calc(var(--swing) * -0.5), 50vh, 100px) rotate3d(0, 1, 1, 180deg) scale(var(--scale));
    }
    75% {
        transform: translate3d(var(--swing), 75vh, 50px) rotate3d(1, 0, 1, 270deg) scale(var(--scale));
    }
    95% {
        opacity: 1;
    }
    100% {
        transform: translate3d(0, 110vh, 0) rotate3d(1, 1, 1, 360deg) scale(var(--scale));
        opacity: 0;
    }
}

/* --- STREAK ANIMATION CENTERED --- */
#streakAnimOverlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100vw;
  height: 100vh;
  transform: none;
  pointer-events: none;
  z-index: 9999;
  opacity: 0;
  transition: opacity 0.3s;
  display: flex;
  align-items: center;
  justify-content: center;
}

#streakAnimOverlay.show-anim {
  opacity: 1;
}

#streakAnimOverlay img {
  width: auto;
  max-width: 90vw;
  height: auto;
  min-width: 300px;
  object-fit: contain;
}

/* Mobile portrait: ensure streak anim stays centered and fits screen */
@media screen and (max-width: 1024px) and (orientation: portrait) {
  #streakAnimOverlay img {
    min-width: unset;
    max-width: 90vw;
    max-height: 40vh;
  }
}

/* --- PHYSICAL GAME TABLE STYLES --- */
#tblPhysScore td,
#tblPhysScore th {
  border: 1px solid rgba(100, 116, 139, 0.5);
  padding: 4px 8px;
}

#tblPhysScore td input {
  border: 1px solid rgba(100, 116, 139, 0.3);
  background: rgba(30, 41, 59, 0.8);
}

#tblPhysScore tr:nth-child(odd) td {
  background: rgba(51, 65, 85, 0.3);
}

#tblPhysScore tr:nth-child(even) td {
  background: rgba(30, 41, 59, 0.3);
}

/* --- LIGHT & HAND THEME WHITE TEXT OVERRIDES --- */
/* Topbar buttons and text (except Menu and SÃ¯Â¿Â½fÃ¯Â¿Â½rla which are already white) */
body.theme-light .topbar .btn,
body.theme-light .topbar select,
body.theme-light .topbar span,
body.theme-hand .topbar .btn,
body.theme-hand .topbar select,
body.theme-hand .topbar span {
  color: white !important;
}

/* Sidebar strips (Ã¯Â¿Â½eritler) */
body.theme-light .sidebar,
body.theme-light .sidebar .strip,
body.theme-light .sidebar .cell,
body.theme-light .sidebar h3,
body.theme-hand .sidebar,
body.theme-hand .sidebar .strip,
body.theme-hand .sidebar .cell,
body.theme-hand .sidebar h3 {
  color: white !important;
}

/* Alerts and custom modals */
body.theme-light .custom-modal-overlay,
body.theme-light .custom-modal-overlay *,
body.theme-light .custom-alert-box,
body.theme-light .custom-alert-box *,
body.theme-light #customAlert,
body.theme-light #customAlert *,
body.theme-hand .custom-modal-overlay,
body.theme-hand .custom-modal-overlay *,
body.theme-hand .custom-alert-box,
body.theme-hand .custom-alert-box *,
body.theme-hand #customAlert,
body.theme-hand #customAlert * {
  color: white !important;
}

/* Stage 2 - Score table */
body.theme-light #stage2 .score-table,
body.theme-light #stage2 .score-table th,
body.theme-light #stage2 .score-table td,
body.theme-hand #stage2 .score-table,
body.theme-hand #stage2 .score-table th,
body.theme-hand #stage2 .score-table td {
  color: white !important;
}

/* Stage 2 - Info panel (except AI which stays yellow via --warn) */
body.theme-light #stage2 .info-panel,
body.theme-light #stage2 .log-box,
body.theme-light #battleCard .card-header,
body.theme-hand #stage2 .info-panel,
body.theme-hand #stage2 .log-box,
body.theme-hand #battleCard .card-header {
  color: white !important;
}

/* Mini game text */
body.theme-light #miniGameBox,
body.theme-light #miniGameBox h2,
body.theme-light #miniGameBox p,
body.theme-light #miniGameBox span,
body.theme-hand #miniGameBox,
body.theme-hand #miniGameBox h2,
body.theme-hand #miniGameBox p,
body.theme-hand #miniGameBox span {
  color: white !important;
}

/* Dropdown content */
body.theme-light .dropdown-content,
body.theme-light .dropdown-content span,
body.theme-hand .dropdown-content,
body.theme-hand .dropdown-content span {
  color: white !important;
}

/* Modal overlays - comprehensive selectors */
body.theme-light #modalOverlay,
body.theme-light #modalOverlay *,
body.theme-light .modal-overlay,
body.theme-light .modal-overlay *,
body.theme-light .modal-box,
body.theme-light .modal-box *,
body.theme-light #modalContent,
body.theme-light #modalContent *,
body.theme-hand #modalOverlay,
body.theme-hand #modalOverlay *,
body.theme-hand .modal-overlay,
body.theme-hand .modal-overlay *,
body.theme-hand .modal-box,
body.theme-hand .modal-box *,
body.theme-hand #modalContent,
body.theme-hand #modalContent * {
  color: white !important;
}

/* Mini game - comprehensive selectors */
body.theme-light [id*="mini"],
body.theme-light [id*="mini"] *,
body.theme-light [class*="mini"],
body.theme-light [class*="mini"] *,
body.theme-hand [id*="mini"],
body.theme-hand [id*="mini"] *,
body.theme-hand [class*="mini"],
body.theme-hand [class*="mini"] * {
  color: white !important;
}

/* Preserve colored elements */
body.theme-light .btn--ok,
body.theme-hand .btn--ok,
body.theme-light .btn--danger,
body.theme-hand .btn--danger {
  color: white !important;
}

/* ============================================
   MOBILE PORTRAIT LAYOUT
   ============================================ */

/* Desktop: Hide mobile-only elements */
.mobile-menu-buttons {
  display: none;
}

.mobile-strips-container {
  display: none;
}

/* Mobile Portrait Mode */
@media screen and (max-width: 1024px) and (orientation: portrait) {

  /* Show mobile menu buttons */
  .mobile-menu-buttons {
    display: flex !important;
    flex-direction: column;
    gap: 5px;
    width: 100%;
    align-items: center;
  }

  body.stage2-active .mobile-menu-buttons {
      display: none !important;
  }

  /* Mobile Menu Button Style */
  .mobile-menu-btn {
    width: 52px;
    min-height: 42px;
    padding: 4px;
    font-size: 9px;
    border-radius: 6px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    background: var(--card);
    border: 1px solid var(--border);
    color: var(--text);
    cursor: pointer;
  }

  .mobile-menu-btn .icon {
    font-size: 15px;
  }

  .mobile-menu-btn .label {
    font-size: 7px;
    white-space: nowrap;
  }

  .mobile-menu-btn.btn--danger {
    background: var(--danger);
    color: white;
  }

  .mobile-menu-btn.btn--ok {
    background: var(--ok);
    color: white;
  }

  .mobile-menu-btn.btn--info {
    background: var(--accent);
    color: white;
  }

  .mobile-menu-btn:disabled {
    opacity: 0.5;
  }

  /* Mobile Dropdown */
  .mobile-dropdown-content {
    position: absolute;
    left: 55px;
    top: 0;
    background-color: #1f2937 !important;
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 6px;
    z-index: 100;
    min-width: 100px;
  }

  /* Show mobile strips container */
  .mobile-strips-container {
    display: flex !important;
    flex-wrap: wrap;
    gap: 4px;
    justify-content: center;
    padding: 8px;
    background: var(--sidebar-bg);
    border-radius: 8px;
    width: 100%;
    max-height: 60vh;
    overflow-y: visible;
    border: 1px solid var(--border);
  }

  /* Hide topbar on mobile */
  .topbar {
    display: none !important;
  }

  /* EXCEPTION: Keep topbar visible in Theme Store and Inline Screens on mobile */
  #themeContainer .topbar,
  #inlineFriendsScreen .topbar,
  #inlineStatsScreen .topbar,
  #settingsModalOverlay .topbar, #inlineLegalScreen .topbar {
    display: flex !important;
    position: sticky;
    top: 0;
    z-index: 1000;
    background: var(--panel);
  }

/* Hide stats button globally in stage 1 */
body.stage1-active #btnStats,
body.stage1-active button[onclick*="openStatsModal"] {
  display: none !important;
}

/* Hide topbar, show mobile sidebar menu */
  .topbar {
    display: none !important;
  }

  /* Stage 1: Force html+body to shrink-wrap content on mobile portrait */
  /* NOTE: stage1-active class doesn't exist in JS, so we use :not(.stage2-active) */
  html:has(body:not(.stage2-active)),
  body:not(.stage2-active) {
    height: auto !important;
    min-height: unset !important;
    overflow-x: hidden !important;
  }

  /* Stage 1 Layout: [Menu Left] [Board Right] */
  #stage1.layout {
    display: grid !important;
    grid-template-columns: auto 1fr !important;
    grid-template-rows: 1fr !important;
    height: 100vh !important;
    max-height: 100vh !important;
    min-height: unset !important;
    overflow: hidden !important;
    padding-bottom: 0 !important;
  }

  /* Mobile Menu - Left Side with scroll */
  #stage1 .sidebar {
    grid-column: 1;
    grid-row: 1;
    width: auto;
    min-width: unset;
    max-width: 80px;
    padding: 8px;
    gap: 6px;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    -webkit-overflow-scrolling: touch;
    display: flex;
    flex-direction: column;
    align-items: center;
    z-index: 200;
    position: relative;
    height: 100% !important;
    max-height: 100vh !important;
  }

  /* Hide "ÅžERÄ°TLER" heading in sidebar on mobile */
  #stage1 .sidebar>h3 {
    display: none;
  }

  /* Hide strip list from sidebar on mobile */
  #stage1 .sidebar>.strips-list {
    display: none !important;
  }

  /* Hide mpInfoPanel in sidebar if present */
  #stage1 .sidebar>#mpInfoPanel {
    display: none;
  }
  /* Main area - right side */
  #stage1 .main-area {
    grid-column: 2;
    grid-row: 1;
    display: flex;
    flex-direction: column;
    padding: 5px;
    overflow-y: auto;
    overflow-x: hidden;
    align-items: center;
    justify-content: flex-start;
    min-width: 0;
    height: 100% !important;
  }

  /* Board card */
  #stage1 .board-card {
    flex-shrink: 1;
    width: 100%;
    max-width: 100%;
    overflow: hidden; /* Fix 3D bounding box overflow */
    margin-bottom: 10px;
  }

  /* Mobile Strips Container - Below Board */
  #stage1 .main-area::after {
    /* Placeholder for strips that will be moved via JS */
    content: "";
  }
}

/* Mobile Menu Buttons - Create visible buttons for mobile menu */
@media screen and (max-width: 1024px) and (orientation: portrait) {

  /* Mobile Menu Buttons Style */
  .mobile-menu-btn {
    width: 60px;
    height: 40px;
    padding: 5px;
    font-size: 10px;
    border-radius: 6px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    background: var(--card);
    border: 1px solid var(--border);
    color: var(--text);
    cursor: pointer;
  }

  .mobile-menu-btn:hover {
    border-color: var(--accent);
  }

  .mobile-menu-btn .icon {
    font-size: 18px;
  }

  .mobile-menu-btn .label {
    font-size: 8px;
    white-space: nowrap;
  }

  /* Strips Container for Mobile - Below Board */
  .mobile-strips-container {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    justify-content: center;
    padding: 10px;
    background: var(--sidebar-bg);
    border-radius: 8px;
    width: 100%;
    max-height: 60vh;
    overflow-y: visible;
  }

  .mobile-strips-container .strip-item {
    width: fit-content;
  }

  /* Mobile Select Styles */
  .mobile-menu-select-wrapper {
    display: flex;
    flex-direction: column;
    width: 90%;
    max-width: 70px;
    gap: 2px;
    margin-bottom: 5px;
  }

  .mobile-menu-select-wrapper .label {
    font-size: 8px;
    color: var(--muted);
    text-align: center;
    font-weight: bold;
  }

  .mobile-menu-select {
    width: 100%;
    max-width: 100%;
    background: var(--card);
    color: var(--text);
    border: 1px solid var(--border);
    font-size: 10px;
    padding: 4px;
    border-radius: 4px;
    border-radius: 4px;
    font-size: 10px;
    padding: 2px;
    text-align: center;
    height: 24px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  /* Stage 2 (Battle) Mobile Layout */
  body.stage2-active #stage2.layout {
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow-y: auto;
    padding: 5px;
    gap: 10px;
  }

  #stage2 .sidebar {
    display: flex !important; /* Force column layout for BÃ„Â°LGÃ„Â° EKRANI in portrait */
    flex-direction: column !important;
    flex-wrap: nowrap !important;
    align-items: center !important;
    justify-content: flex-start !important;
    width: 100% !important;
    gap: 6px;
  }

  #stage2 .main-area {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
  }

  #stage2 #battleCard {
    width: 100%;
    max-width: 100%;
  }

  /* Adjust grid for battle on mobile */
  /* Adjust grid for battle on mobile */
  #gridBattle {
    justify-content: center;
  }
}

/* Ensure gridBattle has display grid by default */
#gridBattle {
  display: grid;
  justify-content: center;
  align-content: center;
  gap: 1px;
  transition: box-shadow 0.3s ease;
}

/* Player turn highlight for gridBattle headers */
#gridBattle.player-turn .cell.head {
  color: var(--ok) !important;
  text-shadow: 0 0 5px var(--ok) !important;
  transition: color 0.3s ease, text-shadow 0.3s ease;
}

/* EMERGENCY LAYOUT FIXES Ã¢â‚¬â€ stage0 sizing now in main CSS (#stage0 rule at top) */

.shell-menu {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 300px;
  margin: 0 0 10px 0; /* Let flex-end push it */
}

/* FIXES FOR MOBILE STAGE 2 & DROPDOWNS (28.12.2025 23:00) */
@media screen and (max-width: 1024px) and (orientation: portrait) {

  /* Bug #3: Ensure dropdown is visible above board */
  .mobile-dropdown-content {
    position: absolute;
    top: 100%;
    bottom: auto !important;
    left: 0 !important;
    right: auto !important;
    background-color: #1f2937 !important;
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 10px;
    z-index: 9999;
    min-width: 150px;
    box-shadow: 0 -5px 15px rgba(0, 0, 0, 0.3);
  }

  /* Bug #5: Compact header height for all board headers */
  .card-header,
  .board-header,
  #stage1 .card-header,
  #stage2 .card-header {
    padding: 4px 8px !important;
    min-height: 28px !important;
  }

  .card-header h2,
  .board-header h2 {
    font-size: 13px !important;
    margin: 0 !important;
  }

  /* Bug #6: Stage 2 - Sidebar BELOW main board (CRITICAL) */
  body.stage2-active #stage2.layout {
    /* display: flex !important; REMOVED to prevent ghosting */
    flex-direction: column !important;
    height: auto !important;
    min-height: 100%;
    overflow-y: auto !important;
    padding: 5px !important;
    gap: 8px !important;
  }

  body.stage2-active #stage2.layout>.main-area {
    order: 1 !important;
    flex: 0 0 auto !important;
    width: 100% !important;
  }

  body.stage2-active #stage2.layout>.sidebar {
    order: 2 !important;
    display: flex !important;
    flex-direction: column !important;
    width: 100% !important;
    margin-bottom: 60px !important;
  }
}

/* Ensure #stage1 sidebar dropdown is visible on all platforms */
#stage1 .sidebar {
  overflow-y: auto !important;
  overflow-x: hidden !important;
  z-index: 999;
}



/* FIX: Ensure dynamic background layer is always behind content */
#bg-layer {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: -1 !important;
  pointer-events: none;
}

/* FORCE TEXT VISIBILITY FOR SPACE BG */
body.bg-space {
  --text: #f3f4f6 !important;
  --muted: #9ca3af !important;
  color: white !important;
}

body.bg-space .sidebar,
body.bg-space .stage2-box,
body.bg-space .score-table,
body.bg-space .info-area,
body.bg-space h3,
body.bg-space span,
body.bg-space div {
  color: white !important;
}

body.bg-space .btn {
  color: white !important;
  border-color: rgba(255, 255, 255, 0.3);
}

/* NEON MENU BUTTONS */
#mainMenuButtons .shell-btn {
  background: transparent !important;
  color: white !important;
  border: 1px solid rgba(255, 255, 255, 0.6);
  box-shadow: 0 0 8px rgba(0, 255, 255, 0.6), inset 0 0 5px rgba(0, 255, 255, 0.2);
  text-shadow: 0 0 8px rgba(0, 255, 255, 0.8);
  transition: all 0.3s ease;
}

#mainMenuButtons .shell-btn:hover {
  background: rgba(0, 255, 255, 0.1) !important;
  border-color: #00ffff;
  box-shadow: 0 0 15px #00ffff, inset 0 0 10px rgba(0, 255, 255, 0.4);
  transform: scale(1.05);
}

/* PHYSICAL GAME FIXES FOR SPACE BG */
body.bg-space .phys-container {
  color: white !important;
}

body.bg-space .phys-header-box,
body.bg-space .p-score-box,
body.bg-space .phys-table-container {
  background: rgba(0, 0, 0, 0.5) !important;
  border: 1px solid rgba(255, 255, 255, 0.3);
  box-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
}

body.bg-space .phys-table th,
body.bg-space .phys-table td {
  color: white !important;
  border-color: rgba(255, 255, 255, 0.3) !important;
  background: transparent !important;
}

body.bg-space .status-text {
  color: #fbbf24 !important;
  /* Keep status visible (gold) */
  text-shadow: 0 0 2px black;
}

body.bg-space #physQBox {
  color: black !important;
  /* Ensure text is visible on white box */
}

body.bg-space #physTimer {
  color: #fbbf24 !important;
  /* Keep timer gold */
}

/* --- TYPOGRAPHY SYSTEM (Based on tipografi.md) --- */
h1,
h2,
h3,
h4,
h5,
h6 {
  font-weight: 700;
  line-height: 1.2;
  /* Tighter line height for headings */
}

h1 {
  letter-spacing: -0.04em;
}

/* Very tight for main titles */
h2 {
  letter-spacing: -0.03em;
}

h3 {
  letter-spacing: -0.02em;
}

h4 {
  letter-spacing: -0.01em;
}

/* Readability for body text is default (0) */
p,
li,
span,
div {
  letter-spacing: 0;
}

/* --- UI REFINEMENTS (04.01.2026) --- */

/* 1. Hide Logo and Bottom Version */
#shellLogo,
.version-text {
  display: none !important;
}

/* 2. Horizontal Profile Layout (Compact) */
#shellProfile {
  flex-direction: row !important;
  width: auto !important;
  max-width: 95%;
  padding: 8px 16px !important;
  gap: 15px !important;
  justify-content: center;
}

.profile-info {
  display: flex !important;
  flex-direction: row !important;
  align-items: center !important;
  gap: 12px !important;
  text-align: left !important;
}

#profileName {
  margin: 0 !important;
  margin-right: 5px !important;
}

.profile-stats {
  display: flex !important;
  gap: 8px !important;
  margin-top: 0 !important;
}

/* 3. Equal Width Menu Buttons & Bottom Layout */
#mainMenuButtons {
  width: 320px !important;
  /* Fixed width for the menu container */
  max-width: 90%;

  /* Bottom Alignment Logic */
  margin-top: auto !important;
  /* Push to bottom */
  margin-bottom: 50px !important;
  /* Increase GAP from Profile as requested */
  margin-bottom: 50px !important;
  overflow: visible !important;
  /* SAFETY for cat animation */
}

#mainMenuButtons .shell-btn {
  width: 100% !important;
  /* Fill the container */
  justify-content: flex-start !important;
  /* Align LEFT */
  padding-left: 20px !important;
  /* Space before symbol */
  text-align: left !important;
  border-radius: 6px !important;
  /* Squared styling */
}

#mainMenuButtons .shell-btn .icon {
  margin-right: 15px !important;
  /* Space between symbol and text */
  width: 24px;
  /* Fixed width for alignment */
  text-align: center;
}

/* PURPLE NEON HOVER (Restored) */
#mainMenuButtons .shell-btn:hover {
  background: rgba(168, 85, 247, 0.1) !important;
  /* Purple tint */
  border-color: #a855f7;
  /* Purple border */
  box-shadow: 0 0 15px #a855f7, inset 0 0 10px rgba(168, 85, 247, 0.4);
  transform: scale(1.02);
  /* Slight scale */
}

/* 4. Bottom Nav Styling (Match Profile) */
.shell-bottom-nav {
  background: rgba(31, 41, 55, 0.4) !important;
  /* Match sidebar-bg/profile transparency */
  border-top: 1px solid var(--border);
  /* Or full border if desired, keeping top for now to separate */
  margin-top: 0 !important;
  /* padding-bottom removed for strict bottom alignment */
}

.nav-item {
  border-radius: 6px !important;
  /* Squared styling */
}

small,
.text-xs,
.text-sm,
.copyright,
.version-tag {
  letter-spacing: 0.02em;
}

/* Uppercase buttons or labels need significant spacing */
.btn,
.label-uppercase,
.topbar {
  letter-spacing: 0.03em;
  /* Slightly wider for UI elements */
}

/* PRO TIP: Tabular numbers for scoreboards and timers to prevent jumping */
.score-table td,
#timerBattle,
.big-score,
#statsPoints {
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
  /* Slightly tight for numbers often looks better */
}

/* --- SLEEPING CAT ANIMATION INTEGRATION --- */
.cat-wrapper {
  position: relative;
  width: 100%;
  /* Ensure wrapper takes full width so button doesn't shrink */
}

.cat-animation {
  position: absolute;
  /* Position: laying on top of button, tail hangs off right edge */
  top: -165px;
  right: -110px;
  /* 10% larger: 280 * 1.1 = 308 */
  width: 308px;
  height: 308px;
  pointer-events: none;
  /* Click-through */
  z-index: 9999;
}

/* Force Lottie Player Dimensions */
lottie-player.cat-animation {
  width: 308px !important;
  height: 308px !important;
}

/* --- CAT EYES (Blinking Animation) --- */
.cat-eye {
  position: absolute;
  width: 5.4px;
  height: 5.4px;
  background: #1a1a1a;
  border-radius: 50%;
  z-index: 10000;
  pointer-events: none;
  opacity: 1;
  transition: opacity 0.3s ease-in-out;
}

/* Position eyes over the closed lottie eyes on cat face */
#eyeLeft {
  top: -13px;
  right: 77px;
}

#eyeRight {
  top: -13px;
  right: 64px;
}

/* Closed state - eyes hidden (original sleeping state) */
.cat-eye.closed {
  opacity: 0;
}



/* UTILITY: Force Hide */
.force-hide {
  display: none !important;
}

/* SUPER SPECIFIC OVERRIDE FOR STAGE 2 GHOSTING */
#stage2.force-hide,
body.stage2-active #stage2.layout.force-hide,
.mobile-stage2-vertical.force-hide,
#stage2.force-hide .sidebar,
#stage2.force-hide .main-area,
#stage2.force-hide .card-header,
#stage2.force-hide h2,
#stage2.force-hide table {
  display: none !important;
}

/* NEW STAGE 2 HEADER LAYOUT */
#stage2 .card-header .header-left,
#stage2 .card-header .header-right {
  flex: 1;
}

#stage2 .card-header .header-right {
  justify-content: flex-end;
}

#stage2 .score-table-mini td {
  padding: 2px 8px;
  border: none !important;
}

/* Compact Sidebar Mini Grid (Reverted to Safe State) */
#stage2 .mini-grid-wrap {
  transform: none;
  width: 80%;
  margin: 0 auto;
  margin-bottom: 0;
}

#stage2 .mini-grid-wrap .grid.mini {
  width: 100% !important;
  height: auto !important;
}

/* Ensure Info Panel Text is visible */
#gameResultStatus {
  display: none;
  /* Now handled by logging to infoPanel */
}

/* MOBILE FIXES (Portrait Menu & Landscape Grid) */
@media screen and (max-width: 1024px) and (orientation: portrait) {

  /* User Request 4: Menu gone. Fix z-index/position */
  /* Enable Topbar for Stage 2 */
  body.stage2-active .topbar {
    display: flex !important;
    position: fixed;
    top: 0;
    width: 100%;
    z-index: 1000;
  }

  /* Fix notification area below fixed topbar */
  body.stage2-active .topbar-notification-area {
    position: fixed;
    top: clamp(60px, 9vw, 84px);
    left: 0;
    width: 100%;
    z-index: 999;
    min-height: 32px;
  }

  /* Let stage2 flow naturally below topbar in flex column */
  body.stage2-active #stage2.layout.mobile-stage2-vertical {
    margin-top: clamp(60px, 9vw, 84px) !important;
    padding-top: 5px !important;
    height: calc(100vh - clamp(60px, 9vw, 84px)) !important;
    position: relative !important;
    top: 0 !important;
  }
}

@media screen and (max-width: 915px) and (orientation: landscape) {

  /* User Request 5: Landscape Grid consistency */
  /* REMOVED forced columns that broke 11x19 grids. Rely on JS inline styles or use var */
  #stage2 .grid.battle-grid {
    /* grid-template-columns: repeat(13, 1fr) !important; <- REMOVED */
    gap: 1px !important;
    /* Ensure sizing fits */
    width: 100%;
    margin: 0 auto;
    justify-content: center !important;
    align-content: center !important;
  }

  #stage2 .grid.battle-grid .cell {
    /* Maintain aspect ratio but allow shrinking */
    width: 100% !important;
    height: 100% !important;
    font-size: 0.7rem !important;
    /* Smaller font for numbers */
  }

  /* Fix Mini Game on Landscape */
  .mini-game-wrapper {
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    justify-content: space-between !important;
    gap: 10px !important;
  }
  .mini-left-col {
    flex: 1 !important;
  }
  .mini-right-col {
    flex: 1 !important;
  }

  /* Fix Header overlap */
  .cell.head {
    font-size: 0.6rem !important;
    overflow: hidden;
  }
}

/* ============================================
   DESKTOP FIXES (v2.5.31)
   ============================================ */
@media screen and (min-width: 769px) and (min-height: 600px) and (orientation: landscape) {

  /* Restore minimum cell size on desktop to prevent collapse */

  /* Fix: Apply min-width ONLY to main game grids, NOT the mini-grid in sidebar */
  .grid:not(.mini) .cell,
  .grid:not(.mini) .cell.head {
    min-width: 40px !important;
    width: auto !important;
    aspect-ratio: 1;
  }

  /* Explicitly ensure mini-grid cells stay small/fluid */
  .mini .cell {
    min-width: 0 !important;
    width: auto !important;
  }

  /* Ensure board card takes up space on desktop */
  .board-card {
    min-width: 600px;
    width: auto;
  }


  /* Prevent sidebar strips from shrinking too much */
  .strip-item {
    min-width: max-content;
  }

  /* Make strip list scrollable within sidebar so MP panel doesn't push it out */
  .sidebar {
    overflow-y: hidden;
    /* Main sidebar hidden, children scroll */
    display: flex;
    flex-direction: column;
  }

  #stripList {
    flex: 1;
    overflow-y: auto;
    min-height: 150px;
    /* Ensure at least some space for strips */
    padding-right: 5px;
    /* Space for scrollbar */
  }

  /* Ensure MP panel stays at bottom if needed, or just flows */
  #mpInfoPanel {
    flex-shrink: 0;
    margin-top: auto;
    max-height: 200px;
    /* Limit height just in case */
    overflow-y: auto;
  }

}

/* MOBILE PORTRAIT - Stage 2 */
@media screen and (max-width: 1024px) and (orientation: portrait) {

  /* 1. Main Container: Fixed full height, centered column, no global scroll */
  body.stage2-active #stage2.layout, body.stage2-active #stage2.mobile-stage2-vertical {
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: flex-start !important;
    height: calc(100vh - clamp(60px, 9vw, 84px)) !important;
    overflow: hidden !important;
    padding: 0 !important;
    padding-top: 5px !important;
    margin-top: clamp(60px, 9vw, 84px) !important;
    position: relative !important;
  }

  /* 2. Top Section (Opponent Board): Pinned Top */
  #stage2>.main-area,
  body.stage2-active #stage2.layout>.main-area {
    order: 1 !important;
    flex: 0 0 auto !important;
    /* Limit height to ensure sidebar visibility */
    max-height: 55vh !important;
    width: 100% !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: flex-start !important;
    /* Align to top */
    padding-top: 0 !important;
    margin-top: 0 !important;
    /* No top padding */
    z-index: 5 !important;
    overflow: visible !important;
  }

  /* 3. Bottom Section (Sidebar): Scrollable */
  #stage2>.sidebar,
  body.stage2-active #stage2.layout>.sidebar {
    order: 2 !important;
    flex: 1 1 auto !important;
    width: 100% !important;
    min-height: 0 !important;
    overflow-y: scroll !important;
    -webkit-overflow-scrolling: touch;
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    padding: 0 0 80px 0 !important;
    /* No top padding */
  }

  /* Content Alignment & Sizing Fixes */
  #stage2 .stage2-box,
  #stage2 .score-table,
  #stage2 #infoPanel {
    width: 90% !important;
    max-width: min(340px, 95vw) !important;
    margin-left: auto !important;
    margin-right: auto !important;
  }

  /* Stage 2 boxes - Reduced Margin */
  #stage2 .stage2-box {
    margin: 5px auto !important;
    max-width: 95vw !important;
    align-self: center !important;
  }

  /* Fix Mini Grid Sizing WITHOUT transform to prevent ghost spacing */
  #stage2 .mini-grid-wrap {
    width: 100% !important;
    transform: none !important;
    margin: 0 auto 2px auto !important;
    /* Minimal margin */
    display: flex;
    justify-content: center;
    order: 1 !important; /* FORCE: Mini grid ABOVE info log */
  }

  /* FORCE: stage2-box column layout + correct order */
  #stage2 .stage2-box {
    display: flex !important;
    flex-direction: column !important;
  }

  #stage2 .stage2-box .info-area,
  #stage2 #infoPanel {
    order: 2 !important; /* FORCE: Info log BELOW mini grid */
  }

  #stage2 .mini-grid .cell {
    font-size: clamp(6px, 2vw, 9px) !important;
    padding: 0 !important;
    margin: 0 !important;
  }

  /* Fonts & Headers - Compact */
  #stage2 h3 {
    text-align: center !important;
    font-size: clamp(14px, 4vw, 18px) !important;
    margin: 2px 0 !important;
    /* Minimal margin */
    width: 100% !important;
  }

  #stage2 .score-table {
    font-size: clamp(12px, 3.5vw, 15px) !important;
  }

  /* ensure #battleCard margin is 0 to touch top */
  #stage2 #battleCard {
    width: 100% !important;
    height: auto !important;
    /* CRITICAL FIX: Stop it from stretching to 55vh */
    max-width: 100vw !important;
    min-height: 0 !important;
    display: flex !important;
    justify-content: center !important;
    margin-top: 0 !important;
    margin-bottom: 0 !important;
    padding: 5px !important;
    /* Keep internal padding small */
  }

  /* Main area padding kill */
  #stage2>.main-area {
    padding: 0 !important;
    margin: 0 !important;
    height: auto !important;
    flex: 0 0 auto !important;
  }

  /* Sidebar first element (h3) margin 0 to touch main-area */
  #stage2 .sidebar>h3:first-child {
    margin-top: 0 !important;
  }

  /* Ensure main-area has no bottom margin either */
  #stage2>.main-area {
    margin-bottom: 0 !important;
    padding-bottom: 0 !important;
  }
}

/* MOBILE LANDSCAPE - Stage 2 */
@media screen and (max-width: 1366px) and (orientation: landscape) {

  /* Stage 2 landscape - horizontal split: SIDEBAR LEFT, BOARD RIGHT */
  body.stage2-active #stage2.layout,
  body.stage2-active #stage2.layout {
    display: flex !important;
    flex-direction: row !important;
    height: 100vh !important;
    overflow: hidden !important;
    padding: 3px !important;
    gap: 5px !important;
  }

  /* Sidebar on LEFT (order: 1) */
  #stage2>.sidebar,
  body.stage2-active #stage2.layout>.sidebar {
    order: 1 !important;
    display: flex !important;
    flex-direction: column !important;
    flex: 0 0 32% !important;
    height: 100% !important;
    overflow-y: auto !important;
    padding: 5px !important;
    align-items: center !important;
  }

  /* Main battle area on RIGHT (order: 2) */
  #stage2>.main-area,
  body.stage2-active #stage2.layout>.main-area {
    order: 2 !important;
    flex: 1 1 65% !important;
    height: 100% !important;
    overflow-y: auto !important;
    display: flex !important;
    flex-direction: column !important;
  }

  /* Dynamic mini-grid for landscape */
  #stage2 .mini-grid-wrap {
    width: 100% !important;
    min-width: 100% !important;
    display: flex !important; 
    flex-wrap: wrap !important;
    justify-content: center !important;
    transform: none !important; /* Let naturally size */
    margin-bottom: 5px !important;
    flex-shrink: 0 !important;
  }
  
  #stage2 #miniGrid,
  html body.stage2-active #stage2 #miniGrid {
    width: 100% !important;
    min-width: 100% !important;
    max-width: 100% !important;
    display: grid !important;
    gap: 2px !important;
    justify-content: center !important;
  }

  /* Force cells to scale perfectly into the grid layout */
  html body.stage2-active #stage2 #miniGrid .cell {
    width: 100% !important;
    height: auto !important;
    aspect-ratio: 1 / 1 !important;
    padding: 0 !important;
    margin: 0 !important;
  }

  #stage2 .stage2-box {
    width: 100% !important;
    margin: 3px 0 !important;
  }

  /* Stretch the battle grid container to the bottom */
  #stage2 #battleCard {
    flex: 1 !important;
    display: flex !important;
    flex-direction: column !important;
    height: 100% !important;
    margin: 0 !important;
  }

  #stage2 .perspective-container {
    flex: 1 !important;
    display: flex !important;
    flex-direction: column !important;
  }

  #stage2 .perspective-container .floating {
    flex: 1 !important;
    height: 100% !important;
    min-height: var(--board-height) !important;
    display: flex !important;
    flex-direction: column !important;
  }

  #stage2 .perspective-container .card_body {
    flex: 1 !important;
    height: 100% !important;
    align-items: flex-start !important; /* Keep grid at the top */
    padding-top: 15px !important;
  }

  #stage2 h3 {
    font-size: clamp(9px, 2vw, 12px) !important;
    margin: 3px 0 !important;
    text-align: center !important;
  }

  #stage2 .score-table {
    font-size: clamp(9px, 1.8vw, 11px) !important;
  }

  #stage2 #infoPanel {
    flex: 0 0 180px !important; /* Taller than 120px, but not 50% of the screen */
    max-height: 180px !important;
    min-height: 180px !important;
    font-size: clamp(8px, 1.5vw, 10px) !important;
    overflow-y: auto !important;
    margin-top: auto !important; /* Push it to the bottom */
    border-top: 2px dashed rgba(255, 255, 255, 0.6) !important; /* Highly visible visual separator line */
    padding-top: 8px !important;
  }

  #stage2 .card-header {
    padding: 2px 5px !important;
    min-height: 22px !important;
  }

  #stage2 .card-header h2 {
    font-size: clamp(9px, 2vw, 12px) !important;
  }

  /* Dynamic grid cells for landscape */
  #stage2 .grid .cell {
    font-size: clamp(7px, 1.8vh, 11px) !important;
  }

  #stage2 .mini-grid .cell {
    font-size: clamp(6px, 1.5vh, 9px) !important;
  }
}

/* PHYSICAL GAME MOBILE FIXES (v3.1.9) */
@media (max-width: 768px) {

  /* 1. Show Topbar in Physical Game */
  #physGameContainer .topbar {
    display: flex !important;
    position: sticky;
    top: 0;
    z-index: 1000;
    background: var(--panel);
  }

  /* 2. Vertical Layout for Game Area */
  #physGameArea {
    flex-direction: column !important;
  }

  /* 3. Scoreboard (Left) -> Top, 60% Height */
  .phys-left {
    width: 100% !important;
    height: 60% !important;
    border-right: none !important;
    border-bottom: 2px solid var(--border);
  }

  /* 4. Bonus (Right) -> Bottom, 40% Height */
  .phys-right {
    width: 100% !important;
    height: 40% !important;
    padding: 10px !important;
    overflow-y: auto;
}
}

/* PHYSICAL GAME MOBILE FIXES (v3.1.9) - PATCH 2 */
@media (max-width: 768px) {

  /* Fix Topbar Visibility for Language Screen too */
  #inlineLangScreen .topbar,
  #inlineHowToScreen .topbar, #inlineLegalScreen .topbar {
    display: flex !important;
    position: sticky;
    top: 0;
    z-index: 1000;
    background: var(--panel);
  }

  /* Header Adjustments: Hide Top-Right 'Bonus', Expand Left */
  .phys-header-right {
    display: none !important;
  }

  .phys-header-left {
    width: 100% !important;
    border-right: none !important;
  }

  /* Show Bonus Title inside Content */
  .mobile-bonus-title {
    display: block !important;
  }
}

/* --- QUICK CHAT SYSTEM UI --- */

/* Chat Toggle Button - Top Left aligned with Menu */
.chat-toggle-btn {
  position: fixed;
  top: 15px;
  left: 450px;
  /* Menu tools hizasÃ„Â±nda, diÃ„Å¸er butonlarÃ„Â±n yanÃ„Â±na */
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  border: 2px solid rgba(255, 255, 255, 0.2);
  font-size: 20px;
  cursor: pointer;
  z-index: 99999;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s;
}

/* Responsive adjustment for mobile */
@media screen and (max-width: 768px) {
  .chat-toggle-btn {
    top: 10px;
    left: auto;
    right: 60px;
    /* Mobilde saÃ„Å¸ ÃƒÂ¼stte daha iyi olur */
  }
}

.chat-toggle-btn:active {
  transform: scale(0.9);
}

.chat-toggle-btn.hidden {
  display: none !important;
}

/* Chat Popup Modal */
.chat-popup {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 90%;
  max-width: 320px;
  max-height: 80vh;
  background: #111;
  border: 1px solid var(--border);
  border-radius: 12px;
  z-index: 100000;
  display: flex;
  flex-direction: column;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.9);
  animation: popupIn 0.2s ease-out;
}

.chat-popup.hidden {
  display: none !important;
}

@keyframes popupIn {
  from {
    opacity: 0;
    transform: translate(-50%, -45%);
  }

  to {
    opacity: 1;
    transform: translate(-50%, -50%);
  }
}

/* Chat Header */
.chat-header {
  background: var(--card);
  padding: 12px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border);
  font-weight: bold;
  color: var(--accent);
}

.close-chat {
  background: none;
  border: none;
  color: var(--text);
  padding: 5px;
  font-size: 18px;
  cursor: pointer;
  font-weight: bold;
}

/* Chat Popup Content */
.chat-section-title {
  padding: 8px 16px;
  font-size: 11px;
  text-transform: uppercase;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.03);
  letter-spacing: 0.5px;
  margin-top: 5px;
}

.chat-emoji-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  padding: 12px;
}

.chat-emoji-btn {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 24px;
  padding: 8px;
  cursor: pointer;
  transition: background 0.1s;
  text-align: center;
}

.chat-emoji-btn:hover {
  background: var(--card);
}

.chat-message-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 0;
  overflow-y: auto;
  max-height: 250px;
  scrollbar-width: thin;
}

.chat-msg-btn {
  background: none;
  border: none;
  color: #eee;
  padding: 12px 16px;
  text-align: left;
  font-size: 14px;
  cursor: pointer;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.chat-msg-btn:hover {
  background: rgba(255, 255, 255, 0.05);
}

.fav-icon {
  opacity: 0.2;
  font-size: 16px;
  transition: opacity 0.2s, color 0.2s;
}

.chat-msg-btn:hover .fav-icon {
  opacity: 0.5;
}

.fav-icon.active {
  opacity: 1;
  color: var(--warn);
}

/* Notification Area */
.chat-notification {
  position: fixed;
  top: 80px;
  left: 50%;
  transform: translateX(-50%);
  background: #000;
  color: #fff;
  padding: 12px 24px;
  border-radius: 8px;
  z-index: 100001;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.7);
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 200px;
  max-width: 90%;
  text-align: center;
  font-weight: bold;
  font-size: 16px;
  animation: slideDown 0.3s ease-out;
  border: 1px solid #333;
}

.chat-notification.hidden {
  display: none !important;
}

.chat-notification-bar {
  width: 100%;
  height: 3px;
  background: var(--warn);
  margin-bottom: 8px;
  border-radius: 2px;
}

@keyframes slideDown {
  from {
    transform: translate(-50%, -50px);
    opacity: 0;
  }

  to {
    transform: translate(-50%, 0);
    opacity: 1;
  }
}

/* --- CHAT SYSTEM FIXES (Combined) --- */
.chat-popup {
  top: 70px !important;
  /* Move below topbar */
  transform: translateX(-50%) !important;
  /* Prevent cutting off top */
  background: rgba(15, 23, 42, 0.98) !important;
  /* Dark opaque bg */
  border: 1px solid var(--border);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  z-index: 10002 !important;
}

/* Remove default styles from message buttons to fix "green lines" */
.chat-msg-btn {
  background: transparent !important;
  border: none !important;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1) !important;
  color: var(--text) !important;
  display: flex !important;
  justify-content: space-between !important;
  align-items: center !important;
  padding: 8px 5px !important;
  width: 100%;
  text-align: left;
}

.chat-msg-btn:last-child {
  border-bottom: none !important;
}

.chat-msg-btn:hover {
  background: rgba(255, 255, 255, 0.05) !important;
}

.chat-msg-btn span {
  color: var(--text) !important;
  font-weight: normal !important;
}

/* Fix Mobile Horizontal Scroll & Visibility */
.chat-message-list {
  max-height: 250px !important;
  overflow-y: auto !important;
  overflow-x: hidden !important;
  padding-right: 5px;
  -webkit-overflow-scrolling: touch;
}

/* Favorites star styling */
.fav-icon {
  font-size: 1.2em;
  opacity: 0.3;
  transition: opacity 0.2s;
  margin-left: 10px;
}

.fav-icon.active {
  color: gold !important;
  opacity: 1;
}

/* Info Panel Chat Messages */
#infoPanel div {
  margin-bottom: 4px;
  line-height: 1.4;
}

/* --- TOPBAR NOTIFICATION AREA (Below Topbar, above board) --- */
.topbar-notification-area {
  position: absolute;
  top: clamp(60px, 9vw, 84px);
  left: 0;
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 36px;
  background: transparent;
  border: none;
  overflow: visible;
  pointer-events: none;
  z-index: 200;
}

#topbarNotificationText {
  font-family: 'Fredoka', cursive, sans-serif !important;
  color: #ffd700;
  font-weight: 600;
  font-size: 1.4em;
  /* Slightly bigger */
  white-space: nowrap;

  /* Strong Neon Glow & Outline */
  text-shadow:
    3px 3px 0 #000,
    -1px -1px 0 #000,
    1px -1px 0 #000,
    -1px 1px 0 #000,
    1px 1px 0 #000,
    0 0 20px #ffd700,
    0 0 30px rgba(255, 215, 0, 0.8);

  opacity: 0;
  /* Spring-like bouncy animation */
  transition: opacity 0.2s, transform 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55);
  transform: translateY(20px) scale(0.5);
  /* Start smaller for bigger pop */
}

#topbarNotificationText.show {
  opacity: 1;
  transform: translateY(0) scale(1);
}

/* Hide old notification element completely */
.chat-notification {
  display: none !important;
}

.chat-notification-bar {
  display: none !important;
}

/* Chat Popup Mobile Landscape Fix */
@media screen and (orientation: landscape) and (max-height: 600px) {
  .chat-popup {
    top: 5px !important;
    bottom: 5px !important;
    right: 5px !important;
    left: auto !important;
    /* Keep it on right side */
    transform: none !important;
    height: 95vh !important;
    max-height: 95vh !important;
    width: 300px !important;
    display: flex;
    flex-direction: column;
  }

  .chat-message-list {
    flex: 1;
    max-height: none !important;
    overflow-y: auto !important;
    min-height: 0;
  }

  .chat-emoji-grid {
    max-height: 100px !important;
    overflow-y: auto;
    flex-shrink: 0;
  }
}

/* Friends Online Status Pulse */
@keyframes pulse-dot {
  0% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.7); }
  70% { box-shadow: 0 0 0 6px rgba(34, 197, 94, 0); }
  100% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0); }
}

/* Auth Pulse Animation */
@keyframes pulse-purple {
  0% {
    box-shadow: 0 0 0 0 rgba(147, 51, 234, 0.7);
  }

  70% {
    box-shadow: 0 0 0 15px rgba(147, 51, 234, 0);
  }

  100% {
    box-shadow: 0 0 0 0 rgba(147, 51, 234, 0);
  }
}

.pulse-btn {
  animation: pulse-purple 2s infinite;
  border-color: #9333ea !important;
  color: #d8b4fe !important;
}

/* Auth Tabs */
.auth-tab-btn {
  flex: 1;
  padding: 10px;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--muted);
  cursor: pointer;
  font-weight: bold;
}

/* --- HOW TO PLAY 4-CARD CLOVER GRID --- */
#htpGridView {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: calc(100vh - 120px);
  width: 100%;
}
.htp-layout {
  position: relative;
  width: 100%;
  max-width: 400px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr;
  gap: 8px;
  aspect-ratio: 1 / 1;
}
.htp-card {
  background: rgba(31, 41, 55, 0.4); /* Much more transparent */
  backdrop-filter: blur(12px) saturate(180%);
  -webkit-backdrop-filter: blur(12px) saturate(180%);
  position: relative;
  overflow: hidden;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-width: 0;
  min-height: 0;
  padding: 15px;
  text-align: center;
  transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
  border: 1px solid rgba(255, 255, 255, 0.1); /* Subtle edge to catch light */
}
.htp-card h3 {
  font-size: 1.1rem;
  color: var(--text);
  margin: 0;
  pointer-events: none;
  font-weight: 700;
  word-break: break-word;
  hyphens: auto;
  white-space: normal;
  max-width: 100%;
}
.htp-card:hover {
  transform: scale(1.05);
  background: rgba(55, 65, 81, 0.6);
  border-color: var(--accent);
  z-index: 5;
}

/* Cut out the inner corners using mask-image - VERTICAL oval (wider height than width) */
.htp-card.tl { border-radius: 40px 40px 0 40px; -webkit-mask-image: radial-gradient(110px 110px at bottom right, transparent 99%, black 100%); mask-image: radial-gradient(110px 110px at bottom right, transparent 99%, black 100%); justify-content: flex-start; padding-top: 20px; }
.htp-card.tr { border-radius: 40px 40px 40px 0; -webkit-mask-image: radial-gradient(110px 110px at bottom left, transparent 99%, black 100%); mask-image: radial-gradient(110px 110px at bottom left, transparent 99%, black 100%); justify-content: flex-start; padding-top: 20px; }
.htp-card.bl { border-radius: 40px 0 40px 40px; -webkit-mask-image: radial-gradient(110px 110px at top right, transparent 99%, black 100%); mask-image: radial-gradient(110px 110px at top right, transparent 99%, black 100%); justify-content: flex-end; padding-bottom: 20px; }
.htp-card.br { border-radius: 0 40px 40px 40px; -webkit-mask-image: radial-gradient(110px 110px at top left, transparent 99%, black 100%); mask-image: radial-gradient(110px 110px at top left, transparent 99%, black 100%); justify-content: flex-end; padding-bottom: 20px; }

/* The Mascot Center */
.htp-mascot {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 220px;
  height: 220px;
  border-radius: 50%;
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 10;
  pointer-events: none;
  filter: drop-shadow(0 10px 15px rgba(0,0,0,0.5));
}

/* Details Panel */
#htpDetailView {
  display: none;
  animation: fadeIn 0.3s ease;
}

/* Mobile portrait adjustments */
@media screen and (max-width: 500px) {
  #htpGridView {
    min-height: calc(100vh - 100px);
  }
  .htp-layout {
    max-width: 330px;
    gap: 6px;
  }
  .htp-card {
    padding: 10px;
  }
  .htp-card h3 {
    font-size: 0.95rem;
  }
  .htp-mascot {
    width: 160px;
    height: 160px;
  }
  .htp-card.tl { -webkit-mask-image: radial-gradient(85px 85px at bottom right, transparent 99%, black 100%); mask-image: radial-gradient(85px 85px at bottom right, transparent 99%, black 100%); }
  .htp-card.tr { -webkit-mask-image: radial-gradient(85px 85px at bottom left, transparent 99%, black 100%); mask-image: radial-gradient(85px 85px at bottom left, transparent 99%, black 100%); }
  .htp-card.bl { -webkit-mask-image: radial-gradient(85px 85px at top right, transparent 99%, black 100%); mask-image: radial-gradient(85px 85px at top right, transparent 99%, black 100%); }
  .htp-card.br { -webkit-mask-image: radial-gradient(85px 85px at top left, transparent 99%, black 100%); mask-image: radial-gradient(85px 85px at top left, transparent 99%, black 100%); }
}

/* Mobile landscape adjustments - fit to shorter viewport */
@media screen and (max-height: 500px) and (orientation: landscape) {
  #htpGridView {
    min-height: calc(100vh - 80px);
  }
  .htp-layout {
    max-width: 280px;
    gap: 5px;
  }
  .htp-card {
    padding: 8px;
  }
  .htp-card h3 {
    font-size: 0.85rem;
  }
  .htp-mascot {
    width: 130px;
    height: 130px;
  }
  .htp-card.tl { -webkit-mask-image: radial-gradient(70px 70px at bottom right, transparent 99%, black 100%); mask-image: radial-gradient(70px 70px at bottom right, transparent 99%, black 100%); }
  .htp-card.tr { -webkit-mask-image: radial-gradient(70px 70px at bottom left, transparent 99%, black 100%); mask-image: radial-gradient(70px 70px at bottom left, transparent 99%, black 100%); }
  .htp-card.bl { -webkit-mask-image: radial-gradient(70px 70px at top right, transparent 99%, black 100%); mask-image: radial-gradient(70px 70px at top right, transparent 99%, black 100%); }
  .htp-card.br { -webkit-mask-image: radial-gradient(70px 70px at top left, transparent 99%, black 100%); mask-image: radial-gradient(70px 70px at top left, transparent 99%, black 100%); }
}

/* --- HOW TO PLAY DETAIL VIEW MOBILE FIX --- */
.howto-content {
  overflow-x: hidden;
  max-width: 100vw;
  box-sizing: border-box;
}

@media screen and (orientation: landscape) and (max-height: 500px) {
  .lb-wrapper {
    padding: 8px !important;
    margin-top: 5px !important;
    margin-bottom: 5px !important;
  }
  .lb-wrapper h4 {
    margin-bottom: 5px !important;
    font-size: 0.9rem !important;
  }
  .lb-container {
    max-height: 120px !important;
  }
  #leaderboardBody td, #maxLeaderboardBody td {
    padding: 3px !important;
    font-size: 11px !important;
  }
}

#htpDetailView {
  max-width: 100%;
  overflow-x: hidden;
  box-sizing: border-box;
  word-wrap: break-word;
  overflow-wrap: break-word;
}

#htpDynamicContent {
  max-width: 100%;
  overflow-x: hidden;
}

/* Friends screen mobile overflow fix */
#inlineFriendsScreen .inline-content {
  overflow-x: hidden;
  max-width: 100vw;
}

/* Stats screen mobile overflow fix */
#inlineStatsScreen .inline-content {
  overflow-x: hidden;
  max-width: 100vw;
}

/* Settings modal mobile overflow fix */
#settingsModalOverlay .inline-screen {
  overflow-x: hidden;
}

/* Avatar Grid Styles */
.avatar-item {
    aspect-ratio: 1;
    background: var(--panel);
    border-radius: 12px;
    border: 2px solid transparent;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    transition: all 0.2s ease;
}
.avatar-item:hover {
    transform: scale(1.05);
    background: rgba(255,255,255,0.1);
}
.avatar-item.selected {
    border-color: var(--accent);
    background: rgba(var(--accent-rgb), 0.2);
    box-shadow: 0 0 15px rgba(var(--accent-rgb), 0.4);
}
#btnTabProfile {
    box-shadow: 0 0 10px rgba(var(--ok-rgb), 0.5);
}
/* Friend Invite DropDown Animation */
@keyframes dropDown {
  from { transform: translateX(-50%) translateY(-100%); opacity: 0; }
  to { transform: translateX(-50%) translateY(0); opacity: 1; }
}

/* ========== CRYSTAL STORE CARDS ========== */
.crystal-pack-card {
  position: relative;
  background: linear-gradient(135deg, rgba(30, 41, 59, 0.9), rgba(51, 65, 85, 0.7));
  border: 1px solid rgba(96, 165, 250, 0.25);
  border-radius: 12px;
  padding: 14px 10px;
  text-align: center;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  overflow: hidden;
}
.crystal-pack-card::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 12px;
  background: linear-gradient(135deg, rgba(96,165,250,0.05), transparent 60%);
  pointer-events: none;
}
.crystal-pack-card:hover,
.crystal-pack-card:active {
  transform: scale(1.04);
  border-color: rgba(96, 165, 250, 0.6);
  box-shadow: 0 0 20px rgba(96, 165, 250, 0.2), inset 0 0 15px rgba(96, 165, 250, 0.05);
}

/* Popular variant */
.crystal-pack-card.popular {
  border-color: rgba(250, 204, 21, 0.4);
  background: linear-gradient(135deg, rgba(30, 41, 59, 0.9), rgba(66, 55, 30, 0.5));
}
.crystal-pack-card.popular::before {
  background: linear-gradient(135deg, rgba(250, 204, 21, 0.08), transparent 60%);
}
.crystal-pack-card.popular:hover {
  border-color: rgba(250, 204, 21, 0.7);
  box-shadow: 0 0 20px rgba(250, 204, 21, 0.15), inset 0 0 15px rgba(250, 204, 21, 0.05);
}

/* Best value variant */
.crystal-pack-card.best-value {
  border-color: rgba(168, 85, 247, 0.4);
  background: linear-gradient(135deg, rgba(30, 41, 59, 0.9), rgba(55, 30, 66, 0.5));
}
.crystal-pack-card.best-value::before {
  background: linear-gradient(135deg, rgba(168, 85, 247, 0.08), transparent 60%);
}
.crystal-pack-card.best-value:hover {
  border-color: rgba(168, 85, 247, 0.7);
  box-shadow: 0 0 20px rgba(168, 85, 247, 0.15), inset 0 0 15px rgba(168, 85, 247, 0.05);
}

.crystal-pack-badge {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  background: linear-gradient(90deg, #facc15, #f59e0b);
  color: #000;
  font-size: 9px;
  font-weight: 800;
  padding: 2px 0;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}
.crystal-pack-card.best-value .crystal-pack-badge {
  background: linear-gradient(90deg, #a855f7, #7c3aed);
  color: #fff;
}

.crystal-pack-amount {
  font-size: 22px;
  font-weight: 900;
  color: #f3f4f6;
  margin: 6px 0 2px;
  text-shadow: 0 0 12px rgba(96, 165, 250, 0.4);
}

.crystal-pack-bonus {
  font-size: 10px;
  font-weight: 700;
  color: #34d399;
  margin-bottom: 4px;
}

.crystal-pack-price {
  font-size: 14px;
  font-weight: 800;
  color: #60a5fa;
  background: rgba(96, 165, 250, 0.1);
  border-radius: 20px;
  padding: 4px 12px;
  display: inline-block;
}
.crystal-pack-card.popular .crystal-pack-price {
  color: #facc15;
  background: rgba(250, 204, 21, 0.1);
}
.crystal-pack-card.best-value .crystal-pack-price {
  color: #c084fc;
  background: rgba(168, 85, 247, 0.1);
}

/* Moved from index.html */

        /* CRITICAL MOBILE TIMER FIX v3 */
        @media screen and (max-width: 1024px) {

            /* Hide Sidebar Timer Box */
            body #mpInfoPanel,
            body .sidebar-box #mpPrepTimer,
            body aside #mpPrepTimer {
                display: none !important;
            }

            /* Show New Mobile Timer - ONLY in multiplayer mode */
            body.multiplayer #mobilePrepTimerContainer {
                display: block !important;
                background: #1e293b;
                border: 2px solid #60a5fa;
                border-radius: 12px;
                padding: 15px;
                margin: 20px auto;
                width: 85%;
                max-width: 320px;
                text-align: center;
                box-shadow: 0 4px 20px rgba(0, 0, 0, 0.6);
                z-index: 9999;
                position: relative;
            }

            /* Typography */
            body #mpPrepTimerMobile {
                font-size: 36px !important;
                line-height: 1;
                display: inline-block;
            }

            body #mobilePrepTimerContainer span:last-child {
                font-size: 14px !important;
                opacity: 0.8;
            }
        }

        /* ===== RANK BADGE (Individual Files) ===== */
        .profile-stats {
            display: flex !important;
            align-items: center !important;
            gap: 10px !important;
            margin-top: 0 !important;
            flex-wrap: nowrap;
        }

        .profile-coins {
            font-size: 0.95rem;
            font-weight: 700;
            color: #fbbf24 !important;
            text-shadow: 0 0 5px rgba(251, 191, 36, 0.3);
        }

        #rankBadgeWrap,
        #statsRankBadgeWrap {
            display: inline-flex;
            align-items: center;
            flex-shrink: 0;
        }

        /* Reserve space for rank badge to prevent layout shift */
        #rankBadgeWrap {
            min-width: 72px;
            min-height: 80px;
        }

        .rank-badge {
            display: inline-flex;
            flex-direction: column;
            align-items: center;
            position: relative;
            width: 72px;
            cursor: default;
            user-select: none;
            background: transparent !important;
            border: none !important;
            transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
            animation: badgeFadeIn 0.4s ease forwards;
        }

        @keyframes badgeFadeIn {
            from { opacity: 0; transform: scale(0.85); }
            to { opacity: 1; transform: scale(1); }
        }

        .rank-badge:hover {
            transform: scale(1.1);
        }

        /* Each badge ring uses its own image from /animasyonlar/ */
        .badge-ring {
            width: 64px;
            height: 64px;
            position: relative;
            background-size: contain;
            background-repeat: no-repeat;
            background-position: center;
            background-color: transparent !important;
            border: none !important;
            filter: drop-shadow(0 0 8px var(--rb-glow, rgba(255, 255, 255, 0.2)));
            z-index: 2;
        }

        .badge-gem {
            position: absolute;
            top: 38%;
            /* Moved slightly up from center */
            left: 50%;
            transform: translate(-50%, -50%);
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 0.95rem;
            /* Made text bigger */
            font-family: 'Fredoka', sans-weight;
            font-weight: 900;
            color: #fff !important;
            z-index: 5;
            text-shadow: 0 0 10px rgba(255, 255, 255, 0.8), 0 2px 4px rgba(0, 0, 0, 0.8);
            /* Better visibility without circle */
            animation: gemTextPulse 3s ease-in-out infinite;
            background: transparent !important;
            border: none !important;
            box-shadow: none !important;
        }

        @keyframes gemTextPulse {

            0%,
            100% {
                opacity: 0.8;
                transform: translate(-50%, -50%) scale(1);
            }

            50% {
                opacity: 1;
                transform: translate(-50%, -50%) scale(1.15);
                text-shadow: 0 0 15px rgba(255, 255, 255, 1), 0 2px 4px rgba(0, 0, 0, 0.8);
            }
        }

        .badge-label {
            font-size: 0.65rem;
            font-weight: 900;
            letter-spacing: 0.08em;
            margin-top: 2px;
            text-transform: uppercase;
            color: var(--rb-color, #ca8a04) !important;
            text-shadow: 0 0 8px rgba(0, 0, 0, 0.8) !important;
        }

        .rank-badge.mini {
            width: 36px;
            /* 72px / 2 */
            margin-right: 8px;
            display: inline-flex;
            vertical-align: middle;
        }

        .rank-badge.mini .badge-ring {
            width: 32px;
            /* 64px / 2 */
            height: 32px;
        }

        .rank-badge.mini .badge-gem {
            /* width: 10px; height: 10px; removed so font size dictates area */
            top: 48%;
            /* Centered for MINI BADGES */
            font-size: 0.45rem;
            /* slightly increased for readability */
            box-shadow: none !important;
            text-shadow: 0 0 5px rgba(255, 255, 255, 0.8), 0 1px 2px rgba(0, 0, 0, 0.8) !important;
        }

        .rank-badge.mini .badge-label {
            display: none;
        }

        .rank-badge.mini .badge-ring::before,
        .rank-badge.mini .badge-ring::after {
            display: none;
        }

        /* Metals (ROZET.png Refined Palettes) */
        /* Individual Rank Images */
        .metal-bakir {
            --rb-color: #b45309;
            --rb-glow: rgba(180, 83, 9, 0.3);
        }

        .metal-bakir .badge-ring {
            background-image: url('animasyonlar/bakir.png');
        }

        .metal-gumus {
            --rb-color: #cbd5e1;
            --rb-glow: rgba(203, 213, 225, 0.3);
        }

        .metal-gumus .badge-ring {
            background-image: url('animasyonlar/gumus.png');
        }

        .metal-altin {
            --rb-color: #fbbf24;
            --rb-glow: rgba(251, 191, 36, 0.4);
        }

        .metal-altin .badge-ring {
            background-image: url('animasyonlar/altin.png');
        }

        .metal-platin {
            --rb-color: #94a3b8;
            --rb-glow: rgba(148, 163, 184, 0.4);
        }

        .metal-platin .badge-ring {
            background-image: url('animasyonlar/platin.png');
        }

        .metal-elmas {
            --rb-color: #38bdf8;
            --rb-glow: rgba(56, 189, 248, 0.5);
        }

        .metal-elmas .badge-ring {
            background-image: url('animasyonlar/elmas.png');
        }

        .metal-ustat {
            --rb-color: #a855f7;
            --rb-glow: rgba(168, 85, 247, 0.8);
        }

        .metal-ustat .badge-ring {
            background-image: url('animasyonlar/ustad.png');
        }

        /* Gems now only define text-shadow colors instead of backgrounds */
        .gem-none {
            display: none !important;
        }

        .gem-yakut {
            text-shadow: 0 0 8px rgba(239, 68, 68, 0.8), 0 2px 4px rgba(0, 0, 0, 0.8) !important;
        }

        .gem-zumrut {
            text-shadow: 0 0 8px rgba(34, 197, 94, 0.8), 0 2px 4px rgba(0, 0, 0, 0.8) !important;
        }

        .gem-ametist {
            text-shadow: 0 0 8px rgba(168, 85, 247, 0.8), 0 2px 4px rgba(0, 0, 0, 0.8) !important;
        }

        .gem-safir {
            text-shadow: 0 0 8px rgba(59, 130, 246, 0.8), 0 2px 4px rgba(0, 0, 0, 0.8) !important;
        }

        .gem-kuvars {
            text-shadow: 0 0 8px rgba(255, 255, 255, 0.8), 0 2px 4px rgba(0, 0, 0, 0.8) !important;
        }

        /* Specialized Effects for Top Tiers */
        .metal-ustat .badge-ring {
            animation: ustatGlow 4s linear infinite;
        }

        @keyframes ustatGlow {

            0%,
            100% {
                box-shadow: 0 0 25px rgba(168, 85, 247, 0.8), inset 0 0 15px rgba(168, 85, 247, 0.4);
            }

            50% {
                box-shadow: 0 0 45px rgba(168, 85, 247, 1), inset 0 0 25px rgba(168, 85, 247, 0.6);
            }
        }

        .metal-ustat .badge-ring::before,
        .metal-ustat .badge-ring::after {
            opacity: 1;
            filter: drop-shadow(0 0 5px #a855f7);
        }
    
        /* Rank Animation Modal CSS */
        .rank-modal {
            position: fixed; top: 0; left: 0; width: 100%; height: 100%;
            background: rgba(15, 23, 42, 0.95);
            display: none; justify-content: center; align-items: center;
            z-index: 10000; opacity: 0; transition: opacity 0.4s ease;
            
        }
        .rank-modal.active { display: flex; opacity: 1; }
        .rank-card {
            background: linear-gradient(145deg, #1e293b, #0f172a);
            border-radius: 20px; border: 2px solid #3b82f6;
            width: 90%; max-width: 380px; padding: 15px;
            box-shadow: 0 10px 40px rgba(59, 130, 246, 0.3);
            text-align: center;
            animation: slideUpFade 0.6s cubic-bezier(0.16, 1, 0.3, 1);
            max-height: 90vh; overflow-y: auto;
        }
        .rank-league-title {
            color: #fbbf24; font-size: 24px; font-weight: bold;
            text-transform: uppercase; letter-spacing: 1px;
            margin-bottom: 5px; text-shadow: 0 0 15px rgba(251, 191, 36, 0.5);
        }
        .rank-timer {
            color: #e2e8f0; font-size: 13px; margin-bottom: 20px;
            display: flex; justify-content: center; gap: 6px; align-items: center;
            font-variant-numeric: tabular-nums;
        }
        /* Slot Container */
        .rank-slot-container {
            background: #0f172a; border-radius: 12px;
            overflow: hidden; border: 1px solid #334155;
            position: relative; max-height: 250px;
            scroll-behavior: smooth;
        }
        .rank-slot-list {
            display: flex; flex-direction: column; transition: transform 2s cubic-bezier(0.25, 1, 0.5, 1);
        }
        .rank-item {
            display: flex; align-items: center; padding: 10px 15px;
            border-bottom: 1px solid #1e293b; background: #1e293b;
            color: #cbd5e1; font-weight: 500; font-size: 14px;
            height: 50px; box-sizing: border-box; transition: background-color 0.3s ease, color 0.3s ease;
        }
        .rank-item.is-me {
            background: linear-gradient(90deg, #d97706, #b45309);
            color: white; border: 2px solid #fcd34d; font-size: 16px;
            box-shadow: inset 0 0 10px rgba(255,255,255,0.2);
            z-index: 2; position: relative;
        }
        .rank-item .rk { width: 35px; text-align: left; font-weight: bold; color: inherit; }
        .rank-item .name { flex: 1; text-align: left; margin-left: 10px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
        .rank-item .score { width: 60px; text-align: right; color: #4ade80; }
        .rank-item.is-me .score { color: #fff; text-shadow: 0 0 5px rgba(255,255,255,0.5); }
        
        .sparkle-container {
            text-shadow: 0 0 8px rgba(0, 0, 0, 0.8) !important;
        }

        .rank-badge.mini {
            width: 36px;
            /* 72px / 2 */
            margin-right: 8px;
            display: inline-flex;
            vertical-align: middle;
        }

        .rank-badge.mini .badge-ring {
            width: 32px;
            /* 64px / 2 */
            height: 32px;
        }

        .rank-badge.mini .badge-gem {
            /* width: 10px; height: 10px; removed so font size dictates area */
            top: 48%;
            /* Centered for MINI BADGES */
            font-size: 0.45rem;
            /* slightly increased for readability */
            box-shadow: none !important;
            text-shadow: 0 0 5px rgba(255, 255, 255, 0.8), 0 1px 2px rgba(0, 0, 0, 0.8) !important;
        }

        .rank-badge.mini .badge-label {
            display: none;
        }

        .rank-badge.mini .badge-ring::before,
        .rank-badge.mini .badge-ring::after {
            display: none;
        }

        /* Metals (ROZET.png Refined Palettes) */
        /* Individual Rank Images */
        .metal-bakir {
            --rb-color: #b45309;
            --rb-glow: rgba(180, 83, 9, 0.3);
        }

        .metal-bakir .badge-ring {
            background-image: url('animasyonlar/bakir.png');
        }

        .metal-gumus {
            --rb-color: #cbd5e1;
            --rb-glow: rgba(203, 213, 225, 0.3);
        }

        .metal-gumus .badge-ring {
            background-image: url('animasyonlar/gumus.png');
        }

        .metal-altin {
            --rb-color: #fbbf24;
            --rb-glow: rgba(251, 191, 36, 0.4);
        }

        .metal-altin .badge-ring {
            background-image: url('animasyonlar/altin.png');
        }

        .metal-platin {
            --rb-color: #94a3b8;
            --rb-glow: rgba(148, 163, 184, 0.4);
        }

        .metal-platin .badge-ring {
            background-image: url('animasyonlar/platin.png');
        }

        .metal-elmas {
            --rb-color: #38bdf8;
            --rb-glow: rgba(56, 189, 248, 0.5);
        }

        .metal-elmas .badge-ring {
            background-image: url('animasyonlar/elmas.png');
        }

        .metal-ustat {
            --rb-color: #a855f7;
            --rb-glow: rgba(168, 85, 247, 0.8);
        }

        .metal-ustat .badge-ring {
            background-image: url('animasyonlar/ustad.png');
        }

        /* Gems now only define text-shadow colors instead of backgrounds */
        .gem-none {
            display: none !important;
        }

        .gem-yakut {
            text-shadow: 0 0 8px rgba(239, 68, 68, 0.8), 0 2px 4px rgba(0, 0, 0, 0.8) !important;
        }

        .gem-zumrut {
            text-shadow: 0 0 8px rgba(34, 197, 94, 0.8), 0 2px 4px rgba(0, 0, 0, 0.8) !important;
        }

        .gem-ametist {
            text-shadow: 0 0 8px rgba(168, 85, 247, 0.8), 0 2px 4px rgba(0, 0, 0, 0.8) !important;
        }

        .gem-safir {
            text-shadow: 0 0 8px rgba(59, 130, 246, 0.8), 0 2px 4px rgba(0, 0, 0, 0.8) !important;
        }

        .gem-kuvars {
            text-shadow: 0 0 8px rgba(255, 255, 255, 0.8), 0 2px 4px rgba(0, 0, 0, 0.8) !important;
        }

        /* Specialized Effects for Top Tiers */
        .metal-ustat .badge-ring {
            animation: ustatGlow 4s linear infinite;
        }

        @keyframes ustatGlow {

            0%,
            100% {
                box-shadow: 0 0 25px rgba(168, 85, 247, 0.8), inset 0 0 15px rgba(168, 85, 247, 0.4);
            }

            50% {
                box-shadow: 0 0 45px rgba(168, 85, 247, 1), inset 0 0 25px rgba(168, 85, 247, 0.6);
            }
        }

        .metal-ustat .badge-ring::before,
        .metal-ustat .badge-ring::after {
            opacity: 1;
            filter: drop-shadow(0 0 5px #a855f7);
        }
    
        /* Rank Animation Modal CSS */
        .rank-modal {
            position: fixed; top: 0; left: 0; width: 100%; height: 100%;
            background: rgba(15, 23, 42, 0.95);
            display: none; justify-content: center; align-items: center;
            z-index: 10000; opacity: 0; transition: opacity 0.4s ease;
            
        }
        .rank-modal.active { display: flex; opacity: 1; }
        .rank-card {
            background: linear-gradient(145deg, #1e293b, #0f172a);
            border-radius: 20px; border: 2px solid #3b82f6;
            width: 90%; max-width: 400px; padding: 20px;
            box-shadow: 0 10px 40px rgba(59, 130, 246, 0.3);
            text-align: center;
            animation: slideUpFade 0.6s cubic-bezier(0.16, 1, 0.3, 1);
        }
        .rank-league-title {
            color: #fbbf24; font-size: 24px; font-weight: bold;
            text-transform: uppercase; letter-spacing: 1px;
            margin-bottom: 5px; text-shadow: 0 0 15px rgba(251, 191, 36, 0.5);
        }
        .rank-timer {
            color: #e2e8f0; font-size: 13px; margin-bottom: 20px;
            display: flex; justify-content: center; gap: 6px; align-items: center;
            font-variant-numeric: tabular-nums;
        }
        /* Slot Container */
        .rank-slot-container {
            background: #0f172a; border-radius: 12px;
            overflow: hidden; border: 1px solid #334155;
            position: relative; max-height: 250px;
            scroll-behavior: smooth;
        }
        .rank-slot-list {
            display: flex; flex-direction: column; transition: transform 2s cubic-bezier(0.25, 1, 0.5, 1);
        }
        .rank-item {
            display: flex; align-items: center; padding: 10px 15px;
            border-bottom: 1px solid #1e293b; background: #1e293b;
            color: #cbd5e1; font-weight: 500; font-size: 14px;
            height: 50px; box-sizing: border-box; transition: background-color 0.3s ease, color 0.3s ease;
        }
        .rank-item.is-me {
            background: linear-gradient(90deg, #d97706, #b45309);
            color: white; border: 2px solid #fcd34d; font-size: 16px;
            box-shadow: inset 0 0 10px rgba(255,255,255,0.2);
            z-index: 2; position: relative;
        }
        .rank-item .rk { width: 35px; text-align: left; font-weight: bold; color: inherit; }
        .rank-item .name { flex: 1; text-align: left; margin-left: 10px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
        .rank-item .score { width: 60px; text-align: right; color: #4ade80; }
        .rank-item.is-me .score { color: #fff; text-shadow: 0 0 5px rgba(255,255,255,0.5); }
        
        .sparkle-container {
            position: absolute; top: 0; left: 0; width: 100%; height: 100%; pointer-events: none; z-index: 10;
        }
        
        @keyframes slideUpFade {
            0% { opacity: 0; transform: translateY(40px) scale(0.9); }
            100% { opacity: 1; transform: translateY(0) scale(1); }
        }
        @keyframes glowPulse {
            0% { transform: scale(1); }
            50% { transform: scale(1.02); }
            100% { transform: scale(1); }
        }
        
        /* (duplicate block removed) */
    
/* Moved from index.html (Block 0) */

                        @keyframes chameleonColorShift {
                            0% { filter: hue-rotate(0deg); }
                            100% { filter: hue-rotate(360deg); }
                        }
                        #chameleonAnim {
                            position: absolute;
                            top: -45px;
                            right: -15px;
                            width: 160px;
                            height: 160px;
                            pointer-events: none;
                            animation: chameleonColorShift 15s linear infinite;
                            z-index: 10;
                        }
                    
/* Moved from index.html (Block 1) */

            #physCustomKeyboard {
                bottom: 0;
                left: 0;
                width: 100%;
                border-top: 1px solid var(--border);
                border-top-left-radius: 12px;
                border-top-right-radius: 12px;
                padding-bottom: 25px;
            }
            .kb-btn {
                background: #1f2937;
                border: 1px solid var(--border);
                color: #fff;
                padding: 8px 0;
                font-size: 16px;
                font-weight: bold;
                border-radius: 6px;
                cursor: pointer;
            }
            .kb-btn:active {
                background: var(--accent);
                color: #000;
            }
            @media (orientation: landscape) {
                #physCustomKeyboard { 
                    bottom: 20px;
                    right: 20px;
                    left: auto;
                    width: 360px;
                    border-radius: 12px;
                    border: 1px solid var(--border);
                    padding-bottom: 10px;
                }
            }
        
/* Moved from index.html (Block 2) */

            /* MaÃ„Å¸aza SayfasÃ„Â± Layout Override - GRID EXACT */
            #themeContainer {
                flex-direction: column;
                overflow-y: auto !important;
                padding-bottom: 40px;
            }
            
            .theme-content-row-layout {
                display: grid !important;
                grid-template-columns: 1fr 1fr;
                justify-items: center !important;
                gap: 5px !important;
                max-width: 500px;
                margin: 20px auto 0 auto;
                width: 100%;
                overflow: visible !important;
                padding: 0 10px;
                box-sizing: border-box;
            }
            
            .theme-content-row-layout > .theme-row-group {
                display: flex;
                flex-direction: column;
                gap: 0px;
                background: transparent !important;
                border: none !important;
                padding: 0 !important;
                width: 100% !important;
                max-width: 200px;
            }
            /* MaÃ„Å¸aza ve Kristal panellerini tam geniÃ…Å¸lik yap (3. ve 4. grup) */
            .theme-content-row-layout > .theme-row-group:nth-child(n+3) {
                grid-column: 1 / -1;
                width: 100% !important;
                max-width: 500px !important;
                margin-top: 15px;
                align-items: center;
            }
            
            .theme-label-col {
                display: flex !important;
                width: 100% !important;
                min-width: 0 !important;
                text-align: center !important;
                justify-content: center !important;
                padding: 0 !important;
                margin: 0 0 8px 0 !important;
                border: none !important;
                font-size: 1.1em;
            }
            
            .theme-options-col {
                display: flex;
                flex-direction: column;
                gap: 4px; /* Butonlar arasÃ„Â± mesafeyi azalttÃ„Â±k */
                align-items: center !important; 
                width: 100%;
            }
            
            #storeActionPanel {
                flex-direction: column;
                align-items: stretch;
                width: 100%;
                max-width: none;
                margin: 0 auto; 
            }
            
            .theme-btn.small {
                width: 100%;
                max-width: 160px; 
                min-height: auto !important;
                padding: 8px 10px !important;
                display: flex;
                flex-direction: column;
                align-items: center;
                gap: 2px;
                line-height: 1.2 !important;
            }
        
/* Moved from index.html (Block 3) */

                    @keyframes crabWalk {
                        0%   { transform: translateX(0px) scaleX(1); }
                        48%  { transform: translateX(-180px) scaleX(1); }
                        50%  { transform: translateX(-180px) scaleX(-1); }
                        98%  { transform: translateX(0px) scaleX(-1); }
                        100% { transform: translateX(0px) scaleX(1); }
                    }
                
/* Moved from index.html (Block 4) */

                .sloth-onboarding-wrapper {
                    position: relative;
                    width: 100%;
                    max-width: 500px;
                    height: 100%;
                    display: flex;
                    flex-direction: column;
                    align-items: center;
                    justify-content: center;
                    padding-bottom: 20px;
                }

                .sloth-bubble-container {
                    position: relative;
                    width: 90%;
                    max-width: 350px;
                    background: #fff;
                    color: #333 !important;
                    padding: 12px 18px;
                    border-radius: 24px;
                    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3);
                    border: 3px solid #333;
                    font-size: 13px;
                    font-weight: 600;
                    opacity: 0;
                    /* JS handles fade in */
                    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
                    z-index: 10;
                    align-self: flex-start;
                    margin-left: 5%;
                    margin-bottom: -15px;
                }

                .sloth-tail-outer {
                    position: absolute;
                    bottom: -16px;
                    right: 40px;
                    width: 0;
                    height: 0;
                    border-left: 12px solid transparent;
                    border-right: 12px solid transparent;
                    border-top: 16px solid #333;
                }

                .sloth-tail-inner {
                    position: absolute;
                    bottom: -10px;
                    right: 43px;
                    width: 0;
                    height: 0;
                    border-left: 9px solid transparent;
                    border-right: 9px solid transparent;
                    border-top: 12px solid #fff;
                    z-index: 2;
                }

                .sloth-lottie-container {
                    width: 280px;
                    height: 280px;
                    margin-bottom: 10px;
                    z-index: 1;
                }

                /* Landscape / Short Screen Adjustments */
                @media screen and (orientation: landscape) and (max-height: 550px) {
                    .sloth-onboarding-wrapper {
                        flex-direction: row;
                        justify-content: center;
                        align-items: center;
                        gap: 15px;
                        padding-bottom: 0;
                        max-width: 700px;
                    }

                    .sloth-bubble-container {
                        margin-left: 0;
                        margin-bottom: 0;
                        align-self: center;
                        font-size: 12px;
                        padding: 10px 15px;
                        max-width: 280px;
                    }

                    .sloth-tail-outer {
                        bottom: auto;
                        top: 50%;
                        right: -16px;
                        transform: translateY(-50%);
                        border-top: 12px solid transparent;
                        border-bottom: 12px solid transparent;
                        border-left: 16px solid #333;
                        border-right: none;
                    }

                    .sloth-tail-inner {
                        bottom: auto;
                        top: 50%;
                        right: -10px;
                        transform: translateY(-50%);
                        border-top: 9px solid transparent;
                        border-bottom: 9px solid transparent;
                        border-left: 12px solid #fff;
                        border-right: none;
                    }

                    .sloth-lottie-container {
                        width: 220px;
                        height: 220px;
                        margin-bottom: 0;
                    }
                }
/* Revert topbar size for online and offline game screens in mobile landscape */
@media screen and (max-height: 600px) and (orientation: landscape) {
    #gameWrapper > .topbar,
    #inlineOnlineScreen > .topbar {
        height: clamp(40px, 8vh, 56px) !important;
        padding: 0 clamp(8px, 1.5vw, 16px) 0 !important;
    }
    
    #gameWrapper > .topbar .btn,
    #gameWrapper > .topbar .select,
    #gameWrapper > .topbar .custom-select-trigger,
    #inlineOnlineScreen > .topbar .btn,
    #inlineOnlineScreen > .topbar .select,
    #inlineOnlineScreen > .topbar .custom-select-trigger {
        height: clamp(28px, 6vh, 36px) !important;
        min-height: auto !important;
        font-size: clamp(11px, 2.5vh, 15px) !important;
        padding: 0 clamp(6px, 1vw, 12px) !important;
    }
    
    #gameWrapper > .topbar h3,
    #inlineOnlineScreen > .topbar h3 {
        font-size: clamp(12px, 2.5vh, 16px) !important;
    }

    body.stage2-active .topbar-notification-area {
        top: clamp(40px, 8vh, 56px) !important;
    }
}

/* Custom Select UI */
.custom-select-ui {
  position: relative;
  display: inline-block;
  width: 100%;
}
.custom-select-trigger {
  background: var(--card);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px;
  font-size: 14px;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  user-select: none;
  min-height: 44px;
}
.mobile-menu-select-wrapper .custom-select-trigger {
  font-size: 10px;
  padding: 4px;
  border-radius: 4px;
  min-height: 24px;
  justify-content: center;
  gap: 4px;
}
.custom-select-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  width: max-content;
  min-width: 100%;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 6px;
  margin-top: 4px;
  z-index: 9999;
  display: none;
  box-shadow: 0 4px 12px rgba(0,0,0,0.5);
  overflow: hidden;
}
@media (max-width: 1024px) and (orientation: portrait) {
  .mobile-menu-select-wrapper .custom-select-dropdown {
    left: 55px;
    top: 0;
    min-width: 120px;
    margin-top: 0;
  }
}
.custom-select-option {
  padding: 10px 14px;
  font-size: 14px;
  color: var(--text);
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.custom-select-option:last-child {
  border-bottom: none;
}
.custom-select-option:hover, .custom-select-option.active {
  background: var(--primary);
  color: #fff;
}
.custom-select-option.disabled {
  color: var(--muted);
  cursor: not-allowed;
  background: #1e293b;
}
.custom-select-option.disabled:hover {
  background: #1e293b;
}


/* --- STAGE 2 FIXES --- */
body.stage2-active #selDiff, 
body.stage2-active #selBoard, 
body.stage2-active #selDiff + .custom-select-ui, 
body.stage2-active #selBoard + .custom-select-ui {
    display: none !important;
}

/* --- SUNRISE PERFORMANCE OVERRIDES --- */
.sun-container-1:after { animation-duration: 60s !important; }
.sun { animation-duration: 60s !important; will-change: transform; }
.sun-container-reflection .sun { animation-duration: 60s !important; will-change: transform; }
.cloud { animation-duration: 180s !important; will-change: transform; }
.cloud-1 { animation-duration: 300s !important; }
.reed, .reed-1 { animation-duration: 60s !important; will-change: transform; }
.light, .light-1, .light-2, .light-3, .light-4, .light-5, .light-6, .light-7 { animation-duration: 60s !important; will-change: transform, opacity; }
.splash { animation-duration: 27s !important; will-change: transform, opacity; }





/* FIX FOR MOBILE PORTRAIT THEME BUTTONS NOT CLICKABLE */
#themeContainer .theme-options-col .theme-btn {
    position: relative !important;
    z-index: 9000 !important;
    pointer-events: auto !important;
}


/* FIX FOR ALL LOTTIE OVERLAPS ON BUTTONS IN MODALS/SCREENS */
.inline-screen .btn,
.custom-modal-overlay .btn {
    position: relative !important;
    z-index: 9000 !important;
    pointer-events: auto !important;
}

/* UI LAYOUT COMPACT FIX FOR LANDSCAPE */
@media screen and (orientation: landscape) and (max-height: 600px) {
  #stage0 {
    padding-top: 15px !important;
  }
  #stage0 .shell-menu {
    margin-bottom: 0px !important;
  }
  .shell-profile {
    margin-top: -5px !important;
  }
}
