.pg-puzzle-game,
.pg-puzzle-game *,
.pg-online-button,
.pg-online-button *{
  box-sizing:border-box;
}

.pg-puzzle-game{
  width:100%;
  padding:25px;
  background:#f5f5f5;
  font-family:Arial,sans-serif;
}

.pg-shell{
  display:flex;
  justify-content:center;
  align-items:flex-start;
  gap:25px;
  direction:ltr;
}

.pg-panel{
  width:230px;
  background:white;
  border:1px solid #ddd;
  border-radius:14px;
  padding:16px;
  text-align:center;
  direction:rtl;
  flex:0 0 auto;
}

.pg-panel h2{
  margin:0 0 15px;
  font-size:20px;
  line-height:1.25;
}

.pg-difficulty{
  display:grid;
  grid-template-columns:1fr;
  gap:8px;
  margin-bottom:16px;
}

.pg-difficulty button,
.pg-action-btn{
  width:100%;
  padding:10px;
  border-radius:8px;
  border:1px solid #ccc;
  background:white;
  color:#111;
  font-family:inherit;
  font-size:15px;
  line-height:1.2;
  cursor:pointer;
}

.pg-difficulty button.selected{
  border:3px solid #222;
  font-weight:bold;
}

.pg-action-btn{
  margin-bottom:16px;
}

.pg-toggle{
  display:flex;
  align-items:center;
  justify-content:flex-start;
  gap:8px;
  margin:10px 0;
  text-align:right;
  font-size:14px;
  line-height:1.35;
  cursor:pointer;
}

.pg-toggle input{
  flex:0 0 auto;
}

.pg-status{
  min-height:42px;
  margin-top:16px;
  color:#333;
  font-size:15px;
  font-weight:700;
  line-height:1.35;
}

.pg-back-link{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  width:100%;
  min-height:40px;
  margin-top:12px;
  padding:9px 12px;
  border:1px solid #222;
  border-radius:8px;
  background:#222;
  color:#fff;
  font-size:15px;
  font-weight:700;
  line-height:1.2;
  text-decoration:none;
}

.pg-back-link:hover,
.pg-back-link:focus{
  background:#fff;
  color:#222;
  text-decoration:none;
}

.pg-board-area{
  direction:ltr;
  text-align:center;
}

.pg-board-wrap{
  display:flex;
  justify-content:center;
  align-items:center;
  min-width:400px;
}

.pg-board{
  --puzzle-image:none;
  --cols:3;
  --rows:3;
  --bg-size-x:300%;
  --bg-size-y:300%;
  width:min(64vw,620px);
  aspect-ratio:1 / 1;
  display:grid;
  grid-template-columns:repeat(var(--cols),1fr);
  grid-template-rows:repeat(var(--rows),1fr);
  gap:5px;
  padding:5px;
  position:relative;
  overflow:hidden;
  border:1px solid #ccc;
  background:#fff;
  touch-action:none;
}

.pg-board::after{
  content:"";
  position:absolute;
  inset:5px;
  z-index:4;
  background-image:var(--puzzle-image);
  background-size:100% 100%;
  background-position:center;
  background-repeat:no-repeat;
  opacity:.2;
  pointer-events:none;
}

