@import url("https://fonts.googleapis.com/css2?family=Roboto:wght@400;500;700;900&display=swap");

:root {
  --bg: #1c1514;
  --bg-soft: #2d201e;
  --text: #fff4ed;
  --muted: #dcc9bf;
  --accent: #bc5335;
  --accent-strong: #7a3326;
  --danger: #e39a7f;
  --card: rgba(47, 31, 29, 0.84);
  --border: rgba(216, 174, 150, 0.3);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--text);
  background: #d1ad97;
  min-height: 100vh;
  min-height: 100dvh;
  font-family: "Roboto", "Segoe UI", sans-serif;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  border: 16px solid #c7102f;
  pointer-events: none;
  z-index: 1000;
}

.ambient-glow {
  display: none;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0.02em;
}

.eyebrow {
  margin: 0;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-size: 0.72rem;
  color: #ffd6c2;
}

.layout {
  max-width: 1260px;
  margin: 0 auto;
  padding: 2.2rem 1.2rem 2.5rem;
  display: grid;
  grid-template-columns: minmax(280px, 380px) 1fr;
  gap: 1.2rem;
  align-items: start;
}

.public-page {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(1rem, 2.4vw, 2rem);
}

.public-page .layout {
  width: min(1260px, 100%);
  margin: 0;
  padding: clamp(1rem, 1.8vw, 1.7rem);
  align-items: center;
}

.panel,
.admin-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 1.2rem;
  backdrop-filter: blur(6px);
}

.panel h1 {
  font-size: clamp(2rem, 3vw, 3rem);
  line-height: 1;
}

.public-page .panel h1 {
  font-size: clamp(1.72rem, 2.35vw, 2.62rem);
  line-height: 1.04;
}

.intro {
  color: var(--muted);
  margin-top: 0.9rem;
  margin-bottom: 1.2rem;
}

.wish-form {
  display: grid;
  gap: 0.62rem;
}

label {
  font-size: 0.88rem;
  color: #f5dfd3;
}

input,
textarea,
select {
  width: 100%;
  border-radius: 12px;
  border: 1px solid rgba(222, 177, 153, 0.33);
  background: rgba(53, 33, 30, 0.65);
  color: var(--text);
  padding: 0.75rem 0.82rem;
  outline: none;
  font-family: inherit;
}

input:focus,
textarea:focus,
select:focus {
  border-color: rgba(236, 176, 140, 0.86);
  box-shadow: 0 0 0 3px rgba(230, 146, 97, 0.18);
}

button {
  border: 0;
  border-radius: 999px;
  background: linear-gradient(130deg, #bf5a3d 0%, #7d3527 100%);
  color: #fff7f3;
  font-weight: 700;
  padding: 0.72rem 1.18rem;
  cursor: pointer;
  font-family: inherit;
}

button:hover {
  filter: brightness(1.06);
}

.form-actions {
  display: flex;
  align-items: center;
  gap: 0.7rem;
}

#submitStatus,
#loginStatus,
#dashboardStatus {
  color: #f3d8ca;
  font-size: 0.84rem;
}

.tree-section {
  display: grid;
  gap: 0.85rem;
}

.tree-stage {
  position: relative;
  width: min(100%, 900px);
  border-radius: 20px;
  overflow: hidden;
  border: 1px solid rgba(222, 178, 153, 0.3);
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.45);
}

#treeImage {
  display: block;
  width: 100%;
  height: auto;
}

#fxCanvas,
#leafLayer {
  position: absolute;
  inset: 0;
}

#leafLayer {
  pointer-events: none;
}

.leaf {
  position: absolute;
  width: calc(18px * var(--leaf-scale, 1));
  height: calc(25px * var(--leaf-scale, 1));
  padding: 0;
  min-width: 0;
  font-size: 0;
  line-height: 0;
  border: 0;
  border-radius: 70% 0 70% 0;
  -webkit-clip-path: polygon(54% 0%, 78% 10%, 96% 28%, 100% 52%, 92% 72%, 72% 90%, 46% 100%, 22% 90%, 6% 72%, 0% 46%, 12% 22%, 30% 8%);
  clip-path: polygon(54% 0%, 78% 10%, 96% 28%, 100% 52%, 92% 72%, 72% 90%, 46% 100%, 22% 90%, 6% 72%, 0% 46%, 12% 22%, 30% 8%);
  background: linear-gradient(155deg, #a9e56a 4%, #53ab4d 60%, #2f7239 100%);
  transform: translate(-50%, -50%) rotate(var(--rot));
  box-shadow: 0 0 calc(5px + 6px * var(--leaf-scale, 1)) rgba(147, 230, 138, 0.58);
  pointer-events: auto;
  touch-action: manipulation;
  animation: sway 3.2s ease-in-out infinite;
}

.leaf::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 999px;
  background: transparent;
  pointer-events: none;
}

