/* Formicarium: a dark room, the farm on its stand, and a row of pixel buttons */

:root {
  --bg: #241c17;
  --stand: #2e241d;
  --stand-line: #4a3a2e;
  --paper: #f1ebdc;
  --paper-dark: #c6bb9f;
  --ink: #3a352c;
  --cream: #efe4cf;
  --muted: #b9a685;
  --orange: #ff5f0b;
  --blue: #1f7fb0;
  /* Stepped corners, like a rounded rectangle drawn in pixels */
  --corners: polygon(0 8px, 4px 8px, 4px 4px, 8px 4px, 8px 0, calc(100% - 8px) 0, calc(100% - 8px) 4px, calc(100% - 4px) 4px, calc(100% - 4px) 8px, 100% 8px, 100% calc(100% - 8px), calc(100% - 4px) calc(100% - 8px), calc(100% - 4px) calc(100% - 4px), calc(100% - 8px) calc(100% - 4px), calc(100% - 8px) 100%, 8px 100%, 8px calc(100% - 4px), 4px calc(100% - 4px), 4px calc(100% - 8px), 0 calc(100% - 8px));
  --corners-sm: polygon(0 4px, 4px 4px, 4px 0, calc(100% - 4px) 0, calc(100% - 4px) 4px, 100% 4px, 100% calc(100% - 4px), calc(100% - 4px) calc(100% - 4px), calc(100% - 4px) 100%, 4px 100%, 4px calc(100% - 4px), 0 calc(100% - 4px));
}

* { box-sizing: border-box; }

html, body { height: 100%; margin: 0; }

body {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg);
  color: var(--cream);
  font-family: 'Silkscreen', ui-monospace, monospace;
  -webkit-tap-highlight-color: transparent;
}

/* ---------- the farm ---------- */

#farm {
  position: relative;
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 12px;
}

#stats {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 4px 16px;
  margin: 0;
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}
#stats b { font-weight: 400; color: var(--cream); }

#farm-glass {
  line-height: 0;
  filter: drop-shadow(0 12px 18px rgba(0, 0, 0, 0.45));
}

#glass {
  display: block;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  touch-action: none;
  cursor: crosshair;
}
body.mode-tap #glass { cursor: pointer; }

.shake { animation: shake 0.25s steps(4); }
@keyframes shake {
  25% { transform: translate(-2px, 1px); }
  50% { transform: translate(2px, -1px); }
  75% { transform: translate(-1px, 0); }
}

#toast {
  position: absolute;
  left: 50%;
  top: 14px;
  z-index: 3;
  max-width: min(560px, calc(100% - 32px));
  padding: 10px 16px;
  background: var(--paper);
  color: var(--ink);
  font-size: 12px;
  line-height: 1.5;
  text-align: center;
  clip-path: var(--corners);
  opacity: 0;
  transform: translate(-50%, -8px);
  pointer-events: none;
  transition: opacity 0.25s, transform 0.25s;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- the stand and its buttons ---------- */

#stand {
  position: relative;
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  height: calc(76px + env(safe-area-inset-bottom));
  padding: 0 16px env(safe-area-inset-bottom);
  background: var(--stand);
  border-top: 4px solid #17110d;
}

.plaque {
  position: absolute;
  left: 22px;
  top: 50%;
  margin-top: calc(env(safe-area-inset-bottom) / -2);
  transform: translateY(-50%);
  padding: 7px 12px 6px;
  background: #c9a24a;
  color: #3a2a0c;
  font-size: 13px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  clip-path: var(--corners-sm);
  box-shadow: inset 0 2px 0 #e8c66a, inset 0 -2px 0 #8a6a2a;
}

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

.sep {
  width: 3px;
  height: 36px;
  margin: 0 4px;
  background: var(--stand-line);
}

.tool {
  appearance: none;
  -webkit-appearance: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  width: 58px;
  height: 52px;
  margin: 0;
  padding: 3px 0 0;
  border: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 10px/1 'Silkscreen', ui-monospace, monospace;
  text-transform: uppercase;
  text-decoration: none;
  cursor: pointer;
  clip-path: var(--corners-sm);
  box-shadow: inset -3px -3px 0 var(--paper-dark), inset 3px 3px 0 #fff;
}
.tool svg { width: 20px; height: 20px; fill: currentColor; shape-rendering: crispEdges; }
.tool:hover { background: #fff8e8; }
.tool:active { box-shadow: inset 3px 3px 0 var(--paper-dark); }
.tool[aria-pressed="true"] {
  background: var(--orange);
  color: #fff;
  box-shadow: inset -3px -3px 0 #b8440a, inset 3px 3px 0 #ff8f52;
}
.tool:focus-visible { outline: none; box-shadow: inset 0 0 0 3px var(--blue); }

/* Quit sits at the right end of the stand, across from the plaque; on narrow
   screens it joins the end of the row */
#btn-quit {
  position: absolute;
  right: 22px;
  top: 50%;
  margin-top: calc(-26px - env(safe-area-inset-bottom) / 2);
}
.sep-quit { display: none; }

@media (max-width: 820px) {
  .plaque { display: none; }
  #btn-quit { position: static; margin-top: 0; }
  .sep-quit { display: block; }
}
@media (max-width: 460px) {
  .tools { gap: 4px; }
  .tool { width: 46px; height: 48px; font-size: 9px; }
  .sep { margin: 0 1px; }
}

/* ---------- odds and ends ---------- */

.sr-only {
  position: absolute !important;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.noscript {
  max-width: 34em;
  padding: 16px 20px;
  background: var(--paper);
  color: var(--ink);
  font-size: 13px;
  line-height: 1.5;
  text-align: center;
}

@media (prefers-reduced-motion: reduce) {
  #toast { transition: none; }
}
