/* Farleyworld — PS1-lounge chrome */

* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --ui-blue-a: #10102e;
  --ui-blue-b: #060618;
  --ui-border: #c8c8dc;
  --ui-text: #f0f0e8;
}

html, body {
  height: 100%;
  background: #05050a;
  color: var(--ui-text);
  font-family: "Lucida Console", Monaco, monospace;
  overflow: hidden;
}

/* ---------- Title screen ---------- */

.title-screen {
  height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.2rem;
  background:
    radial-gradient(ellipse at 50% 120%, #1c1436 0%, #05050a 70%);
}

.game-title {
  font-size: clamp(2rem, 7vw, 4.5rem);
  letter-spacing: 0.35em;
  text-shadow: 0 0 18px #7a5cff88, 3px 3px 0 #000;
}

.game-subtitle {
  color: #9a92c8;
  letter-spacing: 0.5em;
  margin-bottom: 2rem;
}

.enter-form { display: flex; gap: 0.6rem; }

.name-input {
  background: var(--ui-blue-b);
  border: 2px solid var(--ui-border);
  border-radius: 6px;
  color: var(--ui-text);
  font: inherit;
  font-size: 1.1rem;
  padding: 0.6rem 1rem;
  outline: none;
  width: 16ch;
}

.name-input:focus { border-color: #fff; box-shadow: 0 0 12px #7a5cff66; }

.enter-button {
  background: linear-gradient(#3a3a7a, #191940);
  border: 2px solid var(--ui-border);
  border-radius: 6px;
  color: var(--ui-text);
  font: inherit;
  font-size: 1.1rem;
  padding: 0.6rem 1.4rem;
  cursor: pointer;
}

.enter-button:hover { filter: brightness(1.35); }

.flash-alert { color: #ff8a8a; }

.title-hint { color: #6a648f; font-size: 0.85rem; margin-top: 2rem; }

/* ---------- Game screen ---------- */

#game {
  position: fixed;
  inset: 0;
  touch-action: none; /* no scroll/pinch while playing */
}

#game-canvas {
  width: 100%;
  height: 100%;
  display: block;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

.hidden { display: none !important; }

#hud {
  position: absolute;
  top: 12px; left: 12px; right: 12px;
  display: flex;
  gap: 10px;
  align-items: center;
  pointer-events: none;
}

.hud-panel, #hud-leave {
  background: linear-gradient(var(--ui-blue-a), var(--ui-blue-b));
  border: 2px solid var(--ui-border);
  border-radius: 6px;
  padding: 6px 14px;
  font-size: 0.9rem;
  box-shadow: 2px 2px 0 #00000088;
}

#hud-online { margin-left: auto; color: #b8e6b8; }

#hud-leave-form { pointer-events: auto; }

#hud-leave { color: var(--ui-text); font: inherit; font-size: 0.8rem; cursor: pointer; }
#hud-leave:hover { filter: brightness(1.4); }

#prompt {
  position: absolute;
  bottom: 130px; left: 50%;
  transform: translateX(-50%);
  background: linear-gradient(var(--ui-blue-a), var(--ui-blue-b));
  border: 2px solid var(--ui-border);
  border-radius: 6px;
  padding: 5px 16px;
  font-size: 0.9rem;
  color: #ffe9a8;
  box-shadow: 2px 2px 0 #00000088;
  animation: prompt-bob 0.9s ease-in-out infinite alternate;
}

@keyframes prompt-bob { from { margin-bottom: 0; } to { margin-bottom: 6px; } }

#dialog {
  position: absolute;
  left: 50%; bottom: 24px;
  transform: translateX(-50%);
  width: min(680px, 92vw);
  background: linear-gradient(#2a2a68f2, #0a0a24f2);
  border: 3px solid var(--ui-border);
  border-radius: 8px;
  padding: 14px 20px 18px;
  box-shadow: 3px 3px 0 #000000aa, inset 0 0 30px #00000055;
}

#dialog-title { color: #a8d8ff; font-size: 0.8rem; margin-bottom: 6px; letter-spacing: 0.1em; }
#dialog-text { line-height: 1.5; font-size: 1rem; min-height: 3em; white-space: pre-wrap; }
#dialog-more {
  position: absolute; right: 14px; bottom: 6px;
  color: #ffe9a8; font-size: 0.8rem;
  animation: prompt-bob 0.6s ease-in-out infinite alternate;
}

