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

/* Utility */
.hidden { display: none !important; }

:root{
  --bg: #ffffff;
  --text: #13222b;
  --muted: rgba(0,0,0,0.55);
  --shadow: 0 10px 26px rgba(0,0,0,0.10);

  /* default accent (used for cover gradient) */
  --accent-rgb: 255, 255, 255;
  --shell-font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  color-scheme: light;
}

/* Dark mode */
body.dark {
  --bg: #121213;
  --text: #ffffff;
  --muted: rgba(255,255,255,0.55);
  --shadow: 0 10px 26px rgba(0,0,0,0.35);
  color-scheme: dark;
}

html{ -webkit-text-size-adjust: 100%; }

body{
  font-family: var(--shell-font);
  background: var(--bg);
  min-height: 100vh;
  overflow: hidden;
  touch-action: manipulation; /* Allow vertical scroll to pass through to parent article */
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}

#shell{
  position: relative;
  height: 100vh; /* fallback */
  height: calc(var(--vh, 1vh) * 100); /* iOS dynamic viewport */
  height: 100dvh;
  width: 100vw;
  background: var(--bg);
}

#game-frame{
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  background: var(--bg);
  z-index: 1;
  opacity: 1;
  transition: opacity 240ms ease;
}

body.cover-open #game-frame{
  /* Keep the game more visible behind the cover */
  opacity: 0.6;
}

/* Cover (Wordsearch-like) */
.home-screen{
  position: absolute;
  inset: 0;
  z-index: 2000;
  display: flex;
  padding: 20px;
  /* Use flex-start/flex-end (not start/end) for better RTL cross-browser behavior */
  align-items: center;
  justify-content: center;

  background: transparent;
  overflow: hidden;
  touch-action: manipulation; /* Allow scroll gestures to pass through to parent article */
}
.home-screen.hidden{ display:none; }

.home-content{
  width: min(560px, 100%);
  display:flex;
  flex-direction: column;
  gap: 14px;
  position: relative;
  z-index: 1;
  background: var(--bg);
  padding: 20px;
  border-radius: 16px;
  /* border-top-left-radius: 0;
  border-top-right-radius: 0; */
  border: 1px solid rgba(0, 0, 0, 0.1);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12), 0 2px 8px rgba(0, 0, 0, 0.08);
}

