* { box-sizing: border-box; }
html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  background: #14522f;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
#table {
  position: fixed;
  inset: 0;
  height: 100dvh;
  background:
    radial-gradient(ellipse at center, #1f7a46 0%, #17613a 60%, #0f4a2b 100%);
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}
#bar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100000;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  padding: 6px 12px;
  background: rgba(0, 0, 0, 0.35);
  color: #fff;
  font-size: 15px;
  pointer-events: auto;
}
#bar a, #bar button {
  color: #fff;
  background: rgba(255, 255, 255, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.45);
  border-radius: 6px;
  padding: 6px 12px;
  font: inherit;
  text-decoration: none;
  cursor: pointer;
}
#bar a:hover, #bar button:hover { background: rgba(255, 255, 255, 0.3); }
#bar a:focus-visible, #bar button:focus-visible {
  outline: 3px solid #e8b923;
  outline-offset: 2px;
}
#bar .langs { display: flex; gap: 8px; }
#bar a.lang { padding: 6px 8px; line-height: 0; }
#bar .flag {
  display: block;
  width: 26px;
  height: 17px;
  border-radius: 2px;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.35);
}
#bar [hidden] { display: none; }

.tile {
  position: absolute;
  left: 0;
  top: 0;
  width: var(--tw, 40px);
  height: var(--th, 52px);
  padding: calc(var(--tw, 40px) * 0.09) calc(var(--tw, 40px) * 0.1);
  border-radius: calc(var(--tw, 40px) * 0.14);
  background: linear-gradient(160deg, #fffdf4 0%, #f1ead4 100%);
  box-shadow:
    0 0 0 1px rgba(0, 0, 0, 0.25),
    0 3px 0 #2e8b57,
    0 4px 0 rgba(0, 0, 0, 0.35),
    0 6px 8px rgba(0, 0, 0, 0.35);
  cursor: grab;
  touch-action: none;
  will-change: transform;
}
.tile svg { display: block; width: 100%; height: 100%; pointer-events: none; }
.tile.dragging {
  cursor: grabbing;
  box-shadow:
    0 0 0 1px rgba(0, 0, 0, 0.25),
    0 3px 0 #2e8b57,
    0 4px 0 rgba(0, 0, 0, 0.35),
    0 14px 18px rgba(0, 0, 0, 0.45);
}
.tile.dragging svg { filter: brightness(1.03); }

.nojs {
  position: absolute;
  top: 60px;
  left: 16px;
  right: 16px;
  color: #fff;
  font-size: 18px;
}
.license {
  position: fixed;
  right: 8px;
  bottom: 6px;
  margin: 0;
  z-index: 100001;
  font-size: 11px;
  color: rgba(255, 255, 255, 0.55);
  pointer-events: none;
}
.license a {
  color: inherit;
  pointer-events: auto;
}
.license a:hover, .license a:focus-visible { color: #fff; }
.marquee {
  position: absolute;
  z-index: 99999;
  border: 1px dashed #fff;
  background: rgba(255, 255, 255, 0.14);
  pointer-events: none;
}
.tile.selected {
  outline: 2px solid #ffd54a;
  outline-offset: 1px;
}

#help {
  position: fixed;
  left: 8px;
  bottom: 8px;
  z-index: 100002;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  pointer-events: none;
}
#help-btn {
  pointer-events: auto;
  width: 30px;
  height: 30px;
  padding: 0;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.6);
  background: rgba(0, 0, 0, 0.45);
  color: #fff;
  font: 700 17px/1 system-ui, sans-serif;
  cursor: help;
}
#help-btn:hover { background: rgba(0, 0, 0, 0.7); }
#help-btn:focus-visible { outline: 3px solid #e8b923; outline-offset: 2px; }
#help-text {
  order: -1;
  margin: 0;
  max-width: min(400px, calc(100vw - 16px));
  padding: 10px 14px 10px 30px;
  list-style: disc;
  border-radius: 8px;
  background: #0c2e1b;
  border: 1px solid rgba(255, 255, 255, 0.35);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.4);
  color: #fff;
  font-size: 14px;
  line-height: 1.4;
  opacity: 1;
  transition: opacity 0.25s;
}
#help-text li + li { margin-top: 4px; }
#help-btn[aria-expanded="false"] + #help-text {
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s, visibility 0s 0.25s;
}
