* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: -apple-system, 'Helvetica Neue', sans-serif;
  background: #1a1a2e;
}

#app {
  display: flex;
  width: 100%;
  height: 100dvh;
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
}

/* === LEFT: Shaft Position Indicator === */
#shaft-indicator {
  width: 28px;
  display: flex;
  flex-direction: column;
  position: relative;
  background: linear-gradient(180deg, #1a1a1a, #111, #1a1a1a);
  border-right: 1px solid #333;
  padding: 6px 0;
}

.shaft-label {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 8px;
  color: #444;
  font-family: 'Courier New', monospace;
  font-weight: 700;
  position: relative;
  z-index: 2;
}

.shaft-label.current {
  color: #ffd700;
  text-shadow: 0 0 6px #ffd700;
}

#shaft-car {
  position: absolute;
  left: 2px;
  right: 2px;
  height: calc(100% / 15 - 1px);
  background: linear-gradient(90deg, #ffd700 0%, rgba(255,215,0,0.2) 30%, rgba(255,215,0,0.05) 100%);
  border-left: 3px solid #ffd700;
  border-radius: 0 2px 2px 0;
  transition: bottom 0.18s linear;
  bottom: 0;
  box-shadow: 0 0 10px rgba(255,215,0,0.3);
  z-index: 1;
  pointer-events: none;
}

/* === CENTER: Elevator View === */
#elevator {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(180deg, #2a2a3e 0%, #1a1a2e 100%);
  padding: 8px;
}

#elevator-shaft {
  position: relative;
  width: 100%;
  height: 90%;
  max-height: 700px;
  background: #333;
  border: 3px solid #555;
  border-radius: 6px;
  overflow: hidden;
  box-shadow: inset 0 0 20px rgba(0,0,0,0.5), 0 4px 20px rgba(0,0,0,0.5);
}

#floor-scene {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #e8e8e8;
}

#scene-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity 0.3s;
}

#scene-image.visible {
  opacity: 1;
}

/* Doors */
.door {
  position: absolute;
  top: 0;
  width: 50%;
  height: 100%;
  z-index: 10;
  transition: transform 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

#door-left {
  left: 0;
  background: linear-gradient(90deg, #9a9a9a, #b8b8b8 30%, #c8c8c8 50%, #b0b0b0 70%, #9a9a9a);
  border-right: 1px solid #777;
}

#door-right {
  right: 0;
  background: linear-gradient(90deg, #9a9a9a, #b0b0b0 30%, #c8c8c8 50%, #b8b8b8 70%, #9a9a9a);
  border-left: 1px solid #777;
}

#door-left::after {
  content: '';
  position: absolute;
  right: 0;
  top: 0;
  width: 2px;
  height: 100%;
  background: linear-gradient(180deg, #888, #666, #888);
}

#door-right::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  width: 2px;
  height: 100%;
  background: linear-gradient(180deg, #888, #666, #888);
}

#door-left::before {
  content: '';
  position: absolute;
  right: 8px;
  top: 45%;
  width: 4px;
  height: 30px;
  border-radius: 2px;
  background: #777;
}

#door-right::after {
  content: '';
  position: absolute;
  left: 8px;
  top: 45%;
  width: 4px;
  height: 30px;
  border-radius: 2px;
  background: #777;
}

.doors-open #door-left {
  transform: translateX(-95%);
}

.doors-open #door-right {
  transform: translateX(95%);
}

/* === RIGHT: Control Panel (Brushed Steel) === */
#control-panel {
  width: 42%;
  min-width: 130px;
  max-width: 170px;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 10px 6px;
  gap: 8px;
  background-image: url('../images/ui/panel-bg.png');
  background-size: cover;
  background-position: center;
  border-left: 2px solid #777;
  box-shadow: inset 0 0 40px rgba(0,0,0,0.2);
}

/* LED Display */
#floor-display {
  background: #0a0a0a;
  border: 2px solid #555;
  border-radius: 6px;
  padding: 4px 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  box-shadow:
    0 1px 3px rgba(0,0,0,0.5),
    inset 0 0 15px rgba(0,0,0,0.9),
    inset 0 0 2px rgba(255,200,0,0.05);
  width: 80%;
}

#direction-arrow {
  font-size: 14px;
  color: #ffd700;
  min-width: 14px;
  text-align: center;
  text-shadow: 0 0 6px #ffd700;
}

