/* YADOKARI 98: a classic desktop. Bevels follow the 1998 recipe: white and light grey on the
   lit edges, grey and near-black on the shaded ones. */
:root {
  --font: 'Fusion Pixel 12px Proportional SC', 'SimSun', 'NSimSun', monospace;
  --font-sm: 'Fusion Pixel 10px Proportional SC', 'Fusion Pixel 12px Proportional SC', 'SimSun', monospace;
  --desk: #008080;
  --face: #c0c0c0;
  --light: #dfdfdf;
  --hi: #ffffff;
  --shadow: #808080;
  --dark: #0a0a0a;
  --ink: #000000;
  --ink-2: #3c3c3c;
  --ink-3: #6b6b6b;
  --sel: #000080;
  --sel-ink: #ffffff;
  --title-a: #000080;
  --title-b: #1084d0;
  --title-ia: #808080;
  --title-ib: #b5b5b5;
  --good: #006a6a;
  --warn: #a00000;
  --raised: inset -1px -1px var(--dark), inset 1px 1px var(--hi), inset -2px -2px var(--shadow), inset 2px 2px var(--light);
  --window: inset -1px -1px var(--dark), inset 1px 1px var(--light), inset -2px -2px var(--shadow), inset 2px 2px var(--hi);
  --pressed: inset -1px -1px var(--hi), inset 1px 1px var(--dark), inset -2px -2px var(--light), inset 2px 2px var(--shadow);
  --sunken: inset -1px -1px var(--hi), inset 1px 1px var(--shadow), inset -2px -2px var(--light), inset 2px 2px var(--dark);
  --thin-in: inset -1px -1px var(--hi), inset 1px 1px var(--shadow);
  --dither: repeating-conic-gradient(var(--face) 0 25%, var(--hi) 0 50%) 0 0 / 2px 2px;
}

* { box-sizing: border-box; }

html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--desk);
  color: var(--ink);
  font-family: var(--font);
  font-size: 12px;
  line-height: 1.45;
  -webkit-font-smoothing: none;
  -webkit-tap-highlight-color: transparent;
}

button {
  font: inherit;
  color: inherit;
  cursor: default;
}

button:focus-visible,
[role='button']:focus-visible {
  outline: 1px dotted currentColor;
  outline-offset: -4px;
}

.ico { display: inline-grid; place-items: center; line-height: 0; }
.ico svg { display: block; }
.pix { image-rendering: pixelated; display: block; }

::-webkit-scrollbar { width: 16px; height: 16px; }
::-webkit-scrollbar-track { background: var(--dither); }
::-webkit-scrollbar-thumb { background: var(--face); box-shadow: var(--raised); }
::-webkit-scrollbar-corner { background: var(--face); }

/* ---------- desktop ---------- */

.desktop {
  position: fixed;
  inset: 0 0 30px 0;
  overflow: hidden;
}

.icons {
  position: absolute;
  top: 6px;
  left: 4px;
  bottom: 6px;
  display: grid;
  grid-auto-flow: column;
  /* Rows shrink to 62px so all 11 icons fit in one column on screens 744px tall or more. */
  grid-template-rows: repeat(auto-fill, clamp(62px, calc((100vh - 64px) / 11), 74px));
  grid-auto-columns: 92px;
  gap: 2px;
  align-content: start;
}

.dicon {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  width: 92px;
  padding: 4px 2px;
  border: 0;
  background: none;
  color: var(--hi);
}

.dicon img { width: 32px; height: 32px; image-rendering: pixelated; }

.dicon span {
  max-width: 90px;
  padding: 0 2px;
  line-height: 1.25;
  text-align: center;
  overflow-wrap: anywhere;
  border: 1px solid transparent;
}

.dicon.sel span {
  background: var(--sel);
  border: 1px dotted #ffff80;
}

.dicon.sel img { filter: brightness(0.55) sepia(1) hue-rotate(190deg) saturate(4); }
.dicon:focus-visible { outline: none; }
.dicon:focus-visible span { border: 1px dotted var(--hi); }

/* ---------- windows ---------- */

