/* Custom controls (web/src/ui/components.ts), drawn the way the game draws
   its own: flat fills from the game's colour styles, a thick dark outline,
   and the web_button bevel (a darker L on the bottom and right). No browser
   default control is left visible. */

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 36px;
  padding: 6px 14px;
  border: 2px solid var(--outline);
  border-radius: var(--radius);
  background: var(--btn);
  color: var(--ink);
  cursor: pointer;
  font-size: 14px;
  box-shadow: var(--bevel);
  transition: background-color 0.1s;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.btn:hover:not(:disabled) {
  background: var(--btn-hover);
}
.btn:active:not(:disabled) {
  background: var(--btn-active);
  box-shadow: inset 2px 2px 0 rgba(0, 0, 0, 0.25);
}
.btn:disabled {
  cursor: default;
  background: var(--btn-disabled);
  color: rgba(255, 255, 255, 0.55);
}
.btn__icon {
  display: inline-flex;
}
.btn__icon svg {
  fill: currentColor;
}
.btn--small {
  min-height: 28px;
  padding: 2px 10px;
  font-size: 13px;
}
.btn--primary {
  background: var(--pink);
}
.btn--primary:hover:not(:disabled) {
  background: var(--pink-hi);
}
.btn--primary:active:not(:disabled) {
  background: var(--pink-active);
}
.btn--secondary[aria-pressed='true'] {
  background: var(--pink);
}
.btn--ghost {
  border-color: transparent;
  background: transparent;
  box-shadow: none;
  color: var(--ink-soft);
}
.btn--ghost:hover:not(:disabled) {
  border-color: var(--outline);
  background: var(--btn);
  color: var(--ink);
  box-shadow: var(--bevel);
}
.btn--danger {
  background: var(--bad);
}

/* Segmented rail (button_bold_toggle_selection: pink when selected) */
.segmented {
  --count: 2;
  --index: 0;
  position: relative;
  display: grid;
  grid-template-columns: repeat(var(--count), minmax(0, 1fr));
  padding: 3px;
  border: 2px solid var(--outline);
  border-radius: calc(var(--radius) + 3px);
  background: var(--panel-deep);
}
.segmented__thumb {
  position: absolute;
  top: 3px;
  bottom: 3px;
  left: 3px;
  width: calc((100% - 6px) / var(--count));
  transform: translateX(calc(100% * var(--index)));
  border-radius: var(--radius);
  background: var(--pink);
  box-shadow: var(--bevel), 0 0 0 2px var(--outline);
  transition: transform 0.2s cubic-bezier(0.3, 1.25, 0.5, 1);
}
.segmented__item {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 32px;
  padding: 4px 12px;
  border: 0;
  border-radius: var(--radius);
  background: none;
  color: var(--ink-soft);
  cursor: pointer;
  font-size: 14px;
  line-height: 1.15;
  min-width: 0;
  text-align: center;
  overflow-wrap: break-word;
  -webkit-tap-highlight-color: transparent;
}
.segmented__item:hover:not(.is-selected) {
  background: rgba(115, 122, 152, 0.35);
  color: var(--ink);
}
.segmented__item.is-selected {
  color: #fff;
}
.segmented__icon img {
  width: 22px;
  height: 22px;
  object-fit: contain;
}
.segmented--large .segmented__item {
  min-height: 44px;
  font-family: var(--font-display);
  font-size: 18px;
  letter-spacing: 0.02em;
  padding-top: 7px;
}
.segmented--so .segmented__thumb {
  background: #8a7a1a;
}

