:root {
  --primary: #1e88e5;
  --secondary: #26c6da;
  --gold: #ffc857;
  --gold-deep: #f4a900;
  --sky-top: #b9efff;
  --sky-bottom: #eaf9ff;
  --achievement: #f4b400;
  --success: #34a853;
  --warning: #fb8c00;
  --bg: #f8fafc;
  --surface: #ffffff;
  --surface-soft: rgba(255, 255, 255, 0.74);
  --text: #0f172a;
  --muted: #64748b;
  --line: rgba(51, 65, 85, 0.14);
  --line-strong: rgba(51, 65, 85, 0.28);
  --shadow: 0 22px 0 rgba(15, 23, 42, 0.05), 0 30px 58px rgba(30, 136, 229, 0.16), 0 10px 22px rgba(15, 23, 42, 0.1);
  --shadow-soft: 0 8px 0 rgba(15, 23, 42, 0.035), 0 16px 32px rgba(15, 23, 42, 0.08);
  --button-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.42), inset 0 -5px 0 rgba(0, 87, 166, 0.28), 0 14px 24px rgba(30, 136, 229, 0.26);
  --radius-xl: 24px;
  --radius-lg: 18px;
  --radius-md: 14px;
  --radius-sm: 10px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  color-scheme: light;
}

[data-theme="dark"] {
  --bg: #0f172a;
  --surface: #1e293b;
  --surface-soft: rgba(30, 41, 59, 0.74);
  --text: #f8fafc;
  --muted: #b6c3d4;
  --line: rgba(148, 163, 184, 0.22);
  --line-strong: rgba(203, 213, 225, 0.34);
  --shadow: 0 18px 48px rgba(0, 0, 0, 0.28), 0 8px 22px rgba(0, 0, 0, 0.22);
  --shadow-soft: 0 8px 28px rgba(0, 0, 0, 0.22);
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  width: 100%;
  min-height: 100%;
  margin: 0;
  overflow-x: hidden;
  background:
    linear-gradient(180deg, rgba(38, 198, 218, 0.28), rgba(248, 250, 252, 0) 360px),
    linear-gradient(135deg, rgba(255, 200, 87, 0.24), rgba(52, 168, 83, 0.12) 44%, rgba(30, 136, 229, 0.18)),
    var(--bg);
  color: var(--text);
  font-family: Inter, "Segoe UI", Arial, sans-serif;
  font-weight: 650;
  letter-spacing: 0;
}

body.is-rtl {
  font-family: Cairo, Tajawal, "Segoe UI", Tahoma, Arial, sans-serif;
  font-weight: 700;
}

body::before {
  position: fixed;
  inset: 0;
  z-index: -2;
  background:
    linear-gradient(115deg, transparent 0 28%, rgba(255, 255, 255, 0.38) 28.4% 29%, transparent 29.4% 100%),
    repeating-linear-gradient(90deg, rgba(30, 136, 229, 0.05) 0 1px, transparent 1px 78px),
    repeating-linear-gradient(0deg, rgba(38, 198, 218, 0.05) 0 1px, transparent 1px 78px);
  content: "";
  pointer-events: none;
}

.material-symbols-rounded {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: "Material Symbols Rounded";
  font-size: 1.35em;
  font-style: normal;
  font-weight: 700;
  line-height: 1;
  letter-spacing: 0;
  text-transform: none;
  white-space: nowrap;
  direction: ltr;
  font-feature-settings: "liga";
  -webkit-font-feature-settings: "liga";
  font-variation-settings: "FILL" 1, "wght" 700, "GRAD" 0, "opsz" 32;
}

button,
input,
select {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
  touch-action: manipulation;
  user-select: none;
}

button:focus-visible,
[tabindex]:focus-visible {
  outline: 3px solid rgba(255, 200, 87, 0.88);
  outline-offset: 3px;
}

.app-shell {
  position: relative;
  width: min(100%, 1180px);
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0 auto;
  padding: 14px 16px calc(92px + var(--safe-bottom));
}

.screen-root {
  width: 100%;
}

.topbar {
  position: sticky;
  top: 12px;
  z-index: 15;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  margin-bottom: 14px;
  padding: 7px;
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: 26px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(229, 247, 255, 0.8)),
    var(--surface-soft);
  box-shadow: var(--shadow-soft), inset 0 1px 0 rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(18px);
  transition: transform 240ms ease, opacity 220ms ease;
  will-change: transform, opacity;
}

.topbar.is-scroll-hidden {
  opacity: 0;
  pointer-events: none;
  transform: translateY(calc(-100% - 24px));
}

.profile-chip,
.resource-pill,
.icon-button,
.nav-item,
.tool-button,
.mode-tile,
.level-tile,
.toggle-row,
.language-pill,
.small-action,
.piece,
.slot {
  -webkit-tap-highlight-color: transparent;
}

.profile-chip {
  display: flex;
  min-width: 0;
  height: 54px;
  align-items: center;
  gap: 10px;
  padding: 6px 12px 6px 6px;
  border: 1px solid rgba(255, 255, 255, 0.76);
  border-radius: 20px;
  background: linear-gradient(180deg, #ffffff, #eaf8ff);
  color: var(--text);
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.86), inset 0 -4px 0 rgba(30, 136, 229, 0.08), 0 10px 18px rgba(15, 23, 42, 0.09);
}

[data-theme="dark"] .profile-chip {
  background: linear-gradient(180deg, rgba(51, 65, 85, 0.96), rgba(30, 41, 59, 0.72));
}

.avatar {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border: 2px solid rgba(255, 255, 255, 0.78);
  border-radius: 16px;
  background: radial-gradient(circle at 32% 24%, #fff8bb, var(--gold) 48%, var(--gold-deep));
  box-shadow: inset 0 3px 0 rgba(255, 255, 255, 0.45), inset 0 -5px 0 rgba(143, 94, 0, 0.22), 0 8px 14px rgba(244, 180, 0, 0.28);
  color: #0a5ba7;
  font-size: 25px;
}

.profile-meta {
  display: grid;
  min-width: 0;
  gap: 1px;
  text-align: start;
}

.profile-meta strong,
.profile-meta small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.profile-meta strong {
  font-family: Montserrat, Cairo, sans-serif;
  font-weight: 900;
}

.profile-meta small {
  color: var(--muted);
  font-size: 12px;
}

.resource-strip,
.top-actions {
  display: flex;
  gap: 6px;
  align-items: center;
}

.resource-strip {
  justify-content: flex-start;
}

.resource-pill {
  display: inline-flex;
  min-width: 86px;
  height: 44px;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: 18px;
  background: linear-gradient(180deg, #ffffff, #eef9ff);
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.86), inset 0 -4px 0 rgba(30, 136, 229, 0.08), 0 9px 16px rgba(15, 23, 42, 0.08);
  font-family: Montserrat, Cairo, sans-serif;
  font-weight: 900;
}

.resource-pill .material-symbols-rounded {
  color: var(--achievement);
  filter: drop-shadow(0 2px 0 rgba(143, 94, 0, 0.16));
}

.icon-button {
  display: grid;
  width: 46px;
  height: 46px;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.78);
  border-radius: 18px;
  background: linear-gradient(180deg, #ffffff, #eaf8ff);
  color: #12365f;
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.9), inset 0 -4px 0 rgba(30, 136, 229, 0.08), 0 10px 18px rgba(15, 23, 42, 0.1);
  font-size: 23px;
  transition: transform 160ms ease, box-shadow 160ms ease, filter 160ms ease;
}

