@import url('https://fonts.googleapis.com/css2?family=Bitcount+Grid+Double:wght@100..900&family=Bitcount+Single:wght@100..900&display=swap');

/* ============================================================
   RESET & BASE
   ============================================================ */

body {
  margin: 0;
  font-family: 'Bitcount Single', cursive;
  font-weight: 700;
  background-image: url("./images/Background/back.png");
  background-size: cover;
  background-position: center;
  background-attachment: fixed;
}

:root {
  --panel-size: 750px;
  --ui-size: 70px;
}

/* ============================================================
   MAIN LAYOUT
   ============================================================ */

/*
  .app-shell fills the full viewport and centers .app.
  Overflow is hidden because .app uses transform: scale(),
  which does not affect layout flow — the shell clips any
  visual overflow on smaller screens.
*/
.app-shell {
  width: 100vw;
  height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: hidden;
}

/*
  .app is the fixed-size content block (roughly 1700px wide at base).
  Scaling is applied via JS (scaleApp) using transform-origin: center center
  so the whole layout shrinks uniformly without repositioning any elements.
  The base scale(1.1) that was here before is now baked into the JS calculation.
*/
.app {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 60px;
  padding: 40px;
  box-sizing: border-box;
  transform-origin: center center;
  flex-shrink: 0; /* prevents flexbox from squishing children before scale kicks in */
}

/* ============================================================
   LEFT: CHARACTER PREVIEW
   ============================================================ */

.preview {
  position: relative;
  width: var(--panel-size);
  min-width: var(--panel-size);
  aspect-ratio: 1 / 1;
  background-image: url("./images/Background/back_left.png");
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  display: flex;
  justify-content: center;
  align-items: center;
}

.character {
  position: relative;
  width: 85%;
  aspect-ratio: 1 / 1;
  transform: translateY(10px);
  background: transparent;
}

.layer {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: fill;
  pointer-events: none;
  display: block;
}

.layer[src=""],
.layer:not([src]) {
  display: none;
}

/* ============================================================
   RIGHT: CONTROL PANEL
   ============================================================ */

.controls {
  position: relative;
  width: var(--panel-size);
  min-width: var(--panel-size);
  aspect-ratio: 1 / 1;
  box-sizing: border-box;
  overflow: hidden;
  padding: 110px 92px 78px;
  background-image:
    url("./images/Background/bows_right.png"),
    url("./images/Background/stars_right.png"),
    url("./images/Background/top_box.png"),
    url("./images/Background/bottom_box.png"),
    url("./images/Background/back_right.png");
  background-size: 100% 100%, 100% 100%, 100% 100%, 100% 100%, 100% 100%;
  background-repeat: no-repeat;
  background-position: center;
}

.control-section {
  background: transparent !important;
  border: none !important;
  padding: 0 !important;
  margin: 0 !important;
}

.control-section h2 {
  position: absolute;
  font-size: 14px;
  color: #7e5aa3;
  background: rgba(255, 255, 255, 0.75);
  border: none;
  box-shadow: 0 0 0 2px #b993d6;
  padding: 2px 10px;
  line-height: 1;
}

/* ============================================================
   BUTTONS (BASE)
   ============================================================ */

button {
  font-family: 'Bitcount Single', cursive;
  cursor: pointer;
  text-align: center;
  color: #7a589b;
  font-weight: bold;
  border: 2px solid #b993d6;
  background: rgba(255, 255, 255, 0.9);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

button:hover {
  transform: translateY(-1px);
  box-shadow: 0 0 10px rgba(185, 147, 214, 0.55);
}

button:active {
  transform: translateY(1px);
}

/* ============================================================
   CATEGORY ICONS
   ============================================================ */

.category-grid {
  display: grid;
  grid-template-columns: repeat(5, var(--ui-size));
  justify-content: center;
  gap: 8px;
  margin-bottom: 60px;
}

.icon-category-btn {
  width: var(--ui-size);
  height: var(--ui-size);
  min-width: var(--ui-size);
  max-width: var(--ui-size);
  padding: 0 !important;
  margin: 0;
  border: none;
  background: none;
  display: flex;
  justify-content: center;
  align-items: center;
}

.icon-category-btn img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
}

.icon-category-btn.active {
  filter: brightness(1.15);
}

.next-category-btn img {
  transition: transform 0.35s ease;
}

.next-category-btn.back img {
  transform: scaleX(-1);
}

/* ============================================================
   STYLE THUMBNAILS
   ============================================================ */

