:root{
  color-scheme: dark;

  /* Base surfaces (same overall feel as the reference playground) */
  --bg: #232C30;
  --surface: #060C0E;

  --border: rgba(255,255,255,0.10);
  --border2: rgba(255,255,255,0.16);
  --borderSoft: rgba(255,255,255,0.08);

  --text: rgba(243,240,239,0.96);
  --textSoft: rgba(243,240,239,0.92);
  --textSub: rgba(243,240,239,0.80);
  --muted: rgba(243,240,239,0.74);
  --sep: rgba(255,255,255,0.35);

  --glass1: rgba(255,255,255,0.01);
  --glass2: rgba(255,255,255,0.02);
  --glass3: rgba(255,255,255,0.03);
  --glass4: rgba(255,255,255,0.04);
  --glass5: rgba(255,255,255,0.06);

  --panelBg: rgba(0,0,0,0.18);
  --panelBgSoft: rgba(0,0,0,0.10);
  --overlayBg: rgba(0,0,0,0.55);
  --overlayCardBg: rgba(6,12,14,0.92);
  --dim: rgba(243,240,239,0.60);

  --radius: 12px;
  --radiusSm: 10px;

  --shadowLg: 0 22px 60px rgba(0,0,0,0.45);
  --shadowMd: 0 12px 30px rgba(0,0,0,0.35);
  --shadowInset: inset 0 1px 0 rgba(255,255,255,0.04);

  /* SayMe palette */
  --a1: #0388A6;   /* primary blue */
  --a2: #F2A03D;   /* secondary orange */
  --a3: #BDD982;   /* optional green */
  --a4: #075473;   /* rare dark */
  --a5: #ED7D31;   /* dark orange */
  --a6: #F0A04B;   /* orange */
  --a7: #A9D18E;   /* light green */
  --a8: #8FDAF0;   /* light blue */
  --a9: #115E7A;   /* dark blue variant */

  --pad: 12px;
  --gap: 12px;
  --maxW: 980px;

  /* Sokoban board sizing (JS will update --cols/--rows/--cellPx) */
  --board: min(520px, 92vw);
  --boardPad: 14px;
  --boardGap: 6px;
  --cols: 10;
  --rows: 10;
  --cellPx: 34px;
}

html[data-theme="light"]{
  color-scheme: light;

  --bg: #f2f4f6;
  --surface: #ffffff;

  --border: rgba(0,0,0,0.10);
  --border2: rgba(0,0,0,0.16);
  --borderSoft: rgba(0,0,0,0.08);

  --text: rgba(6,12,14,0.92);
  --textSoft: rgba(6,12,14,0.82);
  --textSub: rgba(6,12,14,0.70);
  --muted: rgba(6,12,14,0.64);
  --sep: rgba(0,0,0,0.35);

  --shadowLg: 0 22px 60px rgba(0,0,0,0.18);
  --shadowMd: 0 12px 30px rgba(0,0,0,0.14);
  --shadowInset: inset 0 1px 0 rgba(0,0,0,0.03);

  --glass1: rgba(0,0,0,0.01);
  --glass2: rgba(0,0,0,0.02);
  --glass3: rgba(0,0,0,0.03);
  --glass4: rgba(0,0,0,0.04);
  --glass5: rgba(0,0,0,0.06);

  --panelBg: rgba(0,0,0,0.04);
  --panelBgSoft: rgba(0,0,0,0.02);
  --overlayBg: rgba(0,0,0,0.35);
  --overlayCardBg: rgba(255,255,255,0.92);
  --dim: rgba(6,12,14,0.50);
}

html, body{ height:100%; }
body{
  margin:0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-text-size-adjust: 100%;
}

/* Accessible focus */
:focus-visible{
  outline: 3px solid rgba(143,218,240,0.75);
  outline-offset: 2px;
}

a{ color: inherit; }

/* Layout */
#wrap{
  padding: var(--pad);
  box-sizing: border-box;
  display:flex;
  flex-direction:column;
  gap: var(--gap);
  align-items:center;
}