.home-meta {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.game-cover{
  flex-shrink: 0;
  width: 45px;
  aspect-ratio: var(--cover-ar, 1 / 1);
  border-radius: 0;
  overflow: hidden;
  background: #fff;
  border: none;
  box-shadow: none;
}
.game-cover.hidden{ display:none; }

.game-icon {
  flex-shrink: 0;
  width: 45px;
  aspect-ratio: var(--cover-ar, 1 / 1);
  border-radius: 5px;
  overflow: hidden;
  background: #000;
  border: none;
  box-shadow: none;
}
.game-cover img{
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.home-meta-text {
  flex: 1;
  min-width: 0;
  max-width: 500px;
}

.home-title{
  font-size: 20px;
  line-height: 1.25;
  font-weight: 700;
  color: var(--text);
  text-transform: capitalize;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.home-description{
  margin-top: 6px;
  font-size: 14px;
  line-height: 1.35;
  color: var(--muted);
}
.home-description.hidden{ display:none; }

/* Dark mode home content card */
body.dark .home-content {
  border-color: rgba(255, 255, 255, 0.12);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4), 0 2px 8px rgba(0, 0, 0, 0.3);
}

/* Not found state - muted card */
body.not-found .home-content {
  background: #f5f5f5;
  border-color: rgba(0, 0, 0, 0.15);
}
body.dark.not-found .home-content {
  background: #1a1a1a;
  border-color: rgba(255, 255, 255, 0.1);
}

/* Not found logo should not be inverted */
body.not-found .game-cover img {
  filter: none;
}

.home-play-btn{
  max-width: 180px;
  width: 100%;
  height: 42px;
  border-radius: 999px;
  border:none;
  background: #000;
  color: #fff;
  font-size: 15px;
  font-weight: 800;
  display:flex;
  align-items:center;
  justify-content:center;
  gap: 10px;
  cursor:pointer;
  margin-top: 4px;
}
.home-play-btn:active{ transform: translateY(1px); }
.home-play-icon{ font-size: 18px; transform: translateY(1px); }

/* Dark mode play button */
body.dark .home-play-btn {
  background: #fff;
  color: #000;
}

/* Error message */
.error-message {
  margin-top: 24px;
  padding: 16px 20px;
  background: rgba(220, 53, 69, 0.15);
  border: 1px solid rgba(220, 53, 69, 0.4);
  border-radius: 12px;
  color: #dc3545;
  text-align: center;
  font-size: 14px;
  line-height: 1.5;
}
.error-message.hidden { display: none; }
.home-play-btn.hidden { display: none; }

/* Difficulty controls */
.difficulty-controls {
  display: flex;
  gap: 10px;
  justify-content: flex-start;
  align-items: center;
  margin-bottom: 12px;
}
.difficulty-controls.hidden {
  display: none;
}

.difficulty-btn {
  border: 2px solid rgba(0, 0, 0, 0.18);
  background: rgba(255, 255, 255, 0.60);
  color: rgba(0, 0, 0, 0.72);
  border-radius: 999px;
  padding: 10px 18px;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: -0.2px;
  cursor: pointer;
  transition: background 120ms ease, border-color 120ms ease, transform 80ms ease;
}
.difficulty-btn:hover {
  background: rgba(255, 255, 255, 0.85);
}
.difficulty-btn:active {
  transform: scale(0.985);
}
.difficulty-btn.active {
  background: #fff;
  color: #000;
  border-color: #000;
  font-weight: 800;
}

/* Dark mode difficulty buttons */
body.dark .difficulty-btn {
  border-color: rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.1);
  color: rgba(255, 255, 255, 0.7);
}
body.dark .difficulty-btn:hover {
  background: rgba(255, 255, 255, 0.18);
}
body.dark .difficulty-btn.active {
  background: #fff;
  color: #000;
  border-color: #fff;
}

/* Home actions row */
.home-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 4px;
}

.home-actions .home-play-btn {
  flex: 1;
  margin-top: 0;
}

/* Circle buttons */
.home-circle-btns {
  display: flex;
  gap: 8px;
}

.circle-btn {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: none;
  background: rgba(0, 0, 0, 0.12);
  color: #000;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 150ms ease, transform 100ms ease;
}
.circle-btn:hover {
  background: rgba(0, 0, 0, 0.18);
}
.circle-btn:active {
  transform: scale(0.95);
}
.circle-btn svg {
  width: 20px;
  height: 20px;
}

/* Share button: show a temporary checkmark after copy */
#share-btn .share-icon-check {
  display: none;
}
#share-btn.copied .share-icon {
  display: none;
}
#share-btn.copied .share-icon-check {
  display: block;
}

.circle-btn-brand {
  background: #000;
  color: #fff;
}
.circle-btn-brand:hover {
  background: #222;
}

/* Dark mode circle buttons */
body.dark .circle-btn {
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
}
body.dark .circle-btn:hover {
  background: rgba(255, 255, 255, 0.25);
}
body.dark .circle-btn-brand {
  background: #fff;
  color: #000;
}
body.dark .circle-btn-brand:hover {
  background: #e0e0e0;
}
.circle-btn-letter {
  font-size: 18px;
  font-weight: 900;
  line-height: 1;
}

.circle-btn-logo {
  width: 22px;
  height: 22px;
  object-fit: contain;
}

.circle-btn-logo {
  filter: invert(1);
}

body.dark .circle-btn-logo {
  filter: none;
}

/* Archive section */
.archive-section {
  margin-top: 0px;
}
.archive-section.hidden {
  display: none;
}

.archive-carousel {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding: 4px 0;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.archive-carousel::-webkit-scrollbar {
  display: none;
}

.archive-pill {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border-radius: 999px;
  border: 1.5px solid rgba(0, 0, 0, 0.18);
  background: rgba(255, 255, 255, 0.65);
  font-size: 14px;
  font-weight: 600;
  color: #000;
  cursor: pointer;
  transition: background 150ms ease, border-color 150ms ease;
}
.archive-pill:hover {
  background: rgba(255, 255, 255, 0.9);
  border-color: rgba(0, 0, 0, 0.28);
}
.archive-pill.current {
  background: rgba(0, 0, 0, 0.08);
  border-color: rgba(0, 0, 0, 0.3);
}
.archive-pill.completed {
  border-color: rgba(34, 197, 94, 0.5);
}

.pill-date {
  white-space: nowrap;
}
.pill-sep {
  color: rgba(0, 0, 0, 0.3);
}
.pill-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
}
.pill-icon svg {
  width: 100%;
  height: 100%;
}