/* Stepper: - value + */
.stepper {
  display: inline-flex;
  align-items: stretch;
  border: 2px solid var(--outline);
  border-radius: var(--radius);
  background: var(--panel-deep);
}
.stepper__btn {
  display: grid;
  place-items: center;
  width: 28px;
  min-height: 28px;
  border: 0;
  background: var(--btn);
  box-shadow: var(--bevel);
  color: #fff;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.stepper__btn--minus {
  border-right: 2px solid var(--outline);
  border-radius: 2px 0 0 2px;
}
.stepper__btn--plus {
  border-left: 2px solid var(--outline);
  border-radius: 0 2px 2px 0;
}
.stepper__btn svg {
  fill: currentColor;
  width: 12px;
  height: 12px;
}
.stepper__btn:hover:not(:disabled) {
  background: var(--btn-hover);
}
.stepper__btn:active:not(:disabled) {
  background: var(--btn-active);
}
.stepper__btn:disabled {
  background: var(--btn-disabled);
  color: rgba(255, 255, 255, 0.4);
  cursor: default;
}
.stepper__value {
  display: grid;
  place-items: center;
  min-width: 38px;
  padding: 0 6px;
  font-size: 15px;
  font-weight: 700;
  color: var(--ink);
  cursor: default;
}
.stepper--compact .stepper__btn {
  width: 24px;
  min-height: 24px;
}
.stepper--compact .stepper__value {
  min-width: 28px;
  font-size: 13px;
}

/* Switch (role=switch) */
.switch {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 4px 0;
  border: 0;
  background: none;
  color: var(--ink-soft);
  cursor: pointer;
  text-align: left;
  font-size: 13.5px;
}
.switch__box {
  flex: none;
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border: 2px solid var(--outline);
  border-radius: 3px;
  background: var(--panel-deep);
  box-shadow: inset 1px 1px 0 rgba(0, 0, 0, 0.4);
}
.switch__box img {
  width: 16px;
  height: 16px;
  opacity: 0;
  transform: scale(0.6);
  transition: opacity 0.12s, transform 0.12s;
}
.switch[aria-checked='true'] .switch__box {
  background: var(--pink);
}
.switch[aria-checked='true'] .switch__box img {
  opacity: 1;
  transform: none;
}
.switch:hover {
  color: var(--ink);
}
.switch:hover .switch__box {
  background: var(--toggle-hover);
}
.switch[aria-checked='true']:hover .switch__box {
  background: var(--pink-hi);
}