header{
  width: min(var(--maxW), 100%);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadowMd), var(--shadowInset);
  box-sizing: border-box;

  padding: 12px 14px;
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap: 12px;
}

.brand{
  display:flex;
  flex-direction:column;
  gap: 2px;
  min-width: 0;
}
.brand h1{
  margin:0;
  font-size: 16px;
  letter-spacing: 0.2px;
  white-space: nowrap;
  overflow:hidden;
  text-overflow: ellipsis;
}
.brand .sub{
  margin:0;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.3;
}

.hdrRight{
  display:flex;
  align-items:center;
  gap: 10px;
  flex-wrap:wrap;
  justify-content:flex-end;
}

.lang{
  display:flex;
  align-items:center;
  gap: 8px;
  user-select:none;
  white-space: nowrap;
}
.lang .sep{ color: var(--sep); }
.lang button{
  background: transparent;
  border: 1px solid transparent;
  color: var(--textSoft);
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 12px;
  cursor: pointer;
  transition: background .12s ease, border-color .12s ease, transform .06s ease;
}
.lang button:hover{ background: var(--glass4); border-color: var(--border); }
.lang button:active{ transform: translateY(1px); }
.lang button.active{
  background: rgba(3,136,166,0.18);
  border-color: rgba(3,136,166,0.55);
  color: var(--text);
}

.theme{
  display:flex;
  align-items:center;
  gap: 8px;
  user-select:none;
  white-space: nowrap;
}
.themeTxt{ font-size: 12px; color: var(--textSub); }

/* Cards */
.card{
  width: min(var(--maxW), 100%);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadowMd), var(--shadowInset);
  box-sizing: border-box;
  padding: 14px;
}
.card h2{
  margin:0 0 10px 0;
  font-size: 16px;
  letter-spacing: 0.2px;
}