.archive-pill.completed .pill-icon {
  color: #22c55e;
}
.archive-pill.started .pill-icon {
  color: #f59e0b;
}
.archive-pill.not-started .pill-icon {
  color: #000;
}

/* Dark mode archive pills */
body.dark .archive-pill {
  border-color: rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}
body.dark .archive-pill:hover {
  background: rgba(255, 255, 255, 0.18);
  border-color: rgba(255, 255, 255, 0.3);
}
body.dark .archive-pill.current {
  background: rgba(255, 255, 255, 0.15);
  border-color: rgba(255, 255, 255, 0.35);
}
body.dark .pill-sep {
  color: rgba(255, 255, 255, 0.3);
}
body.dark .archive-pill.not-started .pill-icon {
  color: #fff;
}

/* Modals */
.modal {
  position: fixed;
  inset: 0;
  z-index: 5000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.5);
  padding: 20px;
}
.modal.hidden {
  display: none;
}

.modal-content {
  position: relative;
  width: min(400px, 100%);
  max-height: 80vh;
  background: var(--bg);
  border-radius: 16px;
  padding: 24px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.25);
  overflow-y: auto;
}
.modal-content h2 {
  font-size: 22px;
  font-weight: 800;
  margin-bottom: 12px;
  color: var(--text);
}
.modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 32px;
  height: 32px;
  border: none;
  background: rgba(0, 0, 0, 0.08);
  border-radius: 50%;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text);
}
.modal-close:hover {
  background: rgba(0, 0, 0, 0.15);
}
.modal-placeholder {
  color: var(--muted);
  font-size: 14px;
}

/* Leaderboard modal */
.lb-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 6px 0 14px;
}
.lb-label {
  font-size: 12px;
  font-weight: 800;
  color: var(--muted);
  flex-shrink: 0;
}
.lb-input {
  flex: 1;
  height: 36px;
  border-radius: 10px;
  border: 1px solid rgba(0, 0, 0, 0.14);
  background: rgba(0, 0, 0, 0.03);
  padding: 0 10px;
  font-size: 14px;
  color: var(--text);
  outline: none;
}
.lb-input:focus {
  border-color: rgba(var(--accent-rgb), 0.75);
  box-shadow: 0 0 0 3px rgba(var(--accent-rgb), 0.18);
}
.lb-save {
  height: 36px;
  padding: 0 12px;
  border-radius: 999px;
  border: none;
  background: #000;
  color: #fff;
  font-size: 13px;
  font-weight: 900;
  cursor: pointer;
  flex-shrink: 0;
}
body.dark .lb-save {
  background: #fff;
  color: #000;
}
.lb-me {
  margin: 0 0 12px;
  font-size: 13px;
  color: var(--muted);
  font-weight: 800;
}
.lb-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.lb-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border-radius: 12px;
  padding: 10px 12px;
  background: rgba(0, 0, 0, 0.03);
}
body.dark .lb-row {
  background: rgba(255, 255, 255, 0.06);
}
.lb-row.me {
  box-shadow: 0 0 0 2px rgba(var(--accent-rgb), 0.45) inset;
}
.lb-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.lb-rank {
  font-size: 12px;
  font-weight: 900;
  color: var(--muted);
  width: 18px;
  text-align: right;
  flex-shrink: 0;
}
.lb-name {
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 220px;
}
.lb-right {
  font-size: 13px;
  font-weight: 900;
  color: var(--text);
  flex-shrink: 0;
}

