html {
  font-family: Arial, sans-serif;
}
html,
body {
  margin: 0;
  padding: 0;
  position: relative;
}
canvas {
  display: block;
  width: 100vw;
  height: 100vh;
  /* Dragging rotates the cube, so don't let touch scroll or zoom the page */
  touch-action: none;
}
/* In portrait, keep the cube between the top buttons and the bottom pads */
@media (orientation: portrait) {
  canvas {
    position: fixed;
    top: 68px;
    height: calc(100vh - 68px - 302px);
    height: calc(100dvh - 68px - 302px);
  }
}
div {
  position: absolute;
}
#ui-layer {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  pointer-events: none;
  user-select: none;
}
#ui-layer div {
  position: static;
}
#ui-layer > .panel {
  position: absolute;
  pointer-events: auto;
}
#ui-layer button {
  font: inherit;
  font-size: 16px;
  min-width: 44px;
  min-height: 44px;
  padding: 0 12px;
  border: 1px solid #999;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.85);
  color: #222;
  cursor: pointer;
  touch-action: manipulation;
}
#ui-layer button:hover {
  background: #fff;
  border-color: #555;
}
#ui-layer button.active,
#ui-layer button:active {
  background: #3333cc;
  border-color: #222288;
  color: #fff;
}

#top-controls {
  top: 12px;
  left: 12px;
  display: flex;
  gap: 8px;
}

#settings-panel {
  top: 68px;
  left: 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px;
  border: 1px solid #999;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.95);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
}
#settings-panel[hidden] {
  display: none;
}
#settings-panel h2 {
  margin: 0;
  font-size: 18px;
}
.switch {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
}
.switch input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}
.switch .slider {
  position: relative;
  flex: none;
  width: 40px;
  height: 22px;
  border-radius: 11px;
  background: #bbb;
  transition: background 0.15s;
}
.switch .slider::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.15s;
}
.switch input:checked + .slider {
  background: #3333cc;
}
.switch input:checked + .slider::after {
  transform: translateX(18px);
}
.switch input:focus-visible + .slider {
  outline: 2px solid #3333cc;
  outline-offset: 2px;
}

.pad {
  display: grid;
  grid-template-columns: repeat(3, 52px);
  grid-auto-rows: 52px;
  gap: 6px;
}
#ui-layer .pad button {
  padding: 0;
  font-size: 22px;
}
#ui-layer .pad button.wide {
  grid-column: span 3;
  font-size: 16px;
}

#rotate-controls {
  left: 12px;
  bottom: 12px;
}

#entry-controls {
  right: 12px;
  bottom: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
#entry-mode-controls {
  display: flex;
  gap: 6px;
}
#ui-layer #entry-mode-controls button {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}
/* The icons are dark, so mark the active mode with a ring, not a fill */
#ui-layer #entry-mode-controls button.active {
  background: #dde4ff;
  border-color: #3333cc;
  box-shadow: inset 0 0 0 2px #3333cc;
}
#entry-mode-controls svg {
  width: 36px;
  height: 36px;
  font-family: Arial, sans-serif;
  text-anchor: middle;
  dominant-baseline: central;
}
/* Colours and relative sizes match src/grid.js */
#entry-mode-controls .cell {
  fill: #ffffff;
  stroke: #333333;
  stroke-width: 3;
}
#entry-mode-controls .num-user {
  fill: #113377;
  font-size: 78px;
}
#entry-mode-controls .pencil-corner {
  fill: #333333;
  font-size: 26px;
}
#entry-mode-controls .pencil-center {
  fill: #3333cc;
  font-size: 30px;
}