.arrow-up, .arrow-down {
  animation: blink 0.5s infinite;
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

#floor-number {
  font-size: 32px;
  font-weight: 900;
  color: #ffd700;
  font-family: 'Courier New', monospace;
  text-shadow: 0 0 8px #ffd700, 0 0 16px #ff8c00;
  min-width: 32px;
  text-align: center;
}

/* Door Buttons — Realistic Metal */
#door-buttons {
  display: flex;
  gap: 6px;
  width: 85%;
}

.door-btn {
  flex: 1;
  height: 34px;
  border-radius: 4px;
  border: 1px solid #999;
  background: linear-gradient(180deg, #ccc 0%, #b8b8b8 40%, #aaa 60%, #999 100%);
  color: #555;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
  box-shadow:
    0 2px 3px rgba(0,0,0,0.3),
    inset 0 1px 0 rgba(255,255,255,0.5),
    inset 0 -1px 2px rgba(0,0,0,0.1);
  touch-action: manipulation;
  letter-spacing: -1px;
  text-shadow: 0 1px 0 rgba(255,255,255,0.5), 0 -1px 0 rgba(0,0,0,0.2);
}

.door-btn:active {
  transform: scale(0.95);
  background: linear-gradient(180deg, #bbb 0%, #aaa 40%, #999 60%, #888 100%);
  box-shadow: 0 1px 1px rgba(0,0,0,0.3), inset 0 2px 4px rgba(0,0,0,0.2);
}

/* Floor Buttons Grid */
#button-panel {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 7px;
  padding: 6px 4px;
  flex: 1;
  align-content: start;
  overflow-y: auto;
  width: 100%;
  justify-items: center;
}

/* === Realistic Elevator Button === */
.floor-btn {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  border: none;
  position: relative;
  cursor: pointer;
  touch-action: manipulation;
  transition: transform 0.1s;

  /* Metallic convex dome surface */
  background:
    radial-gradient(circle at 40% 35%, rgba(255,255,255,0.5) 0%, transparent 40%),
    radial-gradient(circle at 50% 50%, #d4d4d4 0%, #bcbcbc 30%, #a8a8a8 55%, #8a8a8a 80%, #6a6a6a 100%);

  /* Bezel + rim + shadow */
  box-shadow:
    /* Outer drop shadow */
    0 3px 5px rgba(0,0,0,0.35),
    0 1px 2px rgba(0,0,0,0.25),
    /* Outer metallic rim */
    inset 0 0 0 3px #aaa,
    inset 0 0 0 4px #777,
    /* Top highlight (convex dome) */
    inset 0 3px 5px rgba(255,255,255,0.35),
    /* Bottom shadow (convex dome) */
    inset 0 -3px 5px rgba(0,0,0,0.2);

  /* Embossed number */
  color: #555;
  font-size: 17px;
  font-weight: 800;
  font-family: 'Helvetica Neue', Arial, sans-serif;
  text-shadow:
    0 1px 1px rgba(255,255,255,0.6),
    0 -1px 1px rgba(0,0,0,0.25);
  line-height: 50px;
  text-align: center;
}

/* Press effect */
.floor-btn:active {
  transform: scale(0.94);
  box-shadow:
    0 1px 2px rgba(0,0,0,0.3),
    inset 0 0 0 3px #aaa,
    inset 0 0 0 4px #777,
    inset 0 3px 8px rgba(0,0,0,0.3);
  background:
    radial-gradient(circle at 50% 50%, #c0c0c0 0%, #aaa 30%, #999 55%, #7a7a7a 80%, #606060 100%);
}

/* Active / Selected floor — golden glow */
.floor-btn.active {
  border: 2px solid #ffd700;
  box-shadow:
    0 0 12px rgba(255,215,0,0.5),
    0 0 4px rgba(255,215,0,0.3),
    0 2px 4px rgba(0,0,0,0.3),
    inset 0 0 0 2px #c8a600,
    inset 0 2px 4px rgba(255,255,255,0.2),
    inset 0 -2px 4px rgba(0,0,0,0.15);
  background:
    radial-gradient(circle at 40% 35%, rgba(255,255,200,0.5) 0%, transparent 40%),
    radial-gradient(circle at 50% 50%, #d8d0a0 0%, #c4b880 30%, #b0a060 55%, #8a7a3a 80%, #6a5a2a 100%);
  color: #ffd700;
  text-shadow:
    0 0 8px rgba(255,215,0,0.8),
    0 0 3px rgba(255,200,0,0.5);
}

/* Install Button */
#btn-install {
  display: none;
  align-items: center;
  justify-content: center;
  width: 85%;
  padding: 8px 0;
  border-radius: 6px;
  border: 1px solid #888;
  background: linear-gradient(180deg, #555 0%, #333 100%);
  color: #ffd700;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 2px 4px rgba(0,0,0,0.4);
  touch-action: manipulation;
  flex-shrink: 0;
  margin-top: auto;
}

#btn-install:active {
  transform: scale(0.95);
  background: linear-gradient(180deg, #444 0%, #222 100%);
}

/* Scrollbar hide */
#button-panel::-webkit-scrollbar { display: none; }
#button-panel { -ms-overflow-style: none; scrollbar-width: none; }

/* === iPhone 16e Mobile Optimization (390×844) === */
@media screen and (max-width: 430px) {
  #app {
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
  }

  #shaft-indicator {
    width: 24px;
  }

  .shaft-label {
    font-size: 7px;
  }

  #elevator {
    padding: 4px;
  }

  #elevator-shaft {
    height: 95%;
    max-height: none;
    border-width: 2px;
  }

  #control-panel {
    width: 38%;
    min-width: 120px;
    max-width: 150px;
    padding: 8px 4px;
    gap: 6px;
  }

  #floor-display {
    padding: 3px 10px;
  }

  #floor-number {
    font-size: 28px;
  }

  #door-buttons {
    width: 90%;
  }

  .door-btn {
    height: 30px;
    font-size: 11px;
  }

  #button-panel {
    gap: 5px;
    padding: 4px 2px;
  }

  .floor-btn {
    width: 44px;
    height: 44px;
    font-size: 15px;
    line-height: 44px;
  }

  #btn-install {
    padding: 6px 0;
    font-size: 12px;
  }
}

