:root {
  --bg0: #070912;
  --bg1: #0d1224;
  --ink: #e8e4d8;
  --ink-dim: #9b96a8;
  --gold: #f6c453;
  --gold-soft: #ffd77a;
  --gold-dark: #c8963e;
  --wood: #8b5a2b;
  --card: #141a2e;
  --card-edge: #232c4a;
  --danger: #ff7a5c;
  font-size: 16px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }

body {
  font-family: ui-rounded, "SF Pro Rounded", system-ui, -apple-system, "Segoe UI", sans-serif;
  background:
    radial-gradient(1200px 800px at 50% 120%, #1a1430 0%, transparent 60%),
    radial-gradient(900px 600px at 80% -10%, #101a38 0%, transparent 55%),
    linear-gradient(var(--bg1), var(--bg0));
  color: var(--ink);
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  overflow-x: hidden;
}

#fx {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 3;
}

.wrap {
  position: relative;
  z-index: 4;
  width: 100%;
  max-width: 560px;
  padding: 24px 20px 60px;
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 1;
}
.wrap-center { justify-content: center; padding-bottom: 24px; }

.brand {
  align-self: flex-start;
  font-size: 0.95rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-dim);
  text-decoration: none;
  margin-bottom: 8px;
}
.brand b { color: var(--gold-soft); font-weight: 600; }

/* ---------- chest scene ---------- */

.scene {
  position: relative;
  width: 320px;
  height: 340px;
  margin: 24px auto 0;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.glow {
  position: absolute;
  left: 50%; bottom: 10px;
  width: 340px; height: 200px;
  transform: translateX(-50%);
  background: radial-gradient(closest-side, rgba(246, 196, 83, 0.28), transparent 70%);
  filter: blur(6px);
  animation: glowPulse 3.2s ease-in-out infinite;
  pointer-events: none;
}
@keyframes glowPulse {
  0%, 100% { opacity: 0.55; transform: translateX(-50%) scale(1); }
  50% { opacity: 1; transform: translateX(-50%) scale(1.08); }
}

.rays {
  position: absolute;
  left: 50%; bottom: 90px;
  width: 420px; height: 420px;
  transform: translate(-50%, 45%);
  background: conic-gradient(
    from -8deg at 50% 50%,
    transparent 0deg 6deg, rgba(255, 215, 122, 0.10) 6deg 14deg,
    transparent 14deg 32deg, rgba(255, 215, 122, 0.08) 32deg 40deg,
    transparent 40deg 58deg, rgba(255, 215, 122, 0.12) 58deg 66deg,
    transparent 66deg 90deg, rgba(255, 215, 122, 0.09) 90deg 98deg,
    transparent 98deg 122deg, rgba(255, 215, 122, 0.11) 122deg 130deg,
    transparent 130deg 152deg, rgba(255, 215, 122, 0.08) 152deg 160deg,
    transparent 160deg 360deg
  );
  border-radius: 50%;
  opacity: 0;
  transition: opacity 0.9s ease;
  animation: raySpin 26s linear infinite;
  pointer-events: none;
}
@keyframes raySpin { to { transform: translate(-50%, 45%) rotate(360deg); } }
.opened .rays { opacity: 1; }

.chest {
  position: relative;
  width: 220px;
  perspective: 720px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  animation: chestBob 3.2s ease-in-out infinite;
  transition: filter 0.5s ease;
}
@keyframes chestBob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}
.opened .chest, .empty .chest { animation: none; cursor: default; }
.empty .chest { filter: saturate(0.15) brightness(0.7); }

.chest.shake { animation: chestShake 0.5s ease; }
@keyframes chestShake {
  0%, 100% { transform: rotate(0); }
  20% { transform: rotate(-3deg); }
  40% { transform: rotate(3deg); }
  60% { transform: rotate(-2.5deg); }
  80% { transform: rotate(2deg); }
}

.lid {
  position: relative;
  z-index: 2;
  transform-origin: 50% 100%;
  transform: rotateX(0deg);
  transition: transform 0.85s cubic-bezier(0.34, 1.3, 0.5, 1);
  will-change: transform;
}
.opened .lid { transform: rotateX(108deg); }
.empty .lid { transform: rotateX(24deg); transition: none; }

.lid svg, .base svg { display: block; width: 100%; height: auto; }

.mouth {
  position: absolute;
  left: 14px; right: 14px;
  top: 76px;
  height: 26px;
  border-radius: 50%;
  background: radial-gradient(closest-side, var(--gold-soft) 0%, rgba(246, 196, 83, 0.5) 55%, transparent 75%);
  filter: blur(4px);
  opacity: 0;
  transition: opacity 0.6s ease 0.15s;
  z-index: 1;
}
.opened .mouth { opacity: 1; }

.base { position: relative; z-index: 0; margin-top: -6px; }

.hint {
  margin-top: 26px;
  text-align: center;
  color: var(--ink-dim);
  font-size: 0.95rem;
  transition: opacity 0.4s ease;
}
.hint .title {
  display: block;
  color: var(--ink);
  font-size: 1.25rem;
  margin-bottom: 6px;
  letter-spacing: 0.01em;
}
.hint .tap { animation: hintFade 2.4s ease-in-out infinite; }
@keyframes hintFade { 0%, 100% { opacity: 0.5; } 50% { opacity: 1; } }

.countdown { color: var(--gold-dark); font-size: 0.85rem; margin-top: 10px; }

/* ---------- reveal card ---------- */

