/* Game-screen layout editor (layout.js). */
.lay-panel { transform-origin: 0 0; }
.lay-moved { position: relative; }
.lay-sized { overflow: auto; }
.lay-rel { position: relative; }

#layoutToggle {
  position: fixed;
  left: max(12px, env(safe-area-inset-left));
  bottom: max(12px, env(safe-area-inset-bottom));
  z-index: 60;
  display: none;
  place-items: center;
  width: 48px;
  height: 48px;
  padding: 0;
  border: 1px solid var(--m-border, #0002) !important;
  border-radius: 14px !important;
  background: var(--m-panel, #fff) !important;
  color: var(--m-text, #1b1d2e) !important;
  box-shadow: var(--m-shadow, 0 8px 24px #0002) !important;
  font-size: 22px;
  transform: none !important;
}
body[data-game-scene] #layoutToggle { display: grid; }
#layoutToggle[aria-pressed="true"] {
  border-color: transparent !important;
  background: linear-gradient(180deg, var(--m-accent, #ff3d71), var(--m-accent-2, #ff2a55)) !important;
  color: #fff !important;
}
html.sidebar-docked body[data-game-scene] #layoutToggle { left: calc(var(--rail-w, 0px) + 12px); }

#layoutBar {
  position: fixed;
  left: 50%;
  bottom: max(12px, env(safe-area-inset-bottom));
  z-index: 59;
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: calc(100vw / var(--site-zoom, 1) - 140px);
  padding: 8px 8px 8px 14px;
  border: 1px solid var(--m-border, #0002);
  border-radius: 14px;
  background: var(--m-panel, #fff);
  color: var(--m-text, #1b1d2e);
  box-shadow: var(--m-shadow, 0 8px 24px #0002);
  font-size: 12px;
  font-weight: 600;
  transform: translateX(-50%);
}
#layoutBar[hidden] { display: none; }
#layoutBar span { color: var(--m-muted, #666); }
#layoutBar button {
  flex: none;
  min-height: 36px;
  padding: 6px 12px;
  border: 1px solid var(--m-border, #0002) !important;
  border-radius: 10px !important;
  background: var(--m-panel-2, #f6f7fc) !important;
  color: var(--m-text, #1b1d2e) !important;
  box-shadow: none !important;
  transform: none !important;
  font-size: 12px;
}
#layoutBar [data-bar="done"] { border: 0 !important; background: linear-gradient(180deg, var(--m-accent, #ff3d71), var(--m-accent-2, #ff2a55)) !important; color: #fff !important; }
@media (max-width: 700px) {
  #layoutBar { left: 72px; right: 12px; max-width: none; transform: none; flex-wrap: wrap; }
  #layoutBar span { flex: 1 0 100%; }
}

/* Editing: every panel gets a dashed outline, a grip, size buttons and a resize corner. */
html.lay-edit .lay-panel { outline: 2px dashed color-mix(in srgb, var(--m-accent, #ff3d71) 75%, transparent); outline-offset: 2px; }
html.lay-edit .lay-panel.lay-active { outline-style: solid; }
html.lay-edit .lay-panel .lay-panel { z-index: 40 !important; }
.lay-cover {
  position: absolute;
  inset: 0;
  z-index: 30;
  border-radius: inherit;
  background: color-mix(in srgb, var(--m-accent, #ff3d71) 7%, transparent);
  cursor: move;
  touch-action: auto;
}
@media (hover: none) { .lay-cover { cursor: default; } }
.lay-cover button {
  min-height: 0;
  margin: 0;
  border: 0 !important;
  box-shadow: 0 4px 12px #0003 !important;
  transform: none !important;
  font-weight: 800;
  line-height: 1;
}
.lay-grip {
  position: absolute;
  top: 6px;
  left: 50%;
  width: 52px;
  height: 34px;
  padding: 0 !important;
  border-radius: 10px !important;
  background: linear-gradient(180deg, var(--m-accent, #ff3d71), var(--m-accent-2, #ff2a55)) !important;
  color: #fff !important;
  font-size: 18px;
  cursor: grab;
  touch-action: none;
  translate: -50% 0;
}
.lay-active .lay-grip { cursor: grabbing; }
.lay-tools { position: absolute; top: 6px; left: 6px; display: flex; gap: 4px; }
.lay-tools button {
  width: 34px;
  height: 34px;
  padding: 0 !important;
  border-radius: 9px !important;
  background: var(--m-panel, #fff) !important;
  color: var(--m-text, #1b1d2e) !important;
  font-size: 12px;
}
.lay-resize {
  position: absolute;
  right: 0;
  bottom: 0;
  width: 40px;
  height: 40px;
  padding: 0 !important;
  border-radius: 0 !important;
  background: linear-gradient(135deg, transparent 50%, var(--m-accent, #ff3d71) 50%) !important;
  box-shadow: none !important;
  cursor: nwse-resize;
  touch-action: none;
}
.lay-size {
  position: absolute;
  right: 44px;
  bottom: 8px;
  padding: 2px 8px;
  border-radius: 6px;
  background: #000a;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  pointer-events: none;
}
.lay-size:empty { display: none; }

/* Panels without their own background get one once moved, so they stay readable on top of others. */
:is(.score-panel, .play-top, .room-toolbar, .game-controls-bar, .board-ledger, .hand-guide, .board-rules).lay-moved {
  padding: 10px 12px;
  border: 1px solid var(--m-border, #0002);
  border-radius: 14px;
  background: var(--m-panel, #fff);
  box-shadow: var(--m-shadow, 0 8px 24px #0002);
}
body[data-game-scene] { overflow-x: clip; }