.thumb-grid {
  display: grid;
  grid-template-columns: repeat(5, var(--ui-size));
  justify-content: center;
  gap: 8px;
  height: 150px;
  overflow: visible;
  margin-top: 30px;
  margin-bottom: 25px;
}

.thumb-btn {
  position: relative;
  width: var(--ui-size);
  height: var(--ui-size);
  min-width: var(--ui-size);
  max-width: var(--ui-size);
  aspect-ratio: 1 / 1;
  padding: 0;
  margin: 0;
  overflow: hidden;
  border-radius: 0 !important;
  border: 2px solid #b993d6;
  background: rgba(255, 255, 255, 0.9);
}

.thumb-btn.active {
  box-shadow: 0 0 14px rgba(255, 255, 255, 0.95);
  border-color: #7e5aa3;
}

.thumb-btn img {
  position: absolute;
  width: var(--thumb-zoom, 260%);
  height: var(--thumb-zoom, 260%);
  object-fit: contain;
  left: var(--thumb-x, 50%);
  top: var(--thumb-y, 50%);
  transform: translate(-50%, -50%);
  pointer-events: none;
}

/* ============================================================
   COLOR SWATCHES
   ============================================================ */

.color-grid {
  display: grid;
  grid-template-columns: repeat(5, var(--ui-size));
  justify-content: center;
  gap: 8px;
  align-items: center;
  height: 95px;
  overflow: visible;
  margin-top: 30px;
  margin-bottom: 25px;
}

.swatch-btn {
  width: var(--ui-size);
  height: var(--ui-size);
  min-width: var(--ui-size);
  max-width: var(--ui-size);
  aspect-ratio: 1 / 1;
  padding: 0;
  margin: 0;
  border-radius: 0 !important;
  border: 2px solid #b993d6;
  background-clip: padding-box;
  box-shadow: none;
}

.clear-swatch-btn {
  background: #fff !important;
  border: 2px solid #b993d6 !important;
  display: flex;
  justify-content: center;
  align-items: center;
}

.clear-swatch-btn img {
  width: 60%;
  height: 60%;
  object-fit: contain;
  pointer-events: none;
}

.empty-colors {
  width: var(--ui-size);
  height: var(--ui-size);
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 12px;
  color: #7e5aa3;
  text-align: center;
  background: rgba(255, 255, 255, 0.6);
  border: 2px solid #b993d6;
  padding: 4px;
  box-sizing: border-box;
}

/* ============================================================
   OPTIONS BUTTONS
   ============================================================ */

.control-section:last-child {
  display: flex !important;
  justify-content: flex-start !important;
  gap: 18px !important;
  margin-top: -30px !important;
}

.control-section:last-child button {
  width: 138px !important;
  height: 50px !important;
  min-width: 108px !important;
  max-width: 108px !important;
  padding: 0;
  margin: 0;
  font-size: 13px;
  border-radius: 0;
  transform: translateX(92px);
}

/* ============================================================
   SECTION LABEL POSITIONING
   ============================================================ */

.control-section:first-child h2 {
  display: none;
}

.control-section:nth-child(2) h2 {
  position: absolute;
  font-size: 18px;
  padding: 4px 14px;
  color: #7e5aa3;
  background: rgba(255, 255, 255, 0.9);
  border: 2px solid #b993d6;
  top: 190px;
  left: 184px;
}

.control-section:nth-child(3) h2 {
  position: absolute;
  font-size: 18px;
  padding: 4px 14px;
  color: #7e5aa3;
  background: rgba(255, 255, 255, 0.9);
  border: 2px solid #b993d6;
  top: 380px;
  left: 184px;
}

.control-section:nth-child(4) h2 {
  position: absolute;
  font-size: 18px;
  padding: 4px 14px;
  color: #7e5aa3;
  background: rgba(255, 255, 255, 0.9);
  border: 2px solid #b993d6;
  top: 530px;
  left: 184px;
}

/* ============================================================
   THICK PIXEL BORDERS
   ============================================================ */

.thumb-btn,
.swatch-btn,
.empty-colors,
.control-section:last-child button {
  border: 4px solid #b993d6 !important;
  box-sizing: border-box !important;
  outline: none !important;
  box-shadow: none !important;
}

/* ============================================================
   UNIFORM BUTTON ANIMATION SYSTEM
   ============================================================ */

.icon-category-btn,
.thumb-btn,
.swatch-btn,
.control-section:last-child button {
  --move-x: 0px;
  transition: transform 0.15s ease, box-shadow 0.15s ease, filter 0.15s ease;
}

.control-section:last-child button {
  --move-x: 92px;
}

