/* =========================
   KJOUMAA SUDOKU IQ — STYLE (Fresh Rebuild)
   assets/css/style.css
   ========================= */

:root{
  --bg1:#b5ffd9;
  --bg2:#a5d8ff;
  --bg3:#fbd1ff;

  --card:rgba(255,255,255,.74);
  --card2:#ffffff;
  --stroke:rgba(15,23,42,.10);

  --text:#0f172a;
  --muted:#475569;

  --accent:#38bdf8;
  --accent2:#22c55e;

  --good:#22c55e;
  --bad:#ef4444;

  --shadow: 0 22px 55px rgba(15,23,42,.18);
  --shadow2: 0 12px 28px rgba(15,23,42,.12);

  --radius: 26px;
}

*{ box-sizing:border-box; }
html,body{ height:100%; }
body{
  margin:0;
  font-family:"Poppins",system-ui,-apple-system,Segoe UI,Roboto,Arial,sans-serif;
  color:var(--text);
  background:
    radial-gradient(circle at top left, var(--bg3), transparent 45%),
    radial-gradient(circle at bottom right, var(--bg1), transparent 55%),
    linear-gradient(135deg, var(--bg2), var(--bg1));
  overflow-x:hidden;
}

.orb{ position:fixed; filter:blur(40px); opacity:.45; border-radius:50%; pointer-events:none; z-index:0; }
.o1{ width:380px; height:380px; left:-120px; top:-120px; background:var(--bg3); animation: float1 14s ease-in-out infinite; }
.o2{ width:420px; height:420px; right:-160px; top:18%; background:var(--bg2); animation: float2 16s ease-in-out infinite; }
.o3{ width:360px; height:360px; left:10%; bottom:-160px; background:var(--bg1); animation: float3 18s ease-in-out infinite; }
@keyframes float1{ 0%,100%{ transform:translate(0,0) } 50%{ transform:translate(40px,30px) } }
@keyframes float2{ 0%,100%{ transform:translate(0,0) } 50%{ transform:translate(-35px,25px) } }
@keyframes float3{ 0%,100%{ transform:translate(0,0) } 50%{ transform:translate(25px,-30px) } }

.confetti{ position:fixed; inset:0; z-index:40; pointer-events:none; }

.screen{
  position:relative; z-index:1;
  min-height:100vh;
  display:flex;
  align-items:center;
  justify-content:center;
  padding:20px;
}
.hidden{ display:none !important; }

