/* Minimal overlay for 3D sandbox. Lobby + game view. */

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

.hidden {
  display: none !important;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: Oxanium, system-ui, -apple-system, sans-serif;
  background: #0f0a12;
}

/* --- Lobby --- */
#lobby {
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse 120% 80% at 50% 100%, rgba(255, 120, 160, 0.35) 0%, transparent 55%),
    linear-gradient(168deg, #1a0f22 0%, #3d1f38 42%, #8b3d52 72%, #e8a070 100%);
  color: #f4e8f0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.lobby-inner {
  max-width: 420px;
  width: 100%;
  text-align: center;
}

#lobby h1.brand-title {
  margin-bottom: 8px;
  font-family: Creepster, Oxanium, cursive;
  font-size: 2.35rem;
  font-weight: 400;
  letter-spacing: 0.02em;
  text-shadow: 0 0 28px rgba(255, 77, 158, 0.55), 0 2px 0 #1a0a14;
  line-height: 1.15;
}

.brand-after {
  display: block;
  font-size: 1.35rem;
  color: #ff9ecf;
  text-shadow: 0 0 18px rgba(255, 158, 207, 0.7);
}

.lobby-notice {
  font-size: 13px;
  padding: 14px 16px;
  margin-bottom: 20px;
  background: rgba(255, 200, 100, 0.2);
  border: 1px solid rgba(255, 180, 80, 0.5);
  border-radius: 8px;
  text-align: left;
  line-height: 1.5;
}

.lobby-notice code {
  font-family: ui-monospace, monospace;
  padding: 2px 6px;
  background: rgba(0, 0, 0, 0.25);
  border-radius: 4px;
}

.lobby-notice a {
  color: #a0d0ff;
}

.lobby-status {
  font-size: 14px;
  margin-bottom: 16px;
  min-height: 1.2em;
}

.lobby-status-error {
  color: #ffaa88;
  background: rgba(120, 60, 40, 0.25);
  padding: 10px 12px;
  border-radius: 6px;
  border: 1px solid rgba(200, 100, 80, 0.4);
}

.lobby-sub {
  font-size: 14px;
  opacity: 0.9;
  margin-bottom: 24px;
}

.room-list {
  background: rgba(0, 0, 0, 0.35);
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 16px;
  max-height: 280px;
  overflow-y: auto;
}

.room-list:empty::before {
  content: 'No rooms yet. Create one below.';
  display: block;
  font-size: 13px;
  opacity: 0.7;
  padding: 8px 0;
}

.room-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  margin-bottom: 6px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 6px;
  text-align: left;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background 0.15s, border-color 0.15s;
}

.room-row:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.2);
}

.room-row .room-name {
  font-weight: 600;
  font-size: 14px;
  margin-right: 8px;
  min-width: 0;
}

.room-row .room-id {
  font-family: ui-monospace, monospace;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.6);
  margin-right: auto;
}

.room-row .room-count {
  font-size: 13px;
  color: #ff9ecf;
}

.lobby-create {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 16px;
}

.room-name-input {
  flex: 1;
  min-width: 0;
  padding: 10px 14px;
  font: inherit;
  font-size: 14px;
  color: #e0e0e0;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 6px;
}

.room-name-input::placeholder {
  color: rgba(255, 255, 255, 0.45);
}

.btn {
  cursor: pointer;
  pointer-events: auto;
  font: inherit;
  padding: 10px 20px;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.3);
  background: rgba(255, 255, 255, 0.1);
  color: #e0e0e0;
  transition: background 0.15s, border-color 0.15s;
}

.btn:hover {
  background: rgba(255, 255, 255, 0.18);
  border-color: rgba(255, 255, 255, 0.45);
}

.btn-primary {
  background: rgba(180, 60, 120, 0.45);
  border-color: rgba(255, 120, 180, 0.75);
  color: #fff5f9;
}

.btn-primary:hover {
  background: rgba(220, 80, 140, 0.55);
  border-color: rgba(255, 180, 210, 0.95);
}

.btn-small {
  padding: 4px 10px;
  font-size: 12px;
}

.btn-quit {
  background: rgba(180, 80, 80, 0.25);
  border-color: rgba(180, 80, 80, 0.5);
}

.btn-quit:hover {
  background: rgba(180, 80, 80, 0.4);
}

.lobby-hint {
  font-size: 12px;
  opacity: 0.7;
  margin-top: 20px;
}

.lobby-hint code {
  font-family: ui-monospace, monospace;
  font-size: 11px;
  padding: 2px 6px;
  background: rgba(0, 0, 0, 0.3);
  border-radius: 4px;
}

/* --- Game view --- */
#game-view {
  position: fixed;
  inset: 0;
}

#game-view #canvas-wrap {
  position: absolute;
  inset: 0;
}

#canvas {
  display: block;
  width: 100%;
  height: 100%;
}