.icon-category-btn:hover,
.thumb-btn:hover,
.swatch-btn:hover,
.control-section:last-child button:hover {
  transform: translateX(var(--move-x)) translateY(-2px) scale(1.04) !important;
  filter: brightness(1.05);
  box-shadow: 0 0 10px rgba(185, 147, 214, 0.55) !important;
}

.icon-category-btn:active,
.thumb-btn:active,
.swatch-btn:active,
.control-section:last-child button:active {
  transform: translateX(var(--move-x)) translateY(1px) scale(0.96) !important;
}

/* ============================================================
   COLOR ACTIONS ROW
   ============================================================ */

.color-actions {
  height: 75px;
  display: flex;
  justify-content: flex-start;
  align-items: flex-start;
  margin-top: 0;
  margin-left: 0;
}

/* ============================================================
   MODALS (SHARED)
   ============================================================ */

.hidden {
  display: none;
}

.modal {
  position: fixed;
  inset: 0;
  overflow: auto;
  background: rgba(0, 0, 0, 0.45);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 999;
}

.modal.hidden {
  display: none;
}

.modal-card {
  position: relative;
  width: 900px;
  height: 900px;
  min-width: 900px;
  min-height: 900px;
  max-width: 900px;
  max-height: 900px;
  background-image: url("./images/Background/popup2.png");
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  border: none;
  box-shadow: none;
  padding: 0;
  box-sizing: border-box;
}

.modal-card h2 {
  position: absolute;
  top: 270px;
  left: 295px;
  width: 270px;
  margin: 0;
  font-size: 18px;
  text-align: center;
  color: #7e5aa3;
  font-weight: 800;
}

/* ============================================================
   FINALIZE MODAL
   ============================================================ */

input[type="text"] {
  position: absolute;
  top: 335px;
  left: 249px;
  width: 380px;
  height: 60px;
  padding: 6px 10px;
  box-sizing: border-box;
  border: 4px solid #b993d6;
  background: rgba(255, 255, 255, 0.95);
  font-family: 'Bitcount Single', cursive;
  font-weight: 800;
  font-size: 16px;
  color: #7e5aa3;
  text-align: center;
  outline: none;
}

.modal-note {
  display: none;
}

.modal-actions {
  position: absolute;
  top: 420px;
  left: 275px;
  display: flex;
  gap: 25px;
}

.modal-actions button {
  width: 150px;
  height: 65px;
  border: 4px solid #b993d6;
  background: rgba(255, 255, 255, 0.9);
  font-family: 'Bitcount Single', cursive;
  font-weight: 800;
  color: #7e5aa3;
  display: flex;
  justify-content: center;
  align-items: center;
  cursor: pointer;
}

/* ============================================================
   INTRO MODAL
   ============================================================ */

.intro-card {
  background-image: url("./images/Background/popup1.png");
}

.intro-card h2 {
  position: absolute;
  top: 260px;
  left: 230px;
  width: 410px;
  margin: 0;
  font-size: 16px;
  line-height: 1.25;
  text-align: center;
  color: #7e5aa3;
  font-weight: 800;
}

.intro-actions {
  position: absolute;
  top: 417px;
  left: 360px;
  display: flex;
}

.intro-actions button {
  width: 150px;
  height: 65px;
  border: 4px solid #b993d6;
  background: rgba(255, 255, 255, 0.9);
  font-family: 'Bitcount Single', cursive;
  font-weight: 800;
  color: #7e5aa3;
  font-size: 16px;
  cursor: pointer;
}

/* ============================================================
   SUCCESS MODAL
   ============================================================ */

.success-card {
  width: 380px !important;
  height: 180px !important;
  min-width: unset !important;
  min-height: unset !important;
  max-width: unset !important;
  max-height: unset !important;
  background: rgba(255, 255, 255, 0.95) !important;
  background-image: none !important;
  border: 4px solid #b993d6;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 15px;
  padding: 20px;
}

.success-card h2 {
  position: static;
  margin: 0 0 20px;
  text-align: center;
  font-size: 18px;
  color: #7e5aa3;
  font-weight: 800;
}

.success-actions {
  margin-top: 10px;
}

.success-actions button {
  width: 150px;
  height: 65px;
  border: 4px solid #b993d6;
  background: rgba(255, 255, 255, 0.9);
  font-family: 'Bitcount Single', cursive;
  font-weight: 800;
  color: #7e5aa3;
}

/* ============================================================
   MODAL ENTRANCE ANIMATION
   ============================================================ */

@keyframes popupAppear {
  from {
    opacity: 0;
    transform: scale(0.85) translateY(20px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.modal:not(.hidden) .modal-card {
  animation: popupAppear 0.25s ease-out;
}