:root {
  --primary: #333;
  --accent: #d97706;
  --bg: #f9fafb;
  --border: #e5e7eb;
  --w: 1241;
  --h: 768;
}
body {
  margin: 0;
  background: #fff;
  font-family: "Noto Sans JP", sans-serif;
  font-optical-sizing: auto;
  font-style: normal;
  color: #333;
}
.wrap {
  max-width: 640px;
  margin: 0 auto;
  padding: 0 16px;
  position: relative;
  padding-top: 40px;
}
header {
  padding: 20px 0;
  text-align: center;
}
header h1 {
  margin: 0;
  font-size: 18px;
  color: #d00;
  font-weight: bold;
}
header p {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  color: #666;
  white-space: nowrap;
}

/* Carousel */
.house-carousel {
  margin-bottom: 20px;
}
.house-slide {
  width: 600px; /* Fixed width for variableWidth mode */
  max-width: 90vw; /* Responsive fallback */
  text-align: center;
  transition: opacity 0.3s;
  opacity: 0.5;
  transform: scale(1);
  margin: 0 10px; /* Adjusted margin */
}
.house-slide.slick-center {
  opacity: 1;
  transform: scale(1);
}
.stage-box {
  background: #fff;
  /* border: 1px solid #eee; */
  /* border-radius: 8px; */
  /* box-shadow: 0 2px 10px rgba(0,0,0,0.05); */
  overflow: hidden;
  aspect-ratio: var(--w) / var(--h);
  width: 100%;
}
.house-container {
  width: 100%;
  /* height: 100%; */
}
.house-img {
  width: 100%;
  height: auto;
  display: block;
  pointer-events: none; /* Prevent dragging image */
  border-radius: 10px;
}
.house-label {
  margin-top: 3px;
  font-weight: 900;
  color: #999;
  font-size: 16px;
}

.house-icon { width: 20px; height: 20px; vertical-align: middle; margin-right: 2px; display: inline !important; margin-bottom:3px; }


.slick-center .house-label {
  color: #333;
}

/* Slick Customization */
.slick-prev, .slick-next {
  z-index: 10;
  width: 30px;
  height: 30px;
}
.slick-prev:before, .slick-next:before {
  color: #333;
  font-size: 30px;
}
.slick-prev { left: calc(50% - 315px); }
.slick-next { right: calc(50% - 315px); }

@media (max-width: 768px) {
  .slick-prev { left: 10px; }
  .slick-next { right: 10px; }
  
  header p {
    white-space: normal;
    font-size: 13px;
    line-height: 1.4;
  }
}

.instruction-text {
  text-align: center;
  font-size: 12px;
  font-weight: bold;
  margin-bottom: 5px;
  background: rgba(255,255,255,0.8);
  padding: 4px;
  border-radius: 4px;
  position: relative;
  z-index: 2;
  margin-top: -20px; /* Overlap slightly */
}

/* Selection Area (Vertical Layout) */
.selection-area {
  display: flex;
  align-items: stretch; /* Match height */
  gap: 0;
  margin-bottom: 20px;
}

/* Tabs */
.tab-nav {
  display: flex;
  flex-direction: column;
  width: 100px;
  flex-shrink: 0;
  border-right: 1px solid #ddd;
  padding-bottom: 0;
  margin-bottom: 0;
}
.tab-item {
  padding: 14px 10px;
  font-size: 13px;
  font-weight: bold;
  color: #666;
  background: #EFEFEF;
  border-radius: 8px 0 0 8px;
  cursor: pointer;
  white-space: normal;
  border: 1px solid transparent;
  border-right: none;
  margin-bottom: 4px;
  text-align: left;
  transition: background 0.2s, color 0.2s;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.tab-label {
  font-size: 14px;
  color: #333;
}
.tab-color-indicator {
  height: 24px; /* Increased height */
  width: 100%;
  background: #ccc; /* Default */
  border: 2px solid #fff;
  border-radius: 2px;
}
.tab-item:last-child {
  margin-bottom: 0;
}
.tab-item.active {
  background: #DAD7D4; /* Match palette area bg */
  color: #000;
  border-color: #ddd;
  border-right: 1px solid #DAD7D4; /* Merge with palette area */
  margin-right: -1px;
  position: relative;
  z-index: 2;
}

/* Palette Area */
.palette-area {
  background: #DAD7D4;
  padding: 14px;
  border-radius: 0 8px 8px 8px;
  margin-bottom: 0;
  flex: 1;
  border: 1px solid #ddd;
  border-left: none;
  min-width: 0; /* Prevent flex item overflow */
  overflow: hidden; /* Ensure slick slider stays contained */
}
.current-color-display {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
  font-size: 16px;
  font-weight: 600;
}
.current-color-preview {
  width: 24px;
  height: 24px;
  border-radius: 4px;
  border: 2px solid #fff;
  background: #ccc; /* default */
}
#current-part-name {
  font-weight: bold;
}