.icon-button:hover,
.nav-item:hover,
.tool-button:hover,
.small-action:hover,
.mode-tile:hover,
.level-tile:not(.is-locked):hover {
  transform: translateY(-2px);
}

.bottom-nav {
  position: fixed;
  left: 50%;
  bottom: calc(12px + var(--safe-bottom));
  z-index: 14;
  display: grid;
  width: min(calc(100% - 28px), 620px);
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  padding: 8px;
  border: 1px solid rgba(255, 255, 255, 0.76);
  border-radius: 28px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(232, 248, 255, 0.9));
  box-shadow: 0 18px 0 rgba(15, 23, 42, 0.045), 0 28px 42px rgba(15, 23, 42, 0.16), inset 0 2px 0 rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(18px);
  transform: translateX(-50%);
}

.nav-item {
  display: grid;
  min-width: 0;
  height: 58px;
  place-items: center;
  gap: 2px;
  border-radius: 20px;
  background: transparent;
  color: var(--muted);
  font-family: Cairo, Montserrat, sans-serif;
  font-weight: 900;
}

.nav-item span {
  font-size: 27px;
  line-height: 1;
}

.nav-item strong {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
}

.nav-item.is-active {
  background: linear-gradient(180deg, #dff8ff, #b8edff);
  color: #075fae;
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.86), inset 0 -5px 0 rgba(30, 136, 229, 0.16), 0 9px 16px rgba(30, 136, 229, 0.16);
}

.splash {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 20px;
  padding: 28px;
  background:
    linear-gradient(180deg, rgba(30, 136, 229, 0.16), rgba(38, 198, 218, 0.08)),
    var(--bg);
  transition: opacity 360ms ease, visibility 360ms ease;
}

.splash.is-hidden {
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
}

.splash-icon {
  width: min(54vw, 224px);
  max-height: 224px;
  border-radius: 38px;
  box-shadow: 0 26px 62px rgba(30, 136, 229, 0.28);
  animation: floatBadge 2100ms ease-in-out infinite;
}

.splash-brand {
  display: grid;
  justify-items: center;
  text-transform: uppercase;
  line-height: 0.9;
  color: #10223e;
  text-shadow: 0 5px 12px rgba(30, 136, 229, 0.18);
}

[data-theme="dark"] .splash-brand {
  color: #f8fafc;
}

.splash-brand span,
.brand-wordmark span {
  font-size: 40px;
  font-weight: 900;
}

.splash-brand strong,
.brand-wordmark strong {
  font-size: 46px;
  font-weight: 950;
  color: #18aee8;
}

.splash-brand small,
.brand-wordmark small {
  font-size: 24px;
  font-weight: 850;
  letter-spacing: 0;
}

.loading-track {
  width: min(320px, 80vw);
  height: 13px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(30, 136, 229, 0.14);
  box-shadow: inset 0 2px 4px rgba(15, 23, 42, 0.12);
}

.loading-track span {
  display: block;
  width: 72%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--primary), var(--secondary), var(--gold));
  animation: loadSweep 1200ms ease-in-out infinite;
}

.home-layout {
  display: grid;
  gap: 16px;
}

.home-hero {
  position: relative;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 16px;
  align-items: center;
  padding: 22px;
  border: 1px solid rgba(255, 255, 255, 0.76);
  border-radius: 30px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.94), rgba(231, 248, 255, 0.78)),
    linear-gradient(125deg, rgba(30, 136, 229, 0.22), rgba(255, 200, 87, 0.2));
  box-shadow: var(--shadow), inset 0 2px 0 rgba(255, 255, 255, 0.92);
  overflow: hidden;
}

.home-hero::after {
  position: absolute;
  width: 260px;
  height: 260px;
  inset-inline-end: -44px;
  bottom: -86px;
  border: 16px solid rgba(30, 136, 229, 0.08);
  border-radius: 50%;
  background:
    linear-gradient(90deg, transparent 47%, rgba(30, 136, 229, 0.1) 48% 52%, transparent 53%),
    linear-gradient(0deg, transparent 47%, rgba(30, 136, 229, 0.1) 48% 52%, transparent 53%);
  content: "";
  pointer-events: none;
}

.home-hero > * {
  position: relative;
  z-index: 1;
}

[data-theme="dark"] .home-hero {
  background:
    linear-gradient(135deg, rgba(30, 41, 59, 0.95), rgba(15, 23, 42, 0.68)),
    linear-gradient(125deg, rgba(30, 136, 229, 0.2), rgba(255, 200, 87, 0.12));
}

.brand-icon {
  width: 148px;
  height: 148px;
  object-fit: cover;
  border: 4px solid rgba(255, 220, 106, 0.95);
  border-radius: 34px;
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.52), 0 22px 0 rgba(15, 23, 42, 0.055), 0 24px 38px rgba(30, 136, 229, 0.22);
}

.brand-copy {
  min-width: 0;
}

.brand-wordmark {
  display: grid;
  align-content: start;
  text-transform: uppercase;
  line-height: 0.9;
  filter: drop-shadow(0 5px 0 rgba(15, 23, 42, 0.08));
}

.brand-wordmark span,
.brand-wordmark strong,
.brand-wordmark small,
.splash-brand span,
.splash-brand strong,
.splash-brand small {
  font-family: Montserrat, Cairo, sans-serif;
  font-weight: 900;
}

.brand-wordmark span,
.splash-brand span {
  color: #10223e;
}

