:root {
  --paper: #f4efe5;
  --ink: #171717;
  --muted: #6c675e;
  --panel: rgba(255, 252, 246, .94);
  --line: #cfc7b8;
  --accent: #6f42c1;
  --accent-dark: #532c98;
  --available: #fffdf8;
  --reserved: #dfd8cb;
  --danger: #a62424;
  --shadow: 0 14px 45px rgba(42, 34, 22, .18);
}

* { box-sizing: border-box; }
html, body { width: 100%; height: 100%; margin: 0; }
body {
  background: var(--paper);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  overflow: hidden;
}
button, input, select { font: inherit; }
button { color: inherit; }

/* Mobile controls: rapid taps should activate controls, not browser double-tap zoom. */
button, .button, a, input, select, label {
  touch-action: manipulation;
}
.hidden { display: none !important; }

.topbar {
  height: 76px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 10px 18px 10px 22px;
  background: var(--paper);
  border-bottom: 1px solid var(--line);
  position: relative;
  z-index: 20;
}
.brand-wrap { min-width: 0; }
.brand-kicker, .eyebrow {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .16em;
  color: var(--muted);
}
h1 {
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(20px, 2.3vw, 31px);
  line-height: 1;
  margin: 4px 0 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.account { display: flex; align-items: center; gap: 10px; }
.account-copy { text-align: right; font-size: 13px; line-height: 1.25; }
.account-copy strong { display: block; }
.account-copy span { color: var(--muted); }

.button {
  border: 1px solid var(--ink);
  border-radius: 7px;
  padding: 10px 14px;
  background: #fff;
  font-weight: 750;
  cursor: pointer;
}
.button:hover { transform: translateY(-1px); }
.button.primary { background: var(--ink); color: #fff; }
.button.secondary { background: transparent; }
.button.twitch { background: #9146ff; color: white; border-color: #7135c9; white-space: nowrap; }
.button:disabled { cursor: not-allowed; opacity: .55; transform: none; }

.pause-banner {
  position: fixed;
  z-index: 25;
  top: 76px;
  left: 0;
  right: 0;
  padding: 9px 16px;
  text-align: center;
  font-weight: 700;
  font-size: 13px;
  background: #ffdc76;
  border-bottom: 1px solid #c99d30;
}

.viewer-shell { position: absolute; inset: 76px 0 0; overflow: hidden; }
#easelCanvas {
  display: block;
  width: 100%;
  height: 100%;
  cursor: grab;
  touch-action: none;
  background: #e8e1d5;
}
#easelCanvas.dragging { cursor: grabbing; }

.floating-panel {
  position: absolute;
  z-index: 4;
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: 0 5px 22px rgba(50, 40, 25, .11);
  backdrop-filter: blur(8px);
}
.instructions {
  left: 16px;
  bottom: 16px;
  border-radius: 9px;
  padding: 10px 13px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-width: min(620px, calc(100vw - 120px));
  font-size: 13px;
}
.instructions span { color: var(--muted); font-size: 12px; }
.zoom-controls {
  right: 16px;
  bottom: 16px;
  border-radius: 9px;
  overflow: hidden;
  display: grid;
  grid-template-columns: 42px 42px;
}
.zoom-controls button {
  border: 0;
  border-right: 1px solid var(--line);
  background: transparent;
  min-height: 38px;
  cursor: pointer;
  font-weight: 800;
}
.zoom-controls button:hover { background: #fff; }
.zoom-controls .wide { grid-column: 1 / -1; border-top: 1px solid var(--line); border-right: 0; font-size: 12px; }
.coord-readout {
  right: 16px;
  top: 16px;
  padding: 6px 9px;
  border-radius: 7px;
  color: var(--muted);
  font-size: 12px;
  pointer-events: none;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  background: rgba(24, 20, 16, .62);
  padding: 18px;
}
.modal-card {
  width: min(980px, 100%);
  max-height: calc(100vh - 36px);
  overflow: auto;
  background: #fbf8f1;
  border: 1px solid #bcb3a3;
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 20px;
  position: relative;
}
.modal-header { display: flex; justify-content: space-between; gap: 20px; align-items: start; margin-bottom: 14px; }
.modal-header h2, .tile-card h2 { margin: 2px 0 0; font-family: Georgia, "Times New Roman", serif; font-size: 25px; }
.muted { color: var(--muted); font-size: 13px; }
.reservation-clock {
  font-variant-numeric: tabular-nums;
  font-weight: 850;
  font-size: 19px;
  border: 1px solid var(--line);
  padding: 7px 10px;
  border-radius: 8px;
  background: #fff;
}
.paint-layout { display: grid; grid-template-columns: 160px minmax(0, 1fr); gap: 18px; align-items: start; }
.drawing-card,
.drawing-card * {
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}
.toolbar { display: flex; flex-direction: column; gap: 7px; }
.toolbar button, .toolbar select, .field {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  min-height: 36px;
}
.toolbar button { cursor: pointer; padding: 7px 9px; text-align: left; font-weight: 700; }
.toolbar button.active { background: var(--ink); color: #fff; border-color: var(--ink); }
.field { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 6px 8px; font-size: 12px; font-weight: 700; }
.field input[type="color"] { width: 38px; height: 24px; border: 0; padding: 0; background: transparent; }
.field select { min-height: 26px; padding: 2px 4px; }
.tool-row { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; }
.paint-stage { display: flex; flex-direction: column; align-items: center; gap: 8px; min-width: 0; }
#paintCanvas {
  width: min(62vh, 100%);
  aspect-ratio: 1;
  height: auto;
  background: white;
  border: 2px solid var(--ink);
  box-shadow: 0 3px 12px rgba(0,0,0,.08);
  cursor: crosshair;

  /* Single-finger pointer events still reach the drawing code, while a
     two-finger gesture is handed to the browser for normal pinch zoom. */
  touch-action: pinch-zoom;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}
.paint-note { color: var(--muted); text-align: center; font-size: 11px; }
.modal-actions { margin-top: 18px; display: flex; justify-content: flex-end; gap: 9px; }
.tile-card { width: min(500px, 100%); text-align: center; }
.tile-card img { display: block; width: 100%; aspect-ratio: 1; object-fit: contain; background: #fff; border: 1px solid var(--line); border-radius: 7px; margin-bottom: 14px; }
.modal-x { position: absolute; right: 7px; top: 7px; width: 36px; height: 36px; border: 0; border-radius: 50%; background: rgba(255,255,255,.92); font-size: 26px; cursor: pointer; z-index: 2; }


.rules-card {
  width: min(620px, 100%);
}
.rules-card h2 {
  margin: 4px 0 6px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 28px;
}
.rules-intro {
  margin: 0 0 16px;
  color: var(--muted);
  font-size: 14px;
}
.rule-item {
  display: grid;
  grid-template-columns: 24px 1fr;
  gap: 11px;
  align-items: start;
  padding: 14px 0;
  border-top: 1px solid var(--line);
  cursor: pointer;
}
.rule-item:last-of-type {
  border-bottom: 1px solid var(--line);
}
.rule-item input {
  margin: 3px 0 0;
  width: 18px;
  height: 18px;
  accent-color: var(--ink);
}
.rule-item strong {
  display: block;
  font-size: 16px;
  margin-bottom: 4px;
}
.rule-item small {
  display: block;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.toast-container { position: fixed; z-index: 200; top: 92px; right: 15px; display: flex; flex-direction: column; gap: 8px; pointer-events: none; }
.toast { max-width: 360px; padding: 10px 13px; border-radius: 8px; background: #171717; color: #fff; box-shadow: var(--shadow); font-size: 13px; animation: toastIn .16s ease-out; }
.toast.error { background: #852323; }
@keyframes toastIn { from { opacity: 0; transform: translateY(-5px); } }

@media (max-width: 720px) {
  .topbar { height: 68px; padding: 8px 10px 8px 12px; }
  .viewer-shell { inset-top: 68px; inset: 68px 0 0; }
  .brand-kicker { display: none; }
  .account-copy { display: none; }
  .pause-banner { top: 68px; }
  .instructions { max-width: calc(100vw - 32px); right: 16px; bottom: 70px; }
  .instructions span { display: none; }
  .paint-layout { grid-template-columns: 1fr; }
  .toolbar { display: grid; grid-template-columns: repeat(3, 1fr); }
  .toolbar .field, .toolbar .tool-row, #clearBtn { grid-column: span 1; }
  .toolbar button { text-align: center; font-size: 12px; }
  .modal-card { padding: 14px; }
  #paintCanvas { width: min(88vw, 54vh); }
}
