:root{
  --bg:#0b0f17;
  --panel:#121a27;
  --panel2:#0f1724;
  --text:#e7edf7;
  --muted:#9fb0c6;
  --accent:#7dd3fc;
  --border:#243045;
}

*{box-sizing:border-box}
body{
  margin:0;
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, "Apple Color Emoji","Segoe UI Emoji";
  background:var(--bg);
  color:var(--text);
}

header, footer{
  padding: 16px 20px;
  border-bottom:1px solid var(--border);
}

a:link {
color: #e7edf7; 
}
a:visited {
color: #9fb0c6;
}
a:hover {
color: #ecf1f9;
}
a:active {
color: #ffffff;
}

footer{border-top:1px solid var(--border); border-bottom:none;}

h1{margin:0 0 6px 0; font-size:20px;}
h2{margin:0 0 8px 0; font-size:16px;}
h3{margin:12px 0 6px 0; font-size:14px;}

.subtle{color:var(--muted); margin:0;}
main{padding:16px 20px; display:flex; flex-direction:column; gap:14px;}

.panel{
  background:var(--panel);
  border:1px solid var(--border);
  border-radius:10px;
  padding:12px;
}

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

.file input{display:none;}
.file span{
  display:inline-block;
  padding:8px 10px;
  border:1px dashed var(--border);
  border-radius:8px;
  cursor:pointer;
  color:var(--text);
}

button{
  padding:8px 12px;
  border-radius:8px;
  border:1px solid var(--border);
  background:var(--panel2);
  color:var(--text);
  cursor:pointer;
}
button:disabled{
  opacity:0.55;
  cursor:not-allowed;
}

.checkbox{
  display:flex;
  gap:8px;
  align-items:center;
  color:var(--muted);
}

.select, .field{
  display:flex;
  gap:6px;
  align-items:center;
  padding:6px 8px;
  border-radius:8px;
  border:1px solid var(--border);
  background:var(--panel2);
  color:var(--muted);
}
.select select, .field input{
  background:transparent;
  border:none;
  color:var(--text);
  outline:none;
}

.grid{
  display:grid;
  grid-template-columns: minmax(320px, 520px) 1fr;
  gap:12px;
}
@media (max-width: 980px){
  .grid{grid-template-columns: 1fr;}
}

.canvasWrap{
  position:relative;
  width:100%;
  max-width:520px;
  margin:0 auto;
  background:#000;
  border-radius:10px;
  overflow:hidden;
  border:1px solid var(--border);
}
canvas{
  display:block;
  width:100%;
  height:auto;
}
#overlay{
  position:absolute;
  top:0; left:0;
  pointer-events:none;
}

.canvasWrap.editing #overlay{
  pointer-events:auto;
  cursor: crosshair;
}

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

.mono{
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  white-space:pre;
  background: #0b1220;
  border:1px solid var(--border);
  border-radius:10px;
  padding:10px;
  overflow:auto;
  max-height:420px;
}

.mono.small{max-height:260px; font-size:12px;}

.legend{
  display:flex;
  flex-wrap:wrap;
  gap:8px;
  align-items:center;
}
.legend .item{
  display:flex;
  gap:8px;
  align-items:center;
  padding:6px 8px;
  border:1px solid var(--border);
  border-radius:10px;
  background:var(--panel2);
  cursor:pointer;
  user-select:none;
}

.legend .item.selected{
  border-color: var(--accent);
  box-shadow: 0 0 0 1px rgba(125, 211, 252, 0.35);
}
.legend .item.selected .swatch{
  outline: 2px solid rgba(255, 255, 255, 0.75);
  outline-offset: 1px;
}
.legend .swatch{
  width:14px;
  height:14px;
  border-radius:4px;
  border:1px solid rgba(255,255,255,0.25);
}

.legend .item .del{
  margin-left: 6px;
  width: 20px;
  height: 20px;
  padding: 0;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.05);
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  line-height: 18px;
  cursor: pointer;
}

.legend .item .del:hover{
  background: rgba(255,255,255,0.10);
  color: var(--text);
}

/* Rock chips (remove rock from bottle) */
#rockLegend .item{
  border-color: rgba(255, 200, 0, 0.55);
}
#rockLegend .item.selected{
  border-color: rgba(255, 200, 0, 0.95);
  box-shadow: 0 0 0 1px rgba(255, 200, 0, 0.35);
}

/* --- Workspace layout (screenshot + detected + solution + final) --- */
.statusLine{
  color:var(--muted);
  padding:4px 2px 10px 2px;
}