/* ---------- Note board ---------- */

#noteboard {
  position: absolute;
  left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  width: min(460px, 92vw);
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  background: linear-gradient(#2a2a68f2, #0a0a24f2);
  border: 3px solid var(--ui-border);
  border-radius: 8px;
  box-shadow: 3px 3px 0 #000000aa, inset 0 0 30px #00000055;
  pointer-events: auto;
  z-index: 6;
}

#noteboard-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-bottom: 2px solid #ffffff22;
}

#noteboard-title { color: #a8d8ff; letter-spacing: 0.1em; font-size: 0.9rem; }

#noteboard-close {
  background: none; border: none;
  color: #ffe9a8; font: inherit; font-size: 1.1rem;
  line-height: 1; cursor: pointer;
}
#noteboard-close:hover { filter: brightness(1.4); }

#noteboard-sub {
  padding: 8px 14px 0;
  color: #9a92c8; font-size: 0.78rem; line-height: 1.4;
  white-space: pre-wrap;
}

#noteboard-notes {
  flex: 1;
  overflow-y: auto;
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 60px;
}

.note-item {
  background: #00000055;
  border-left: 3px solid #d0b060;
  border-radius: 3px;
  padding: 6px 10px;
}
.note-body { font-size: 0.9rem; line-height: 1.4; white-space: pre-wrap; word-break: break-word; }
.note-meta { color: #8a84b0; font-size: 0.72rem; margin-top: 3px; }
.note-empty { color: #6a648f; font-size: 0.82rem; text-align: center; padding: 12px 0; }

#noteboard-form {
  display: flex;
  gap: 8px;
  padding: 10px 14px;
  border-top: 2px solid #ffffff22;
}

#noteboard-input {
  flex: 1;
  background: var(--ui-blue-b);
  border: 2px solid var(--ui-border);
  border-radius: 6px;
  color: var(--ui-text);
  font: inherit; font-size: 0.85rem;
  padding: 6px 10px;
  outline: none;
}
#noteboard-input:focus { border-color: #fff; box-shadow: 0 0 10px #7a5cff55; }

#noteboard-post {
  background: linear-gradient(#3a3a7a, #191940);
  border: 2px solid var(--ui-border);
  border-radius: 6px;
  color: var(--ui-text);
  font: inherit; font-size: 0.85rem;
  padding: 6px 14px;
  cursor: pointer;
}
#noteboard-post:hover { filter: brightness(1.35); }

/* ---------- Graffiti wall editor ---------- */

#graffiti {
  position: absolute;
  left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  width: min(560px, 94vw);
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  background: linear-gradient(#2a2a68f2, #0a0a24f2);
  border: 3px solid var(--ui-border);
  border-radius: 8px;
  box-shadow: 3px 3px 0 #000000aa, inset 0 0 30px #00000055;
  pointer-events: auto;
  z-index: 20; /* above the touch pad so strokes aren't stolen on phones */
}

#graffiti-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-bottom: 2px solid #ffffff22;
}
#graffiti-title { color: #a8d8ff; letter-spacing: 0.1em; font-size: 0.9rem; }
#graffiti-close {
  background: none; border: none;
  color: #ffe9a8; font: inherit; font-size: 1.1rem;
  line-height: 1; cursor: pointer;
}
#graffiti-close:hover { filter: brightness(1.4); }

#graffiti-sub {
  padding: 8px 14px 0;
  color: #9a92c8; font-size: 0.78rem; line-height: 1.4;
  white-space: pre-wrap;
}

#graffiti-stage { padding: 10px 14px; }

/* The concrete under-render — CSS only, never part of the exported PNG, so the
   drawing stays transparent where the artist didn't paint. */
