:root {
  color: #000;
  background: #fff;
  font-family: Arial, Helvetica, sans-serif;
  font-size: 14px;
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; overflow: hidden; }
button, input, textarea { font: inherit; border: 1px solid #000; border-radius: 0; color: #000; }
button { background: #ddd; cursor: pointer; padding: 3px 8px; }
button:hover, button:focus-visible { background: #fff; outline: 1px dotted #000; outline-offset: -4px; }
button:disabled { color: #666; cursor: not-allowed; }
input, textarea { background: #fff; padding: 4px; width: 100%; }
textarea { font-family: "Courier New", monospace; resize: vertical; }
a { color: #00e; }

.topbar {
  height: 37px;
  position: fixed;
  inset: 0 0 auto;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 5px 8px;
  background: #eee;
  border-bottom: 1px solid #000;
}
.brand { white-space: nowrap; }
.brand a { color: #000; font-weight: bold; text-decoration: none; }
.brand span, #status, .fine-print { color: #333; font-size: 12px; }
.top-actions { display: flex; align-items: center; gap: 7px; }

#canvas { position: fixed; inset: 37px 0 0; overflow: hidden; touch-action: none; cursor: grab; background: #fafafa; user-select: none; -webkit-user-select: none; -webkit-user-drag: none; }
#canvas.dragging { cursor: grabbing; }
#canvas * { user-select: none; -webkit-user-select: none; -webkit-user-drag: none; }
#grid-background { position: absolute; inset: 0; background-color: #f8f8f8; }
#tile-layer { position: absolute; inset: 0; pointer-events: none; }

.tile-card { position: absolute; width: 220px; height: 220px; background: #fff; pointer-events: auto; overflow: hidden; transform: translate3d(var(--x), var(--y), 0); contain: strict; }
.tile-card:hover { background: #ffffe8; }
.tile-card.selected { outline: 3px solid #000; outline-offset: -3px; background: #fff; z-index: 3; }
.tile-card.empty { background: #f6f6f6; }
.tile-label { position: absolute; inset: 0; z-index: 2; padding: 5px; color: #000; font-size: 12px; text-shadow: 0 0 2px #fff, 0 0 2px #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; pointer-events: none; }
.tile-card iframe { display: block; width: 100%; height: 100%; border: 0; background: #fff; }
.tile-card.active .tile-label { display: none; }
.tile-owner { color: #333; }

.panel, .modal { background: #fff; border: 2px solid #000; box-shadow: 4px 4px 0 #777; }
.panel { position: fixed; z-index: 20; left: 8px; top: 46px; width: min(310px, calc(100vw - 16px)); padding: 10px; }
.panel h2, .modal h2 { margin: 0 24px 8px 0; font-size: 16px; }
.panel p { margin: 7px 0; }
.panel-close { position: absolute; right: 6px; top: 6px; min-width: 22px; padding: 1px 5px; font-weight: bold; }

#modal-backdrop { position: fixed; z-index: 50; inset: 0; overflow: auto; padding: 45px 16px 16px; background: rgba(255,255,255,.82); }
.modal { position: relative; width: min(390px, 100%); margin: 0 auto 20px; padding: 14px; }
.modal.wide { width: min(700px, 100%); }
.modal.editor { width: min(810px, 100%); }
form > label { display: block; margin: 8px 0; font-weight: bold; }
form > label > input, form > label > textarea { margin-top: 3px; font-weight: normal; }
.form-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.simple-list { margin: 6px 0; padding-left: 19px; }
.simple-list li { margin: 4px 0; }
.upload-box, #revisions-area { margin-top: 14px; padding-top: 8px; border-top: 1px dotted #000; }
.upload-box h3, #revisions-area h3, #account-modal h3 { font-size: 14px; margin: 7px 0; }
#upload-form { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
#upload-form input { max-width: 300px; }
#toast { position: fixed; z-index: 80; bottom: 12px; left: 50%; transform: translateX(-50%); max-width: min(520px, calc(100vw - 24px)); padding: 7px 10px; background: #fff; border: 2px solid #000; box-shadow: 3px 3px 0 #777; }
.admin-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.admin-table th, .admin-table td { border: 1px solid #000; padding: 4px; text-align: left; }
.admin-table th { background: #ddd; }

@media (max-width: 620px) {
  .brand span { display: none; }
  .topbar { gap: 4px; }
  #status { max-width: 90px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  #modal-backdrop { padding: 40px 7px 8px; }
  .modal { padding: 11px; }
}