.wwin {
  position: absolute;
  display: flex;
  flex-direction: column;
  min-width: 220px;
  max-height: calc(100% - 16px);
  padding: 3px;
  background: var(--face);
  box-shadow: var(--window);
}

.wwin[hidden] { display: none; }

.wwin.max {
  left: 0 !important;
  top: 0 !important;
  width: 100% !important;
  height: 100% !important;
  max-height: none;
}

.titlebar {
  display: flex;
  align-items: center;
  gap: 4px;
  height: 20px;
  padding: 0 2px 0 3px;
  background: linear-gradient(90deg, var(--title-ia), var(--title-ib));
  color: var(--face);
  user-select: none;
  touch-action: none;
}

.wwin.active > .titlebar {
  background: linear-gradient(90deg, var(--title-a), var(--title-b));
  color: var(--hi);
}

.titlebar .title {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  letter-spacing: 0.02em;
}

.t-ico { width: 16px; height: 16px; flex: none; }
.tb-btns { display: flex; align-items: center; gap: 0; }
.tb-extra { display: flex; margin-right: 4px; }

.tb-btn {
  display: grid;
  place-items: center;
  width: 16px;
  height: 14px;
  margin-left: 0;
  padding: 0;
  border: 0;
  background: var(--face);
  color: var(--ink);
  box-shadow: var(--raised);
  font-size: 12px;
  line-height: 1;
}

.tb-btn[data-wm='close'] { margin-left: 2px; }
.tb-btn:active { box-shadow: var(--pressed); }
.tb-btn .ico svg { width: 10px; height: 10px; }

.dlg-body {
  flex: 1;
  min-height: 0;
  margin-top: 2px;
  padding: 8px 10px 10px;
  overflow: auto;
  color: var(--ink);
}

.dlg-foot {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
  padding: 6px 8px 5px;
}

.dlg-foot[hidden] { display: none; }

.foot-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
}

.foot-row.end { justify-content: flex-end; }

.dlg-btn {
  min-width: 75px;
  min-height: 23px;
  padding: 3px 10px;
  border: 0;
  background: var(--face);
  color: var(--ink);
  box-shadow: var(--raised);
}

.dlg-btn:active:not(:disabled) { box-shadow: var(--pressed); padding: 4px 9px 2px 11px; }
.dlg-btn.solid { box-shadow: 0 0 0 1px var(--dark), var(--raised); }
.dlg-btn.solid:active:not(:disabled) { box-shadow: 0 0 0 1px var(--dark), var(--pressed); }
.dlg-btn:disabled { color: var(--shadow); text-shadow: 1px 1px 0 var(--hi); }
.dlg-btn.arrow::after { content: ''; }

.dlg-body h3 {
  margin: 14px 0 6px;
  padding-bottom: 3px;
  border-bottom: 1px solid var(--shadow);
  box-shadow: 0 1px 0 var(--hi);
  font-size: 12px;
  font-weight: normal;
}