/* Stats modal */
.stats-body {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.stats-title {
  font-size: 14px;
  font-weight: 800;
  color: var(--text);
  margin: 2px 0 0;
}

.stats-subtitle {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.35;
}

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

.stats-card {
  border: none;
  background: rgba(0, 0, 0, 0.03);
  border-radius: 12px;
  padding: 12px;
}

body.dark .stats-card {
  background: rgba(255, 255, 255, 0.06);
}

.stats-k {
  font-size: 12px;
  color: var(--muted);
  font-weight: 700;
}
.stats-v {
  margin-top: 4px;
  font-size: 18px;
  font-weight: 900;
  color: var(--text);
  letter-spacing: -0.3px;
}
.stats-v.small {
  font-size: 14px;
  font-weight: 800;
  letter-spacing: -0.1px;
}

.stats-chart {
  background: rgba(0, 0, 0, 0.02);
  border-radius: 12px;
  padding: 10px;
}
body.dark .stats-chart {
  border-color: rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.05);
}
.stats-chart svg {
  width: 100%;
  height: 110px;
  display: block;
}
.stats-axis-labels {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-top: 6px;
  font-size: 12px;
  color: var(--muted);
}

.stats-actions {
  display: flex;
  gap: 10px;
}
.stats-actions .stats-action {
  flex: 1;
  height: 38px;
  border-radius: 999px;
  border: none;
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
}
.stats-action.secondary {
  background: rgba(0, 0, 0, 0.10);
  color: var(--text);
}
.stats-action.danger {
  background: rgba(220, 53, 69, 0.15);
  color: #dc3545;
}
body.dark .stats-action.secondary {
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
}
body.dark .stats-action.danger {
  background: rgba(220, 53, 69, 0.22);
}

/* Dark mode modal */
body.dark .modal-close {
  background: rgba(255, 255, 255, 0.1);
}
body.dark .modal-close:hover {
  background: rgba(255, 255, 255, 0.18);
}

/* Calendar Modal */
.calendar-modal-content {
  width: min(360px, 100%);
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
  margin-top: 16px;
}

.calendar-header {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.calendar-month {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
}

.calendar-nav {
  display: flex;
  gap: 8px;
}

.calendar-nav-btn {
  width: 32px;
  height: 32px;
  border: none;
  background: rgba(0, 0, 0, 0.08);
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text);
  transition: background 150ms ease;
}
.calendar-nav-btn:hover {
  background: rgba(0, 0, 0, 0.15);
}
.calendar-nav-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}
.calendar-nav-btn svg {
  width: 16px;
  height: 16px;
}

body.dark .calendar-nav-btn {
  background: rgba(255, 255, 255, 0.1);
}
body.dark .calendar-nav-btn:hover {
  background: rgba(255, 255, 255, 0.18);
}

.calendar-weekday {
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  text-align: center;
  padding: 4px 0;
  text-transform: uppercase;
}

.calendar-day {
  aspect-ratio: 1;
  border: none;
  background: rgba(0, 0, 0, 0.06);
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 150ms ease, transform 100ms ease;
  position: relative;
}
.calendar-day:hover {
  background: rgba(0, 0, 0, 0.12);
}
.calendar-day:active {
  transform: scale(0.95);
}
.calendar-day.empty {
  background: transparent;
  cursor: default;
}
.calendar-day.empty:hover {
  background: transparent;
}
.calendar-day.today {
  background: rgba(var(--accent-rgb), 0.2);
  font-weight: 800;
}
.calendar-day.selected {
  background: #000;
  color: #fff;
}
.calendar-day.completed::after {
  content: '';
  position: absolute;
  bottom: 4px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #22c55e;
}
.calendar-day.started::after {
  content: '';
  position: absolute;
  bottom: 4px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #f59e0b;
}
.calendar-day.future {
  opacity: 0.3;
  cursor: not-allowed;
}
.calendar-day.future:hover {
  background: rgba(0, 0, 0, 0.06);
}

body.dark .calendar-day {
  background: rgba(255, 255, 255, 0.08);
}
body.dark .calendar-day:hover {
  background: rgba(255, 255, 255, 0.15);
}
body.dark .calendar-day.today {
  background: rgba(var(--accent-rgb), 0.25);
}
body.dark .calendar-day.selected {
  background: #fff;
  color: #000;
}
body.dark .calendar-day.future:hover {
  background: rgba(255, 255, 255, 0.08);
}

