:root {
  --bg-color: #ffffff;
  --text-color: #2c3e50;
  --accent-blue: #3498db;
  --accent-blue-light: #ebf5fb;
  --accent-gray: #ecf0f1;
  --border-color: #bdc3c7;
  --modal-bg: rgba(0, 0, 0, 0.5);
  --card-bg: #ffffff;
  --font-main: 'Outfit', sans-serif;
  --zoom-level: 1;
}

body.dark-mode {
  --bg-color: #0f172a;
  --text-color: #f1f5f9;
  --accent-blue: #38bdf8;
  /* Brighter blue for dark mode */
  --accent-blue-light: #1e293b;
  --accent-gray: #334155;
  --border-color: #475569;
  --card-bg: #1e293b;
  --modal-bg: rgba(0, 0, 0, 0.7);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-main);
  background-color: var(--bg-color);
  color: var(--text-color);
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  overflow-y: auto;
  /* Allow scrolling for content */
  transition: background-color 0.3s ease, color 0.3s ease;
}

.branding {
  position: absolute;
  top: 20px;
  left: 20px;
  z-index: 10;
  display: inline-block;
  color: inherit;
  text-decoration: none !important;
}

.branding:hover,
.branding:focus-visible,
.branding:visited {
  color: inherit;
  text-decoration: none !important;
}

.brand-tag {
  font-weight: 700;
  font-size: 1.2rem;
  color: var(--text-color);
  opacity: 0.8;
  letter-spacing: 1px;
  text-decoration: none !important;
}

/* Ensure Ezoic / Gatekeeper consent layers stay on top without overlapping each other */
#ez-cmp-ui-container,
.ez-cmp-ui-container,
.ez-cmp-overlay {
  position: fixed !important;
  inset: 0 !important;
  z-index: 2147483647 !important;
}

[id^="ez-cmp"] {
  z-index: 2147483646 !important;
}

.screen {
  width: 100%;
  max-width: 480px;
  /* Slightly wider for content */
  padding: 40px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  transition: opacity 0.3s ease, transform 0.3s ease;
  transform: scale(var(--zoom-level));
  transform-origin: top center;
}

.is-hidden {
  display: none !important;
  opacity: 0;
  pointer-events: none;
}

/* Start Screen */
.screen--start {
  text-align: center;
}

.title {
  font-size: 2.5rem;
  font-weight: 700;
  margin-bottom: 3rem;
  color: var(--text-color);
  line-height: 1.1;
  letter-spacing: -1px;
}

.selection {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
  margin-bottom: 60px;
}

.select-btn {
  width: 90px;
  height: 90px;
  border-radius: 24px;
  border: none;
  background-color: var(--accent-gray);
  cursor: pointer;
  display: flex;
  justify-content: center;
  align-items: center;
  transition: transform 0.2s ease, background-color 0.2s ease, box-shadow 0.2s ease;
}

.select-btn:hover {
  transform: translateY(-4px);
  background-color: var(--border-color);
  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.1);
}

.select-btn:active {
  transform: translateY(0);
}

.or {
  font-size: 1.2rem;
  font-weight: 500;
  color: var(--border-color);
}

/* SEO Content / About Section */
.seo-content {
  width: 100%;
  text-align: left;
  color: var(--text-color);
}

.section-title {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 24px;
  text-align: center;
  color: var(--text-color);
}

.info-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
  margin-bottom: 32px;
}

.info-card {
  background-color: var(--card-bg);
  padding: 20px;
  border-radius: 16px;
  border: 1px solid var(--border-color);
}

.info-card h3 {
  font-size: 1.1rem;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.info-card p,
.info-card li {
  font-size: 0.95rem;
  line-height: 1.6;
  opacity: 0.8;
  list-style: none;
}

.step-list {
  padding: 0;
}

.step-list li {
  margin-bottom: 12px;
  position: relative;
  padding-left: 24px;
}

.step-list li::before {
  content: '•';
  position: absolute;
  left: 0;
  color: var(--accent-blue);
  font-weight: bold;
}

.mode-list {
  display: grid;
  gap: 12px;
}

.mode-item {
  background-color: var(--accent-blue-light);
  padding: 12px 16px;
  border-radius: 12px;
}

.mode-item strong {
  color: var(--accent-blue);
  display: block;
  margin-bottom: 4px;
}

/* Icons (CSS Shapes) */
.icon-x,
.icon-x-sm {
  position: relative;
  width: 40px;
  height: 40px;
}

.icon-x::before,
.icon-x::after,
.icon-x-sm::before,
.icon-x-sm::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 100%;
  height: 8px;
  background-color: var(--accent-blue);
  border-radius: 4px;
}

.icon-x::before,
.icon-x-sm::before {
  transform: translate(-50%, -50%) rotate(45deg);
}

.icon-x::after,
.icon-x-sm::after {
  transform: translate(-50%, -50%) rotate(-45deg);
}

.icon-o,
.icon-o-sm {
  width: 40px;
  height: 40px;
  border: 8px solid #2ecc71;
  border-radius: 50%;
  box-sizing: border-box;
}

/* Small Icons for Stats */
.icon-x-sm {
  width: 16px;
  height: 16px;
}