.muted{
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.spacer{ height: 12px; }
.rule{ height:1px; background: var(--border); margin: 12px 0; }

/* Inputs & buttons */
button, input, select{ font: inherit; }
button, input[type="checkbox"], input[type="radio"]{ cursor:pointer; }

.btn{
  background: var(--glass4);
  border: 1px solid var(--border2);
  color: var(--text);
  padding: 8px 10px;
  border-radius: var(--radiusSm);
  font-size: 13px;
  transition: transform .06s ease, background .12s ease, border-color .12s ease;
}
.btn:hover{ background: var(--glass5); }
.btn:active{ transform: translateY(1px); }

.btn.primary{
  background: rgba(3,136,166,0.16);
  border-color: rgba(3,136,166,0.60);
}
.btn.primary:hover{ background: rgba(3,136,166,0.22); }

.btn.danger{
  background: rgba(237,125,49,0.12);
  border-color: rgba(237,125,49,0.50);
}

input[type="number"], select{
  width: 140px;
  background: var(--glass3);
  border: 1px solid var(--border2);
  color: var(--text);
  border-radius: var(--radiusSm);
  padding: 7px 8px;
  box-sizing:border-box;
}
select{ width: 240px; }

/* Level picker (Bank / Level) */
#bankSelect{ width: 88px; }
#levelSelect{ width: 96px; }

input[type="range"]{ width: 160px; }

.pill{
  padding: 2px 10px;
  border: 1px solid var(--border2);
  border-radius: 999px;
  font-size: 12px;
  color: var(--textSoft);
  background: var(--glass2);
  white-space: nowrap;
}
.pill.mini{ font-size: 11px; padding: 1px 8px; opacity: 0.92; }
.pill.good{ border-color: rgba(169,209,142,0.55); background: rgba(169,209,142,0.10); }
.pill.warn{ border-color: rgba(242,160,61,0.55); background: rgba(242,160,61,0.10); }
.pill.bad{ border-color: rgba(237,125,49,0.55); background: rgba(237,125,49,0.10); }

.kbd{
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 11px;
  padding: 2px 6px;
  border: 1px solid var(--border2);
  border-radius: 8px;
  background: var(--glass3);
  color: var(--textSoft);
}

.srOnly{
  position:absolute;
  width:1px;
  height:1px;
  padding:0;
  margin:-1px;
  overflow:hidden;
  clip: rect(0,0,0,0);
  white-space:nowrap;
  border:0;
}

/* GAME */
.gameShell{
  display:flex;
  flex-direction:column;
  align-items:center;
  gap: 12px;
}

.gameHeader{
  width: var(--board);
  display:flex;
  align-items:flex-end;
  justify-content:space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.titleBlock{
  display:flex;
  flex-direction:column;
  gap: 6px;
}

.titleBlock .tTitle{
  font-size: 42px;
  line-height: 1;
  font-weight: 800;
  margin:0;
  letter-spacing: 0.2px;
  color: var(--text);
}

.titleBlock .tIntro{
  margin:0;
  color: var(--muted);
  font-size: 13px;
}

.stats{ display:flex; gap: 8px; align-items:stretch; }
.statBox{
  background: var(--glass3);
  border: 1px solid var(--border);
  color: var(--textSoft);
  border-radius: 10px;
  padding: 10px 14px;
  min-width: 92px;
  text-align:center;
  box-sizing:border-box;
}
.statBox .lbl{
  font-size: 12px;
  opacity: 0.85;
  text-transform: uppercase;
  letter-spacing: .4px;
  margin-bottom: 4px;
}
.statBox .val{
  font-size: 22px;
  font-weight: 800;
  line-height: 1;
}

.gameActions{
  width: var(--board);
  display:flex;
  justify-content:space-between;
  gap: 10px;
  align-items:center;
  flex-wrap:wrap;
}

.gameActions .howto{
  margin:0;
  font-size: 13px;
  color: var(--muted);
  line-height: 1.35;
}

.actionsRow{ display:flex; gap: 10px; flex-wrap: wrap; align-items:center; }
.selectWrap{ display:flex; }

.boardWrap{
  width: var(--board);
  position: relative;
  user-select:none;
  touch-action: manipulation;
}

.sokoContainer{
  border-radius: 14px;
  position: relative;
  padding: var(--boardPad);
  width: var(--board);
  box-sizing:border-box;
  border: 1px solid var(--border);
  background:
    radial-gradient(1200px 500px at -10% -30%, rgba(3,136,166,0.25), transparent 60%),
    radial-gradient(900px 400px at 120% 0%, rgba(242,160,61,0.16), transparent 60%),
    var(--glass2);
  max-height: min(600px, 70vh);
  overflow: auto;
}


.sokoBoard{
  display:grid;
  grid-template-columns: repeat(var(--cols), var(--cellPx));
  grid-template-rows: repeat(var(--rows), var(--cellPx));
  gap: var(--boardGap);
  justify-content:center;
}

.cell{
  width: var(--cellPx);
  height: var(--cellPx);
  border-radius: 10px;
  position: relative;
  box-sizing:border-box;
  background: var(--glass2);
  border: 1px solid var(--borderSoft);
}

.cell.wall{
  background: rgba(17,94,122,0.82);
  border-color: rgba(143,218,240,0.22);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.06);
}

/* Goal ring */
.cell.goal:not(.wall)::before{
  content:"";
  position:absolute;
  inset: 18%;
  border-radius: 999px;
  border: 2px dashed rgba(169,209,142,0.70);
  opacity: 0.90;
}

/* Better layering: use actual child divs for box/player (added by JS). */
.cell .layer{
  position:absolute;
  inset: 0;
  pointer-events:none;
  display:flex;
  align-items:center;
  justify-content:center;
}

.cell .boxLayer,
.cell .playerLayer{
  position:absolute;
}

.cell .boxLayer{
  inset: 14%;
  border-radius: 10px;
  background: rgba(242,160,61,0.90);
  border: 1px solid rgba(0,0,0,0.25);
  box-shadow: 0 8px 20px rgba(0,0,0,0.35), inset 0 1px 0 rgba(255,255,255,0.25);
}

.cell.goal .boxLayer{ background: rgba(169,209,142,0.92); }

.cell .playerLayer{
  inset: 18%;
  border-radius: 999px;
  background: rgba(143,218,240,0.92);
  box-shadow: 0 6px 16px rgba(0,0,0,0.35), inset 0 1px 0 rgba(255,255,255,0.25);
}

.cell.pathHint:not(.wall){
  outline: 2px dashed rgba(242,160,61,0.45);
  outline-offset: -2px;
}

.cell.pathNext:not(.wall){
  outline: 3px solid rgba(242,160,61,0.75);
  outline-offset: -3px;
}

/* Overlay */
.overlay{
  position:absolute;
  inset: 0;
  display:none;
  align-items:center;
  justify-content:center;
  z-index: 5;
  background: var(--overlayBg);
  border-radius: 14px;
  text-align:center;
  padding: 18px;
  box-sizing:border-box;
}
.overlay.show{ display:flex; }
.overlayCard{
  width: min(420px, 100%);
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--overlayCardBg);
  box-shadow: var(--shadowLg), var(--shadowInset);
  padding: 14px;
}
.overlay h3{ margin:0 0 8px 0; font-size: 26px; }
.overlay p{ margin:0 0 12px 0; color: var(--muted); font-size: 13px; }
.overlay .actions{ display:flex; gap: 10px; justify-content:center; flex-wrap:wrap; margin-top: 6px; }