/* Settings Bottom Sheet */
.settings-modal {
  align-items: flex-end;
  justify-content: center;
  padding: 0;
  opacity: 1;
  transition: opacity 0.25s ease;
}
.settings-modal.hidden {
  display: flex !important;
  opacity: 0;
  pointer-events: none;
}
.settings-sheet {
  width: 100%;
  max-width: 385px;
  background: var(--bg);
  border-radius: 24px 24px 0 0;
  padding: 20px 24px calc(28px + env(safe-area-inset-bottom, 0px));
  box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.18);
  position: relative;
  transform: translateY(100%);
  transition: transform 0.32s cubic-bezier(0.32, 0.72, 0, 1);
}
.settings-modal:not(.hidden) .settings-sheet {
  transform: translateY(0);
}
.settings-close-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 50%;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.08);
  color: var(--muted);
  transition: background 0.15s ease, transform 0.15s ease;
}
body.dark .settings-close-btn {
  background: rgba(255, 255, 255, 0.1);
}
.settings-close-btn:hover {
  background: rgba(0, 0, 0, 0.12);
}
body.dark .settings-close-btn:hover {
  background: rgba(255, 255, 255, 0.18);
}
.settings-close-btn svg {
  width: 18px;
  height: 18px;
}
.settings-icons {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
  padding: 48px 0 12px;
}
.settings-circle-btn {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  border: none;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.18s ease, color 0.18s ease, transform 0.12s ease;
  /* Inactive state: grayish */
  background: rgba(0, 0, 0, 0.08);
  color: rgba(0, 0, 0, 0.4);
}
body.dark .settings-circle-btn {
  background: rgba(255, 255, 255, 0.1);
  color: rgba(255, 255, 255, 0.4);
}
.settings-circle-btn:hover {
  transform: scale(1.06);
}
.settings-circle-btn:active {
  transform: scale(0.96);
}
.settings-circle-btn svg {
  width: 26px;
  height: 26px;
}
/* Active state: black bg, white icon */
.settings-circle-btn[aria-pressed="true"] {
  background: #000;
  color: #fff;
}
body.dark .settings-circle-btn[aria-pressed="true"] {
  background: #fff;
  color: #000;
}
/* Icon visibility based on state */
.settings-circle-btn .icon-off { display: none; }
.settings-circle-btn .icon-on { display: block; }
.settings-circle-btn[aria-pressed="false"] .icon-on { display: none; }
.settings-circle-btn[aria-pressed="false"] .icon-off { display: block; }
/* Action buttons (info, restart) - always show single icon */
.settings-circle-btn:not([aria-pressed]) .icon-on,
.settings-circle-btn:not([aria-pressed]) .icon-off {
  display: block;
}

/* Results Bottom Sheet */
.results-modal {
  align-items: flex-end;
  justify-content: center;
  padding: 0;
  opacity: 1;
  transition: opacity 0.25s ease;
}
.results-modal.hidden {
  display: flex !important;
  opacity: 0;
  pointer-events: none;
}
.results-sheet {
  width: 100%;
  max-width: 400px;
  background: var(--bg);
  border-radius: 16px 16px 0 0;
  padding: 14px 20px calc(16px + env(safe-area-inset-bottom, 0px));
  box-shadow: 0 -8px 30px rgba(0, 0, 0, 0.15);
  position: relative;
  transform: translateY(100%);
  transition: transform 0.32s cubic-bezier(0.32, 0.72, 0, 1);
}
.results-modal:not(.hidden) .results-sheet {
  transform: translateY(0);
}
.results-close-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 50%;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.08);
  color: var(--muted);
  transition: background 0.15s ease;
}
body.dark .results-close-btn {
  background: rgba(255, 255, 255, 0.1);
}
.results-close-btn:hover {
  background: rgba(0, 0, 0, 0.12);
}
body.dark .results-close-btn:hover {
  background: rgba(255, 255, 255, 0.18);
}
.results-close-btn svg {
  width: 14px;
  height: 14px;
}

/* Results Score Section */
.results-score-section {
  text-align: center;
  padding: 16px 0 10px;
}
.results-score-value {
  font-size: 28px;
  font-weight: 800;
  color: var(--text);
  line-height: 1.1;
  letter-spacing: -0.5px;
}
.results-score-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-top: 2px;
}

