* {
  box-sizing: border-box;
}
body {
  align-items: flex-start;
  background-color: #f9bf3b;
  display: flex;
  justify-content: center;
  min-height: 100vh;
  padding-top: 80px;
}
:root {
  --height: 400;
  --width: 280;
  --depth: 200;
  --drawerSize: calc((var(--height) / 3) - 10);
  --drawerHole: calc((var(--height) - ((10 * 4) + (10 + 30))) / 3);
}
.chest {
  height: calc(var(--height) * 1px);
  transform: rotateX(-30deg) rotateY(40deg);
  transform-style: preserve-3d;
  width: calc(var(--width) * 1px);
}
.chest__panel {
  height: 100%;
  position: absolute;
  transform-style: preserve-3d;
  width: 100%;
}
.chest__panel:after {
  content: '';
  display: block;
  height: 100%;
  width: 100%;
}
.chest__panel--front {
  transform: translate3d(0, 0, calc(var(--depth) / 2 * 1px));
}
.chest__panel--front:after {
  background: #5b5b5b;
  content: '';
  height: 4px;
  position: absolute;
  top: -2px;
  width: 100%;
}
.chest__panel--front-frame {
  border: 10px solid #5b5b5b;
  border-bottom-width: 30px;
  border-top-width: 10px;
  transform: translate3d(0, 0, 0);
}
.chest__panel--front-frame:before {
  background: #5b5b5b;
  content: '';
  height: 20px;
  left: 0;
  position: absolute;
  top: calc(var(--drawerHole) * 1px);
  width: 100%;
}
.chest__panel--front-frame:after {
  background: #5b5b5b;
  content: '';
  height: 20px;
  left: 0;
  position: absolute;
  top: calc(var(--drawerHole) * 2px + 20px);
  width: 100%;
}
.chest__panel--back {
  background: #5b5b5b;
  transform: translate3d(0, 0, calc(var(--depth) / 2 * -1px));
}
.chest__panel--back:after {
  background: #000;
  transform: translate3d(0, 0, 1px);
}
.chest__panel--top {
  background: #474747;
  bottom: 100%;
  height: calc(var(--depth) * 1px);
  left: 0;
  transform: rotateX(90deg) translate3d(0, 50%, 1px);
  transform-origin: bottom;
  transform-style: preserve-3d;
}
.chest__panel--top:after {
  background: #1a1a1a;
  transform: translate3d(0, 0, -1px);
}
.chest__panel--bottom {
  background: #474747;
  height: calc(var(--depth) * 1px);
  left: 0;
  top: 100%;
  transform: translateY(-50%) rotateX(90deg);
}
.chest__panel--bottom:after {
  background: #0d0d0d;
  transform: translate3d(0, 0, 1px);
}
.chest__panel--right {
  background: #323232;
  right: 0;
  transform: translate3d(0, 0, calc(var(--depth) / 2 * 1px)) rotateY(-90deg);
  transform-origin: right center;
  width: calc(var(--depth) * 1px);
}
.chest__panel--right:after {
  background: #1a1a1a;
  transform: translate3d(0, 0, 1px);
}
.chest__panel--left {
  width: calc(var(--depth) * 1px);
  left: 0;
  background: #323232;
  transform-origin: left center;
  transform: translate3d(0, -1px, calc(var(--depth) / 2 * 1px)) rotateY(90deg);
}
.chest__panel--left:after {
  background: #1a1a1a;
  transform: translate3d(0, 0, 1px);
}
.chest-drawer {
  height: calc(var(--drawerSize) * 1px);
  left: 0;
  position: absolute;
  top: 0;
  transition: transform 0.25s;
  transform-style: preserve-3d;
  width: 100%;
}
.chest-drawer--top,
.chest-drawer--middle,
.chest-drawer--bottom {
  transform: translate3d(0, 0, calc(var(--depth) * 0.51px));
}
.chest-drawer--top {
  top: 5px;
  z-index: 3;
}
.chest-drawer--middle {
  top: calc((var(--drawerSize) + 10) * 1px);
  z-index: 2;
}
.chest-drawer--bottom {
  top: calc((var(--drawerSize) * 2 + 15) * 1px);
  z-index: 1;
}

/* Drawer Button - Clickable Area */
.drawer-button {
  background: #303030;
  cursor: pointer;
  height: 100%;
  left: 0;
  position: absolute;
  outline: 0;
  top: 0;
  width: 100%;
  z-index: 10;
  border: none;
  padding: 0;
  margin: 0;
  transition: transform 0.25s;
  pointer-events: auto;
}

.drawer-button:after {
  background: #adadad;
  content: '';
  height: 5%;
  left: 50%;
  position: absolute;
  top: 10%;
  transform: translate(-50%, 0);
  width: 40%;
}