/* AI PANEL */
.aiTop{
  display:grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 12px;
  align-items:start;
}
@media (max-width: 820px){
  .aiTop{ grid-template-columns: 1fr; }
}

.aiBlock{
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  background: var(--glass2);
  box-shadow: var(--shadowInset);
}

.aiBlock h3{
  margin:0 0 8px 0;
  font-size: 14px;
  letter-spacing: 0.2px;
}

.controls{ display:flex; flex-direction:column; gap: 10px; }

.controlRow{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap: 10px;
  flex-wrap:wrap;
  font-size: 13px;
}

.toggle{ display:flex; align-items:center; gap: 10px; }

.switch{
  position: relative;
  width: 46px;
  height: 26px;
  border-radius: 999px;
  border: 1px solid var(--border2);
  background: var(--glass4);
  box-sizing:border-box;
}
.switch input{
  opacity:0;
  position:absolute;
  inset:0;
  z-index:2;
  width:100%;
  height:100%;
  margin:0;
}
.switch .knob{
  pointer-events:none;
  position:absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  border-radius: 999px;
  background: var(--textSoft);
  transition: transform .14s ease, background .14s ease;
}
.switch input:checked + .knob{
  transform: translateX(20px);
  background: var(--a8);
}

.switch.small{
  width: 38px;
  height: 22px;
}
.switch.small .knob{
  width: 16px;
  height: 16px;
  top: 2px;
  left: 2px;
}
.switch.small input:checked + .knob{
  transform: translateX(16px);
}

.inlineLabel{
  display:flex;
  gap: 8px;
  align-items:center;
  flex-wrap:wrap;
}

.btnRow{ display:flex; gap: 10px; flex-wrap:wrap; }

.optGrid{
  display:grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
@media (max-width: 820px){
  .optGrid{ grid-template-columns: 1fr; }
}

.opt{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap: 10px;
  padding: 10px 10px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--glass2);
  transition: background .12s ease, border-color .12s ease;
}
.opt.selected{
  background: rgba(3,136,166,0.13);
  border-color: rgba(3,136,166,0.52);
  box-shadow: 0 0 0 1px rgba(3,136,166,0.10) inset;
}

.optMain{
  display:flex;
  align-items:flex-start;
  gap: 10px;
  min-width: 0;
  cursor:pointer;
}
.optMain input{ margin-top: 2px; }
.optText{ display:flex; flex-direction:column; gap: 3px; min-width: 0; }
.optTitle{ font-size: 13px; color: var(--text); white-space: nowrap; overflow:hidden; text-overflow: ellipsis; }
.optSub{ font-size: 12px; color: var(--muted); line-height: 1.3; }

.optRight{
  display:flex;
  align-items:center;
  gap: 10px;
  flex: 0 0 auto;
}