.leaf::after {
  content: "";
  position: absolute;
  width: calc(1px + 1px * var(--leaf-scale, 1));
  height: calc(8px * var(--leaf-scale, 1));
  right: calc(1px * var(--leaf-scale, 1));
  top: calc(17px * var(--leaf-scale, 1));
  background: rgba(61, 111, 62, 0.85);
  transform: rotate(40deg);
  pointer-events: none;
}

.leaf.pop-in {
  animation: pop-in 420ms cubic-bezier(0.2, 1.5, 0.4, 1), sway 3.2s ease-in-out infinite 420ms;
}

.leaf.pending {
  filter: grayscale(0.3);
  opacity: 0.52;
  box-shadow: 0 0 9px rgba(181, 199, 173, 0.45);
  cursor: default;
}

.legend {
  margin: 0;
  color: #000000;
  font-size: 0.9rem;
}

.wish-modal {
  position: fixed;
  inset: 0;
  background: rgba(27, 13, 12, 0.72);
  display: grid;
  place-items: center;
  padding: 1rem;
}

.wish-modal-card {
  width: min(94vw, 540px);
  border-radius: 16px;
  padding: 1.1rem 1.2rem;
  background: rgba(64, 37, 34, 0.95);
  border: 1px solid rgba(230, 184, 159, 0.34);
  position: relative;
}

.close-btn {
  position: absolute;
  right: 0.8rem;
  top: 0.6rem;
  font-size: 1.4rem;
  line-height: 1;
  border-radius: 8px;
  background: transparent;
  color: #ffe6df;
  padding: 0.2rem 0.35rem;
}

#wishText {
  margin-top: 0.7rem;
  line-height: 1.5;
  white-space: pre-wrap;
}

.wish-time {
  margin-top: 0.7rem;
  color: #e7c3b3;
  font-size: 0.86rem;
}

.hidden {
  display: none !important;
}

.admin-page .admin-layout {
  max-width: 1320px;
  margin: 0 auto;
  padding: 1.35rem 1rem;
}

#dashboard {
  display: flex;
  flex-direction: column;
  gap: 0.95rem;
  height: calc(100vh - 2.7rem);
  height: calc(100dvh - 2.7rem);
  overflow: hidden;
}

.dashboard-header {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: center;
  margin-bottom: 0;
}

.dashboard-content {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(360px, 1.16fr) minmax(340px, 1fr);
  gap: 1rem;
}