#crosshair {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 2px;
  height: 14px;
  margin: -7px 0 0 -1px;
  background: rgba(255, 180, 220, 0.95);
  pointer-events: none;
  box-shadow: 0 0 6px rgba(255, 77, 158, 0.6);
}

#crosshair::before {
  content: '';
  position: absolute;
  left: 50%;
  top: 50%;
  width: 14px;
  height: 2px;
  margin: -1px 0 0 -7px;
  background: rgba(255, 180, 220, 0.95);
  box-shadow: 0 0 6px rgba(255, 77, 158, 0.6);
}

.crash-flash {
  position: absolute;
  inset: 0;
  background: #ffb8e0;
  pointer-events: none;
  opacity: 0;
  transition: none;
}

#ui {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 12px 16px;
  background: linear-gradient(transparent, rgba(12, 4, 18, 0.88));
  color: #f0e4ee;
  font-size: 13px;
  pointer-events: none;
}

#ui .btn {
  pointer-events: auto;
}

.chat-panel {
  position: absolute;
  top: 12px;
  left: 12px;
  width: 280px;
  max-height: 220px;
  display: flex;
  flex-direction: column;
  background: rgba(0, 0, 0, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 8px;
  pointer-events: auto;
}

.chat-panel.hidden {
  display: none !important;
}

.chat-messages {
  flex: 1;
  min-height: 60px;
  max-height: 160px;
  overflow-y: auto;
  padding: 8px 10px;
  font-size: 13px;
  line-height: 1.4;
  color: #e0e0e0;
}

.chat-messages .chat-msg {
  margin-bottom: 4px;
  word-break: break-word;
}

.chat-messages .chat-msg .chat-nick {
  font-weight: 600;
  margin-right: 6px;
}

.chat-input-wrap {
  display: flex;
  gap: 8px;
  padding: 8px 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.15);
}

.chat-input {
  flex: 1;
  padding: 8px 12px;
  font: inherit;
  font-size: 13px;
  color: #e0e0e0;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 6px;
}

.chat-input::placeholder {
  color: rgba(255, 255, 255, 0.5);
}

.players-panel {
  position: absolute;
  top: 12px;
  right: 12px;
  max-width: 240px;
  padding: 8px 12px;
  background: rgba(0, 0, 0, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 8px;
  font-size: 12px;
  opacity: 0.95;
  pointer-events: none;
}

.players-panel-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  opacity: 0.65;
  margin-bottom: 4px;
}

.players-list {
  font-size: 12px;
  opacity: 0.9;
}

#top-row {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 6px;
  flex-wrap: wrap;
}

#room-display {
  font-weight: 600;
}

.player-color-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  pointer-events: auto;
}

.player-color-keys {
  display: flex;
  gap: 3px;
}

.player-color-keys span {
  display: inline-block;
  width: 18px;
  height: 18px;
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 3px;
  cursor: pointer;
}

.player-color-keys span.active {
  border-color: rgba(255, 180, 220, 0.98);
  box-shadow: 0 0 0 2px rgba(255, 77, 158, 0.55);
}

.my-name-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  pointer-events: auto;
}

.my-name-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  opacity: 0.75;
  white-space: nowrap;
}

#my-name-input {
  width: min(160px, 28vw);
  padding: 4px 8px;
  font-size: 13px;
  color: #fff;
  background: rgba(0, 0, 0, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 6px;
  outline: none;
}

#my-name-input:focus {
  border-color: rgba(255, 120, 180, 0.9);
  box-shadow: 0 0 0 2px rgba(255, 77, 158, 0.28);
}

#players-display {
  color: #ff9ecf;
}

#status {
  margin-left: auto;
}

#status.connected {
  color: #e8b8dc;
}

#status.error {
  color: #e08080;
}

.block-keys {
  display: flex;
  gap: 4px;
  margin-bottom: 6px;
  font-size: 12px;
}

.block-keys span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border: 1px solid rgba(255, 180, 210, 0.4);
  border-radius: 3px;
  color: #fff5fa;
  font-weight: 600;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.85);
}

.block-keys span.active {
  border-color: rgba(255, 158, 210, 0.98);
  box-shadow: 0 0 0 2px rgba(255, 77, 158, 0.45);
}

#controls-hint {
  font-size: 11px;
  opacity: 0.85;
}

#controls-hint .kbd-key {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-width: 1.85em;
  padding: 2px 6px 3px;
  margin: 0 1px;
  vertical-align: middle;
  font-family: ui-monospace, monospace;
  font-size: 10px;
  line-height: 1.05;
  color: #f0f4ff;
  background: linear-gradient(180deg, #4a5568 0%, #2d3748 100%);
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 4px;
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.45);
}

#controls-hint .kbd-key-main {
  font-size: 13px;
  font-weight: 700;
}

#controls-hint .kbd-key-sub {
  font-size: 9px;
  opacity: 0.85;
}