.workspaceGrid{
  display:grid;
  grid-template-columns: minmax(520px, 1.5fr) minmax(360px, 1fr) minmax(360px, 1fr);
  gap:12px;
  align-items:stretch;
}
@media (max-width: 1280px){
  .workspaceGrid{grid-template-columns: 1fr;}
}

.pane{
  background:var(--panel2);
  border:1px solid var(--border);
  border-radius:10px;
  padding:12px;
}

.leftPane{
  display:grid;
  grid-template-columns: minmax(320px, 520px) 1fr;
  gap:12px;
  align-items:start;
}
@media (max-width: 980px){
  .leftPane{grid-template-columns: 1fr;}
}

.detectedPane{
  display:flex;
  flex-direction:column;
  gap:8px;
}

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

.stats{
  display:flex;
  flex-direction:column;
  gap:4px;
  padding:10px;
  background:#0b1220;
  border:1px solid var(--border);
  border-radius:10px;
  color:var(--muted);
  font-size:12px;
  line-height:1.25;
}
.stats b{color:var(--text); font-weight:600;}

.powerups{
  display:flex;
  flex-wrap:wrap;
  gap:8px;
}
.chip{
  display:inline-flex;
  align-items:center;
  gap:8px;
  padding:6px 10px;
  border:1px solid var(--border);
  border-radius:999px;
  background:#0b1220;
  color:var(--text);
  font-size:12px;
}
.chip .k{color:var(--muted);}

/* --- Bottle board renderer --- */
.board{
  display:flex;
  flex-direction:column;
  gap:18px;
  align-items:center;
  padding:4px 0;
}

/* Final-state board: keep rows left-aligned so row 2 lines up under row 1
   (e.g., bottle 4 under bottle 1), and any extra bottle(s) stay off to the right. */
#boardFinal{
  align-items:flex-start;
}
#boardFinal .boardRow{
  justify-content:flex-start;
}
.boardRow{
  display:flex;
  gap:22px;
  align-items:flex-end;
  justify-content:center;
}
.bottleWrap{
  display:flex;
  flex-direction:column;
  align-items:center;
  gap:8px;
}
.bottleNum{
  color:var(--muted);
  font-size:14px;
  user-select:none;
}
.bottle{
  width:74px;
  height:184px;
  border:4px solid #000;
  border-radius:14px;
  background:#0b1220;
  overflow:hidden;
  position:relative;
}
.bottle.rock{
  outline:3px solid rgba(231, 237, 247, 0.85);
  outline-offset:2px;
}
.bottleSlots{
  position:absolute;
  inset:0;
  display:flex;
  flex-direction:column;
}
.slot{
  flex:1;
  border-top:3px solid #000;
}

.slot.selectedColor{
  box-shadow: inset 0 0 0 3px rgba(255, 255, 255, 0.85);
}
.slot:first-child{border-top:none;}
.slot.empty{background:transparent;}

/* --- Solver display --- */

.paneTitleRow{
  display:flex;
  align-items:baseline;
  justify-content:flex-start;
  gap:10px;
  margin-bottom:10px;
}

.paneTitleRow h2{margin:0;}

.solverMeta{
  color:var(--muted);
  font-size:12px;
}

.middlePane{
  display:flex;
  flex-direction:column;
  height:100%;
}

.movesList{
  display:flex;
  flex-direction:column;
  gap:0;
  flex:1 1 auto;
  min-height:0;
  overflow:auto;
  padding-right:4px;
}

.moveItem{
  display:grid;
  grid-template-columns: 36px 1fr auto;
  align-items:center;
  gap:12px;
  padding:8px 12px;
  background:#0b1220;
  border:1px solid var(--border);
  border-radius:0;
}

.moveItem + .moveItem{border-top:0;}
.moveItem:first-child{border-top-left-radius:10px; border-top-right-radius:10px;}
.moveItem:last-child{border-bottom-left-radius:10px; border-bottom-right-radius:10px;}
.moveStep{
  color:var(--muted);
  font-size:14px;
  text-align:right;
}
.moveText{
  font-size:16px;
  font-weight:600;
}
.moveSub{
  font-size:12px;
  color:var(--muted);
  font-weight:400;
}
.moveSquares{
  display:flex;
  gap:6px;
  align-items:center;
}
.moveSquare{
  width:22px;
  height:22px;
  border-radius:5px;
  border:1px solid rgba(255,255,255,0.25);
}