.dlg-body ul { margin: 0; padding-left: 18px; }
.dlg-body li { margin: 6px 0; }
.dlg-body a { color: #0000ff; text-underline-offset: 3px; }
.dlg-body p { margin: 8px 0; }

.muted { color: var(--ink-3); }
.small { font-family: var(--font-sm); font-size: 10px; }
.warn { color: var(--warn); }
p.warn { margin: 8px 0; }

/* toggles and segmented buttons */

.seg { display: flex; gap: 2px; }

.tool {
  display: grid;
  place-items: center;
  min-width: 24px;
  height: 22px;
  padding: 0 6px;
  border: 0;
  background: transparent;
  color: var(--ink);
}

.tool:hover { box-shadow: inset -1px -1px var(--shadow), inset 1px 1px var(--hi); }
.tool:active,
.tool.on { background: var(--dither); box-shadow: inset -1px -1px var(--hi), inset 1px 1px var(--shadow); }
.tool.busy { animation: blink 0.8s steps(2, jump-none) infinite; }
.tool:disabled { color: var(--shadow); }

.dlg .seg .tool { min-width: 34px; background: var(--face); box-shadow: var(--raised); }
.dlg .seg .tool.on { background: var(--dither); box-shadow: var(--pressed); }
.dlg .seg .tool:disabled { color: var(--shadow); text-shadow: 1px 1px 0 var(--hi); }

@keyframes blink { 50% { opacity: 0.35; } }

.sep {
  width: 2px;
  height: 20px;
  margin: 0 4px;
  border-left: 1px solid var(--shadow);
  border-right: 1px solid var(--hi);
}

.spacer { flex: 1; }

/* ---------- the beach window ---------- */

.win-main {
  --fit: max(420px, calc((100vh - 196px) * 1.6 + 14px));
  left: 106px;
  top: 8px;
  width: min(880px, calc(100vw - 120px), var(--fit));
}

/* Maximized: full desktop height; the width keeps the beach near 16:10 (151px of window
   chrome + the 30px taskbar), and the canvas takes whatever height is left. */
.win-main.max {
  left: 50% !important;
  width: min(100%, calc((100vh - 182px) * 1.6 + 10px)) !important;
  transform: translateX(-50%);
}

.win-main.max .tank { flex: 1 1 0; min-height: 0; display: flex; align-items: center; }
.win-main.max .tank canvas { max-height: 100%; }

.toolbar {
  display: flex;
  align-items: center;
  gap: 1px;
  height: 30px;
  margin: 2px 0;
  padding: 2px 3px;
  box-shadow: inset 0 -1px var(--shadow), inset 0 -2px var(--hi);
}

.tank {
  position: relative;
  padding: 2px;
  background: #16110d;
  box-shadow: var(--sunken);
}

.tank canvas {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 432 / 270;
  image-rendering: pixelated;
  touch-action: none;
}

.tank canvas.hover { cursor: grab; }
.tank canvas.grabbing { cursor: grabbing; }
.tank canvas.aiming { cursor: crosshair; }

.species {
  position: absolute;
  top: 8px;
  right: 10px;
  max-width: 78%;
  font-family: var(--font-sm);
  font-size: 10px;
  line-height: 1.4;
  text-align: right;
  color: #e7e2cf;
  text-shadow: 1px 1px 0 #120d0a;
  pointer-events: none;
}

.zoom {
  position: absolute;
  left: 8px;
  bottom: 8px;
  display: flex;
  gap: 2px;
}

.zbtn {
  display: grid;
  place-items: center;
  width: 26px;
  height: 24px;
  padding: 0;
  border: 0;
  background: var(--face);
  color: var(--ink);
  box-shadow: var(--raised);
}

.zbtn:active { box-shadow: var(--pressed); }

.zlabel {
  display: grid;
  place-items: center;
  width: 30px;
  height: 24px;
  background: var(--hi);
  box-shadow: var(--sunken);
  font-family: var(--font-sm);
  font-size: 10px;
}

.console {
  margin-top: 4px;
  height: 64px;
  overflow: hidden;
  padding: 3px 6px;
  background: var(--hi);
  box-shadow: var(--sunken);
  cursor: default;
}

.console .c1 {
  padding-bottom: 2px;
  margin-bottom: 2px;
  border-bottom: 1px dotted var(--shadow);
  color: var(--sel);
}

.console .c1,
.console .c2 > div {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.console .c2 > div { color: var(--ink-3); line-height: 1.35; }
.console .c2 > div:first-child { color: var(--ink); }
.console .c2 > div:nth-child(n + 4) { display: none; }

.statusbar {
  display: flex;
  gap: 2px;
  margin-top: 3px;
  font-family: var(--font-sm);
  font-size: 10px;
}

.statusbar .status { display: flex; gap: 2px; flex: 1; min-width: 0; }

.statusbar .status span,
.statusbar .ver {
  padding: 1px 6px;
  box-shadow: var(--thin-in);
  white-space: nowrap;
}

.statusbar .status .push { margin-left: auto; }
.statusbar .ver { color: var(--ink-3); }

/* ---------- taskbar and start menu ---------- */

.taskbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  gap: 3px;
  height: 30px;
  padding: 3px 2px 2px;
  background: var(--face);
  box-shadow: inset 0 1px var(--light), inset 0 2px var(--hi);
}

.start {
  display: flex;
  align-items: center;
  gap: 4px;
  height: 23px;
  padding: 0 6px 0 4px;
  border: 0;
  background: var(--face);
  box-shadow: var(--raised);
  font-weight: bold;
}

.start.on { box-shadow: var(--pressed); background: var(--dither); }

.tasks {
  display: flex;
  gap: 3px;
  flex: 1;
  min-width: 0;
  padding-left: 4px;
  border-left: 1px solid var(--shadow);
  box-shadow: inset 1px 0 var(--hi);
}

.task {
  display: flex;
  align-items: center;
  gap: 4px;
  flex: 0 1 160px;
  min-width: 40px;
  height: 23px;
  padding: 0 6px 0 4px;
  border: 0;
  background: var(--face);
  box-shadow: var(--raised);
  text-align: left;
}

.task .task-label { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.task.on { background: var(--dither); box-shadow: var(--pressed); font-weight: bold; }

.tray {
  display: flex;
  align-items: center;
  gap: 4px;
  height: 23px;
  padding: 0 8px 0 4px;
  box-shadow: var(--thin-in);
}

.tray-btn {
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  padding: 0;
  border: 0;
  background: none;
}

.tray-btn.busy { animation: blink 0.8s steps(2, jump-none) infinite; }
.tray-clock { min-width: 64px; text-align: center; white-space: nowrap; }

.start-menu {
  position: fixed;
  left: 2px;
  bottom: 28px;
  z-index: 10001;
  display: flex;
  padding: 3px;
  background: var(--face);
  box-shadow: var(--window);
}

.start-menu[hidden] { display: none; }

.sm-side {
  display: flex;
  align-items: flex-end;
  gap: 2px;
  width: 22px;
  padding: 6px 0;
  background: linear-gradient(0deg, var(--title-a), var(--title-b));
  color: var(--face);
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  font-size: 14px;
  letter-spacing: 0.08em;
}

.sm-side b { color: var(--hi); }

.start-menu ul { margin: 0; padding: 0; list-style: none; min-width: 190px; }

.start-menu li button {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  height: 28px;
  padding: 0 18px 0 6px;
  border: 0;
  background: none;
  text-align: left;
}

.start-menu li button:hover,
.start-menu li button:focus-visible { background: var(--sel); color: var(--sel-ink); outline: none; }

.start-menu li.sep {
  height: 2px;
  margin: 3px 2px;
  border-top: 1px solid var(--shadow);
  border-bottom: 1px solid var(--hi);
}

.shutdown {
  position: fixed;
  inset: 0;
  z-index: 20000;
  display: grid;
  place-content: center;
  gap: 18px;
  background: #000;
  color: #ff8c00;
  text-align: center;
  font-size: 22px;
  cursor: default;
}

.shutdown p { margin: 0; }
.shutdown .small { color: #806040; font-size: 12px; }

/* ---------- inside the windows ---------- */

.row {
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 7px 0;
  border-bottom: 1px solid var(--shadow);
  box-shadow: 0 1px 0 var(--hi);
}

.pv {
  width: 52px;
  height: 52px;
  image-rendering: pixelated;
  background: #2b2319;
  box-shadow: var(--sunken);
}

.row-main .name { color: var(--ink); }
.row-main .meta { color: var(--ink-3); font-family: var(--font-sm); font-size: 10px; }
.row-main .note { color: var(--good); font-family: var(--font-sm); font-size: 10px; }
.row-act { display: flex; flex-direction: column; gap: 4px; align-items: stretch; }
.row-act .dlg-btn { min-width: 72px; min-height: 22px; padding: 2px 8px; }
.row.slim { grid-template-columns: minmax(0, 1fr) auto; gap: 0 10px; }
.row.slim .pv { display: none; }
.row.stale .row-main .note { color: var(--warn); }
.tag { color: var(--ink-3); font-family: var(--font-sm); font-size: 10px; }
.tag.busy { animation: blink 0.8s steps(2, jump-none) infinite; }

.market-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 2px 0 6px;
  border-bottom: 1px solid var(--shadow);
  box-shadow: 0 1px 0 var(--hi);
}

.bal { color: var(--ink-2); }

.crab-card { display: grid; gap: 10px; padding-top: 2px; }
.pv-wrap { display: grid; place-items: center; padding: 4px 0; }
.pv.big { width: 144px; height: 144px; }

.kv {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 4px 12px;
  margin: 4px 0 0;
}

.kv dt { color: var(--ink-3); }
.kv dd { margin: 0; overflow-wrap: anywhere; }

.bars { display: inline-flex; gap: 8px; }
.bars .bar { display: inline-flex; gap: 1px; }
.bars .bar i { width: 5px; height: 9px; background: var(--hi); box-shadow: inset 0 0 0 1px var(--shadow); }
.bars .bar i.on { background: #008000; box-shadow: none; }

.txrow {
  display: grid;
  grid-template-columns: 62px 1fr auto auto;
  gap: 8px;
  padding: 3px 4px;
  font-family: var(--font-sm);
  font-size: 10px;
}

.txrow:nth-child(odd) { background: rgba(255, 255, 255, 0.35); }
.st.confirmed { color: #006000; }
.st.pending { color: #806000; }
.st.failed,
.st.dropped { color: var(--warn); }
.hash { color: var(--ink-3); }

.set-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 7px 0;
  border-bottom: 1px solid var(--shadow);
  box-shadow: 0 1px 0 var(--hi);
}

.set-row.warn span { color: var(--warn); }

.log { margin: 0; padding: 4px 6px; list-style: none; background: var(--hi); box-shadow: var(--sunken); }
.log li { padding: 2px 0; }

.act-row { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0 4px; }
.act-row .dlg-btn { min-height: 23px; }
.line-end { display: inline-flex; align-items: center; gap: 10px; }
.line-end .dlg-btn { min-height: 22px; }

.dlg.wide-dlg { max-width: calc(100% - 16px); }

.costs {
  width: 100%;
  border-collapse: collapse;
  background: var(--hi);
  box-shadow: var(--sunken);
  font-family: var(--font-sm);
  font-size: 10px;
}

.costs th {
  padding: 3px 6px;
  background: var(--face);
  box-shadow: var(--raised);
  font-weight: normal;
  text-align: left;
}

.costs td { padding: 3px 6px; }

.help-dlg section:first-child h3 { margin-top: 2px; }

/* the hatching window */

.hatch-stage { display: grid; place-items: center; padding: 3px; background: #2b2319; box-shadow: var(--sunken); }
.hatch-canvas { display: block; width: 480px; max-width: 100%; height: auto; aspect-ratio: 240 / 110; image-rendering: pixelated; }
.hatch-status { margin: 10px 2px 6px; min-height: 18px; }
.progress { height: 20px; padding: 3px; background: var(--hi); box-shadow: var(--sunken); }
.progress .bar { height: 100%; width: 0; background: repeating-linear-gradient(90deg, var(--sel) 0 8px, transparent 8px 10px); }
.hatch-list { margin-top: 10px; padding: 3px; background: var(--hi); box-shadow: var(--sunken); }
.hatch-row { display: grid; grid-template-columns: 8px auto auto minmax(0, 1fr) auto; gap: 8px; align-items: center; padding: 3px 4px; }
.hatch-row .dlg-btn { min-width: 60px; min-height: 21px; padding: 1px 8px; }
.hatch-dot { width: 8px; height: 8px; box-shadow: inset 0 0 0 1px var(--dark); }
.hatch-name { white-space: nowrap; }
.hatch-meta { font-family: var(--font-sm); font-size: 10px; color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* the recycle bin */

.bin-head { display: flex; align-items: center; gap: 14px; padding: 4px 0 6px; }
.bin-head img { width: 32px; height: 32px; image-rendering: pixelated; }
.bin-num { font-size: 18px; }

/* short screens: the icons need a second column, so the beach window moves clear of it */

@media (height < 744px) {
  .win-main { left: 198px; width: min(880px, calc(100vw - 212px), var(--fit)); }
}

/* narrow screens: icons along the top, windows fill the width */

@media (max-width: 700px) {
  .icons { position: static; grid-auto-flow: row; grid-template-columns: repeat(auto-fill, 80px); grid-template-rows: none; padding: 4px; }
  .win-main { left: 0 !important; width: 100% !important; top: 0; }
}