/* Results Stats Row */
.results-stats-row {
  display: flex;
  justify-content: center;
  gap: 20px;
  padding: 8px 0 10px;
}
.results-stat {
  display: flex;
  align-items: center;
  gap: 5px;
}
.results-stat-icon {
  font-size: 13px;
  opacity: 0.6;
}
.results-stat-value {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
}

/* Results Action Buttons (circle icons) */
.results-actions {
  display: flex;
  justify-content: center;
  gap: 12px;
  padding: 10px 0;
}
.results-circle-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: none;
  background: rgba(0, 0, 0, 0.08);
  color: var(--text);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease, transform 0.1s ease;
}
.results-circle-btn:hover {
  background: rgba(0, 0, 0, 0.14);
}
.results-circle-btn:active {
  transform: scale(0.95);
}
.results-circle-btn svg {
  width: 20px;
  height: 20px;
}
body.dark .results-circle-btn {
  background: rgba(255, 255, 255, 0.12);
}
body.dark .results-circle-btn:hover {
  background: rgba(255, 255, 255, 0.20);
}

/* Results End Content */
.results-end-content {
  text-align: center;
  padding: 10px 0;
}
.results-end-content.hidden {
  display: none;
}
.results-end-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 4px;
}
.results-end-text {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.4;
  margin-bottom: 10px;
}
.results-end-text:empty {
  display: none;
}
.results-end-cta-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 24px;
  border: none;
  border-radius: 999px;
  background: #000;
  color: #fff;
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.1s ease;
}
.results-end-cta-btn:hover {
  background: #222;
}
.results-end-cta-btn:active {
  transform: scale(0.97);
}
body.dark .results-end-cta-btn {
  background: #fff;
  color: #000;
}
body.dark .results-end-cta-btn:hover {
  background: #e0e0e0;
}
.results-end-cta-icon {
  width: 18px;
  height: 18px;
}
.results-end-cta-icon.hidden {
  display: none;
}

/* Results Auto-play */
.results-autoplay {
  text-align: center;
  padding: 10px 0 2px;
  font-size: 12px;
  color: var(--muted);
}
.results-autoplay.hidden {
  display: none;
}
.results-autoplay-countdown {
  font-weight: 800;
  color: var(--text);
}

/* RTL (Hebrew/Arabic) Support */
html[dir="rtl"] .home-screen {
  /* Mirror the cover: bottom-right (don’t rely on logical start/end values) */
  /* justify-content: flex-end; */
}

html[dir="rtl"] .home-content {
  direction: rtl;
  text-align: right;
  /* align-items: flex-end;  */
}

html[dir="rtl"] .home-play-btn {
  /* Keep bidi stable while placing icon on the right */
  direction: ltr;
  unicode-bidi: isolate;
  flex-direction: row-reverse; /* Icon on the right in RTL */
}

html[dir="rtl"] .home-play-btn > span{
  unicode-bidi: isolate;
}

html[dir="rtl"] .home-meta-text {
  text-align: right;
}

html[dir="rtl"] .home-actions {
  flex-direction: row-reverse;
  justify-content: flex-end;
}

html[dir="rtl"] .home-play-btn {
  flex-direction: row-reverse;
}

html[dir="rtl"] .home-circle-btns {
  flex-direction: row-reverse;
}

html[dir="rtl"] .difficulty-controls {
  flex-direction: row-reverse;
  justify-content: flex-end;
}

html[dir="rtl"] .modal-close {
  right: auto;
  left: 12px;
}

html[dir="rtl"] .settings-close-btn {
  right: auto;
  left: 10px;
}

html[dir="rtl"] .lb-row {
  flex-direction: row-reverse;
}

html[dir="rtl"] .lb-left {
  flex-direction: row-reverse;
}

html[dir="rtl"] .lb-rank {
  text-align: left;
}

html[dir="rtl"] .lb-controls {
  flex-direction: row-reverse;
}

html[dir="rtl"] .calendar-header {
  flex-direction: row-reverse;
}

html[dir="rtl"] .calendar-nav {
  flex-direction: row-reverse;
}

html[dir="rtl"] .stats-axis-labels {
  flex-direction: row-reverse;
}

html[dir="rtl"] .stats-grid {
  direction: rtl;
}

html[dir="rtl"] .archive-carousel {
  flex-direction: row-reverse;
}