.brand-wordmark strong,
.splash-brand strong {
  background: linear-gradient(180deg, #5be8ff 0%, #1e88e5 58%, #0662b1 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  text-shadow: 0 8px 16px rgba(30, 136, 229, 0.14);
}

.brand-copy p {
  max-width: 520px;
  margin: 12px 0 0;
  color: #36536f;
  font-weight: 800;
  line-height: 1.55;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 16px;
}

.primary-action,
.secondary-action,
.gold-action {
  display: inline-flex;
  min-width: 150px;
  min-height: 56px;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 0 18px;
  border-radius: 20px;
  color: #ffffff;
  font-family: Cairo, Montserrat, sans-serif;
  font-weight: 900;
  box-shadow: var(--button-shadow);
}

.primary-action {
  background: linear-gradient(180deg, #4fe7ff 0%, var(--primary) 58%, #0869bf 100%);
}

.secondary-action {
  border: 1px solid rgba(255, 255, 255, 0.78);
  background: linear-gradient(180deg, #ffffff, #edf9ff);
  color: #0b6ec5;
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.9), inset 0 -4px 0 rgba(30, 136, 229, 0.09), 0 12px 20px rgba(15, 23, 42, 0.08);
}

.gold-action {
  color: #3c2c00;
  background: linear-gradient(180deg, #fff4a3 0%, var(--gold) 52%, #ef9f00 100%);
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.58), inset 0 -5px 0 rgba(143, 94, 0, 0.22), 0 14px 22px rgba(244, 180, 0, 0.28);
}

.section-title {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 10px;
  margin: 2px 2px 0;
}

.section-title h2,
.screen-title h1 {
  margin: 0;
  font-size: 24px;
  line-height: 1.18;
  font-family: Cairo, Montserrat, sans-serif;
  font-weight: 900;
  color: #10223e;
  text-shadow: 0 3px 0 rgba(255, 255, 255, 0.72), 0 10px 18px rgba(30, 136, 229, 0.1);
}

.section-title p,
.screen-title p {
  margin: 4px 0 0;
  color: #48637f;
  font-weight: 800;
  line-height: 1.45;
}

.category-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.category-card {
  position: relative;
  display: grid;
  min-height: 292px;
  grid-template-rows: 164px auto;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.78);
  border-radius: 30px;
  background: linear-gradient(180deg, #ffffff, #eef9ff);
  box-shadow: var(--shadow), inset 0 2px 0 rgba(255, 255, 255, 0.92), inset 0 -7px 0 rgba(30, 136, 229, 0.06);
  color: var(--text);
  text-align: start;
  transition: transform 180ms ease, filter 180ms ease, box-shadow 180ms ease;
}

.category-card::after {
  position: absolute;
  inset-inline-end: 16px;
  top: 112px;
  z-index: 3;
  width: 54px;
  height: 54px;
  border: 3px solid rgba(255, 255, 255, 0.75);
  border-radius: 50%;
  background:
    linear-gradient(90deg, transparent 45%, rgba(255, 255, 255, 0.9) 46% 54%, transparent 55%),
    linear-gradient(0deg, transparent 45%, rgba(255, 255, 255, 0.9) 46% 54%, transparent 55%),
    rgba(30, 136, 229, 0.22);
  box-shadow: 0 10px 18px rgba(15, 23, 42, 0.14);
  content: "";
  pointer-events: none;
}

.category-card::before {
  position: absolute;
  inset: 0 0 auto;
  z-index: 2;
  height: 54px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.58), rgba(255, 255, 255, 0));
  content: "";
  pointer-events: none;
}

.category-card:hover {
  filter: saturate(1.08);
  box-shadow: 0 24px 0 rgba(15, 23, 42, 0.055), 0 34px 58px rgba(30, 136, 229, 0.2);
}

.category-card.is-locked {
  filter: saturate(0.72);
}

.category-art {
  position: relative;
  overflow: hidden;
  background: linear-gradient(180deg, #aeefff, #e9fbff);
}

.category-art img,
.category-art svg {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scale(1.02);
}

.category-art::after {
  position: absolute;
  inset: auto 0 0;
  height: 44px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0), var(--surface));
  content: "";
}

.category-info {
  display: grid;
  gap: 10px;
  padding: 16px;
}

.category-info h3 {
  margin: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: Cairo, Montserrat, sans-serif;
  font-size: 21px;
  font-weight: 900;
  line-height: 1.2;
}

.card-title-icon {
  display: inline-grid;
  width: 36px;
  height: 36px;
  place-items: center;
  border-radius: 13px;
  background: linear-gradient(180deg, #fff4a3, var(--gold));
  color: #0b6ec5;
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.62), inset 0 -4px 0 rgba(143, 94, 0, 0.16), 0 8px 14px rgba(244, 180, 0, 0.22);
}

.category-info p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  font-weight: 800;
  line-height: 1.45;
}

.progress-line {
  display: grid;
  gap: 6px;
}

.progress-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  color: var(--primary);
  font-weight: 850;
}

.progress-track {
  height: 9px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(100, 116, 139, 0.18);
}

.progress-track span {
  display: block;
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--success), #72d65d);
}

.status-badge {
  position: absolute;
  top: 12px;
  inset-inline-end: 12px;
  display: inline-flex;
  min-height: 34px;
  align-items: center;
  justify-content: center;
  padding: 0 10px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.78);
  background: linear-gradient(180deg, #fff9bd, var(--gold));
  color: var(--text);
  font-size: 13px;
  font-family: Cairo, Montserrat, sans-serif;
  font-weight: 900;
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.72), inset 0 -4px 0 rgba(143, 94, 0, 0.16), 0 10px 18px rgba(15, 23, 42, 0.13);
  backdrop-filter: blur(12px);
}

.stats-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.stat-card {
  min-width: 0;
  padding: 14px;
  border: 1px solid rgba(255, 255, 255, 0.78);
  border-radius: 22px;
  background: linear-gradient(180deg, #ffffff, #eef9ff);
  box-shadow: var(--shadow-soft), inset 0 2px 0 rgba(255, 255, 255, 0.9);
}

.stat-card strong {
  display: block;
  color: #0b6ec5;
  font-family: Montserrat, Cairo, sans-serif;
  font-size: 26px;
  font-weight: 900;
}

.stat-card span {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 850;
}

.category-screen,
.world-screen,
.settings-panel,
.achievement-panel,
.store-panel {
  display: grid;
  gap: 14px;
}

.screen-head {
  display: flex;
  align-items: center;
  gap: 12px;
}

.screen-title {
  min-width: 0;
}

.preview-stage {
  position: relative;
  min-height: 260px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.78);
  border-radius: 32px;
  background: linear-gradient(135deg, rgba(30, 136, 229, 0.2), rgba(38, 198, 218, 0.12)), var(--surface);
  box-shadow: var(--shadow), inset 0 2px 0 rgba(255, 255, 255, 0.86);
}

.preview-stage .preview-image {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 1;
}

.preview-overlay {
  position: relative;
  z-index: 1;
  display: grid;
  min-height: 260px;
  align-content: end;
  gap: 14px;
  padding: 22px;
  background: linear-gradient(180deg, rgba(15, 23, 42, 0), rgba(15, 23, 42, 0.48));
  color: #fff;
}

