html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
  font-family: "Arial", sans-serif;
  background: #f4f4f4;
  -webkit-user-select: none;
  user-select: none;
}

#landing {
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 24px;
  box-sizing: border-box;
}

#landing h1 {
  font-size: 42px;
  margin: 0 0 8px;
}

#landing p {
  color: #555;
  max-width: 420px;
  margin: 0 0 20px;
}

#goForm {
  display: flex;
  gap: 8px;
}

#goForm input {
  font-size: 16px;
  padding: 10px 12px;
  border: 1px solid #ccc;
  border-radius: 6px;
  width: 200px;
}

#goForm button {
  font-size: 16px;
  padding: 10px 18px;
  border: none;
  border-radius: 6px;
  background: #111;
  color: #fff;
  cursor: pointer;
}

#app {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 16px;
  box-sizing: border-box;
  background: #1b1b1e;
}

/* Letterboxed 16:9 frame. The width is capped by both the available
   width and by (available height * 16/9), so the box always fits inside
   the flex area without ever clipping - the aspect-ratio then derives
   the matching height. The canvas's pixel backing store is fixed (set
   once in JS) and never resized to match this box; only its CSS size
   follows the frame, so window/viewport changes can never wipe or
   shrink the drawing surface. */
#canvasWrap {
  width: min(100%, calc((100vh - 190px) * 16 / 9));
  aspect-ratio: 16 / 9;
  max-height: calc(100vh - 190px);
  background: #ffffff;
  border-radius: 10px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
  overflow: hidden;
  position: relative;
}

#canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  cursor: crosshair;
}

#toolbar {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(0, 0, 0, 0.08);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
  border-radius: 999px;
  padding: 8px 14px;
  z-index: 10;
  flex: 0 0 auto;
}

#swatches {
  display: flex;
  gap: 6px;
}

.swatch {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid rgba(0, 0, 0, 0.15);
  cursor: pointer;
  padding: 0;
}

.swatch.active {
  border-color: #111;
}

#colorPicker {
  width: 28px;
  height: 28px;
  padding: 0;
  border: none;
  background: none;
  cursor: pointer;
}

#size {
  width: 90px;
}

#toolbar button {
  font-size: 13px;
  padding: 8px 12px;
  border: 1px solid rgba(0, 0, 0, 0.12);
  border-radius: 999px;
  background: #fff;
  cursor: pointer;
}

#eraserBtn.active {
  background: #111;
  color: #fff;
}

#status {
  position: fixed;
  top: 12px;
  right: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: #555;
  background: rgba(255, 255, 255, 0.85);
  padding: 5px 10px;
  border-radius: 999px;
  z-index: 10;
}

#statusDot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #d9a300;
}

#status.live #statusDot {
  background: #1fa855;
}

#status.error #statusDot {
  background: #d43;
}

@media (max-width: 480px) {
  #toolbar {
    gap: 6px;
    padding: 6px 10px;
    max-width: calc(100% - 24px);
    overflow-x: auto;
  }
  #size {
    width: 60px;
  }
}