.wish-queue {
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.login-form {
  margin-top: 1rem;
  display: grid;
  gap: 0.7rem;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  align-items: center;
  margin-bottom: 0.8rem;
}

.toolbar label {
  margin-right: 0.25rem;
}

.ghost-btn {
  background: transparent;
  border: 1px solid rgba(226, 184, 161, 0.45);
  color: #ffe2da;
}

.danger-btn {
  background: linear-gradient(130deg, #cc4a44 0%, #8c2f2a 100%);
  color: #fff4ef;
}

.wish-list {
  display: grid;
  gap: 0.76rem;
  min-height: 0;
  overflow: auto;
  padding-right: 0.22rem;
}

.wish-item {
  border: 1px solid rgba(219, 176, 151, 0.34);
  border-radius: 14px;
  padding: 0.82rem;
  background: rgba(47, 29, 27, 0.76);
  cursor: pointer;
  transition: border-color 140ms ease, box-shadow 140ms ease, transform 140ms ease;
}

.wish-item:hover {
  border-color: rgba(235, 194, 171, 0.52);
}

.wish-item.selected {
  border-color: rgba(255, 196, 135, 0.86);
  box-shadow: 0 0 0 2px rgba(255, 190, 108, 0.25);
  transform: translateY(-1px);
}

.wish-item header {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  color: #f6d4c4;
  font-size: 0.87rem;
}

.wish-select {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  min-width: 0;
}

.wish-select span {
  overflow-wrap: anywhere;
}

.wish-select-checkbox {
  appearance: auto;
  width: 16px !important;
  min-width: 16px;
  height: 16px;
  margin: 0;
  padding: 0;
  border-radius: 4px;
  accent-color: #f3af58;
  border: 0;
  box-shadow: none;
  flex: 0 0 auto;
  cursor: pointer;
}

.wish-select-checkbox:focus {
  box-shadow: none;
  border: 0;
}

.wish-message {
  margin: 0.5rem 0 0.6rem;
  white-space: pre-wrap;
  max-height: 8.4rem;
  overflow: auto;
  padding-right: 0.24rem;
}

.wish-meta {
  color: #dcb3a3;
  font-size: 0.84rem;
}

.wish-actions {
  margin-top: 0.7rem;
  display: flex;
  gap: 0.45rem;
  flex-wrap: wrap;
}

.wish-actions button {
  border-radius: 10px;
  padding: 0.5rem 0.86rem;
  font-size: 0.84rem;
}

.reject-btn {
  background: linear-gradient(130deg, #e2a06f 0%, #b86a49 100%);
  color: #3a1d12;
}

.layout-editor {
  margin-top: 0;
  border-top: 0;
  padding-top: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
  overflow: auto;
  padding-right: 0.2rem;
}

.layout-editor-header h3 {
  margin: 0 0 0.35rem;
  font-size: 1.1rem;
}

.layout-stage {
  position: relative;
  width: 100%;
  max-width: none;
  flex: 0 0 auto;
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid rgba(223, 179, 154, 0.3);
  background: rgba(46, 29, 27, 0.82);
}

#layoutTreeImage {
  display: block;
  width: 100%;
  height: auto;
  user-select: none;
  pointer-events: none;
}

#layoutCanvas {
  position: absolute;
  inset: 0;
  touch-action: none;
  cursor: crosshair;
}

.layout-controls {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  flex-wrap: wrap;
}

.layout-controls input {
  width: 140px;
}

.layout-actions {
  display: flex;
  gap: 0.6rem;
  align-items: center;
  flex-wrap: wrap;
}

#layoutStatus {
  color: #f3d8ca;
  font-size: 0.84rem;
}

.wish-list,
.wish-message,
.layout-editor {
  scrollbar-width: thin;
  scrollbar-color: rgba(232, 187, 152, 0.56) rgba(73, 43, 39, 0.65);
}

.wish-list::-webkit-scrollbar,
.wish-message::-webkit-scrollbar,
.layout-editor::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

.wish-list::-webkit-scrollbar-thumb,
.wish-message::-webkit-scrollbar-thumb,
.layout-editor::-webkit-scrollbar-thumb {
  background: rgba(232, 187, 152, 0.56);
  border-radius: 999px;
}

.wish-list::-webkit-scrollbar-track,
.wish-message::-webkit-scrollbar-track,
.layout-editor::-webkit-scrollbar-track {
  background: rgba(73, 43, 39, 0.65);
}

@keyframes sway {
  0% {
    transform: translate(-50%, -50%) rotate(calc(var(--rot) - 4deg));
  }
  50% {
    transform: translate(-50%, -50%) rotate(calc(var(--rot) + 5deg));
  }
  100% {
    transform: translate(-50%, -50%) rotate(calc(var(--rot) - 4deg));
  }
}

@keyframes pop-in {
  0% {
    transform: translate(-50%, -50%) scale(0.15) rotate(var(--rot));
    opacity: 0;
  }
  100% {
    transform: translate(-50%, -50%) scale(1) rotate(var(--rot));
    opacity: 1;
  }
}

@media (max-width: 980px) {
  .public-page {
    display: block;
    padding: 0;
  }

  .public-page .layout {
    width: auto;
    margin: 0 auto;
    padding: 1.2rem 1rem 1.4rem;
    align-items: start;
  }

  .layout {
    grid-template-columns: 1fr;
  }

  .tree-stage {
    width: 100%;
  }

  .admin-page .admin-layout {
    padding: 1rem 0.7rem;
  }

  #dashboard {
    height: calc(100vh - 2rem);
    height: calc(100dvh - 2rem);
  }

  .dashboard-content {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(0, 1fr) minmax(0, 1fr);
    gap: 0.75rem;
  }
}

@media (max-width: 760px) {
  .toolbar {
    gap: 0.5rem;
  }

  .wish-item {
    padding: 0.72rem;
  }

  .wish-message {
    max-height: 6.6rem;
  }
}