.preview-overlay h2 {
  max-width: 640px;
  margin: 0;
  font-family: Cairo, Montserrat, sans-serif;
  font-size: 34px;
  font-weight: 900;
  line-height: 1.16;
  text-shadow: 0 4px 0 rgba(0, 0, 0, 0.18), 0 16px 24px rgba(0, 0, 0, 0.22);
}

.preview-overlay p {
  max-width: 620px;
  margin: 0;
  font-weight: 850;
  line-height: 1.45;
}

.mode-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.mode-tile {
  display: flex;
  min-height: 86px;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border: 1px solid rgba(255, 255, 255, 0.78);
  border-radius: 22px;
  background: linear-gradient(180deg, #ffffff, #eef9ff);
  color: var(--text);
  box-shadow: var(--shadow-soft), inset 0 2px 0 rgba(255, 255, 255, 0.9), inset 0 -5px 0 rgba(30, 136, 229, 0.06);
  text-align: start;
}

.mode-tile span:first-child {
  display: grid;
  width: 48px;
  height: 48px;
  flex: 0 0 48px;
  place-items: center;
  border-radius: 18px;
  background: linear-gradient(180deg, #dff8ff, #aeefff);
  color: #0b6ec5;
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.8), inset 0 -4px 0 rgba(30, 136, 229, 0.14);
  font-size: 28px;
}

.mode-tile strong,
.mode-tile small {
  display: block;
}

.mode-tile strong {
  font-family: Cairo, Montserrat, sans-serif;
  font-size: 16px;
  font-weight: 900;
}

.mode-tile small {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  line-height: 1.35;
}

.level-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
}

.level-tile {
  position: relative;
  display: grid;
  min-height: 92px;
  place-items: center;
  gap: 4px;
  border: 1px solid rgba(255, 255, 255, 0.78);
  border-radius: 22px;
  background: linear-gradient(180deg, #ffffff, #eef9ff);
  color: var(--text);
  box-shadow: var(--shadow-soft), inset 0 2px 0 rgba(255, 255, 255, 0.9), inset 0 -5px 0 rgba(30, 136, 229, 0.06);
}

.level-tile strong {
  color: #12365f;
  font-family: Montserrat, Cairo, sans-serif;
  font-size: 26px;
  font-weight: 900;
}

.level-tile span {
  max-width: 92%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--muted);
  font-size: 11px;
  font-weight: 850;
}

body.is-rtl .category-screen,
body.is-rtl .category-screen .screen-title,
body.is-rtl .category-screen .preview-overlay,
body.is-rtl .category-screen .mode-tile,
body.is-rtl .category-screen .level-tile,
body.is-rtl .game-screen,
body.is-rtl .game-screen .game-title {
  font-family: Cairo, Tajawal, "Segoe UI", Tahoma, Arial, sans-serif;
}

body.is-rtl .category-screen .preview-overlay h2,
body.is-rtl .category-screen .screen-title h1,
body.is-rtl .category-screen .mode-tile strong,
body.is-rtl .category-screen .level-tile span {
  font-family: Cairo, Tajawal, "Segoe UI", Tahoma, Arial, sans-serif;
  font-weight: 900;
}

body.is-rtl .category-screen .level-tile span {
  font-size: 12px;
  letter-spacing: 0;
}

.level-tile.is-done {
  border-color: rgba(52, 168, 83, 0.35);
  background: linear-gradient(180deg, #e8ffef, #ffffff);
  color: var(--success);
}

.level-tile.is-revealed {
  overflow: hidden;
  border-color: rgba(255, 255, 255, 0.84);
  background:
    linear-gradient(180deg, rgba(15, 23, 42, 0.12), rgba(15, 23, 42, 0.7)),
    var(--tile-bg);
  background-position: center;
  background-size: cover;
  color: #ffffff;
  box-shadow: var(--shadow), inset 0 2px 0 rgba(255, 255, 255, 0.36);
}

.level-tile.is-revealed::after {
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.2), transparent 42%);
  content: "";
  pointer-events: none;
}

.level-tile.is-revealed strong,
.level-tile.is-revealed span {
  position: relative;
  z-index: 1;
  color: #ffffff;
  text-shadow: 0 2px 8px rgba(15, 23, 42, 0.72);
}

.level-tile.is-locked {
  cursor: default;
  opacity: 0.58;
}

.game-screen {
  display: grid;
  gap: 12px;
  min-height: calc(100vh - 180px);
}

.game-top {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
}

.game-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.game-title {
  min-width: 0;
  text-align: center;
}

.game-title h1,
.game-title p {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.game-title h1 {
  margin: 0;
  font-size: 20px;
  font-family: Cairo, Montserrat, sans-serif;
  font-weight: 900;
  color: #10223e;
  text-shadow: 0 3px 0 rgba(255, 255, 255, 0.72);
}

.game-title p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
}

.timer-pill,
.attempt-pill {
  display: inline-flex;
  min-width: 92px;
  height: 46px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid rgba(255, 255, 255, 0.78);
  border-radius: 18px;
  background: linear-gradient(180deg, #ffffff, #eef9ff);
  box-shadow: var(--shadow-soft), inset 0 2px 0 rgba(255, 255, 255, 0.9), inset 0 -4px 0 rgba(30, 136, 229, 0.08);
  color: var(--text);
  font-family: Montserrat, Cairo, sans-serif;
  font-weight: 900;
}

.attempt-pill {
  min-width: 70px;
  border-color: rgba(255, 200, 87, 0.72);
  background: linear-gradient(180deg, #fff7cf, #ffcf49);
  color: #7a4a00;
  box-shadow: var(--shadow-soft), inset 0 2px 0 rgba(255, 255, 255, 0.82), inset 0 -5px 0 rgba(180, 94, 0, 0.1);
}

.playfield {
  display: grid;
  grid-template-columns: minmax(250px, 0.92fr) minmax(300px, 1.12fr);
  gap: 14px;
  align-items: stretch;
}

.country-clue,
.puzzle-panel,
.piece-tray,
.tool-row,
.win-panel,
.ad-banner {
  border: 1px solid rgba(255, 255, 255, 0.78);
  border-radius: 30px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.92), rgba(235, 249, 255, 0.86));
  box-shadow: var(--shadow), inset 0 2px 0 rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(16px);
}

.country-clue {
  position: relative;
  min-height: 400px;
  overflow: hidden;
  outline: 4px solid rgba(255, 255, 255, 0.38);
  outline-offset: -8px;
}

.clue-image {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: saturate(1.04);
}

.country-clue::after {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(15, 23, 42, 0), rgba(15, 23, 42, 0.28));
  content: "";
}