#graffiti-canvas {
  display: block;
  width: 100%;
  aspect-ratio: 512 / 320;
  border: 2px solid var(--ui-border);
  border-radius: 4px;
  cursor: crosshair;
  touch-action: none; /* draw instead of scroll/zoom */
  background:
    repeating-linear-gradient(90deg, #00000010 0 2px, transparent 2px 40px),
    repeating-linear-gradient(0deg, #00000010 0 2px, transparent 2px 40px),
    linear-gradient(#7d7a74, #66635d);
  box-shadow: inset 0 0 24px #00000055;
}

#graffiti-tools {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 4px 14px 10px;
}
#graffiti-colors, #graffiti-sizes { display: flex; gap: 5px; }

.g-swatch {
  width: 22px; height: 22px;
  border: 2px solid #ffffff33;
  border-radius: 4px;
  padding: 0; cursor: pointer;
}
.g-swatch.active { border-color: #fff; box-shadow: 0 0 8px #ffffffaa; }
.g-eraser {
  background: #1a1a2e;
  color: #cfc8f0; font: inherit; font-size: 0.85rem; line-height: 1;
}

.g-size {
  min-width: 26px; height: 22px;
  background: var(--ui-blue-b);
  border: 2px solid #ffffff33;
  border-radius: 4px;
  color: var(--ui-text); font: inherit; font-size: 0.7rem;
  cursor: pointer;
}
.g-size.active { border-color: #fff; box-shadow: 0 0 8px #7a5cff88; }

#graffiti-clear {
  margin-left: auto;
  background: linear-gradient(#5a2a3a, #2a1420);
  border: 2px solid var(--ui-border);
  border-radius: 6px;
  color: var(--ui-text); font: inherit; font-size: 0.78rem;
  padding: 5px 12px; cursor: pointer;
}
#graffiti-clear:hover { filter: brightness(1.3); }

#graffiti-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  padding: 10px 14px;
  border-top: 2px solid #ffffff22;
}
#graffiti-cancel, #graffiti-submit {
  border: 2px solid var(--ui-border);
  border-radius: 6px;
  color: var(--ui-text); font: inherit; font-size: 0.85rem;
  padding: 6px 16px; cursor: pointer;
}
#graffiti-cancel { background: var(--ui-blue-b); }
#graffiti-submit { background: linear-gradient(#3a3a7a, #191940); }
#graffiti-cancel:hover, #graffiti-submit:hover { filter: brightness(1.35); }

#notices {
  position: absolute;
  left: 14px; bottom: 60px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  pointer-events: none;
}

.notice {
  background: #00000099;
  border-left: 3px solid #8878d8;
  padding: 3px 10px;
  font-size: 0.8rem;
  color: #cfc8f0;
  transition: opacity 0.8s;
}

#controls-hint {
  position: absolute;
  right: 14px; bottom: 12px;
  color: #ffffff55;
  font-size: 0.72rem;
  letter-spacing: 0.05em;
  pointer-events: none;
}

#fade {
  position: absolute; inset: 0;
  background: #000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.35s ease;
}

#fade.active { opacity: 1; pointer-events: auto; }

/* ---------- Touch controls (mobile) ---------- */

#game.touch-enabled #controls-hint { display: none; }

#touch-controls {
  position: absolute;
  inset: 0;
  pointer-events: none; /* only the pad and button take touches */
}

#touch-pad {
  position: absolute;
  left: max(18px, env(safe-area-inset-left));
  bottom: max(18px, env(safe-area-inset-bottom));
  width: 132px;
  height: 132px;
  border-radius: 50%;
  border: 2px solid #c8c8dc66;
  background: radial-gradient(circle at 50% 40%, #10102ecc, #060618cc);
  box-shadow: 2px 2px 0 #00000066;
  pointer-events: auto;
  touch-action: none;
  display: flex;
  align-items: center;
  justify-content: center;
}

#touch-nub {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: 2px solid var(--ui-border);
  background: linear-gradient(#3a3a7a, #191940);
  box-shadow: 0 0 10px #7a5cff44;
  pointer-events: none;
}