.palette-tabs {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-bottom: 10px;
  border-bottom: 1px solid #ccc;
  padding-bottom: 5px;
}
.palette-tab {
  background: none;
  border: none;
  font-size: 14px;
  font-weight: bold;
  color: #666;
  cursor: pointer;
  padding: 5px 10px;
  border-radius: 4px;
}
.palette-tab.active {
  background: #fff;
  color: #333;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}
.palette-tab:hover {
  background: rgba(255,255,255,0.5);
}

.instruction-text {
  position: relative;
  z-index: 10;
  background: #fff;
  border: 2px solid #999;
  border-radius: 999px;
  padding: 12px 24px;
  margin: -50px auto -10px;
  width: fit-content;
  font-size: 14px;
  font-weight: bold;
  color: #333;
}

.palette-grid {
  /* display: grid; removed for slick */
  display: block;
  /* grid-template-columns: repeat(4, 1fr); removed */
  /* gap: 10px; removed */
  margin-bottom: 20px; /* space for dots */
}
* {
  box-sizing: border-box;
}
.palette-slide {
  width: 100%;
  padding: 0 5px; /* Add some padding to prevent edge touching */
}
.palette-slide-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  width: 100%;
  padding-top:5px;
}
@media (max-width: 639px) {
  .palette-slide-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}
.palette-item {
  cursor: pointer;
  text-align: left;
}
.palette-item:hover .color-swatch {
  transform: scale(1.05);
}
.color-swatch {
  width: 100%;
  height: 30px; /* Fixed height instead of aspect ratio */
  /* aspect-ratio: 3 / 1; removed */
  border-radius: 4px;
  border: 2px solid #fff;
  position: relative;
  margin-bottom: 4px;
  transition: transform 0.2s;
}
.color-swatch.selected {
  border: 3px solid #cc0000 !important;
  box-shadow: 0 0 0 2px #fff inset; /* Inner white border for contrast */
}
.color-label {
  font-size: 11px;
  color: #333;
  line-height: 1.2;
  word-break: break-all;
}

/* Palette Controls */
.palette-controls-container {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 15px;
  padding: 0 10px;
}
.palette-arrow {
  background: none;
  border: 1px solid #999;
  border-radius: 50%;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: #666;
  font-size: 12px;
  transition: all 0.2s;
}
.palette-arrow:hover {
  background: #fff;
  color: #333;
}
.palette-page-info {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 14px;
  color: #666;
}
.palette-select {
  padding: 2px 5px;
  border: 1px solid #ccc;
  border-radius: 4px;
  font-size: 14px;
  color: #333;
  cursor: pointer;
}
.palette-total-text {
  font-weight: bold;
}

/* Enforce fixed height for palette to keep controls stable */
.palette-grid {
  display: block;
  margin-bottom: 0; /* Removed margin since controls are separate */
  min-height: 330px; /* Approx height for 6 rows (30px height + 10px gap * 6) */
}

/* Controls */
.controls-area {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}
.btn {
  border: 1px solid #ccc;
  background: #fff;
  padding: 10px 12px;
  border-radius: 4px;
  font-size: 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-weight: bold;
  transition: all 0.15s ease;
}
.btn:active {
  transform: scale(0.95);
}
.btn-reset {
  background: #f0f0f0;
  height: 100%;
}
.btn-omakase {
  flex: 1;
  justify-content: space-between;
  border: 1px solid #333;
  height: 100%;
}
.btn-save {
  background: #d04a38;
  color: #fff !important;
  border: none;
  transition: transform 0.2s;
}
.btn-save:hover {
  transform: scale(1.05);
}
.btn-save:active {
  background: #b83d2e;
}

.export-container {
  background: #f5f5f5;
  padding: 8px 12px;
  border-radius: 8px;
  height: 100%;
  display: flex;
  flex-direction: column;
  gap: 5px;
  align-items: center;
  justify-content: center;
}