.clue-content {
  position: absolute;
  inset: auto 0 0;
  z-index: 1;
  display: grid;
  gap: 8px;
  padding: 18px;
  background: linear-gradient(180deg, rgba(3, 18, 39, 0), rgba(3, 18, 39, 0.64));
  color: #fff;
}

.clue-content h2 {
  margin: 0;
  font-size: 24px;
  font-family: Cairo, Montserrat, sans-serif;
  font-weight: 900;
  line-height: 1.16;
  text-shadow: 0 4px 0 rgba(0, 0, 0, 0.18);
}

.clue-content p {
  margin: 0;
  font-weight: 850;
  line-height: 1.45;
}

.puzzle-panel {
  display: grid;
  gap: 12px;
  padding: 14px;
}

.puzzle-board {
  display: grid;
  width: min(100%, 390px);
  aspect-ratio: 1 / 1;
  direction: ltr;
  unicode-bidi: isolate;
  gap: 0;
  justify-self: center;
  padding: 4px;
  border: 1px solid rgba(255, 255, 255, 0.74);
  border-radius: 24px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(212, 242, 255, 0.78));
  box-shadow: inset 0 4px 10px rgba(255, 255, 255, 0.82), inset 0 -7px 18px rgba(30, 136, 229, 0.1), 0 12px 18px rgba(15, 23, 42, 0.1);
}

[data-theme="dark"] .puzzle-board {
  background: linear-gradient(180deg, rgba(30, 41, 59, 0.95), rgba(15, 23, 42, 0.82));
}

.slot {
  position: relative;
  display: grid;
  min-width: 0;
  min-height: 0;
  place-items: center;
  overflow: hidden;
  border: 0;
  border-radius: 3px;
  background:
    linear-gradient(135deg, rgba(30, 136, 229, 0.08), rgba(38, 198, 218, 0.08)),
    rgba(255, 255, 255, 0.46);
  background-repeat: no-repeat;
  box-shadow: inset 0 0 0 1px rgba(30, 136, 229, 0.08);
}

.slot.is-filled {
  border: 0;
  border-radius: 0;
  box-shadow: none;
}

.slot.is-hint,
.piece.is-hint {
  animation: hintPulse 900ms ease-in-out 3;
}

.piece.is-hint {
  opacity: 1;
  box-shadow:
    0 16px 24px rgba(30, 136, 229, 0.24),
    0 0 0 4px rgba(255, 200, 87, 0.9),
    0 0 28px rgba(255, 200, 87, 0.4);
  transform: translateY(-4px) scale(1.04);
}

.piece.is-used.is-hint {
  opacity: 0.78;
  pointer-events: none;
}

.piece-tray {
  display: grid;
  min-height: 118px;
  grid-template-columns: repeat(auto-fit, minmax(62px, 1fr));
  direction: ltr;
  unicode-bidi: isolate;
  gap: 10px;
  align-items: center;
  padding: 14px;
}

.piece {
  position: relative;
  display: block;
  width: 100%;
  aspect-ratio: 1 / 1;
  border: 2px solid rgba(255, 255, 255, 0.82);
  border-radius: 18px;
  background-color: #e8f6fb;
  background-repeat: no-repeat;
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.36), inset 0 -5px 0 rgba(15, 23, 42, 0.12), 0 12px 20px rgba(15, 23, 42, 0.16);
  transition: transform 150ms ease, box-shadow 150ms ease, opacity 160ms ease;
}

.piece.is-selected {
  transform: translateY(-5px) scale(1.03);
  box-shadow: 0 16px 24px rgba(30, 136, 229, 0.24), 0 0 0 3px rgba(255, 200, 87, 0.86);
}

.piece.is-used {
  opacity: 0.22;
  pointer-events: none;
}

.piece.is-wrong {
  animation: shake 320ms ease;
}

.tool-row {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 7px;
  padding: 8px;
}

.tool-button {
  position: relative;
  display: grid;
  min-height: 62px;
  grid-template-rows: auto auto;
  place-items: center;
  align-content: center;
  gap: 3px;
  min-width: 0;
  padding: 14px 4px 7px;
  border: 1px solid rgba(255, 255, 255, 0.78);
  border-radius: 22px;
  background: linear-gradient(180deg, #ffffff, #eef9ff);
  color: var(--text);
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.9), inset 0 -5px 0 rgba(30, 136, 229, 0.07), 0 10px 18px rgba(15, 23, 42, 0.08);
  font-family: Cairo, Montserrat, sans-serif;
  font-weight: 900;
}

.tool-button .tool-icon {
  color: #0b6ec5;
  font-size: 25px;
  line-height: 1;
}

.tool-button strong {
  max-width: 100%;
  overflow: hidden;
  font-size: 11.5px;
  line-height: 1.1;
  text-overflow: ellipsis;
  white-space: normal;
  overflow-wrap: anywhere;
}