.copied-texture-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
  font-size: 11px;
  color: rgba(255, 255, 255, 0.85);
}
.copied-label {
  flex-shrink: 0;
}
.copied-empty {
  color: rgba(255, 255, 255, 0.5);
  font-style: italic;
}
.copied-texture-preview {
  width: 32px;
  height: 32px;
  object-fit: contain;
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 3px;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}
.copied-texture-preview.hidden {
  display: none;
}

.mode-toggles {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 14px;
  margin-bottom: 4px;
}
.mode-toggles .break-mode {
  margin-bottom: 0;
}
#fly-mode-btn.fly-mode-toggle {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.85);
  background: rgba(0, 0, 0, 0.28);
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 4px;
  padding: 2px 10px;
  cursor: pointer;
  font-family: inherit;
}
#fly-mode-btn.fly-mode-toggle:hover {
  border-color: rgba(255, 255, 255, 0.45);
}
#fly-mode-btn.fly-mode-toggle.active {
  color: #ffe0f5;
  border-color: rgba(255, 120, 180, 0.65);
  box-shadow: 0 0 10px rgba(255, 77, 158, 0.25);
}

.break-mode {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.8);
  margin-bottom: 4px;
  cursor: default;
}

/* Draw-on-surface modal */
.draw-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  pointer-events: auto;
}

.draw-modal-inner {
  background: linear-gradient(145deg, #1a101c 0%, #2d1828 100%);
  padding: 16px;
  border-radius: 10px;
  border: 1px solid rgba(255, 120, 180, 0.45);
  box-shadow: 0 0 32px rgba(255, 77, 158, 0.12), inset 0 1px 0 rgba(255, 255, 255, 0.06);
  text-align: center;
}

.poststamp-modal-inner {
  width: min(1120px, calc(100vw - 24px));
  height: min(86vh, 860px);
  display: flex;
  flex-direction: column;
  text-align: left;
}

.poststamp-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.poststamp-help {
  font-size: 12px;
  opacity: 0.88;
}

.poststamp-iframe {
  width: 100%;
  flex: 1;
  min-height: 0;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 8px;
  background: #111827;
}

.draw-title {
  font-size: 13px;
  margin-bottom: 10px;
  color: #ffd6ec;
  letter-spacing: 0.02em;
}

.rate-panel,
.rate-hud {
  margin-top: 4px;
  font-size: 11px;
  opacity: 0.7;
}

#draw-canvas {
  display: block;
  width: 128px;
  height: 128px;
  margin: 0 auto 10px;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  /* Checkerboard shows through transparent pixels (block-paint mode); opaque face fills still look fine. */
  background-color: #2a1828;
  background-image:
    linear-gradient(45deg, #3d2440 25%, transparent 25%),
    linear-gradient(-45deg, #3d2440 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #3d2440 75%),
    linear-gradient(-45deg, transparent 75%, #3d2440 75%);
  background-size: 10px 10px;
  background-position: 0 0, 0 5px, 5px -5px, -5px 0;
  border: 2px solid rgba(255, 120, 180, 0.45);
  border-radius: 4px;
  cursor: crosshair;
}

.draw-colors {
  display: flex;
  gap: 6px;
  justify-content: center;
  margin-bottom: 12px;
}

.draw-swatch {
  width: 24px;
  height: 24px;
  border: 2px solid rgba(255, 255, 255, 0.4);
  border-radius: 4px;
  cursor: pointer;
  padding: 0;
}

.draw-swatch.active {
  border-color: #ff9ecf;
  box-shadow: 0 0 0 2px rgba(255, 77, 158, 0.65), 0 0 12px rgba(255, 77, 158, 0.35);
}

.draw-actions {
  display: flex;
  gap: 8px;
  justify-content: center;
}

.draw-actions .btn.active {
  border-color: rgba(255, 255, 255, 0.9);
  background: rgba(255, 255, 255, 0.2);
}

/* Place sign modal */
.sign-label {
  display: block;
  text-align: left;
  font-size: 12px;
  color: #b0b0b0;
  margin: 10px 0 4px;
}
.sign-label:first-of-type {
  margin-top: 0;
}
.sign-input {
  width: 100%;
  max-width: 280px;
  padding: 8px 10px;
  font-size: 14px;
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 6px;
  background: #1a1a1a;
  color: #e0e0e0;
  box-sizing: border-box;
}
.sign-textarea {
  width: 100%;
  max-width: 280px;
  min-height: 100px;
  padding: 8px 10px;
  font-size: 14px;
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 6px;
  background: #1a1a1a;
  color: #e0e0e0;
  resize: vertical;
  box-sizing: border-box;
}

/* Read sign modal */
.read-sign-inner {
  max-width: 360px;
  text-align: left;
}
.read-sign-message {
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 14px;
  line-height: 1.5;
  color: #e0e0e0;
  max-height: 60vh;
  overflow-y: auto;
  margin-bottom: 12px;
  padding: 8px 0;
}