.pg-slot{
  position:relative;
  z-index:1;
  min-width:0;
  min-height:0;
  overflow:hidden;
  background:var(--slot-tint,#fff);
}

.pg-slot::before{
  content:"";
  position:absolute;
  inset:0;
  background-image:var(--puzzle-image);
  background-size:var(--bg-size-x) var(--bg-size-y);
  background-position:var(--bg-x) var(--bg-y);
  opacity:.16;
  pointer-events:none;
}

.pg-board.hide-guide .pg-slot::before{
  opacity:0;
}

.pg-board.hide-guide::after{
  opacity:0;
}

.pg-piece{
  position:relative;
  z-index:1;
  width:100%;
  height:100%;
  padding:0;
  border:1px solid rgba(0,0,0,.4);
  background-color:var(--piece-tint,#fff);
  background-image:var(--puzzle-image);
  background-size:var(--bg-size-x) var(--bg-size-y);
  background-position:var(--bg-x) var(--bg-y);
  background-blend-mode:multiply;
  cursor:pointer;
  display:block;
}

.pg-board.no-hints .pg-piece{
  background-color:#fff;
  background-blend-mode:normal;
}

.pg-piece.selected{
  outline:4px solid #59bcf9;
  outline-offset:-4px;
  z-index:2;
}

.pg-piece.correct{
  border-color:rgba(0,0,0,.22);
}

.pg-piece:focus-visible{
  outline:4px solid #111;
  outline-offset:-4px;
}

.pg-board.complete .pg-piece{
  cursor:default;
}

.pg-finish-modal{
  position:fixed;
  inset:0;
  z-index:99999;
  display:none;
  align-items:center;
  justify-content:center;
  padding:20px;
  background:rgba(0,0,0,.45);
}

.pg-finish-modal.is-open{
  display:flex;
}

.pg-finish-card{
  width:min(100%,380px);
  padding:26px;
  border-radius:14px;
  background:#fff;
  color:#111;
  text-align:center;
  direction:rtl;
  box-shadow:0 18px 60px rgba(0,0,0,.22);
}

.pg-finish-card h2{
  margin:0 0 10px;
  font-size:30px;
  line-height:1.2;
}

.pg-finish-card p{
  margin:0 0 20px;
  font-size:18px;
  line-height:1.45;
}

.pg-finish-actions{
  display:grid;
  gap:10px;
}

.pg-finish-actions button,
.pg-finish-actions a{
  display:flex;
  align-items:center;
  justify-content:center;
  min-height:44px;
  padding:10px 14px;
  border:1px solid #111;
  border-radius:8px;
  background:#fff;
  color:#111;
  font-family:inherit;
  font-size:16px;
  font-weight:700;
  line-height:1.2;
  text-decoration:none;
  cursor:pointer;
}

.pg-finish-actions a[hidden]{
  display:none !important;
}

.pg-finish-actions button{
  background:#59bcf9;
  border-color:#59bcf9;
  color:#fff;
}

.pg-finish-actions a:hover,
.pg-finish-actions a:focus,
.pg-finish-actions button:hover,
.pg-finish-actions button:focus{
  filter:brightness(.96);
  text-decoration:none;
}

.pg-online-button{
  display:inline-flex !important;
  align-items:center !important;
  justify-content:center !important;
  gap:10px !important;
  width:357px !important;
  max-width:100% !important;
  min-height:63px !important;
  padding:0 38px !important;
  border:0 !important;
  border-radius:999px !important;
  background:#59bcf9 !important;
  color:#fff !important;
  direction:ltr !important;
  font-family:inherit !important;
  font-size:19px !important;
  font-weight:700 !important;
  line-height:1 !important;
  text-decoration:none !important;
  white-space:nowrap !important;
  box-shadow:none !important;
}

.pg-online-button:hover,
.pg-online-button:focus{
  background:#59bcf9 !important;
  color:#fff !important;
  text-decoration:none !important;
}

.pg-online-button__icon{
  display:inline-flex !important;
  align-items:center !important;
  justify-content:center !important;
  flex:0 0 auto !important;
  width:26px !important;
  height:26px !important;
}

.pg-online-button__svg{
  width:26px !important;
  height:26px !important;
  display:block !important;
  flex:0 0 auto !important;
}

.pg-online-button__text{
  direction:rtl !important;
  color:#fff !important;
  font-size:19px !important;
  font-weight:700 !important;
  line-height:1 !important;
}

@media (max-width:900px){
  .pg-puzzle-game{
    padding:12px;
  }

  .pg-shell{
    flex-direction:column;
    align-items:center;
  }

  .pg-panel{
    width:min(100%,420px);
  }

  .pg-board-wrap{
    min-width:0;
    width:100%;
  }

  .pg-board{
    width:100%;
  }
}

@media (max-width:480px){
  .pg-online-button{
    width:100% !important;
    padding:0 24px !important;
  }
}