.reveal {
  position: relative;
  z-index: 5;
  width: 100%;
  max-width: 480px;
  margin-top: 0;
  opacity: 0;
  transform: translateY(90px) scale(0.85);
  pointer-events: none;
  transition: transform 0.9s cubic-bezier(0.2, 1.4, 0.4, 1) 0.35s, opacity 0.6s ease 0.35s;
}
.opened .reveal {
  margin-top: -260px;
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

.card {
  background: linear-gradient(180deg, #fdf6e3, #f3e7c7);
  color: #3c2f1b;
  border-radius: 14px;
  padding: 26px 26px 22px;
  box-shadow:
    0 0 0 1px rgba(200, 150, 62, 0.55),
    0 0 40px rgba(246, 196, 83, 0.25),
    0 24px 50px rgba(0, 0, 0, 0.55);
}
.card .msg {
  white-space: pre-wrap;
  overflow-wrap: break-word;
  font-size: 1.06rem;
  line-height: 1.55;
  font-family: Georgia, "Times New Roman", serif;
}
.card .meta {
  margin-top: 18px;
  padding-top: 12px;
  border-top: 1px dashed rgba(120, 90, 40, 0.4);
  font-size: 0.8rem;
  color: #8a713f;
  display: flex;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.file-row { display: flex; align-items: center; gap: 14px; }
.file-icon { font-size: 2rem; }
.file-name { font-weight: 600; word-break: break-all; }
.file-size { color: #8a713f; font-size: 0.85rem; margin-top: 2px; }

/* ---------- buttons & form ---------- */

.btn {
  display: inline-block;
  border: none;
  border-radius: 10px;
  padding: 12px 22px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  background: linear-gradient(180deg, var(--gold-soft), var(--gold-dark));
  color: #34250d;
  box-shadow: 0 3px 0 #916a25, 0 8px 20px rgba(246, 196, 83, 0.25);
  transition: transform 0.12s ease, box-shadow 0.12s ease, filter 0.2s ease;
  text-decoration: none;
}
.btn:hover { filter: brightness(1.06); }
.btn:active { transform: translateY(2px); box-shadow: 0 1px 0 #916a25; }
.btn:disabled { filter: saturate(0.3) brightness(0.7); cursor: not-allowed; }
.btn.ghost {
  background: transparent;
  color: var(--ink-dim);
  box-shadow: inset 0 0 0 1px var(--card-edge);
}
.btn.small { padding: 8px 14px; font-size: 0.85rem; }

.panel {
  width: 100%;
  background: rgba(20, 26, 46, 0.85);
  border: 1px solid var(--card-edge);
  border-radius: 16px;
  padding: 22px;
  backdrop-filter: blur(8px);
  margin-top: 22px;
}

.tabs { display: flex; gap: 8px; margin-bottom: 16px; }
.tab {
  flex: 1;
  padding: 10px;
  border-radius: 10px;
  border: 1px solid var(--card-edge);
  background: transparent;
  color: var(--ink-dim);
  font: inherit;
  cursor: pointer;
  transition: all 0.15s ease;
}
.tab.active {
  background: rgba(246, 196, 83, 0.12);
  border-color: var(--gold-dark);
  color: var(--gold-soft);
}

textarea, input[type="password"], input[type="text"] {
  width: 100%;
  background: rgba(7, 9, 18, 0.7);
  border: 1px solid var(--card-edge);
  border-radius: 10px;
  color: var(--ink);
  font: inherit;
  padding: 12px 14px;
  resize: vertical;
  outline: none;
  transition: border-color 0.15s ease;
}
textarea:focus, input:focus { border-color: var(--gold-dark); }
textarea { min-height: 130px; }

.drop {
  border: 2px dashed var(--card-edge);
  border-radius: 12px;
  padding: 32px 16px;
  text-align: center;
  color: var(--ink-dim);
  cursor: pointer;
  transition: all 0.15s ease;
}
.drop:hover, .drop.over { border-color: var(--gold-dark); color: var(--gold-soft); background: rgba(246, 196, 83, 0.06); }
.drop .picked { color: var(--ink); font-weight: 600; word-break: break-all; }

.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 16px; }
.row .label { color: var(--ink-dim); font-size: 0.85rem; margin-right: 4px; }

.chip {
  padding: 7px 14px;
  border-radius: 999px;
  border: 1px solid var(--card-edge);
  background: transparent;
  color: var(--ink-dim);
  font: inherit;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.15s ease;
}
.chip.active {
  background: rgba(246, 196, 83, 0.14);
  border-color: var(--gold-dark);
  color: var(--gold-soft);
}

.toggle { display: flex; align-items: center; gap: 8px; cursor: pointer; user-select: none; color: var(--ink-dim); font-size: 0.9rem; }
.toggle input { accent-color: var(--gold-dark); width: 16px; height: 16px; }
.toggle.on { color: var(--danger); }

.actions { display: flex; align-items: center; gap: 12px; margin-top: 20px; }

.error { color: var(--danger); font-size: 0.88rem; margin-top: 12px; min-height: 1.2em; }

/* result */
.linkbox {
  display: flex;
  gap: 8px;
  margin-top: 14px;
}
.linkbox input {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.9rem;
  color: var(--gold-soft);
}
.result-meta { color: var(--ink-dim); font-size: 0.85rem; margin-top: 12px; }
.burn-note { color: var(--danger); }

.keyrow { margin-top: 14px; }
.keyrow summary { color: var(--ink-dim); font-size: 0.82rem; cursor: pointer; }
.keyrow input { margin-top: 8px; }

.foot {
  margin-top: auto;
  padding-top: 40px;
  color: rgba(155, 150, 168, 0.4);
  font-size: 0.75rem;
  text-align: center;
}

@media (max-width: 420px) {
  .scene { transform: scale(0.85); margin-top: 0; }
  .reveal { margin-top: -230px; }
}