.card{
  background:var(--card);
  border:1px solid var(--stroke);
  box-shadow:var(--shadow);
  border-radius:var(--radius);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.hero{ width:min(980px, 100%); padding:26px 26px 18px; }

.brand{ display:flex; gap:14px; align-items:center; padding:10px 10px 18px; }
.logo{
  width:56px; height:56px; border-radius:18px;
  display:grid; place-items:center;
  font-weight:900; letter-spacing:.5px;
  background:rgba(255,255,255,.85);
  border:1px solid var(--stroke);
  box-shadow:var(--shadow2);
}
.title{ font-size:34px; font-weight:900; line-height:1; }
.subtitle{ margin-top:4px; color:var(--muted); }

.form{ padding:8px 10px 16px; }
.field{ display:flex; flex-direction:column; gap:8px; margin-bottom:14px; }
.field span{ font-size:13px; color:var(--muted); font-weight:700; }

input,select{
  border-radius:16px;
  border:1px solid var(--stroke);
  background:rgba(255,255,255,.88);
  padding:12px 12px;
  outline:none;
  font-weight:700;
}
input:focus, select:focus{
  box-shadow:0 0 0 4px rgba(56,189,248,.25);
  border-color:rgba(56,189,248,.45);
}

.row{ display:grid; grid-template-columns: 1fr 1fr; gap:14px; }
.btnrow{ display:flex; gap:10px; flex-wrap:wrap; }
.cta{ display:flex; align-items:center; gap:12px; flex-wrap:wrap; padding-top:8px; }
.hint{ color:var(--muted); font-size:13px; font-weight:700; }

.btn{
  border:none;
  border-radius:18px;
  padding:12px 16px;
  font-weight:900;
  cursor:pointer;
  transition: transform .12s ease, box-shadow .12s ease, background .12s ease;
  box-shadow:var(--shadow2);
}
.btn:active{ transform:translateY(1px) scale(.99); box-shadow:0 8px 18px rgba(15,23,42,.14); }
.btn.primary{ background:linear-gradient(135deg, #38bdf8, #22c55e); color:#0b1220; }
.btn.ghost{ background:rgba(255,255,255,.88); color:var(--text); border:1px solid var(--stroke); }
.btn.danger{ background:linear-gradient(135deg, #fb7185, #ef4444); color:white; }

.footnote{ padding:10px 12px 6px; color:var(--muted); font-size:13px; text-align:center; font-weight:700; }

.topbar{
  position:sticky;
  top:0;
  z-index:10;

  padding:10px 12px;
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;

  background:rgba(255,255,255,.72);
  border-bottom:1px solid var(--stroke);
  backdrop-filter: blur(12px);

  margin:0 auto 12px auto;   /* center it */
  max-width:560px;           /* SAME as boardWrap */
  width:100%;
}

/* TOPBAR MUST WRAP ON MOBILE */
.topbar{
  flex-wrap:wrap;
  justify-content:center;
}

/* each section takes full row when needed */
.topbar .left,
.topbar .center,
.topbar .right{
  flex:1 1 100%;
  display:flex;
  justify-content:center;
  gap:10px;
}



.left,.center,.right{ display:flex; align-items:center; gap:10px; }
.center{ flex:1; justify-content:center; flex-wrap:wrap; }

.chip{
  display:flex; align-items:center; gap:10px;
  padding:8px 12px;
  border-radius:999px;
  background:rgba(255,255,255,.88);
  border:1px solid var(--stroke);
  box-shadow:var(--shadow2);
  font-weight:900;
}
.chip b{ font-size:16px; }
.pill{
  display:flex; align-items:center; gap:10px;
  padding:8px 12px;
  border-radius:999px;
  background:rgba(255,255,255,.88);
  border:1px solid var(--stroke);
  box-shadow:var(--shadow2);
}
.pill .dot{ width:10px; height:10px; border-radius:50%; background:var(--accent); box-shadow:0 0 0 4px rgba(56,189,248,.18); }
.pill .label{ color:var(--muted); font-weight:900; font-size:12px; }

.iconbtn{
  border:1px solid var(--stroke);
  background:rgba(255,255,255,.88);
  border-radius:16px;
  padding:10px 12px;
  font-weight:900;
  cursor:pointer;
  box-shadow:var(--shadow2);
  transition: transform .12s ease, box-shadow .12s ease;
}
.iconbtn:active{ transform:translateY(1px); box-shadow:0 8px 18px rgba(15,23,42,.14); }
.iconbtn.danger{ border:none; color:white; background:linear-gradient(135deg,#fb7185,#ef4444); }

.msgwrap{ display:flex; justify-content:center; padding:14px 12px 6px; width:100%; }
.msg{
  width:min(980px, 100%);
  background:rgba(255,255,255,.84);
  border:1px solid var(--stroke);
  border-radius:18px;
  box-shadow:var(--shadow2);
  padding:12px 14px;
  font-weight:900;
  text-align:center;
}

.arena{
  width:min(1200px, 100%);
  margin:0 auto;
  padding:10px 12px 26px;
  display:grid;
  grid-template-columns: 1fr 320px;
  gap:14px;
  align-items:start;
}

/* BOARD WRAP: always contains a square board and the pad below it */
.boardWrap{
  width:100%;
  max-width: 560px;
  margin:0 auto;
  background:rgba(255,255,255,.55);
  border:1px solid var(--stroke);
  border-radius:var(--radius);
  box-shadow:var(--shadow);
  padding:14px;
}

/* THE BOARD IS ALWAYS PERFECTLY SQUARE AND NEVER OVERFLOWS */
.sudoku{
  width:100%;
  aspect-ratio: 1 / 1;
  display:grid;
  grid-template-columns: repeat(9, 1fr);
  grid-template-rows: repeat(9, 1fr);
  border-radius: 22px;
  overflow:hidden;
  background:
    radial-gradient(circle at 20% 20%, rgba(56,189,248,.12), transparent 45%),
    radial-gradient(circle at 80% 70%, rgba(34,197,94,.12), transparent 50%),
    rgba(255,255,255,.94);
  border:1px solid rgba(15,23,42,.12);
}

.cell{
  position:relative;
  border:1px solid rgba(15,23,42,.08);
  background: rgba(241,245,249,.85);
  display:flex;
  align-items:center;
  justify-content:center;
  cursor:pointer;
  user-select:none;
  transition: transform .08s ease, box-shadow .08s ease, background .08s ease;
}
.cell:hover{ transform: translateY(-1px); box-shadow: 0 10px 18px rgba(15,23,42,.10); }
.cell.given{ cursor: default; background:rgba(226,232,240,.78); color:#0b1220; }
.cell.selected{ outline: 3px solid rgba(56,189,248,.55); z-index:2; background: rgba(56,189,248,.10); }
.cell.peer{ background: rgba(56,189,248,.08); }
.cell.same{ background: rgba(34,197,94,.10); }
.cell.wrong{ background: rgba(239,68,68,.16); color:#7f1d1d; }
.cell.correctFlash{ animation: correctFlash .35s ease; }
@keyframes correctFlash{
  0%{ box-shadow: 0 0 0 0 rgba(34,197,94,.0); }
  50%{ box-shadow: 0 0 0 6px rgba(34,197,94,.28); }
  100%{ box-shadow: 0 0 0 0 rgba(34,197,94,.0); }
}

/* Thick borders for 3×3 boxes */
.cell.boxR{ border-right:3px solid rgba(15,23,42,.18); }
.cell.boxB{ border-bottom:3px solid rgba(15,23,42,.18); }

.notes{
  position:absolute;
  inset:6px;
  display:grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  gap:2px;
  font-size: clamp(9px, 2.2vw, 11px);
  font-weight:800;
  color:rgba(15,23,42,.55);
  pointer-events:none;
}
.notes span{ display:flex; align-items:center; justify-content:center; }

.value{
  font-size: clamp(16px, 4.2vw, 26px);
  font-weight:1000;
}

/* PAD: always under the board and same width */
.pad{
  margin-top:14px;
  background:rgba(255,255,255,.72);
  border:1px solid var(--stroke);
  border-radius:22px;
  padding:12px;
  display:grid;
  grid-template-columns: repeat(3, 1fr);
  gap:10px;
  box-shadow:var(--shadow2);
}
.padbtn{
  border:none;
  border-radius:16px;
  padding:12px 10px;
  font-weight:1000;
  cursor:pointer;
  background:rgba(255,255,255,.92);
  border:1px solid rgba(15,23,42,.10);
  box-shadow: 0 10px 18px rgba(15,23,42,.08);
  transition: transform .10s ease, box-shadow .10s ease;
}
.padbtn:active{ transform: translateY(1px); box-shadow: 0 6px 12px rgba(15,23,42,.10); }
.padbtn.wide{ grid-column: 1 / -1; background: linear-gradient(135deg, #fb7185, #ef4444); color:white; }

.side{ display:flex; flex-direction:column; gap:14px; }
.mini{ padding:14px; }
.mini-title{ font-weight:1000; }
.mini-text{ color:var(--muted); margin-top:8px; font-weight:800; line-height:1.35; }
.mini-sep{ height:1px; background:rgba(15,23,42,.10); margin:12px 0; }

.overlay, .modal{
  position:fixed; inset:0; z-index:50;
  display:flex; align-items:center; justify-content:center;
  background: rgba(2,6,23,.55);
  padding:18px;
}
.endCard, .modalCard{
  width:min(520px, 100%);
  background:rgba(255,255,255,.94);
  border:1px solid var(--stroke);
  border-radius: 26px;
  box-shadow: var(--shadow);
  overflow:hidden;
  animation: popEnd .32s ease;
}
@keyframes popEnd{
  from{ transform:scale(.7) translateY(30px); opacity:0; }
  to{ transform:scale(1) translateY(0); opacity:1; }
}
.endCard{ padding:18px 18px 16px; text-align:center; }
.endEmoji{ font-size:44px; }
.endTitle{ font-size:24px; font-weight:1000; margin-top:6px; }
.endText{ color:var(--muted); font-weight:900; margin:10px auto 14px; max-width: 420px; line-height:1.35; }
.endBtns{ display:flex; gap:10px; justify-content:center; flex-wrap:wrap; }

.modalCard{ max-width:680px; }
.modalHead{ display:flex; align-items:center; justify-content:space-between; padding:14px 14px; border-bottom:1px solid rgba(15,23,42,.10); background:rgba(255,255,255,.95); }
.modalTitle{ font-weight:1000; }
.modalBody{ padding:14px; }
.rules{ margin:0; padding-left:18px; color:var(--muted); font-weight:900; line-height:1.6; }
.tipbox{
  margin-top:12px;
  padding:12px;
  border-radius:18px;
  border:1px solid rgba(56,189,248,.25);
  background: rgba(56,189,248,.10);
  font-weight:1000;
}
.modalFoot{ padding:14px; border-top:1px solid rgba(15,23,42,.10); background:rgba(255,255,255,.95); display:flex; justify-content:flex-end; }

.hide-sm{ display:inline; }

@media (max-width: 980px){
  .arena{ grid-template-columns: 1fr; }
  .side{ max-width:560px; margin:0 auto; }
}
@media (max-width: 720px){
  .row{ grid-template-columns: 1fr; }
  .hide-sm{ display:none; }
  .topbar{ position:static; }
  #gameScreen.screen{ align-items:flex-start; }
}

/* ===== GAME SCREEN LAYOUT FIX ===== */

#gameScreen.screen{
  display:block !important;
  min-height:auto !important;
  padding:12px !important;
}

/* Topbar must sit at top like normal header */
#gameScreen .topbar{
  margin:0 auto 12px auto;
}