.infoBtn{
  width: 22px;
  height: 22px;
  border-radius: 6px;
  border: 1px solid var(--border2);
  background: var(--glass3);
  color: var(--textSoft);
  display:flex;
  align-items:center;
  justify-content:center;
  font-weight: 800;
  font-size: 12px;
  cursor:pointer;
  flex: 0 0 auto;
  transition: background .12s ease, border-color .12s ease, transform .06s ease;
}
.infoBtn:hover{ background: var(--glass5); }
.infoBtn:active{ transform: translateY(1px); }
.infoBtn[aria-expanded="true"]{
  border-color: rgba(242,160,61,0.60);
  background: rgba(242,160,61,0.12);
}

.grid2{
  display:grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
@media (max-width: 820px){
  .grid2{ grid-template-columns: 1fr; }
  select{ width: 100%; }
}

.rangeRow{ display:flex; gap: 10px; align-items:center; flex-wrap:wrap; }

.progress{
  margin-top: 10px;
  border: 1px dashed var(--border2);
  border-radius: var(--radius);
  padding: 10px;
  background: var(--panelBg);
}

/* Info panels (like the 2048 project) */
.infoPanel{
  grid-column: 1 / -1;
  margin-top: 6px;
  border: 1px dashed var(--border2);
  border-radius: var(--radius);
  padding: 10px;
  background: var(--panelBg);
}
.infoPanel .infoTop{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap: 10px;
  margin-bottom: 8px;
}
.infoPanel .infoTop .ttl{
  margin: 0;
  font-size: 13px;
  color: var(--text);
  font-weight: 700;
}
.infoPanel .close{
  border: 1px solid var(--border2);
  background: var(--glass3);
  color: var(--textSoft);
  border-radius: 8px;
  padding: 4px 8px;
  font-size: 12px;
  cursor:pointer;
}
.infoPanel .close:hover{ background: var(--glass5); }

.infoPanel .body{
  display:flex;
  gap: 10px;
  flex-wrap:wrap;
  align-items:flex-start;
}
.infoPanel .body .txt{
  flex: 1 1 280px;
  min-width: 240px;
  font-size: 12px;
  line-height: 1.45;
  color: var(--muted);
}
.infoPanel .body .viz{
  flex: 0 0 190px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--glass2);
  padding: 8px;
  box-sizing:border-box;
}
.infoPanel svg{ width: 100%; height: auto; display:block; }

/* Decision Inspector */
.pillRow{ display:flex; gap: 10px; flex-wrap:wrap; margin-bottom: 10px; }

.tableWrap{
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow:auto;
  background: var(--panelBgSoft);
}

.tbl{
  width: 100%;
  border-collapse: collapse;
  min-width: 720px;
}

.tbl th, .tbl td{
  text-align:left;
  padding: 9px 10px;
  border-bottom: 1px solid var(--borderSoft);
  font-size: 12px;
  color: var(--textSoft);
}
.tbl th{ font-weight: 700; color: var(--text); background: rgba(0,0,0,0.35); position: sticky; top: 0; }
.tbl tr:last-child td{ border-bottom: 0; }

.tbl .dim{ color: var(--dim); }
.tbl .yes{ color: rgba(169,209,142,0.90); font-weight: 700; }
.tbl .no{ color: rgba(237,125,49,0.90); font-weight: 700; }

.tbl tr.chosenRow td{
  background: rgba(3,136,166,0.10);
}

.planStrip{ margin-top: 12px; }
.arrows{
  font-size: 18px;
  line-height: 1.8;
  display:flex;
  flex-wrap:wrap;
  gap: 6px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--glass2);
}
.arr{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  width: 28px;
  height: 28px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--panelBg);
}
.arr.current{
  background: rgba(242,160,61,0.18);
  border-color: rgba(242,160,61,0.55);
}
.arr.done{
  opacity: 0.65;
}

.modalOverlay[hidden] {
    display: none !important;
}

body.modalOpen {
    overflow: hidden;
}

/* Light-theme tweaks for a few fixed overlays */
html[data-theme="light"] .tbl th{
  background: rgba(0,0,0,0.06);
}

@media (max-width: 520px){
  .statBox{ min-width: 84px; padding: 10px 12px; }
  .titleBlock .tTitle{ font-size: 36px; }
}
