html,
body,
.container-main {
  margin: 0;
}

body {
  background: #fff;
  direction: rtl;
}

.container-main {
  max-width: 970px;
  margin: 0 auto;
  padding: 0 8px 10px;
}

#myCanvas {
  background-color: #dff3ff;
  display: block;
  width: 600px;
  max-width: 100%;
  height: auto;
  margin: 0 auto;
  touch-action: none;
  position: relative;
  z-index: 2;
  border-radius: 12px;
}

.the-canvas {
  position: relative;
  z-index: 1;
}

.the-controls,
.the-canvas,
.todo {
  padding: 0;
}

.todo {
  width: 620px;
  margin-right: auto;
  margin-left: auto;
}

.btn { cursor: pointer; }
.hidden { display: none !important; }

.maze-main-title {
  text-align: center;
  font-size: 32px;
  margin: 0 0 4px;
  line-height: 1.2;
}

.maze-top-text {
  text-align: center;
  margin: 6px auto 12px;
  font-size: 14px;
  line-height: 1.7;
  color: #333;
  width: 95%;
}

.maze-layout {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  gap: 8px;
  direction: rtl;
}

.the-controls,
.the-canvas { float: none !important; }
.the-controls { width: 310px; flex: 0 0 310px; }
.the-canvas { width: 620px; flex: 0 0 620px; }

.top-panel,
.instructions-panel {
  margin-bottom: 10px;
  border: 1px solid #ddd;
  border-radius: 12px;
  box-shadow: none;
}

.top-panel-body,
.controls-buttons-body,
.instructions-box,
.maze-seo,
.maze-faq,
.maze-win,
.maze-win-box { direction: rtl; }

.top-panel-body {
  padding-top: 14px;
  padding-bottom: 8px;
}

.controls-buttons-body {
  padding-top: 6px !important;
  text-align: center;
}

.instructions-box {
  line-height: 1.9;
  text-align: center;
}

.top-panel-title {
  margin: 0 0 10px;
  font-size: 22px;
  line-height: 1.2;
  text-align: center;
}

.builder-label {
  display: block;
  font-size: 13px;
  color: #333;
  margin: 0 0 6px;
}

.phrase-input,
.builder-select {
  width: 100%;
  border: 1px solid #cfd8e3;
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 16px;
  outline: none;
  background: #fff;
  box-shadow: inset 0 1px 2px rgba(0,0,0,0.04);
}

.phrase-input {
  resize: vertical;
  min-height: 88px;
  line-height: 1.6;
}

.phrase-input:focus,
.builder-select:focus {
  border-color: #5b8def;
  box-shadow: 0 0 0 3px rgba(91,141,239,0.14);
}

.builder-row {
  margin-top: 10px;
}

.phrase-help {
  margin-top: 7px;
  font-size: 12px;
  color: #666;
  text-align: center;
}

.phrase-status {
  margin-top: 10px;
  border-radius: 12px;
  padding: 10px 12px;
  text-align: center;
  font-size: 14px;
  line-height: 1.6;
  border: 1px solid #d9e3f1;
  background: #f8fbff;
  color: #234;
}