/* Text field with a unit (InputFieldBackground) */
.field {
  display: grid;
  gap: 4px;
  min-width: 0;
}
.field__label {
  font-size: 12px;
  color: var(--ink-mute);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.field__box {
  display: flex;
  align-items: center;
  min-width: 0;
  border: 2px solid var(--outline);
  border-radius: var(--radius);
  background: #f4f4f2;
  color: var(--ink-dark);
  box-shadow: inset 2px 2px 0 rgba(0, 0, 0, 0.15);
}
.field__box:focus-within {
  border-color: var(--warn);
}
.field__input {
  flex: 1;
  width: 100%;
  min-width: 0;
  padding: 7px 10px;
  border: 0;
  background: none;
  color: var(--ink-dark);
  font: inherit;
  font-size: 16px;
  font-weight: 700;
  outline: none;
}
.field__unit {
  padding-right: 10px;
  color: #6b6b74;
  font-size: 13px;
}

/* Slider */
.slider {
  padding: 12px 11px;
  touch-action: none;
}
.slider__track {
  position: relative;
  height: 10px;
  border: 2px solid var(--outline);
  border-radius: 6px;
  background: var(--panel-deep);
  cursor: pointer;
}
.slider__ok {
  position: absolute;
  inset: 0 auto 0 0;
  width: calc(var(--ok) * 100%);
  border-radius: 4px;
  background: rgba(26, 186, 0, 0.35);
}
.slider__fill {
  position: absolute;
  inset: 0 auto 0 0;
  width: calc(var(--f) * 100%);
  border-radius: 4px;
  background: var(--pink);
}
.slider__mark {
  position: absolute;
  top: 50%;
  left: calc(var(--f) * 100%);
  width: 2px;
  height: 14px;
  transform: translate(-1px, -50%);
  background: rgba(255, 255, 255, 0.18);
}
.slider__thumb {
  position: absolute;
  top: 50%;
  left: calc(var(--f) * 100%);
  width: 22px;
  height: 22px;
  transform: translate(-50%, -50%);
  border: 2px solid var(--outline);
  border-radius: 50%;
  background: var(--btn-active);
  box-shadow: inset -2px -2px 0 rgba(0, 0, 0, 0.25);
  cursor: grab;
}
.slider__thumb:active {
  cursor: grabbing;
  background: #fff;
}

/* Dropdown (custom listbox) */
.dropdown {
  position: relative;
}
.dropdown__trigger {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-height: 36px;
  padding: 4px 10px;
  border: 2px solid var(--outline);
  border-radius: var(--radius);
  background: var(--btn);
  box-shadow: var(--bevel);
  color: var(--ink);
  cursor: pointer;
  text-align: left;
}
.dropdown__trigger:hover {
  background: var(--btn-hover);
}
.dropdown__value {
  flex: 1;
}
.dropdown__chevron svg {
  fill: var(--ink-soft);
  transition: transform 0.15s;
}
.dropdown.is-open .dropdown__chevron svg {
  transform: rotate(180deg);
}
.dropdown__icon img {
  width: 24px;
  height: 24px;
  object-fit: contain;
}
.dropdown__list {
  position: absolute;
  z-index: 30;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  max-height: 280px;
  margin: 0;
  padding: 3px;
  overflow-y: auto;
  list-style: none;
  border: 2px solid var(--outline);
  border-radius: var(--radius);
  background: var(--panel-raised);
  box-shadow: var(--shadow);
  outline: none;
  animation: pop 0.12s ease-out;
}
.dropdown__option {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 2px;
  cursor: pointer;
}
.dropdown__option.is-active {
  background: var(--btn-hover);
}
.dropdown__option.is-selected {
  background: var(--pink);
}
.dropdown__text {
  display: grid;
}
.dropdown__text small {
  color: var(--ink-mute);
}
@keyframes pop {
  from {
    opacity: 0;
    transform: translateY(-4px) scale(0.98);
  }
}

/* Dialog: a game window with the pink header */
.dialog {
  width: min(680px, calc(100vw - 32px));
  max-height: calc(100vh - 48px);
  padding: 0;
  border: 0;
  background: none;
  color: var(--ink);
}
.dialog::backdrop {
  background: rgba(8, 9, 14, 0.72);
}
.dialog[open] {
  animation: pop 0.16s ease-out;
}
.dialog__frame {
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 48px);
  border: 2px solid var(--outline);
  border-radius: var(--radius-lg);
  background: var(--panel);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.dialog__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px 8px 18px;
  border-bottom: 2px solid var(--outline);
  background: var(--pink-head);
}
.dialog__head h2 {
  font-family: var(--font-display);
  font-size: 21px;
  padding-top: 3px;
}
.dialog__close {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border: 2px solid var(--outline);
  border-radius: var(--radius);
  background: var(--pink);
  box-shadow: var(--bevel);
  color: #fff;
  cursor: pointer;
}
.dialog__close svg {
  fill: currentColor;
}
.dialog__close:hover {
  background: var(--pink-hi);
}
.dialog__body {
  display: grid;
  gap: 12px;
  padding: 18px 20px 22px;
  overflow-y: auto;
  color: var(--ink-soft);
}
.dialog__body h3 {
  margin-top: 6px;
  color: var(--ink);
  font-family: var(--font-display);
  font-size: 17px;
}
.dialog__actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 6px;
}
.copy-field {
  width: 100%;
  border: 2px solid var(--outline);
  border-radius: var(--radius);
  background: #f4f4f2;
  color: var(--ink-dark);
  font-size: 13px;
  font-weight: 400;
}

/* Tooltip (the game's light hover card) and toast */
.tooltip {
  position: fixed;
  z-index: 50;
  max-width: 300px;
  padding: 6px 10px;
  border: 2px solid var(--outline);
  border-radius: var(--radius);
  background: #f4f4f2;
  color: var(--ink-dark);
  font-size: 13px;
  line-height: 1.35;
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.35);
  pointer-events: none;
}
.toast {
  position: fixed;
  z-index: 60;
  right: 20px;
  bottom: 20px;
  padding: 9px 16px;
  border: 2px solid var(--outline);
  border-radius: var(--radius);
  background: var(--good);
  color: #fff;
  font-weight: 700;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.2s, transform 0.2s;
}
.toast.is-shown {
  opacity: 1;
  transform: none;
}

/* Game icons (white sprites) tinted with currentColor */
.gicon {
  display: inline-block;
  width: 18px;
  height: 18px;
  background-color: currentColor;
  -webkit-mask: var(--icon) center / contain no-repeat;
  mask: var(--icon) center / contain no-repeat;
  flex: none;
}