/* Omakase Menu */
.omakase-menu {
  position: absolute;
  bottom: 100%;
  left: 0;
  width: 100%;
  background: #fff;
  box-shadow: 0 4px 20px rgba(0,0,0,0.15);
  border-radius: 8px;
  z-index: 100;
  padding-bottom: 10px;
  margin-bottom: 5px;
  display: none;
  border: 1px solid #ddd;
}
.omakase-menu.open {
  display: block;
}
.omakase-item.selected {
  background-color: #fff3e0;
  border-color: #ffb74d;
  color: #e65100;
}
.omakase-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px;
  border-bottom: 1px solid #eee;
  font-weight: bold;
}
.close-btn {
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
}
.omakase-list {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.omakase-item {
  padding: 12px;
  text-align: left;
  background: #f9f9f9;
  border: 1px solid #eee;
  border-radius: 8px;
  cursor: pointer;
  font-weight: bold;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}
.omakase-item:hover {
  background: #eee;
}
.omakase-name {
  flex: 1;
}
.omakase-chips {
  display: flex;
  gap: 2px;
}
.omakase-chip {
  width: 16px;
  height: 16px;
  border-radius: 2px;
  border: 1px solid rgba(0,0,0,0.1);
}

.disclaimer-text {
  font-size: 12px;
  color: #666;
  margin-bottom: 10px;
  line-height: 1.5;
}

/* Loading Overlay */
.house-container {
  position: relative;
  width: 100%;
  /* Aspect Ratio 1241:768 = 1.61588... */
  padding-top: 61.88%;
  background: #f3f4f6; /* Placeholder color */
  overflow: hidden;
}
.house-img {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.loading-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(255,255,255,0.8);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 10;
  opacity: 1;
  transition: opacity 0.3s ease;
}
.loading-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}
.spinner {
  width: 40px;
  height: 40px;
  border: 4px solid #f3f3f3;
  border-top: 4px solid #d04a38;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}
@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* Splash Screen */
#splash-screen {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: #fff;
  z-index: 9999;
  display: flex;
  justify-content: center;
  align-items: center;
  transition: opacity 0.5s ease-out;
}
.splash-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 30px;
  width: 100%;
}
.splash-logo {
  width: 500px;
  max-width: 80%;
}
.splash-bar-container {
  width: 300px;
  max-width: 70%;
  height: 4px;
  background: #eee;
  border-radius: 2px;
  overflow: hidden;
}
.splash-bar {
  width: 0%;
  height: 100%;
  background: #d04a38;
  animation: splashLoad 2s ease-in-out infinite;
}
@keyframes splashLoad {
  0% { width: 0%; transform: translateX(-100%); }
  50% { width: 100%; transform: translateX(0%); }
  100% { width: 100%; transform: translateX(100%); }
}

#splash-screen.fade-out {
  opacity: 0;
  pointer-events: none;
}

/* Hide color labels on small screens */
@media (max-width: 639px) {
  .current-color-display {
    font-size: 12px;
  }
  .instruction-text{
    font-size: 12px;
  }
  .color-label {
    display: none;
  }
  
  /* Reorder controls area on mobile */
  .controls-area {
    flex-direction: column;
    align-items: stretch;
  }
  
  .btn-reset {
    order: 3;
  }
  
  .controls-area > div[style*="position: relative"] {
    order: 1;
  }
  
  .export-container {
    order: 2;
  }
  
  /* Make export buttons full width */
  .export-container > div[style*="display: flex"] {
    width: 100%;
  }
  
  .export-container .btn-save {
    flex: 1;
  }
  .color-swatch{
    margin-bottom: 0;
  }
}

/* Modal Styles */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 10000;
  opacity: 1;
  transition: opacity 0.3s ease;
}

.modal-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

.modal-box {
  background: #fff;
  padding: 24px;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  text-align: center;
  max-width: 90%;
  width: 320px;
}

.modal-message {
  font-size: 16px;
  font-weight: bold;
  margin-bottom: 20px;
  color: #333;
}

.modal-buttons {
  display: flex;
  gap: 10px;
  justify-content: center;
}

.btn-confirm, .btn-cancel {
  padding: 8px 20px;
  border-radius: 4px;
  font-size: 14px;
  font-weight: bold;
  cursor: pointer;
  border: none;
  transition: opacity 0.2s;
}

.btn-confirm {
  background: #d04a38;
  color: #fff;
}

.btn-cancel {
  background: #e5e7eb;
  color: #333;
}

.btn-confirm:hover, .btn-cancel:hover {
  opacity: 0.8;
}

/* Fix for iOS Safari blue text */
.btn, .omakase-item, .btn-reset {
  color: #333;
}

/* Chevron Up Icon */
.dli-chevron-up {
  display: inline-block;
  vertical-align: middle;
  color: #333;
  line-height: 1;
  width: 1em;
  height: 1em;
  border: 0.3em solid currentColor;
  border-left: 0;
  border-bottom: 0;
  box-sizing: border-box;
  transform: translateY(25%) rotate(-45deg);
  margin-left: 5px; /* Add some spacing */
}
