/* Compact map controls beside the dice, with a touch-friendly popover. */
.island-header.tools-open { z-index: 35; }
.header-tools { position: relative; display: flex; flex: none; }
.header-actions #toolsToggle {
  position: relative;
  display: grid;
  place-items: center;
  width: 46px;
  min-width: 46px;
  height: 46px;
  min-height: 46px;
  padding: 0;
  border: 1px solid #bbd3bf;
  border-radius: 13px;
  background: #fffdf5;
  color: #087d68;
}
#toolsToggle svg { width: 23px; height: 23px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }
#toolsToggle svg circle { fill: #fffdf5; }
.header-actions #toolsToggle[aria-expanded="true"] { background: #e3f2e5; border-color: #6aab8f; }
.header-actions #toolsToggle:focus-visible,
#mapTools button:focus-visible { outline: 3px solid #e3ae31; outline-offset: 2px; }

#mapTools {
  position: absolute;
  top: calc(100% + 9px);
  right: 0;
  z-index: 2;
  width: 270px;
  padding: 10px;
  border: 1px solid #c4dac8;
  border-radius: 18px;
  background: #fffdf5;
  color: #285544;
  box-shadow: 0 14px 34px #153b3033;
}
#mapTools .tools-heading { position: static; display: flex; align-items: center; justify-content: space-between; padding: 0 2px 6px; background: none; }
#mapTools .tools-heading strong { font-size: 17px; }
.header-actions #mapTools #toolsClose {
  display: grid;
  place-items: center;
  width: 40px;
  min-width: 40px;
  height: 40px;
  min-height: 40px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: #e8f1e5;
  font-size: 19px;
}
#mapTools .drag-modes { display: flex; height: auto; min-height: 50px; margin: 0 0 6px; padding: 3px; background: #ebf2e8; }
.header-actions #mapTools .drag-modes button { flex: 1; min-height: 44px; padding: 6px; border: 0; background: transparent; box-shadow: none; font-size: 17px; }
.header-actions #mapTools .drag-modes button[aria-pressed="true"] { background: #d2ebd6; }
.header-actions #mapTools #motionToggle,
.header-actions #mapTools #helpShortcut {
  display: block;
  width: 100%;
  min-height: 44px;
  padding: 8px 12px;
  border: 1px solid #d4e3d1;
  border-radius: 11px;
  background: #f6f8f0;
  box-shadow: none;
  color: #285544;
  font-size: 16px;
  text-align: left;
}
#mapTools #motionToggle { margin-bottom: 6px; }
.header-actions #mapTools button:hover { background: #e6f1e6; }
.island-app[data-phase="night"] #mapTools { background: #1a3447; border-color: #718c92; color: #e8f5ef; }
.island-app[data-phase="night"] #mapTools .drag-modes,
.island-app[data-phase="night"] .header-actions #mapTools #motionToggle,
.island-app[data-phase="night"] .header-actions #mapTools #helpShortcut { background: #29495a; border-color: #607c83; color: #e8f5ef; }
.island-app[data-phase="night"] .header-actions #mapTools .drag-modes button { color: #e8f5ef; }
.island-app[data-phase="night"] .header-actions #mapTools .drag-modes button[aria-pressed="true"] { background: #406d6c; }
.island-app[data-phase="night"] .header-actions #mapTools button:hover:not([aria-pressed="true"]) { background: #365968; }

@media (max-width: 799px) {
  .header-actions #helpOpen { display: none; }
  .header-tools { position: static; }
  .header-actions #rollDice,
  .header-actions #toolsToggle,
  .header-actions #menuToggle {
    display: grid;
    place-items: center;
    flex: 0 0 44px;
    width: 44px;
    min-width: 44px;
    height: 44px;
    min-height: 44px;
    padding: 0;
    border-radius: 10px;
    line-height: 1;
  }
  #menuToggle svg { display: block; width: 23px; height: 23px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }
  #mapTools {
    position: absolute;
    top: calc(100% + 9px);
    right: 0;
    width: min(270px, calc(100vw - 24px));
    max-height: calc(100dvh - 156px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
    overflow: auto;
  }
}
