/* Squares World: a white page with dark-blue text; the map is a framed blue-ocean window. Flat colors, hard shadows. */
:root {
  --ocean: #a6d5f7; --navy: #0a1f5c; --ink: #0a1f5c; --paper: #f3f7ff; --line: #b9c6e6;
  --logo: #1a73e8; --pink: #ff3d8b; --yellow: #ffe14d; --blue: #2f6bff;
  --sans: Verdana, Tahoma, Geneva, sans-serif;
  --brand: "Helvetica Neue", Helvetica, Arial, sans-serif;
  --mono: "Courier New", Courier, monospace;
  --safe-b: env(safe-area-inset-bottom, 0px); --safe-t: env(safe-area-inset-top, 0px);
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; background: #fff; color: var(--ink); font: 13px/1.45 var(--sans); overscroll-behavior: none; -webkit-text-size-adjust: 100%; }
body { display: flex; flex-direction: column; }
button, input, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* page: header, map window, footer */
header.site { flex: none; padding: calc(10px + var(--safe-t)) 16px 12px; }
.wordmark { margin: 0; line-height: 0; color: var(--logo); }
.logo { display: block; height: min(54px, calc((100vw - 32px) / 10.5)); width: auto; overflow: visible; fill: none; stroke: currentColor; stroke-linejoin: miter; stroke-miterlimit: 10; stroke-linecap: square; }
.sub { margin: 6px 0 0; font-size: clamp(13px, 2.7vw, 17px); line-height: 1.5; color: var(--ink); }
.dot { display: inline-block; width: max(9px, 0.52em); height: max(9px, 0.52em); margin: 0 0.5em 0 0.3em; border-radius: 0; background: var(--ink); opacity: 1; vertical-align: 0.1em; }
.dot.sm { width: 0.38em; height: 0.38em; margin: 0 0.45em; vertical-align: 0.08em; }
.sub > span:first-child { margin-right: 0; }
.cta { background: none; border: 0; padding: 0; font: inherit; font-weight: 400; color: var(--ink); cursor: pointer; text-decoration: none; }
.cta:hover { color: #000; }
footer.site { flex: none; padding: 9px 16px calc(9px + var(--safe-b)); text-align: center; font-size: 12px; }
footer.site a { color: var(--ink); text-underline-offset: 3px; }
#stage { position: relative; flex: 1 1 auto; min-height: 0; background: var(--ocean); border-top: 2px solid var(--navy); border-bottom: 2px solid var(--navy); overflow: hidden; }
#map { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; cursor: grab; outline-offset: -4px; user-select: none; -webkit-user-select: none; }
#map.dragging { cursor: grabbing; }
#map.area { cursor: crosshair; }
/* shown only when JavaScript is off */
.nojs { position: absolute; inset: 0; margin: 0; display: grid; place-items: center; padding: 24px; text-align: center; background: var(--ocean); color: var(--navy); font-weight: bold; }
#loading { position: absolute; inset: 0; display: grid; place-items: center; color: var(--navy); font: bold 13px var(--sans); letter-spacing: 0.06em; text-transform: uppercase; pointer-events: none; }

.chip { background: var(--navy); color: #fff; padding: 6px 10px; border: 2px solid #fff; box-shadow: 3px 3px 0 var(--navy); }
.chip.warn { background: var(--yellow); color: var(--ink); border-color: var(--navy); font-size: 11px; }
.count { position: absolute; top: 10px; right: 10px; font-size: 12px; white-space: nowrap; pointer-events: none; }
.count #claimed { font-weight: 800; }
#devbar { position: absolute; top: 10px; left: 10px; max-width: calc(100% - 190px); pointer-events: none; }

#toolbar { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); display: flex; flex-direction: column; gap: 6px; }
.tool { width: 44px; height: 44px; background: #fff; border: 2px solid var(--navy); box-shadow: 3px 3px 0 var(--navy); font: bold 20px/1 var(--sans); cursor: pointer; padding: 0; }
.tool.small { font-size: 11px; margin: 0; color: var(--ink); }
.tool:active { transform: translate(3px, 3px); box-shadow: none; }
.tool[aria-pressed="true"] { background: var(--pink); }

#hover { position: absolute; left: 50%; bottom: 12px; transform: translateX(-50%); background: var(--navy); color: #fff; padding: 4px 10px; font: 11px var(--sans); border: 2px solid #fff; pointer-events: none; white-space: nowrap; }

/* windows */
.panel .titlebar { position: sticky; top: -14px; z-index: 3; } /* the X stays at the top of the box while the box scrolls */
.titlebar { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: -14px -14px 12px; padding: 4px 4px 4px 12px; background: var(--navy); color: #fff; font: bold 12px var(--mono); letter-spacing: 0.1em; text-transform: uppercase; }
.modal .titlebar { margin: -20px -20px 14px; }
.xbtn { flex: none; width: 36px; height: 36px; display: grid; place-items: center; padding: 0 0 3px; background: transparent; color: #fff; border: 2px solid #fff; font: 700 28px/1 var(--sans); cursor: pointer; }
.xbtn:hover { background: var(--pink); color: var(--navy); border-color: var(--pink); }
.xbtn:focus-visible { outline: 3px solid var(--yellow); outline-offset: 2px; }
.panel { position: fixed; z-index: 5; left: 8px; right: 8px; bottom: calc(8px + var(--safe-b)); max-height: 60vh; overflow: auto; background: var(--paper); border: 2px solid var(--navy); box-shadow: 5px 5px 0 var(--navy); padding: 14px; overscroll-behavior: contain; }
@media (min-width: 760px) { .panel { left: auto; right: 14px; top: calc(var(--stage-top, 120px) + 58px); bottom: auto; width: 350px; max-height: calc(100vh - var(--stage-top, 120px) - 116px); } }
.panel section:not([hidden]) ~ section:not([hidden]) { margin-top: 14px; padding-top: 14px; border-top: 2px dotted var(--line); }
.panel h2 { margin: 0 0 4px; font: bold 18px/1.25 var(--mono); }
.place { margin: 0 0 8px; font-weight: bold; }
.hintnote { font-weight: 400; font-size: 11.5px; color: #3d4c78; }
.small { font-size: 11px; color: #3d4c78; margin: 4px 0; }
.fine { font-size: 10.5px; color: #4a5a85; margin: 8px 0 0; }
.hint { margin: 2px 0 10px; color: #3d4c78; }
.sel { margin: 0; font-size: 15px; } .sel b { font: bold 22px var(--mono); }
.row { display: flex; gap: 8px; flex-wrap: wrap; }

.btn { background: #fff; border: 2px solid var(--navy); box-shadow: 3px 3px 0 var(--navy); padding: 9px 14px; min-height: 42px; font-weight: bold; cursor: pointer; }
.btn.primary { background: var(--pink); }
.btn.wide { width: 100%; font-size: 15px; }
.btn:active:not([disabled]) { transform: translate(3px, 3px); box-shadow: none; }
.btn[disabled] { background: #e4e9f5; color: #66739b; box-shadow: none; border-color: #8a97be; cursor: not-allowed; }
.link { background: none; border: 0; padding: 4px 0; margin-bottom: 6px; color: var(--blue); text-decoration: underline; cursor: pointer; }
:is(button, input, textarea, canvas):focus-visible { outline: 3px solid var(--blue); outline-offset: 2px; }
#map:focus-visible { outline: 3px solid var(--yellow); outline-offset: -3px; }

.tile { display: flex; min-height: 64px; max-height: 38vh; overflow: auto; padding: 8px; text-align: center; border: 2px solid var(--navy); font-weight: bold; font-size: 14px; overflow-wrap: anywhere; margin: 6px 0; }
.tile .t { margin: auto; max-width: 100%; white-space: pre-wrap; }
.field { margin: 12px 0; }
.lbl { display: block; font-weight: bold; margin-bottom: 5px; }
.swatches { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.sw { width: 28px; height: 28px; border: 2px solid var(--navy); padding: 0; cursor: pointer; }
.sw[aria-pressed="true"] { outline: 3px solid var(--blue); outline-offset: 1px; }
.customsw { position: relative; display: inline-grid; place-items: center; min-width: 78px; height: 30px; padding: 0 10px; background: #fff; color: var(--navy); border: 2px solid var(--navy); font: 700 12px var(--sans); cursor: pointer; }
.customsw input { position: absolute; inset: 0; width: 100%; height: 100%; padding: 0; border: 0; opacity: 0; cursor: pointer; }
.customsw.on { outline: 3px solid var(--blue); outline-offset: 1px; }
.customsw:focus-within { outline: 3px solid var(--blue); outline-offset: 1px; }
input[type="text"], input[type="number"], textarea { width: 100%; padding: 9px 10px; border: 2px solid var(--navy); background: #fff; min-height: 42px; border-radius: 0; }
textarea { resize: vertical; min-height: 84px; line-height: 1.4; }
/* The message box IS the preview: it is drawn in the chosen colors, so you type straight onto your square. */
textarea.msgtile { min-height: 130px; max-height: 38vh; padding: 12px; text-align: center; font-weight: bold; font-size: 14px; caret-color: currentColor; overflow-wrap: anywhere; }
textarea.msgtile::placeholder { color: inherit; opacity: 0.55; font-weight: normal; }
.money { display: flex; align-items: center; gap: 6px; font-weight: bold; } .money input { max-width: 140px; font-family: var(--mono); }
.sum { margin: 8px 0 0; font: bold 16px var(--mono); }

.before { margin: 18px 0 10px; font-size: 13px; color: #3d4c78; }
.check { display: flex; gap: 8px; align-items: flex-start; font-weight: 400; cursor: pointer; margin-bottom: 12px; }
.check input { width: 20px; height: 20px; margin: 1px 0 0; flex: none; accent-color: var(--navy); }
.error { margin: 0 0 10px; padding: 8px 10px; background: #ffd9e6; border: 2px solid var(--navy); font-weight: bold; }
.pays { display: grid; gap: 8px; }
#checkout-form { min-height: 120px; }
#payNote { margin: 6px 0 0; }
@media (max-width: 759px) {
  /* dvh = the height you can actually see (phone browsers hide part of 100vh behind their address bar); the first line is the fallback */
  .panel.buying { max-height: calc(100vh - 150px); max-height: calc(100dvh - 24px - var(--safe-t) - var(--safe-b)); } body.buying #toolbar { display: none; }
  /* phone: the controls sit in a row along the bottom of the map and never move; an open box sits just above them */
  #toolbar { left: 10px; right: 10px; top: auto; bottom: 10px; transform: none; flex-direction: row; justify-content: center; }
  .panel:not(.buying) { bottom: calc(var(--below-stage, 40px) + 80px); max-height: calc(100vh - var(--stage-top, 130px) - var(--below-stage, 40px) - 98px); max-height: calc(100dvh - var(--stage-top, 130px) - var(--below-stage, 40px) - 98px); }
}

.backdrop { position: fixed; inset: 0; z-index: 10; display: grid; place-items: center; padding: 14px; background: rgba(10, 31, 92, 0.72); }
.modal { width: min(440px, 100%); max-height: 90vh; overflow: auto; background: var(--paper); border: 2px solid var(--navy); box-shadow: 6px 6px 0 var(--pink); padding: 20px; }
.modal h2 { margin: 0 0 10px; font: bold 22px/1.25 var(--mono); }
.modal p { margin: 0 0 10px; font-size: 14px; }
.modal .fine { font-size: 11px; }

#toast { position: fixed; z-index: 20; left: 50%; top: calc(var(--stage-top, 120px) + 12px); transform: translateX(-50%); max-width: calc(100vw - 24px); background: var(--yellow); color: var(--ink); border: 2px solid var(--navy); box-shadow: 3px 3px 0 var(--navy); padding: 8px 12px; font-weight: bold; }

.share { margin: 14px 0 12px; padding-top: 12px; border-top: 2px dotted var(--line); }
.sharehead { margin: 0 0 8px; font: bold 14px var(--mono); }
.sharegrid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.sharegrid .btn { display: grid; place-items: center; text-align: center; text-decoration: none; color: var(--ink); padding: 8px 10px; min-height: 42px; font-size: 13px; }
#shNative { grid-column: 1 / -1; width: 100%; font-size: 15px; }
.sharenote { grid-column: 1 / -1; margin: -2px 0 2px; }
.sharelink { margin: 12px 0 14px; word-break: break-all; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
.sub span { white-space: nowrap; }
.steps { margin: 10px 0; padding-left: 20px; } .steps li { margin: 7px 0; font-size: 14px; }