.phrase-status.ok { background: #eef9f0; border-color: #bfe0c3; color: #1f6f2f; }
.phrase-status.warn { background: #fff8ea; border-color: #ecd49c; color: #8a5b00; }
.phrase-status.error { background: #fff0f0; border-color: #e4b6b6; color: #a63030; }
.phrase-status.neutral { background: #f8fbff; border-color: #d9e3f1; color: #234; }

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

.stat-pill {
  border: 1px solid #dce6f4;
  border-radius: 12px;
  padding: 8px 10px;
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.stat-label {
  font-size: 12px;
  color: #666;
}

.stat-value {
  font-size: 14px;
  font-weight: bold;
  color: #133b6b;
}

.controls-buttons-body .btn-group,
.controls-buttons-body .print-wrap,
.controls-buttons-body .btn-group.btn-group-justified,
.controls-buttons-body .btn-group.btn-group-justified > .btn-group {
  display: block !important;
  width: 100% !important;
  margin: 0 0 12px 0 !important;
  text-align: center;
}

.controls-buttons-body .btn-group:last-child,
.controls-buttons-body .print-wrap:last-child,
.controls-buttons-body .btn-group.btn-group-justified:last-child {
  margin-bottom: 0 !important;
}

.action-btn,
#create-instant,
#print-maze,
#solve-animate,
#toggle-character-picker {
  display: block !important;
  width: 200px !important;
  max-width: 100%;
  margin: 0 auto !important;
  float: none !important;
  border-radius: 8px;
  font-size: 15px;
}

#toggle-character-picker {
  background: #337ab7 !important;
  border-color: #2e6da4 !important;
  color: #fff !important;
}


.phrase-progress-card {
  margin: 0 auto 10px;
  max-width: 600px;
  background: #eef6ff;
  border: 1px solid #cfe0f2;
  border-radius: 12px;
  padding: 8px 6px 6px;
}

.phrase-progress {
  min-height: 44px;
  line-height: 1.7;
  direction: rtl;
  text-align: center;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: flex-start;
  gap: 6px 8px;
}

.phrase-word {
  display: inline-flex;
  flex-direction: row;
  direction: rtl;
  gap: 3px;
  white-space: nowrap;
  margin: 0 5px;
}

.phrase-space {
  width: 4px;
  display: inline-block;
}

.phrase-progress.empty {
  display:block;
  min-height: 20px;
}

.progress-char {
  display:inline-flex;
  align-items:center;
  justify-content:center;
  width:26px;
  height:31px;
  border-radius:8px;
  border:1px solid #bfd5ef;
  background:#ffffff;
  font-size:18px;
  font-weight:700;
  color:#0b2239;
  vertical-align:middle;
}

.progress-char.pending {
  color:transparent;
  background:#f7fbff;
}

.progress-char.collected {
  color:#0b2239;
  background:#ffffff;
}

.progress-char.next {
  color:#0b2239;
  background:#e9f4ff;
  border-color:#8fb8e8;
}

.maze-stage {
  position: relative;
  width: 100%;
  max-width: 600px;
  margin: 0 auto;
}

.play-hint {
  text-align: center;
  font-size: 13px;
  color: #555;
  margin: 10px 0 8px;
}

.maze-controls-pad {
  width: 210px;
  margin: 0 auto;
  text-align: center;
}

.move-middle {
  display: flex;
  flex-direction: row;
  direction: ltr;
  gap: 8px;
  justify-content: center;
  margin-top: 8px;
}

.move-btn {
  width: 62px;
  height: 50px;
  border: 1px solid #cfd8e3;
  background: #f8fafc;
  border-radius: 12px;
  font-size: 22px;
  font-weight: bold;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.08);
}

.move-btn:hover { background: #eef4ff; }
.move-up { display: block; margin: 0 auto; }

.maze-win {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.9);
  z-index: 5;
  padding: 14px;
  text-align: center;
}

.maze-win-box {
  width: min(92%, 340px);
  background: #fff;
  border: 2px solid #dbeafe;
  border-radius: 18px;
  box-shadow: 0 12px 35px rgba(0, 0, 0, 0.16);
  padding: 20px 16px;
  text-align: center;
  unicode-bidi: plaintext;
}

.maze-win-icon { font-size: 40px; line-height: 1; margin-bottom: 8px; }
.maze-win-title { font-size: 28px; font-weight: bold; color: #2563eb; margin-bottom: 6px; }
.maze-win-text { font-size: 16px; color: #333; margin-bottom: 14px; }
.win-btn { width: 190px; max-width: 100%; margin: 6px auto 0; display: block; border-radius: 10px; }

.character-picker-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.28);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  z-index: 9999;
  padding: 24px 10px;
}

.character-picker-modal {
  width: min(760px, 96vw);
  max-height: 82vh;
  overflow: auto;
  background: #fff;
  border: 1px solid #d7dfec;
  border-radius: 18px;
  padding: 16px 14px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.22);
}

.character-picker-title,
.character-picker-subtitle { text-align: center; }
.character-picker-title { font-size: 18px; font-weight: bold; color: #222; margin-bottom: 6px; }
.character-picker-subtitle { font-size: 13px; color: #666; margin-bottom: 8px; }

.character-options {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(44px, 44px));
  justify-content: center;
  gap: 8px;
}

.character-option {
  width: 44px;
  height: 44px;
  border: 1px solid #cfd8e3;
  background: #fff;
  border-radius: 12px;
  font-size: 26px;
  line-height: 1;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.character-option.active {
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.14);
}

.maze-seo {
  max-width: 920px;
  margin: 28px auto 10px;
  padding: 0 10px;
  line-height: 1.9;
  color: #222;
  text-align: center;
}

.maze-seo h2 { font-size: 26px; margin: 0 0 10px; }
.maze-seo h3 { font-size: 20px; margin: 0 0 6px; }
.maze-seo p { margin: 0 0 16px; font-size: 18px; }

.maze-faq {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin: 8px auto 20px;
}

.faq-item {
  border: 1px solid #e3e7ef;
  border-radius: 12px;
  padding: 14px 12px;
  background: #fff;
}

.maze-big-links { text-align: center; margin: 18px auto; }
.maze-big-btn {
  display: inline-block;
  margin: 6px 8px;
  padding: 12px 22px;
  background: #1a5b94;
  color: #fff !important;
  text-decoration: none;
  border-radius: 10px;
  font-size: 18px;
  line-height: 1.4;
  transition: background 0.2s ease;
}

.maze-big-btn:hover { background: #134872; color: #fff !important; text-decoration: none; }

.ad-loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(255,255,255,0.8);
  z-index: 99998;
  display: none;
  align-items: center;
  justify-content: center;
  flex-direction: column;
}

.ad-loading-overlay.show { display: flex; }

.ad-ring {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 4px solid #dbeafe;
  border-top-color: #2563eb;
  animation: spin 1s linear infinite;
}

.ad-loading-text { margin-top: 10px; font-size: 16px; color: #234; }

@keyframes spin {
  to { transform: rotate(360deg); }
}

@media (max-width: 767px) {
  body { overflow-x: hidden; }

  .container.container-main {
    width: 100%;
    max-width: 100%;
    padding-left: 8px;
    padding-right: 8px;
  }

  .maze-main-title {
    font-size: 21px;
    margin: 8px 0 6px;
    line-height: 1.25;
  }

  .maze-top-text {
    font-size: 13px;
    line-height: 1.8;
    width: 96%;
  }

  .maze-layout {
    display: flex;
    flex-direction: column;
    direction: rtl;
    gap: 0;
  }

  .the-controls,
  .the-canvas,
  .todo,
  #cell-info,
  .col-xs-4,
  .col-xs-8 {
    width: 100% !important;
    flex: none;
    float: none !important;
    padding: 6px;
  }

  .the-canvas { order: 1; }
  .the-controls { order: 2; }

  .top-panel-title { font-size: 20px; }

  .phrase-input { min-height: 84px; }

  .action-btn,
  #create-instant,
  #print-maze,
  #solve-animate,
  #toggle-character-picker {
    width: 175px !important;
  }

  .stats-grid { grid-template-columns: 1fr 1fr; }

  #myCanvas {
    width: 100%;
    max-width: 600px;
    margin: 0 auto;
  }

  .play-hint { font-size: 12px; margin: 8px 0 7px; }
  .maze-controls-pad { width: 190px; }
  .move-btn { width: 56px; height: 46px; font-size: 20px; }
  .maze-win-box { width: min(94%, 310px); padding: 16px 12px; }
  .maze-win-title { font-size: 24px; }
  .win-btn { width: 170px; }
  .character-picker-overlay { padding-top: 16px; }
  .character-picker-modal { width: min(96vw, 640px); max-height: 84vh; padding: 14px 10px; }
  .character-options { grid-template-columns: repeat(6, 1fr); gap: 6px; }
  .character-option { width: 100%; height: 44px; font-size: 25px; }
  .maze-seo { margin-top: 22px; padding: 0 8px; }
  .maze-seo h2 { font-size: 22px; }
  .maze-seo h3 { font-size: 18px; }
  .maze-seo p { font-size: 16px; }
  .maze-faq { grid-template-columns: 1fr; gap: 10px; }
  .phrase-progress-card { padding: 8px 6px; }
  .progress-char { min-width: 24px; height: 30px; font-size: 16px; }
}


.builder-title {
  display:block;
  text-align:center;
  font-size:24px;
  font-weight:700;
  color:#12345a;
  margin:0 0 10px;
}

.create-primary-wrap {
  text-align:center;
  margin:10px 0 12px;
}

.primary-create-btn {
  width:220px !important;
}

.phrase-progress-card {
  margin: 0 auto 10px;
  max-width: 600px;
  background: #eef6ff;
  border: 1px solid #cfe0f2;
  border-radius: 12px;
  padding: 8px 6px 6px;
}

.phrase-progress {
  min-height: 44px;
  line-height: 1.7;
  direction: rtl;
  text-align: right;
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-start;
  align-items: flex-start;
  gap: 6px 8px;
}

.phrase-word {
  display: inline-flex;
  flex-direction: row;
  direction: rtl;
  gap: 3px;
  white-space: nowrap;
  margin: 0 5px;
}

.phrase-space {
  width: 4px;
  display: inline-block;
}

.phrase-progress.empty {
  display:block;
  min-height: 20px;
}

.progress-char {
  display:inline-flex;
  align-items:center;
  justify-content:center;
  width:26px;
  height:31px;
  border-radius:8px;
  border:1px solid #bfd5ef;
  background:#ffffff;
  font-size:18px;
  font-weight:700;
  color:#0b2239;
  vertical-align:middle;
}

.progress-char.pending {
  color:transparent;
  background:#f7fbff;
}

.progress-char.collected {
  color:#0b2239;
  background:#ffffff;
}

.progress-char.next {
  color:#0b2239;
  background:#e9f4ff;
  border-color:#8fb8e8;
}


body {
  margin: 0 !important;
  padding: 0 !important;
}

body > .desktop:first-child,
body > .mobile:first-child {
  margin-top: 0 !important;
  padding-top: 0 !important;
}

.desktop iframe {
  display: block;
  margin: 0 auto 2px;
}

.container-main {
  padding-top: 0 !important;
}

.maze-main-title {
  margin-top: 0 !important;
}

.phrase-progress-card {
  background: #ffffff !important;
  border: 1px solid #d9e3f1 !important;
  padding: 8px 8px 6px !important;
}

.phrase-progress {
  min-height: 36px !important;
  gap: 5px 7px !important;
}

.phrase-word {
  gap: 4px !important;
  margin-left: 8px !important;
}

.progress-char {
  width: 22px !important;
  height: 28px !important;
  border-radius: 7px !important;
  background: #ffffff !important;
  border: 1px solid #c9d9ed !important;
  font-size: 16px !important;
  font-weight: 700 !important;
}

.progress-char.pending {
  background: #ffffff !important;
  color: transparent !important;
}

.progress-char.next {
  background: #eaf4ff !important;
  border-color: #9ec3ee !important;
}

@media (max-width: 767px) {
  .progress-char {
    width: 20px !important;
    min-width: 20px !important;
    height: 26px !important;
    font-size: 14px !important;
  }
}



.share-game-instructions {
  margin: 0 0 12px;
  border: 1px solid #ddd;
  border-radius: 12px;
  box-shadow: none;
  background: #fff;
}

.share-game-instructions.hidden {
  display: none !important;
}

.share-game-instructions-box {
  line-height: 1.9;
  text-align: center;
  font-size: 14px;
  color: #333;
  padding: 12px 10px;
}

/* share/game mode + centered progress */
.phrase-progress-card {
  margin: 0 auto 10px;
  text-align: center;
}

.phrase-progress {
  justify-content: center !important;
  text-align: center !important;
}

.builder-config-area.hidden,
#instructions-panel.hidden,
#share-game-instructions.hidden,
#compact-create-wrap.hidden,
#share-btn-wrap.hidden {
  display: none !important;
}

#compact-create-wrap .action-btn,
#share-btn-wrap .action-btn,
#create-from-game {
  width: 200px !important;
}

.phrase-help strong {
  font-size: 13px;
}

@media (max-width: 767px) {
  .phrase-progress {
    justify-content: center !important;
  }
}


.share-inline-wrap {
  display:block !important;
  width:100% !important;
  margin: 0 auto 10px !important;
  text-align:center;
}

#share-maze {
  width:220px !important;
}

 a {color:blue;}

        h1 {
            margin-top: 5px;
            margin-bottom: 5px;
        }
        .desktop, .mobile {
            display: none;
        }

        @media only screen and (max-width: 768px) {
            .mobile {
                display: block;
            }
        }

        @media only screen and (min-width: 769px) {
            .desktop {
                display: block;
            }
        }
        .responsive-div {
            width: 100%;
        }

        @media only screen and (max-width: 768px) {
            .responsive-div {
                width: 100%; 
            }
        }

        @media only screen and (min-width: 769px) {
            .responsive-div {
                width: 800px; 
                margin: 0 auto; 
            }
        }