.icon-x-sm::before,
.icon-x-sm::after {
  height: 3px;
}

.icon-o-sm {
  width: 16px;
  height: 16px;
  border-width: 3px;
}

.icon-scale {
  width: 16px;
  height: 16px;
  border-bottom: 2px solid var(--border-color);
  position: relative;
}

.icon-scale::before {
  content: '';
  position: absolute;
  top: 2px;
  left: 50%;
  transform: translateX(-50%);
  width: 2px;
  height: 12px;
  background-color: var(--border-color);
}

/* Game Screen */
.game-header {
  display: flex;
  justify-content: space-between;
  width: 100%;
  margin-bottom: 40px;
}

.stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.stat-value {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-color);
  opacity: 0.7;
}

.board-container {
  width: 100%;
  display: flex;
  justify-content: center;
  margin-bottom: 40px;
}

/* Reverted Grid Style (Internal Borders Only) */
.board {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  width: 100%;
  aspect-ratio: 1;
  /* No outer border or gap background */
}

.cell {
  background: transparent;
  display: flex;
  justify-content: center;
  align-items: center;
  cursor: pointer;
  position: relative;
  width: 100%;
  height: 100%;
  border: 1px solid var(--border-color);
  /* Default border */
  /* Remove outer borders to create hashtag look */
}

/* Top Row */
.cell:nth-child(1),
.cell:nth-child(2),
.cell:nth-child(3) {
  border-top: none;
}

/* Bottom Row */
.cell:nth-child(7),
.cell:nth-child(8),
.cell:nth-child(9) {
  border-bottom: none;
}

/* Left Column */
.cell:nth-child(1),
.cell:nth-child(4),
.cell:nth-child(7) {
  border-left: none;
}

/* Right Column */
.cell:nth-child(3),
.cell:nth-child(6),
.cell:nth-child(9) {
  border-right: none;
}


/* Marks in Board */
.cell .icon-x {
  width: 50%;
  height: 50%;
}

.cell .icon-o {
  width: 50%;
  height: 50%;
}

/* Fading out old moves in Infinity Mode */
.cell.fade-out {
  opacity: 0.4;
}

.controls {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  width: 100%;
}

.turn-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  background-color: var(--accent-blue-light);
  padding: 8px 16px;
  border-radius: 20px;
}

.turn-text {
  font-weight: 700;
  color: var(--accent-blue);
  text-transform: uppercase;
  font-size: 0.9rem;
}

.turn-icon {
  display: block;
}

.turn-icon.x {
  width: 14px;
  height: 14px;
  position: relative;
}

.turn-icon.x::before,
.turn-icon.x::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 100%;
  height: 2px;
  background-color: var(--accent-blue);
  border-radius: 1px;
}

.turn-icon.x::before {
  transform: translate(-50%, -50%) rotate(45deg);
}

.turn-icon.x::after {
  transform: translate(-50%, -50%) rotate(-45deg);
}

.turn-icon.o {
  width: 12px;
  height: 12px;
  border: 2px solid #2ecc71;
  border-radius: 50%;
}

.actions {
  display: flex;
  align-items: center;
  gap: 16px;
}

.action-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background-color: var(--accent-gray);
  border: none;
  color: var(--text-color);
  display: flex;
  justify-content: center;
  align-items: center;
  cursor: pointer;
  transition: background-color 0.2s;
}

.action-btn:hover {
  background-color: var(--border-color);
}

.mode-pill {
  padding: 10px 20px;
  background-color: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 20px;
  font-weight: 700;
  color: var(--text-color);
  font-size: 0.8rem;
  letter-spacing: 0.5px;
}

/* Modal */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: var(--modal-bg);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 100;
  opacity: 1;
  transition: opacity 0.3s ease;
  backdrop-filter: blur(4px);
}

.modal {
  background-color: var(--card-bg);
  padding: 24px;
  border-radius: 24px;
  width: 90%;
  max-width: 340px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.2);
  border: 1px solid var(--border-color);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
}

.modal-header h2 {
  font-size: 1.4rem;
  color: var(--text-color);
  font-weight: 700;
}

.close-btn {
  background: none;
  border: none;
  font-size: 1.8rem;
  cursor: pointer;
  color: var(--text-color);
  opacity: 0.5;
  transition: opacity 0.2s;
}

.close-btn:hover {
  opacity: 1;
}

.setting-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  color: var(--text-color);
  font-weight: 500;
}

/* Switch Toggle */
.switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 26px;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: var(--border-color);
  transition: .3s;
}

.slider:before {
  position: absolute;
  content: "";
  height: 20px;
  width: 20px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: .3s;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

input:checked+.slider {
  background-color: var(--accent-blue);
}

input:checked+.slider:before {
  transform: translateX(18px);
}

.slider.round {
  border-radius: 34px;
}

.slider.round:before {
  border-radius: 50%;
}

/* Zoom Controls */
.zoom-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  background-color: var(--accent-gray);
  padding: 4px;
  border-radius: 8px;
}

.zoom-controls button {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  border: none;
  background: var(--card-bg);
  cursor: pointer;
  color: var(--text-color);
  font-weight: 700;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.zoom-controls span {
  font-size: 0.9rem;
  min-width: 44px;
  text-align: center;
  font-weight: 600;
}
