:root {
  --bg: #f4f6f9;
  --surface: #ffffff;
  --border: #e2e8f0;
  --text: #1e293b;
  --muted: #64748b;
  --accent: #3b82f6;
  --accent-hover: #2563eb;
  --x-color: #ef4444;
  --o-color: #3b82f6;
  --win-bg: #dbeafe;
  --shadow: 0 4px 24px rgba(15, 23, 42, 0.08);
}

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

body {
  min-height: 100vh;
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

body.rtl {
  direction: rtl;
}

.app {
  max-width: 820px;
  margin: 0 auto;
  padding: 1.5rem 1rem 3rem;
}

.header {
  text-align: center;
  margin-bottom: 0.75rem;
}

.title {
  font-size: 1.75rem;
  font-weight: 700;
}

.lang-nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.35rem 0.5rem;
  margin-bottom: 1.25rem;
  padding: 0.75rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
}

.lang-nav-footer {
  margin-top: 1.25rem;
  margin-bottom: 0;
  max-width: 100%;
}

.lang-nav a {
  padding: 0.35rem 0.6rem;
  border-radius: 6px;
  font-size: 0.78rem;
  color: var(--muted);
  text-decoration: none;
  transition: all 0.15s;
  white-space: nowrap;
}

.lang-nav a:hover {
  color: var(--accent);
  background: #eff6ff;
}

.lang-nav a.active {
  color: #fff;
  background: var(--accent);
  font-weight: 600;
}

body.rtl .lang-nav {
  direction: rtl;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  margin-bottom: 1.25rem;
}

.mode-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.55rem 0.9rem;
  border: 2px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--muted);
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.2s;
}

.mode-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.mode-btn.active {
  border-color: var(--accent);
  background: #eff6ff;
  color: var(--accent);
  font-weight: 600;
}

.mode-btn svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
  flex-shrink: 0;
}

.difficulty-wrap {
  display: none;
  align-items: center;
  gap: 0.5rem;
}

.difficulty-wrap.visible {
  display: flex;
}

.difficulty-wrap label {
  font-size: 0.85rem;
  color: var(--muted);
}

.difficulty-wrap select {
  padding: 0.45rem 0.75rem;
  border: 2px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  font-size: 0.85rem;
  cursor: pointer;
}

.game-card {
  background: var(--surface);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 1.5rem;
  border: 1px solid var(--border);
}

.status {
  text-align: center;
  font-size: 1.05rem;
  font-weight: 600;
  margin-bottom: 1.25rem;
  min-height: 1.6em;
}

.game-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.25rem;
}

@media (min-width: 560px) {
  .game-area {
    flex-direction: row;
    justify-content: center;
    align-items: flex-start;
  }
}

.player-panel {
  flex: 0 0 120px;
  text-align: center;
  padding: 1rem 0.75rem;
  border-radius: 12px;
  border: 2px solid var(--border);
  background: #fafbfc;
  transition: all 0.25s;
}

.player-panel.active {
  border-color: var(--accent);
  background: #eff6ff;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.player-panel .symbol {
  font-size: 2rem;
  font-weight: 700;
  line-height: 1;
  margin-bottom: 0.35rem;
}

.player-panel.x .symbol { color: var(--x-color); }
.player-panel.o .symbol { color: var(--o-color); }

.player-panel .name {
  font-size: 0.8rem;
  color: var(--muted);
  margin-bottom: 0.5rem;
  word-break: break-word;
}

.player-panel .score {
  font-size: 1.75rem;
  font-weight: 700;
}

.board {
  display: grid;
  grid-template-columns: repeat(3, 90px);
  grid-template-rows: repeat(3, 90px);
  gap: 6px;
  background: var(--border);
  border-radius: 14px;
  padding: 6px;
}

@media (min-width: 480px) {
  .board {
    grid-template-columns: repeat(3, 100px);
    grid-template-rows: repeat(3, 100px);
  }
}

.cell {
  width: 100%;
  height: 100%;
  min-height: 90px;
  background: var(--surface);
  border: none;
  border-radius: 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
}

.cell:hover:not(.taken):not(:disabled) {
  background: #f8fafc;
}

.cell.taken,
.cell:disabled {
  cursor: default;
}

.cell.win {
  background: var(--win-bg);
}

.cell svg {
  width: 52%;
  height: 52%;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.6rem;
  margin-top: 1.5rem;
}

