/* Blobbo — styled after the Mac OS 8/9 "Platinum" look the original ran under */
:root {
  --desk: #3a6ea5;
  --desk2: #5b8fc4;
  --win: #dddddd;
  --win-dark: #999;
  --win-light: #fff;
  --ink: #111;
  --muted: #555;
  --accent: #3355bb;
  --done: #2b8a3e;
  --font: "Chicago", "Charcoal", "Geneva", -apple-system, "Segoe UI", system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font: 14px/1.4 var(--font);
  color: var(--ink);
  background: radial-gradient(ellipse at top, var(--desk2), var(--desk) 70%) fixed;
  -webkit-font-smoothing: antialiased;
}
button, select, input { font: inherit; color: inherit; }

/* ---------- menu bar ---------- */
.menubar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 4px;
  height: 26px; padding: 0 10px;
  background: linear-gradient(#f4f4f4, #dcdcdc);
  border-bottom: 1px solid #777;
}
.menubar .apple { width: 18px; height: 16px; background: url(../assets/sprites/207.png) 0 0 / 32px 16px no-repeat; margin-right: 6px; image-rendering: pixelated; }
.menubar b { margin-right: 10px; }
.menubar button { background: none; border: 0; padding: 2px 8px; cursor: pointer; border-radius: 2px; }
.menubar button:hover, .menubar button:focus-visible { background: var(--accent); color: #fff; outline: none; }
.menubar .grow { flex: 1; }
.menubar .tagline { color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

#loading { color: #fff; text-align: center; padding: 80px 16px; font-size: 18px; }

/* ---------- views ---------- */
.view { display: none; }
body[data-view="select"] #select { display: grid; }
body[data-view="play"] #play { display: flex; }
body[data-view="help"] #help { display: flex; }
body[data-view="edit"] #edit { display: flex; }

/* ---------- windows ---------- */
.window {
  background: var(--win);
  border: 1px solid #000;
  box-shadow: inset 1px 1px 0 var(--win-light), inset -1px -1px 0 var(--win-dark), 2px 3px 0 rgba(0,0,0,.35);
}
.titlebar {
  position: relative;
  display: flex; align-items: center; justify-content: center;
  height: 22px; margin: 2px 2px 0;
  background: repeating-linear-gradient(#e8e8e8 0 1px, #a8a8a8 1px 2px);
  border-bottom: 1px solid #777;
}
.titlebar span {
  background: var(--win); padding: 0 10px; font-weight: bold;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: calc(100% - 60px);
}
.titlebar .close {
  position: absolute; right: 6px; top: 3px; width: 16px; height: 15px; line-height: 11px;
  padding: 0; border: 1px solid #555; background: var(--win); cursor: pointer; font-size: 13px;
}
.content { padding: 12px 14px; }

button:not(.level):not(.world):not(.link):not(.close):not(.del) , .filebtn {
  padding: 3px 12px; border: 1px solid #333; border-radius: 4px;
  background: linear-gradient(#fafafa, #d6d6d6);
  cursor: pointer; box-shadow: 0 1px 0 rgba(0,0,0,.25);
}
button:disabled { opacity: .45; cursor: default; }
button.primary { border-width: 2px; padding: 2px 14px; box-shadow: 0 0 0 2px var(--win), 0 0 0 3px #333; }
button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.filebtn { display: inline-block; position: relative; overflow: hidden; }
.filebtn input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.filebtn.small { font-size: 13px; }
.link { background: none; border: 0; color: var(--muted); text-decoration: underline; cursor: pointer; padding: 0; }

/* ---------- level select ---------- */
#select {
  grid-template-columns: 240px 1fr; gap: 16px;
  max-width: 1200px; margin: 18px auto; padding: 0 16px;
  align-items: start;
}
.side { padding-bottom: 12px; }
#worlds { list-style: none; margin: 8px 0; padding: 0 8px; }
#worlds li { display: flex; align-items: center; }
.world {
  flex: 1; display: flex; justify-content: space-between; gap: 8px;
  padding: 6px 8px; border: 0; background: none; text-align: left; cursor: pointer; border-radius: 3px;
}
.world:hover { background: #ccd; }
.world.on { background: var(--accent); color: #fff; }
.wcount { opacity: .75; font-variant-numeric: tabular-nums; }
.del { border: 0; background: none; cursor: pointer; font-size: 16px; color: var(--muted); padding: 0 6px; }
.side .filebtn { margin: 4px 16px 0; }
.side .hint { margin: 8px 16px 0; font-size: 12px; color: var(--muted); }
.sub { margin: 0 0 12px; color: var(--muted); }
#levels { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.level {
  display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto auto;
  gap: 2px 6px; padding: 8px; text-align: left; cursor: pointer;
  background: #fff; border: 1px solid #555; border-radius: 3px; box-shadow: 1px 1px 0 #888;
}
.level canvas { grid-column: 1 / -1; width: 100%; height: auto; aspect-ratio: 8 / 5; image-rendering: auto; border: 1px solid #aaa; background: #eee; }
.level .num { font-weight: bold; color: var(--muted); font-variant-numeric: tabular-nums; }
.level .lname { font-weight: bold; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.level .best { grid-column: 1 / -1; font-size: 12px; color: var(--muted); }
.level.done { border-color: var(--done); }
.level.done .best { color: var(--done); font-weight: bold; }
.level:not(:disabled):hover { outline: 2px solid var(--accent); }
.level.locked { background: #e6e6e6; cursor: not-allowed; }
.level.locked canvas { background: repeating-linear-gradient(45deg, #ddd 0 6px, #ccc 6px 12px); }
.foot { margin: 16px 0 0; font-size: 12px; }

/* ---------- play ---------- */
#play { justify-content: center; padding: 14px 8px 24px; }
.game { display: flex; flex-direction: column; align-items: stretch; max-width: 100%; }
#board-wrap { position: relative; margin: 6px 8px 0; align-self: center; line-height: 0; }
#board {
  display: block; width: 1024px; max-width: 100%; height: auto;
  image-rendering: pixelated; image-rendering: crisp-edges;
  border: 1px solid #000; background: #fff; cursor: pointer; touch-action: none;
}
#board[data-cursor="Z"] { cursor: wait; }
body.whatis #board { cursor: help; }
.status {
  display: flex; flex-wrap: wrap; gap: 6px 24px; justify-content: center;
  padding: 8px 10px 4px; font-size: 14px;
}
.status b { font-variant-numeric: tabular-nums; }
#st-carry canvas { width: 16px; height: 16px; vertical-align: -3px; image-rendering: pixelated; }
.toolbar { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; padding: 6px 10px; }
.toolbar .sep { width: 10px; }
#btn-whatis.on { background: var(--accent); color: #fff; }
#whatis-text, #watch-label { margin: 0 12px 6px; text-align: center; min-height: 0; color: #333; }
#whatis-text:empty, #watch-label:empty { display: none; }
#watch-label { display: none; }
body.watching #watch-label { display: block; color: var(--accent); font-weight: bold; }

#message {
  position: absolute; left: 50%; bottom: 10px; transform: translate(-50%, 10px);
  background: rgba(0,0,0,.78); color: #fff; padding: 6px 12px; border-radius: 4px;
  line-height: 1.3; font-size: 14px; max-width: 90%; text-align: center;
  opacity: 0; transition: opacity .2s, transform .2s; pointer-events: none;
}
#message.show { opacity: 1; transform: translate(-50%, 0); }

#overlay {
  position: absolute; inset: 1px; display: flex; align-items: center; justify-content: center;
  background: rgba(255,255,255,.35); line-height: 1.4;
}
#overlay[hidden] { display: none; }
#overlay.small { align-items: flex-end; background: none; padding-bottom: 12%; }
.dialog {
  background: var(--win); border: 2px solid #000; padding: 16px 20px; min-width: 260px; max-width: 90%;
  box-shadow: inset 2px 2px 0 #fff, inset -2px -2px 0 #888, 4px 4px 0 rgba(0,0,0,.4);
  text-align: center;
}
.dialog h2 { margin: 0 0 6px; font-size: 18px; }
.dialog p { margin: 0 0 14px; }
.dialog .buttons { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }

.debugbar { display: none; }
body.debug .debugbar {
  display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: center;
  margin: 2px 10px 8px; padding: 6px 8px; background: #fff3c4; border: 1px dashed #a80;
}
.debugbar input { width: 4.5em; }
#debug-cell { font-size: 12px; min-width: 20ch; }

/* on-screen pad for touch screens */
.pad { display: none; }
@media (pointer: coarse) {
  .pad {
    display: grid; grid-template-columns: repeat(3, 64px); grid-template-rows: repeat(3, 56px);
    gap: 6px; justify-content: center; margin: 4px auto 10px;
  }
  .pad button { font-size: 20px; padding: 0; touch-action: manipulation; }
  .pad .u { grid-area: 1 / 2; } .pad .l { grid-area: 2 / 1; } .pad .z { grid-area: 2 / 2; font-size: 14px; }
  .pad .r { grid-area: 2 / 3; } .pad .d { grid-area: 3 / 2; } .pad .x { grid-area: 3 / 3; font-size: 14px; }
}

/* ---------- help ---------- */
#help { justify-content: center; padding: 18px 16px; }
.helpwin { width: min(900px, 100%); }
.helpgrid { display: grid; grid-template-columns: 200px 1fr; min-height: 60vh; }
#help-nav { display: flex; flex-direction: column; padding: 10px 8px; border-right: 1px solid #999; gap: 2px; }
#help-nav button { text-align: left; border: 0; background: none; padding: 5px 8px; cursor: pointer; border-radius: 3px; }
#help-nav button.on { background: var(--accent); color: #fff; }
#help-body { padding: 14px 22px; background: #fff; max-height: 75vh; overflow: auto; font-family: Georgia, "Times New Roman", serif; font-size: 15px; line-height: 1.5; }
#help-body h2 { font-family: var(--font); font-size: 20px; margin: 6px 0 10px; }
#help-body h3 { font-family: var(--font); font-size: 16px; }
#help-body a { color: #b00; text-decoration: underline; text-decoration-color: #999; }

/* ---------- settings ---------- */
.floating { position: fixed; top: 40px; right: 16px; z-index: 30; width: min(340px, calc(100% - 32px)); }
.floating label { display: block; margin: 0 0 10px; }
.floating select { margin-left: 6px; }

@media (max-width: 720px) {
  #select { grid-template-columns: 1fr; }
  .menubar .tagline { display: none; }
  .helpgrid { grid-template-columns: 1fr; }
  #help-nav { flex-direction: row; flex-wrap: wrap; border-right: 0; border-bottom: 1px solid #999; }
  #levels { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); }
}

.floating hr { border: 0; border-top: 1px solid #999; margin: 12px 0; }
.floating .hint { font-size: 12px; color: var(--muted); margin: 6px 0 0; }
button.danger { color: #a00; }
.level .going { grid-column: 1 / -1; font-size: 12px; color: var(--accent); font-weight: bold; }

/* ---------- editor ---------- */
.sidebtn { margin: 8px 16px 0; display: block; }
.worldbar { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
#btn-backedit { display: none; }
body.testing #btn-backedit { display: inline-block; }
body.testing #btn-levels, body.testing #btn-prev, body.testing #btn-next { display: none; }
#edit { justify-content: center; padding: 14px 8px 24px; }
.editwin { max-width: 100%; }
.edit-top { display: flex; flex-wrap: wrap; gap: 6px 8px; align-items: center; padding: 8px 10px 4px; }
.edit-top input[type=text] { width: 14em; }
.edit-top select { max-width: 16em; }
.edit-main { display: flex; flex-wrap: wrap; gap: 10px; padding: 4px 10px 10px; align-items: flex-start; }
.edit-boardcol { flex: 1 1 auto; min-width: 0; }
#edit-board {
  display: block; width: 1024px; max-width: 100%; height: auto; image-rendering: pixelated;
  border: 1px solid #000; background: #fff; cursor: crosshair; touch-action: none;
}
#edit-status { margin: 6px 0; font-size: 13px; }
#edit-status.bad { color: #a00; }
#edit-status.good { color: var(--done); }
.edit-tools { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.edit-tools .sep { width: 10px; }
.edit-boardcol .hint { font-size: 12px; color: var(--muted); max-width: 70ch; margin: 8px 0 0; }
.palette { flex: 0 0 auto; background: #fff; border: 1px solid #777; padding: 6px; }
#pal-tabs { display: flex; gap: 2px; margin-bottom: 6px; flex-wrap: wrap; }
#pal-tabs button { border: 1px solid #777; background: #eee; padding: 2px 8px; cursor: pointer; border-radius: 3px 3px 0 0; }
#pal-tabs button.on { background: var(--accent); color: #fff; }
#pal-grid { display: grid; gap: 2px; justify-content: start; }
.ptile { width: 34px; height: 34px; padding: 0; border: 1px solid transparent; background: none; cursor: pointer; line-height: 0; }
.ptile canvas { width: 32px; height: 32px; image-rendering: pixelated; }
.ptile:hover { border-color: #999; }
.ptile.on { border: 1px solid #d00; box-shadow: 0 0 0 1px #d00; }
#pal-sel { display: flex; gap: 8px; align-items: flex-start; margin-top: 8px; max-width: 290px; font-size: 13px; }
#pal-sel canvas { width: 32px; height: 32px; image-rendering: pixelated; flex: none; border: 1px solid #999; }
