* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
}

#map {
  width: 100%;
  height: 100%;
  background-color: var(--map-background);
}

/* ============================================
   Minecraft-inspired UI Theme
   ============================================ */

/* Track styles with subtle glow effect */
.track.occupied {
  stroke: var(--track-occupied);
}
.track.reserved {
  stroke: var(--track-reserved);
  filter: drop-shadow(0 0 2px var(--track-reserved));
}
.track {
  stroke: var(--track-free);
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Tooltip styles - Minecraft inventory style */
.train-name,
.station-name {
  font-family: var(--ui-font);
  font-weight: bold;
  font-size: 14px;
  background: #100010 !important;
  border: 2px solid #25015b !important;
  border-radius: 0 !important;
  color: #fff !important;
  box-shadow: inset 0 0 0 1px #2d0070, 0 2px 8px rgba(0, 0, 0, 0.6) !important;
  padding: 6px 10px !important;
}
.station-name .track-number,
.train-name .car-number {
  display: inline-block;
  width: 1.5em;
  text-align: center;
  border-radius: 0;
  background-color: #5a4d7a;
  color: #fff;
  margin-left: 4px;
  font-size: 12px;
  padding: 1px 2px;
}

/* Icon styles */
.station-icon .fill {
  fill: var(--station-color);
}
.station-icon .outline {
  fill: var(--station-outline);
}

.portal-icon .fill {
  fill: var(--portal-color);
}
.portal-icon .outline {
  fill: var(--portal-outline);
}

.signal-icon.green .light {
  fill: var(--signal-green);
}
.signal-icon.yellow .light {
  fill: var(--signal-yellow);
}
.signal-icon.red .light {
  fill: var(--signal-red);
}
.signal-icon .frame {
  fill: var(--signal-outline);
}

/* Train car styling with outline effect */
.train {
  stroke: var(--train-color);
  stroke-linecap: round;
  stroke-linejoin: round;
  filter: drop-shadow(0 0 1px rgba(0, 0, 0, 0.8));
}
.train.lead-car {
  stroke: var(--lead-car-color);
}

/* Train car outline layer */
.train-outline {
  stroke: #1a1a1a;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Locomotive head icon */
.head-icon .outline {
  fill: #1a1a1a;
}
.head-icon .fill {
  fill: var(--lead-car-color);
}
.head-icon .arrow {
  fill: var(--lead-car-color);
}
.head-icon .window {
  fill: #1a1a1a;
}
.head-icon .light-top {
  fill: #fef08a;
}

/* ============================================
   Coordinates Display - Minecraft HUD style
   ============================================ */
.coords-control {
  font-family: var(--ui-font);
  font-size: 14px;
  font-weight: 500;
  background: #100010;
  border: 2px solid #1a1a2e;
  border-top-color: #3d3d5c;
  border-left-color: #3d3d5c;
  border-radius: 0;
  padding: 6px 10px;
  color: #e0e0e0;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
}

.coords-input {
  display: flex;
  gap: 4px;
  margin-bottom: 6px;
  align-items: center;
}

.coords-input input {
  font-family: var(--ui-font);
  font-size: 13px;
  background: #2a2a2a;
  border: 1px solid #1a1a1a;
  border-top-color: #4a4a4a;
  border-left-color: #4a4a4a;
  border-radius: 0;
  padding: 3px 5px;
  color: #e0e0e0;
  outline: none;
}

.coords-input input:focus {
  background: #3a3a3a;
  border-color: #5a5a5a;
}

.coords-go-button {
  font-family: var(--ui-font);
  font-size: 13px;
  font-weight: bold;
  background: #3d3d3d;
  border: 2px solid #1a1a1a;
  border-top-color: #5a5a5a;
  border-left-color: #5a5a5a;
  border-radius: 0;
  padding: 3px 10px;
  color: #e0e0e0;
  cursor: pointer;
  transition: background-color 0.1s;
}

.coords-go-button:hover {
  background: #4a4a4a;
}

.coords-go-button:active {
  background: #2a2a2a;
  border-top-color: #1a1a1a;
  border-left-color: #1a1a1a;
  border-bottom-color: #5a5a5a;
  border-right-color: #5a5a5a;
}

.coords-control .icon {
  display: inline-block;
  width: 14px;
  height: 14px;
  line-height: 20px;
  margin-right: 6px;
  transform: translate(1px, 2px);
  filter: brightness(0.9);
}

.coords-control .center-x,
.coords-control .center-z,
.coords-control .cursor-x,
.coords-control .cursor-z {
  display: inline-block;
  padding: 0 4px;
  color: #aaa;
}

/* ============================================
   Control Panels - Minecraft inventory style
   ============================================ */
.leaflet-control-ctm:not(.leaflet-control-expanded) .leaflet-control-body,
.leaflet-control-layers:not(.leaflet-control-layers-expanded) .leaflet-control-layers-list {
  display: none;
}

.leaflet-control-toggle,
.leaflet-control-layers-toggle {
  display: block;
  width: 40px;
  height: 40px;
  background-position: 50% 50%;
  background-size: 28px 28px;
  background-color: #3d3d3d;
  border: 2px solid #1a1a1a;
  border-top-color: #5a5a5a;
  border-left-color: #5a5a5a;
  transition: background-color 0.1s;
}

.leaflet-control-toggle:hover,
.leaflet-control-layers-toggle:hover {
  background-color: #4a4a4a;
}

.leaflet-control-ctm {
  margin-top: 8px;
  background: #2a2a2a;
  border: 2px solid #1a1a1a;
  border-top-color: #4a4a4a;
  border-left-color: #4a4a4a;
  border-radius: 0;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
}

.leaflet-control-expanded,
.leaflet-control-layers-expanded {
  padding: 8px;
}

.leaflet-control-layers-separator {
  margin: 8px 0;
  border: none;
  height: 2px;
  background: linear-gradient(to right, transparent, #4a4a4a, transparent);
}

.leaflet-control-layers-toggle {
  background-image: url(../icons/layers.svg);
}

.leaflet-control-ctm label,
.leaflet-control-layers label {
  font-family: var(--ui-font);
  font-size: 13px;
  color: #e0e0e0;
}

.leaflet-control-layers input[type="radio"],
.leaflet-control-layers input[type="checkbox"] {
  display: none;
}

.leaflet-control-layers input[type="radio"] + span,
.leaflet-control-layers input[type="checkbox"] + span {
  display: inline-block;
  width: 100%;
  border-radius: 0;
  padding: 4px 8px;
  margin-top: 2px;
  background: #3a3a3a;
  border: 1px solid #2a2a2a;
  border-top-color: #4a4a4a;
  border-left-color: #4a4a4a;
  color: #c0c0c0;
  transition: all 0.1s;
}

.leaflet-control-layers-overlays label input + span {
  border-radius: 0;
}

.leaflet-control-layers-overlays label:first-child input + span,
.leaflet-control-layers-overlays label:last-child input + span {
  border-radius: 0;
}

.leaflet-control-layers input[type="radio"] + span:hover,
.leaflet-control-layers input[type="checkbox"] + span:hover {
  cursor: pointer;
  background-color: #4a4a4a;
  border-color: #5a5a5a;
}

.leaflet-control-layers input[type="radio"]:checked + span,
.leaflet-control-layers input[type="checkbox"]:checked + span {
  background: #5a8f5a;
  border-color: #3d6b3d;
  border-top-color: #7ab87a;
  border-left-color: #7ab87a;
  color: #fff;
  font-weight: bold;
}

/* List control buttons */
.leaflet-control-train-list-toggle {
  background-image: url(../icons/trains.svg);
}
.leaflet-control-station-list-toggle {
  background-image: url(../icons/stations.svg);
}

.leaflet-control-scrollbar {
  overflow-y: scroll;
  overflow-x: hidden;
  padding-right: 5px;
}
.leaflet-control-scrollbar::-webkit-scrollbar {
  width: 6px;
}
.leaflet-control-scrollbar::-webkit-scrollbar-track {
  background: #2a2a2a;
}
.leaflet-control-scrollbar::-webkit-scrollbar-thumb {
  background: #5a5a5a;
  border: 1px solid #3a3a3a;
}

.leaflet-right .leaflet-control {
  float: right;
}

/* Train and Station list items */
.ctm-station-list .station,
.ctm-train-list .train {
  font-family: var(--ui-font);
  font-size: 13px;
  display: block;
  border-radius: 0;
  padding: 4px 8px;
  margin-top: 2px;
  background: #3a3a3a;
  border: 1px solid #2a2a2a;
  border-top-color: #4a4a4a;
  border-left-color: #4a4a4a;
  color: #c0c0c0;
  transition: all 0.1s;
}
.ctm-station-list .station:hover,
.ctm-train-list .train:hover {
  cursor: pointer;
  background-color: #4a4a4a;
  color: #fff;
}

/* Position adjustments */
.leaflet-top {
  top: 12px;
}
.leaflet-bottom {
  bottom: 12px;
}
.leaflet-left {
  left: 12px;
}
.leaflet-right {
  right: 12px;
}

/* ============================================
   Zoom Controls - Minecraft button style
   ============================================ */
.leaflet-bar {
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
  border-radius: 0;
  border: none;
}

.leaflet-bar a,
.leaflet-bar a:hover {
  background: #3d3d3d;
  border: 2px solid #1a1a1a;
  border-top-color: #5a5a5a;
  border-left-color: #5a5a5a;
  border-radius: 0;
  width: 32px;
  height: 32px;
  line-height: 28px;
  color: #e0e0e0;
  font-weight: bold;
  font-size: 18px;
}

.leaflet-bar a:hover {
  background: #4a4a4a;
}

.leaflet-bar a:first-child,
.leaflet-bar a:last-child {
  border-radius: 0;
}

.leaflet-bar a.leaflet-disabled {
  background: #2a2a2a;
  color: #555;
  border-top-color: #3a3a3a;
  border-left-color: #3a3a3a;
}

/* ============================================
   Layer Control - Minecraft panel style
   ============================================ */
.leaflet-control-layers {
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
  background: #2a2a2a;
  border: 2px solid #1a1a1a;
  border-top-color: #4a4a4a;
  border-left-color: #4a4a4a;
  border-radius: 0;
}

.leaflet-control-layers-expanded {
  background: #2a2a2a;
  color: #e0e0e0;
}

/* ============================================
   Tooltips - Remove default leaflet styling
   ============================================ */
.leaflet-tooltip {
  background: #100010;
  border: 2px solid #25015b;
  border-radius: 0;
  color: #fff;
  box-shadow: inset 0 0 0 1px #2d0070, 0 2px 8px rgba(0, 0, 0, 0.6);
  padding: 6px 10px;
}

.leaflet-tooltip-top:before,
.leaflet-tooltip-bottom:before,
.leaflet-tooltip-left:before,
.leaflet-tooltip-right:before {
  border: none;
}