.btn {
  padding: 0.65rem 1.25rem;
  border: none;
  border-radius: 10px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}

.btn-primary:hover {
  background: var(--accent-hover);
}

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

.btn-secondary:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.35);
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 1rem;
}

.overlay.open {
  display: flex;
}

.modal {
  background: var(--surface);
  border-radius: 16px;
  padding: 1.75rem;
  max-width: 360px;
  width: 100%;
  text-align: center;
  box-shadow: var(--shadow);
}

.modal h2 {
  font-size: 1.2rem;
  margin-bottom: 0.5rem;
}

.modal p {
  color: var(--muted);
  margin-bottom: 1.25rem;
}

.modal-actions {
  display: flex;
  gap: 0.6rem;
}

.modal-actions .btn {
  flex: 1;
}

.names-form {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-bottom: 1rem;
  text-align: start;
}

.names-form label {
  font-size: 0.85rem;
  color: var(--muted);
}

.names-form input {
  display: block;
  width: 100%;
  margin-top: 0.35rem;
  padding: 0.55rem 0.75rem;
  border: 2px solid var(--border);
  border-radius: 8px;
  font-size: 0.95rem;
}

.names-form input:focus {
  outline: none;
  border-color: var(--accent);
}

.info-page .info-back {
  margin-bottom: 0.75rem;
  text-align: start;
}

.info-page .info-back a {
  color: var(--accent);
  text-decoration: none;
  font-size: 0.9rem;
}

.info-page .info-back a:hover {
  text-decoration: underline;
}

.info-content {
  margin-top: 0;
}

.info-subnav {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.5rem;
  margin: 1.5rem 0;
}

.info-subnav a {
  padding: 0.45rem 0.85rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  text-decoration: none;
  font-size: 0.88rem;
}

.info-subnav a:hover,
.info-subnav a.active {
  border-color: var(--accent);
  color: var(--accent);
  background: #eff6ff;
}

.info-subnav-muted {
  margin-top: -0.75rem;
}

.info-subnav-muted a {
  font-size: 0.82rem;
  padding: 0.35rem 0.7rem;
}

.content {
  margin-top: 2.5rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 1.75rem 1.5rem;
  box-shadow: var(--shadow);
}

.content-intro {
  font-size: 1.05rem;
  color: var(--text);
  margin-bottom: 1.5rem;
}

.content-section {
  margin-bottom: 2rem;
}

.content-section h2 {
  font-size: 1.35rem;
  margin-bottom: 0.75rem;
  color: var(--text);
}

.content-section h3 {
  font-size: 1.05rem;
  margin: 1.25rem 0 0.5rem;
  color: var(--text);
}

.content-section p {
  margin-bottom: 0.85rem;
  color: var(--muted);
}

.content-section ul {
  margin: 0.5rem 0 1rem 1.25rem;
  color: var(--muted);
}

.content-section li {
  margin-bottom: 0.35rem;
}

.content-cta {
  font-weight: 600;
  color: var(--text) !important;
}

.faq-item {
  border: 1px solid var(--border);
  border-radius: 10px;
  margin-bottom: 0.6rem;
  padding: 0.25rem 0.85rem;
  background: #fafbfc;
}

.faq-item summary {
  cursor: pointer;
  font-weight: 600;
  padding: 0.65rem 0;
  color: var(--text);
  list-style: none;
}

.faq-item summary::-webkit-details-marker {
  display: none;
}

.faq-item summary::after {
  content: "›";
  float: inline-end;
  color: var(--accent);
  font-size: 1.2rem;
  transition: transform 0.2s;
}

body.rtl .faq-item summary::after {
  float: inline-start;
}

.faq-item[open] summary::after {
  transform: rotate(90deg);
}

.faq-item p {
  margin: 0 0 0.85rem;
  padding-top: 0.25rem;
}

.site-footer {
  margin-top: 2rem;
  text-align: center;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}

.footer-brand {
  font-weight: 600;
  margin-bottom: 0.75rem;
  color: var(--text);
}

.footer-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.5rem 1rem;
  margin-bottom: 0.75rem;
}

.footer-links a {
  font-size: 0.9rem;
  color: var(--accent);
  text-decoration: none;
}

.footer-links a:hover {
  text-decoration: underline;
}

.footer-links-muted a {
  color: var(--muted);
  font-size: 0.82rem;
}