#touch-action {
  position: absolute;
  right: max(22px, env(safe-area-inset-right));
  bottom: max(40px, calc(env(safe-area-inset-bottom) + 22px));
  width: 76px;
  height: 76px;
  border-radius: 50%;
  border: 2px solid var(--ui-border);
  background: radial-gradient(circle at 50% 35%, #3a3a7acc, #10102ecc);
  color: #ffe9a8;
  font: inherit;
  font-size: 1.7rem;
  box-shadow: 2px 2px 0 #00000088;
  pointer-events: auto;
  touch-action: none;
  cursor: pointer;
}

#touch-action:active {
  filter: brightness(1.5);
  transform: scale(0.94);
}

#touch-message {
  position: absolute;
  right: max(30px, calc(env(safe-area-inset-right) + 8px));
  bottom: max(126px, calc(env(safe-area-inset-bottom) + 108px));
  width: 60px;
  height: 60px;
  border-radius: 50%;
  border: 2px solid var(--ui-border);
  background: radial-gradient(circle at 50% 35%, #7a5a1acc, #2a1c08cc);
  color: #ffcf8a;
  font: inherit;
  font-size: 1.4rem;
  box-shadow: 2px 2px 0 #00000088;
  pointer-events: auto;
  touch-action: none;
  cursor: pointer;
}
#touch-message:active {
  filter: brightness(1.5);
  transform: scale(0.94);
}

/* ---- Soapstone composer ---- */
#soapstone {
  position: absolute;
  left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  width: min(420px, 92vw);
  display: flex;
  flex-direction: column;
  background: linear-gradient(#3a2a10f2, #1a1204f2);
  border: 3px solid var(--ui-border);
  border-radius: 8px;
  box-shadow: 3px 3px 0 #000000aa, inset 0 0 30px #00000055;
  pointer-events: auto;
  z-index: 6;
}

#soapstone-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-bottom: 2px solid #ffffff22;
}

#soapstone-title { color: #ffcf8a; letter-spacing: 0.1em; font-size: 0.9rem; }

#soapstone-close {
  background: none; border: none;
  color: #ffe9a8; font: inherit; font-size: 1.1rem;
  line-height: 1; cursor: pointer;
}
#soapstone-close:hover { filter: brightness(1.4); }

#soapstone-sub {
  padding: 8px 14px 0;
  color: #b6a074; font-size: 0.78rem; line-height: 1.4;
}

#soapstone-glyphs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 12px 14px 4px;
}

.s-glyph {
  width: 38px; height: 38px;
  background: #00000055;
  border: 2px solid var(--ui-border);
  border-radius: 6px;
  color: #ffcf8a;
  font-size: 1.15rem; line-height: 1;
  cursor: pointer;
}
.s-glyph:hover { filter: brightness(1.3); }
.s-glyph.active {
  border-color: #ffcf7a;
  background: #ff9d3a22;
  box-shadow: 0 0 10px #ff9d3a88;
}

#soapstone-form {
  display: flex;
  gap: 8px;
  padding: 10px 14px;
  border-top: 2px solid #ffffff22;
}

#soapstone-input {
  flex: 1;
  background: var(--ui-blue-b);
  border: 2px solid var(--ui-border);
  border-radius: 6px;
  color: var(--ui-text);
  font: inherit; font-size: 0.85rem;
  padding: 6px 10px;
  outline: none;
}
#soapstone-input:focus { border-color: #ffcf7a; box-shadow: 0 0 10px #ff9d3a55; }

#soapstone-place {
  background: linear-gradient(#7a5a1a, #402a08);
  border: 2px solid var(--ui-border);
  border-radius: 6px;
  color: var(--ui-text);
  font: inherit; font-size: 0.85rem;
  padding: 6px 14px;
  cursor: pointer;
}
#soapstone-place:hover { filter: brightness(1.35); }

/* keep the dialog clear of thumbs on small screens */
@media (max-width: 700px) {
  #dialog { bottom: 120px; width: 94vw; }
  #prompt { bottom: 220px; }
  #noteboard { top: 42%; max-height: 62vh; width: 94vw; }
  #graffiti { top: 44%; width: 96vw; }
  #soapstone { top: 40%; width: 94vw; }
}