.tool-badge {
  position: absolute;
  top: 5px;
  left: 6px;
  display: inline-flex;
  min-width: 20px;
  height: 18px;
  align-items: center;
  justify-content: center;
  padding: 0 6px;
  border: 1px solid rgba(255, 255, 255, 0.9);
  border-radius: 999px;
  background: linear-gradient(180deg, #ffe88a, #f6ad1f);
  color: #12365f;
  box-shadow: 0 5px 10px rgba(180, 111, 0, 0.2), inset 0 1px 0 rgba(255, 255, 255, 0.76);
  font-family: Cairo, Montserrat, sans-serif;
  font-size: 9px;
  font-weight: 950;
  line-height: 1;
  pointer-events: none;
}

.tool-button.is-smart .tool-icon {
  color: #177bd4;
  text-shadow: 0 5px 12px rgba(30, 136, 229, 0.22);
}

.tool-button.is-prime {
  border-color: rgba(255, 211, 78, 0.78);
  background: linear-gradient(180deg, #fff8d6, #ffcf43);
  color: #3c2a00;
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.9), inset 0 -5px 0 rgba(128, 78, 0, 0.1), 0 12px 20px rgba(180, 111, 0, 0.2);
}

.tool-button.is-prime .tool-icon {
  color: #a55f00;
}

.tool-button.is-prime .tool-badge {
  background: linear-gradient(180deg, #fff3ad, #f4a900);
  color: #3c2a00;
}

.ad-banner {
  display: none;
  min-height: max(72px, 12vh);
  align-items: center;
  justify-content: center;
  padding: 14px;
  border-style: dashed;
  color: var(--muted);
  text-align: center;
  font-weight: 800;
}

.ad-banner.is-visible {
  display: flex;
}

.completion-hero {
  position: relative;
  display: grid;
  min-height: 270px;
  place-items: center;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.86);
  border-radius: 32px;
  background:
    radial-gradient(circle at 50% 18%, rgba(255, 228, 122, 0.34), transparent 34%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(220, 247, 255, 0.88));
  box-shadow: var(--shadow), inset 0 2px 0 rgba(255, 255, 255, 0.9);
  animation: victoryReveal 720ms cubic-bezier(0.2, 0.9, 0.2, 1) both;
}

.completion-hero::after {
  position: absolute;
  inset: -40%;
  background: linear-gradient(105deg, transparent 38%, rgba(255, 255, 255, 0.54) 48%, transparent 58%);
  content: "";
  transform: translateX(-52%) rotate(8deg);
  animation: victorySheen 1400ms ease-out both;
  pointer-events: none;
}

.flag-result {
  position: relative;
  z-index: 1;
  display: block;
  width: auto;
  max-width: min(88%, 420px);
  height: auto;
  max-height: 260px;
  object-fit: contain;
  overflow: hidden;
  border: 4px solid rgba(255, 255, 255, 0.86);
  border-radius: 30px;
  background: #ffffff;
  box-shadow:
    0 22px 34px rgba(15, 23, 42, 0.18),
    0 0 0 8px rgba(255, 200, 87, 0.12),
    0 0 34px rgba(255, 200, 87, 0.34);
  animation: flagReveal 760ms cubic-bezier(0.18, 0.9, 0.18, 1) both, flagGlow 2600ms ease-in-out infinite;
}

.completion-hero.is-monument img {
  width: min(88%, 360px);
  aspect-ratio: 1 / 1;
  object-fit: cover;
  border: 4px solid rgba(255, 255, 255, 0.86);
  border-radius: 30px;
  box-shadow: 0 22px 32px rgba(15, 23, 42, 0.18);
}

.win-panel {
  display: grid;
  gap: 14px;
  padding: 20px;
}

.puzzle-panel.is-complete .win-panel {
  grid-template-columns: 1fr;
  align-items: stretch;
  gap: 14px;
  padding: 20px;
}

.win-panel h2,
.win-panel p {
  margin: 0;
  text-align: center;
}

.win-panel h2 {
  font-family: Cairo, Montserrat, sans-serif;
  font-size: 25px;
  font-weight: 900;
  color: #10223e;
}

.puzzle-panel.is-complete .hero-actions {
  grid-column: 1 / -1;
  margin-top: 0;
}

.win-panel p {
  color: var(--muted);
  font-weight: 850;
  line-height: 1.55;
}

.win-facts {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.win-facts span {
  display: grid;
  gap: 4px;
  min-width: 0;
  padding: 12px;
  border: 1px solid rgba(30, 136, 229, 0.1);
  border-radius: 18px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.86), rgba(236, 249, 255, 0.74));
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.8);
}

.win-facts small {
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
}

.win-facts strong {
  overflow-wrap: anywhere;
  color: var(--text);
  font-weight: 900;
}

.modal-root {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: grid;
  place-items: center;
  padding: 18px;
  overflow: auto;
  background: rgba(15, 23, 42, 0.44);
  backdrop-filter: blur(8px);
}

.modal-root.is-hidden {
  display: none;
}

.modal-card {
  width: min(100%, 560px);
  max-height: min(84vh, 760px);
  max-height: min(84dvh, 760px);
  overflow: auto;
  border: 1px solid rgba(255, 255, 255, 0.78);
  border-radius: 30px;
  background: linear-gradient(180deg, #ffffff, #eef9ff);
  box-shadow: 0 28px 80px rgba(15, 23, 42, 0.34);
}

.modal-head {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-soft);
  backdrop-filter: blur(18px);
}

.modal-head h2 {
  margin: 0;
  font-size: 21px;
  font-family: Cairo, Montserrat, sans-serif;
  font-weight: 900;
}

.modal-body {
  display: grid;
  gap: 12px;
  padding: 16px;
}

.settings-group {
  display: grid;
  gap: 8px;
}

.settings-group h3 {
  margin: 0;
  font-size: 15px;
}