.drawer-button:hover {
  transform: translate3d(0, 0, calc(var(--depth) * 0.05px));
}

/* Drawer Container States */
.chest-drawer.hover {
  transform: translate3d(0, 0, calc(var(--depth) * 0.56px)) !important;
}

.chest-drawer.open {
  transform: translate3d(0, 0, calc(var(--depth) * 1.41px)) !important;
}

.chest-drawer__structure {
  height: 100%;
  left: 0;
  position: absolute;
  top: 0;
  transform-style: preserve-3d;
  transition: transform 0.25s;
  width: 100%;
  transform: translate3d(0, 0, 0);
}

.chest-drawer__panel {
  height: 100%;
  position: absolute;
  transform-style: preserve-3d;
  width: 100%;
}
.chest-drawer__panel--left {
  background: #e6e6e6;
  bottom: 0;
  height: calc(var(--drawerHole) * 0.65px);
  left: 10px;
  transform: translate3d(0, -16px, -2px) rotateY(90deg);
  transform-origin: left;
  width: calc(var(--depth) * 1px);
}
.chest-drawer__panel--right {
  background: #e6e6e6;
  bottom: 0;
  height: calc(var(--drawerHole) * 0.65px);
  right: 10px;
  transform: translate3d(0, -16px, -2px) rotateY(-90deg);
  transform-origin: right;
  width: calc((var(--depth) - 3) * 1px);
}
.chest-drawer__panel--bottom {
  background: #fff;
  bottom: 18px;
  height: calc(var(--depth) * 1px);
  left: 10px;
  transform: rotateX(90deg) translate3d(0, -2px, 0);
  transform-origin: bottom center;
  width: calc(100% - (2px * 10));
}
.chest-drawer__panel--back {
  align-items: center;
  background: #d9d9d9;
  bottom: 16px;
  display: flex;
  font-family: 'Arial', sans-serif;
  font-size: calc(var(--drawerHole) * 0.35px);
  font-weight: bold;
  height: calc(var(--drawerHole) * 0.65px);
  justify-content: center;
  left: 10px;
  transform: translate3d(0, 0, calc((var(--depth) - 2) * -1px));
  width: calc(100% - (2px * 10));
  color: #111;
  overflow: hidden;
  padding: 0;
}

.drawer-image {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}


/* Control Panel */
.control-panel {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: #f9bf3b;
  padding: 30px 40px;
  border-radius: 15px;
  box-shadow: none;
  z-index: 1000;
  font-family: 'Segoe UI', sans-serif;
  min-width: 600px;
}

.control-panel h3 {
  margin: 0 0 15px 0;
  color: #333;
  font-size: 16px;
  text-align: center;
}

.control-groups-container {
  display: flex;
  gap: 20px;
  align-items: center;
  justify-content: center;
  flex-wrap: nowrap;
}

.control-group {
  display: flex;
  gap: 8px;
  align-items: center;
  white-space: nowrap;
}

.control-group label {
  color: #333;
  font-size: 14px;
  font-weight: 500;
  min-width: 55px;
}

.control-group input {
  width: 100px;
  padding: 8px 12px;
  border: 2px solid #ddd;
  border-radius: 5px;
  font-size: 14px;
  transition: border-color 0.3s;
  background: white;
}

.control-group input:focus {
  outline: none;
  border-color: #f9bf3b;
}

.control-group button {
  padding: 8px 14px;
  background: #f9bf3b;
  color: #333;
  border: 2px solid #e6a800;
  border-radius: 5px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.3s;
  min-width: 50px;
}

.control-group button:hover {
  transform: translateY(-2px);
  background: #ffcc4d;
  box-shadow: 0 4px 12px rgba(249, 191, 59, 0.4);
}

.control-group button:active {
  transform: translateY(0);
}

.export-btn {
  padding: 10px 20px;
  background: #f9bf3b;
  color: #333;
  border: 2px solid #e6a800;
  border-radius: 5px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  transition: all 0.3s;
  white-space: nowrap;
  margin-left: 10px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.download-icon {
  width: 18px;
  height: 18px;
  stroke: #333;
}

.export-btn:hover {
  transform: translateY(-2px);
  background: #ffcc4d;
  box-shadow: 0 4px 12px rgba(249, 191, 59, 0.4);
}

.export-btn:hover .download-icon {
  stroke: #333;
}

.export-btn:active {
  transform: translateY(0);
}

@media (max-width: 900px) {
  .control-panel {
    bottom: 10px;
    left: 10px;
    right: 10px;
    transform: none;
    min-width: auto;
    padding: 20px;
  }

  .control-groups-container {
    gap: 10px;
    flex-wrap: wrap;
  }

  .control-group input {
    width: 80px;
  }

  .export-btn {
    margin-left: 0;
    margin-top: 10px;
    width: 100%;
  }
}