/* Very small screens (iPhone SE, etc.) */
@media screen and (max-width: 375px) {
  #shaft-indicator {
    width: 20px;
  }

  .shaft-label {
    font-size: 6px;
  }

  #control-panel {
    min-width: 110px;
    max-width: 130px;
    padding: 6px 3px;
  }

  .floor-btn {
    width: 40px;
    height: 40px;
    font-size: 14px;
    line-height: 40px;
  }

  #floor-number {
    font-size: 24px;
  }
}


/* === iPad / Tablet (768px+) === */
@media screen and (min-width: 768px) {
  #shaft-indicator {
    width: 40px;
  }

  .shaft-label {
    font-size: 11px;
  }

  #elevator {
    padding: 16px;
  }

  #elevator-shaft {
    max-height: 900px;
    border-width: 4px;
    border-radius: 10px;
  }

  #control-panel {
    width: 35%;
    min-width: 200px;
    max-width: 260px;
    padding: 16px 10px;
    gap: 12px;
  }

  #floor-display {
    padding: 8px 20px;
    border-radius: 10px;
  }

  #floor-number {
    font-size: 44px;
    min-width: 44px;
  }

  #direction-arrow {
    font-size: 20px;
  }

  #door-buttons {
    width: 80%;
    gap: 10px;
  }

  .door-btn {
    height: 46px;
    font-size: 16px;
    border-radius: 6px;
  }

  #button-panel {
    gap: 12px;
    padding: 10px 8px;
  }

  .floor-btn {
    width: 62px;
    height: 62px;
    font-size: 22px;
    line-height: 62px;
  }

  #btn-install {
    padding: 12px 0;
    font-size: 16px;
    border-radius: 8px;
  }
}

/* === iPad Pro / Large tablets (1024px+) === */
@media screen and (min-width: 1024px) {
  #shaft-indicator {
    width: 50px;
  }

  .shaft-label {
    font-size: 13px;
  }

  #elevator {
    padding: 24px;
  }

  #elevator-shaft {
    max-height: 1100px;
    border-width: 5px;
  }

  #control-panel {
    min-width: 240px;
    max-width: 300px;
    padding: 20px 14px;
    gap: 16px;
  }

  #floor-display {
    padding: 10px 24px;
  }

  #floor-number {
    font-size: 52px;
    min-width: 52px;
  }

  #direction-arrow {
    font-size: 24px;
  }

  .door-btn {
    height: 52px;
    font-size: 18px;
  }

  #button-panel {
    gap: 14px;
    padding: 12px 10px;
  }

  .floor-btn {
    width: 70px;
    height: 70px;
    font-size: 26px;
    line-height: 70px;
  }
}