.language-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.language-pill,
.toggle-row,
.link-row {
  display: flex;
  min-height: 52px;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid rgba(255, 255, 255, 0.76);
  border-radius: 18px;
  background: linear-gradient(180deg, #ffffff, #f2fbff);
  color: var(--text);
  text-align: start;
  text-decoration: none;
  font-family: Cairo, Montserrat, sans-serif;
  font-weight: 900;
}

.language-pill.is-active {
  border-color: rgba(30, 136, 229, 0.42);
  background: linear-gradient(135deg, rgba(30, 136, 229, 0.14), rgba(38, 198, 218, 0.13));
  color: var(--primary);
}

.language-pill.is-disabled {
  opacity: 0.58;
}

.language-pill.is-disabled strong {
  color: var(--muted);
  font-size: 11px;
}

.switch {
  position: relative;
  flex: 0 0 auto;
  width: 50px;
  height: 30px;
  border-radius: 999px;
  background: rgba(100, 116, 139, 0.28);
  transition: background 160ms ease;
}

.switch::after {
  position: absolute;
  top: 4px;
  inset-inline-start: 4px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 3px 8px rgba(15, 23, 42, 0.22);
  content: "";
  transition: transform 160ms ease;
}

.toggle-row.is-on .switch {
  background: var(--success);
}

.toggle-row.is-on .switch::after {
  transform: translateX(20px);
}

body.is-rtl .toggle-row.is-on .switch::after {
  transform: translateX(-20px);
}

.achievement-list {
  display: grid;
  gap: 10px;
}

.achievement-item {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 12px;
  border: 1px solid rgba(255, 255, 255, 0.76);
  border-radius: 22px;
  background: linear-gradient(180deg, #ffffff, #f2fbff);
  box-shadow: var(--shadow-soft), inset 0 2px 0 rgba(255, 255, 255, 0.9);
}

.achievement-icon {
  display: grid;
  width: 52px;
  height: 52px;
  place-items: center;
  border-radius: 18px;
  background: linear-gradient(180deg, #fff7ad, var(--achievement));
  color: #0b6ec5;
  font-size: 29px;
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.62), inset 0 -5px 0 rgba(143, 94, 0, 0.18), 0 10px 16px rgba(244, 180, 0, 0.23);
}

.achievement-copy {
  min-width: 0;
}

.achievement-copy strong,
.achievement-copy small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.achievement-copy small {
  margin-top: 4px;
  color: var(--muted);
  font-weight: 700;
}

.achievement-check {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 999px;
  background: rgba(100, 116, 139, 0.16);
  color: var(--muted);
  font-weight: 900;
}

.achievement-item.is-complete .achievement-check {
  background: var(--success);
  color: #fff;
}

.store-hero {
  display: grid;
  gap: 14px;
  padding: 18px;
  border: 1px solid rgba(255, 255, 255, 0.78);
  border-radius: 30px;
  background:
    linear-gradient(135deg, rgba(255, 228, 122, 0.52), rgba(255, 200, 87, 0.2)),
    var(--surface);
  box-shadow: var(--shadow), inset 0 2px 0 rgba(255, 255, 255, 0.9);
}

.prime-list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.prime-list li {
  display: flex;
  gap: 8px;
  align-items: center;
  color: var(--text);
  font-weight: 750;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(96px + var(--safe-bottom));
  z-index: 90;
  max-width: min(92vw, 460px);
  padding: 12px 16px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow);
  font-weight: 800;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 16px);
  transition: opacity 180ms ease, transform 180ms ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

.is-hidden {
  display: none !important;
}

@keyframes floatBadge {
  0%,
  100% {
    transform: translateY(0) rotate(-1deg);
  }
  50% {
    transform: translateY(-10px) rotate(1deg);
  }
}

@keyframes loadSweep {
  0% {
    transform: translateX(-82%);
  }
  100% {
    transform: translateX(152%);
  }
}

@keyframes hintPulse {
  0%,
  100% {
    box-shadow: inset 0 0 0 1px rgba(255, 200, 87, 0.3);
  }
  50% {
    box-shadow: inset 0 0 0 3px rgba(255, 200, 87, 0.92), 0 0 0 4px rgba(255, 200, 87, 0.18);
  }
}

@keyframes shake {
  0%,
  100% {
    transform: translateX(0);
  }
  25% {
    transform: translateX(-6px);
  }
  75% {
    transform: translateX(6px);
  }
}

@keyframes victoryReveal {
  0% {
    opacity: 0;
    transform: translateY(18px) scale(0.94);
    filter: saturate(0.9);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
    filter: saturate(1.08);
  }
}

@keyframes victorySheen {
  0% {
    transform: translateX(-58%) rotate(8deg);
  }
  100% {
    transform: translateX(58%) rotate(8deg);
  }
}

@keyframes flagReveal {
  0% {
    opacity: 0;
    transform: translateY(16px) scale(0.92);
    filter: saturate(0.92) brightness(1.04);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
    filter: saturate(1.04) brightness(1);
  }
}

@keyframes flagGlow {
  0%,
  100% {
    box-shadow:
      0 22px 34px rgba(15, 23, 42, 0.18),
      0 0 0 8px rgba(255, 200, 87, 0.1),
      0 0 28px rgba(255, 200, 87, 0.28);
  }
  50% {
    box-shadow:
      0 24px 38px rgba(15, 23, 42, 0.2),
      0 0 0 10px rgba(255, 200, 87, 0.14),
      0 0 42px rgba(255, 200, 87, 0.42);
  }
}

@media (min-width: 900px) {
  .home-layout {
    grid-template-columns: minmax(0, 1fr);
  }

  .category-screen {
    grid-template-columns: minmax(0, 0.9fr) minmax(320px, 0.7fr);
    align-items: start;
  }

  .category-screen .screen-head,
  .category-screen .preview-stage {
    grid-column: 1 / -1;
  }
}

@media (max-width: 840px) {
  .app-shell {
    padding: 10px 10px calc(92px + var(--safe-bottom));
  }

  .topbar {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .resource-strip {
    grid-row: auto;
    grid-column: auto;
    justify-content: flex-start;
  }

  .top-actions {
    justify-content: end;
  }

  .home-hero {
    grid-template-columns: 1fr;
    justify-items: center;
    text-align: center;
  }

  .brand-copy p {
    margin-inline: auto;
  }

  .hero-actions {
    justify-content: center;
  }

  .category-grid,
  .stats-row,
  .mode-actions {
    grid-template-columns: 1fr;
  }

  .level-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .playfield {
    grid-template-columns: 1fr;
  }

  .country-clue {
    min-height: 210px;
  }

  .puzzle-board {
    width: min(100%, 390px);
  }
}

@media (max-width: 520px) {
  .app-shell {
    padding-inline: 8px;
    padding-bottom: calc(88px + var(--safe-bottom));
  }

  .topbar {
    top: 8px;
    margin-bottom: 10px;
    border-radius: 22px;
  }

  .resource-pill {
    min-width: 76px;
    height: 42px;
    padding-inline: 10px;
  }

  .icon-button {
    width: 44px;
    height: 44px;
    border-radius: 16px;
  }

  .brand-icon {
    width: 108px;
    height: 108px;
    border-radius: 24px;
  }

  .splash-brand span,
  .brand-wordmark span {
    font-size: 34px;
  }

  .splash-brand strong,
  .brand-wordmark strong {
    font-size: 40px;
  }

  .splash-brand small,
  .brand-wordmark small {
    font-size: 21px;
  }

  .section-title {
    display: grid;
  }

  .screen-head {
    gap: 8px;
  }

  .section-title h2,
  .screen-title h1 {
    font-size: 21px;
  }

  .screen-title p {
    font-size: 13px;
  }

  .preview-stage,
  .preview-overlay {
    min-height: 220px;
    border-radius: 26px;
  }

  .preview-overlay {
    gap: 10px;
    padding: 16px;
  }

  .preview-overlay h2 {
    font-size: 27px;
  }

  .mode-tile {
    min-height: 76px;
    padding: 10px;
  }

  .mode-tile span:first-child {
    width: 42px;
    height: 42px;
    flex-basis: 42px;
    border-radius: 15px;
  }

  .level-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
  }

  .level-tile {
    min-height: 86px;
    border-radius: 18px;
  }

  .level-tile strong {
    font-size: 23px;
  }

  .game-top {
    grid-template-columns: auto minmax(0, 1fr) auto;
    gap: 6px;
  }

  .game-title h1 {
    font-size: 17px;
  }

  .game-title p {
    font-size: 12px;
  }

  .game-actions {
    gap: 5px;
  }

  .attempt-pill,
  .timer-pill {
    min-width: 76px;
    height: 44px;
    padding-inline: 8px;
    gap: 5px;
  }

  .attempt-pill {
    min-width: 58px;
  }

  .country-clue,
  .puzzle-panel,
  .piece-tray,
  .tool-row,
  .win-panel,
  .ad-banner {
    border-radius: 24px;
  }

  .country-clue {
    min-height: 190px;
    outline-width: 3px;
  }

  .clue-content {
    padding: 14px;
  }

  .clue-content h2 {
    font-size: 21px;
  }

  .clue-content p {
    font-size: 13px;
  }

  .puzzle-panel {
    gap: 10px;
    padding: 10px;
  }

  .puzzle-board {
    padding: 3px;
    border-radius: 20px;
  }

  .tool-row {
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 5px;
    padding: 6px;
  }

  .tool-button {
    min-height: 60px;
    border-radius: 18px;
    padding: 13px 3px 6px;
  }

  .tool-button .tool-icon {
    font-size: 23px;
  }

  .tool-button strong {
    font-size: 10.5px;
  }

  .tool-badge {
    top: 4px;
    left: 4px;
    min-width: 18px;
    height: 16px;
    padding-inline: 5px;
    font-size: 8px;
  }

  .puzzle-panel.is-complete .win-panel {
    grid-template-columns: 1fr;
    padding: 14px;
  }

  .completion-hero {
    min-height: 220px;
    border-radius: 26px;
  }

  .flag-result {
    max-width: min(88%, 330px);
    max-height: 220px;
    border-radius: 24px;
  }

  .win-facts {
    grid-template-columns: 1fr;
  }

  .piece-tray {
    min-height: 102px;
    grid-template-columns: repeat(auto-fit, minmax(58px, 1fr));
    gap: 8px;
    padding: 10px;
  }

  .piece {
    border-radius: 14px;
  }

  .bottom-nav {
    width: calc(100% - 16px);
    gap: 4px;
    padding: 6px;
    border-radius: 20px;
  }

  .nav-item {
    height: 52px;
    border-radius: 15px;
  }

  .modal-root {
    padding: 10px;
  }

  .modal-card {
    max-height: calc(100dvh - 20px);
    border-radius: 24px;
  }

  .modal-head,
  .modal-body {
    padding: 12px;
  }
}

@media (max-width: 380px) {
  .app-shell {
    padding-inline: 6px;
    padding-bottom: calc(84px + var(--safe-bottom));
  }

  .topbar {
    gap: 5px;
    padding: 5px;
  }

  .resource-pill {
    min-width: 68px;
    height: 40px;
    gap: 4px;
    font-size: 13px;
  }

  .icon-button {
    width: 42px;
    height: 42px;
  }

  .hero-actions {
    display: grid;
    grid-template-columns: 1fr;
  }

  .primary-action,
  .secondary-action,
  .gold-action {
    width: 100%;
    min-width: 0;
    min-height: 52px;
  }

  .category-card {
    min-height: 248px;
    grid-template-rows: 132px auto;
    border-radius: 24px;
  }

  .category-info {
    gap: 7px;
    padding: 12px;
  }

  .category-info h3 {
    font-size: 18px;
  }

  .category-info p {
    font-size: 12px;
  }

  .stats-row {
    gap: 7px;
  }

  .stat-card {
    padding: 11px;
    border-radius: 18px;
  }

  .level-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .game-top {
    grid-template-columns: auto minmax(0, 1fr);
  }

  .game-actions {
    grid-column: 1 / -1;
    justify-content: center;
  }

  .country-clue {
    min-height: 170px;
  }

  .puzzle-board {
    width: min(100%, 330px);
  }

  .tool-row {
    gap: 3px;
    padding: 5px 4px;
  }

  .tool-button {
    min-height: 56px;
    border-radius: 16px;
    padding: 12px 2px 5px;
  }

  .tool-button .tool-icon {
    font-size: 21px;
  }

  .tool-button strong {
    font-size: 9.5px;
    line-height: 1.05;
  }

  .piece-tray {
    grid-template-columns: repeat(auto-fit, minmax(50px, 1fr));
    gap: 7px;
  }

  .completion-hero {
    min-height: 196px;
  }

  .win-panel h2 {
    font-size: 21px;
  }

  .bottom-nav {
    bottom: calc(8px + var(--safe-bottom));
    width: calc(100% - 10px);
    padding: 5px;
    border-radius: 18px;
  }

  .nav-item {
    height: 50px;
    border-radius: 14px;
  }

  .nav-item span {
    font-size: 24px;
  }

  .nav-item strong {
    font-size: 10px;
  }

  .language-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-height: 520px) and (min-width: 680px) {
  .app-shell {
    padding-top: 8px;
    padding-bottom: 18px;
  }

  .topbar,
  .bottom-nav {
    position: static;
    transform: none;
  }

  .bottom-nav {
    margin: 10px auto 0;
  }

  .game-screen {
    gap: 8px;
  }

  .playfield {
    grid-template-columns: minmax(230px, 0.86fr) minmax(320px, 1.14fr);
    gap: 10px;
  }

  .country-clue {
    min-height: 220px;
  }

  .puzzle-panel {
    gap: 8px;
    padding: 10px;
  }

  .puzzle-board {
    width: min(100%, 320px);
  }

  .piece-tray {
    min-height: 92px;
    grid-template-columns: repeat(auto-fit, minmax(48px, 1fr));
    gap: 7px;
    padding: 9px;
  }

  .tool-row {
    gap: 5px;
    padding: 6px;
  }

  .tool-button {
    min-height: 56px;
  }
}

@media (min-width: 1200px) {
  .app-shell {
    padding-top: 22px;
  }

  .category-card {
    min-height: 280px;
  }

  .preview-stage,
  .preview-overlay {
    min-height: 320px;
  }
}

@media (min-width: 1440px) {
  .app-shell {
    width: min(100%, 1320px);
  }

  .category-grid {
    gap: 18px;
  }

  .level-grid {
    grid-template-columns: repeat(6, minmax(0, 1fr));
  }

  .playfield {
    grid-template-columns: minmax(380px, 0.9fr) minmax(480px, 1fr);
    gap: 18px;
  }

  .puzzle-board {
    width: min(100%, 500px);
  }
}

@media (min-width: 1800px) {
  .app-shell {
    width: min(100%, 1500px);
  }

  .home-layout,
  .world-screen,
  .category-screen,
  .game-screen,
  .achievement-panel,
  .store-panel {
    gap: 18px;
  }

  .category-card {
    min-height: 324px;
    grid-template-rows: 190px auto;
  }

  .preview-stage,
  .preview-overlay {
    min-height: 380px;
  }

  .country-clue {
    min-height: 560px;
  }

  .puzzle-board {
    width: min(100%, 560px);
  }

  .piece-tray {
    min-height: 160px;
    grid-template-columns: repeat(auto-fit, minmax(78px, 1fr));
  }
}

@media (min-height: 850px) {
  .country-clue {
    min-height: 480px;
  }

  .puzzle-board {
    width: min(100%, 460px);
  }

  .piece-tray {
    min-height: 150px;
    grid-template-columns: repeat(auto-fit, minmax(70px, 1fr));
  }

  .tool-button {
    min-height: 64px;
  }
}

@media (min-width: 1800px) and (min-height: 850px) {
  .country-clue {
    min-height: 560px;
  }

  .puzzle-board {
    width: min(100%, 560px);
  }

  .piece-tray {
    min-height: 160px;
    grid-template-columns: repeat(auto-fit, minmax(78px, 1fr));
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}
