:root {
  --bg-top: #f2e6c8;
  --bg-mid: #d6b588;
  --bg-low: #7f6244;
  --card: #fff8ea;
  --line: #3f2f21;
  --text: #2a1d13;
  --muted: #6f5845;
  --accent: #b1681a;
  --accent-dark: #8a4f14;
  --ok: #2f7d3a;
  --error: #af2f2f;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Palatino Linotype", "Book Antiqua", serif;
  color: var(--text);
  background:
    radial-gradient(circle at 8% 12%, #ffefc7 0, transparent 26%),
    radial-gradient(circle at 90% 16%, #f8dba8 0, transparent 30%),
    linear-gradient(180deg, var(--bg-top) 0%, var(--bg-mid) 55%, var(--bg-low) 100%);
  min-height: 100vh;
}

.page {
  position: relative;
  overflow: hidden;
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1.5rem;
}

.page::before,
.page::after {
  content: "";
  position: absolute;
  width: 180px;
  height: 180px;
  border: 14px solid rgba(64, 43, 26, 0.17);
  border-radius: 24px;
  transform: rotate(12deg);
  z-index: 0;
  animation: drift 7s ease-in-out infinite;
}

.page::before {
  left: -78px;
  top: 10%;
}

.page::after {
  right: -80px;
  bottom: 8%;
  animation-delay: 0.8s;
}

.card {
  position: relative;
  z-index: 1;
  width: min(560px, 100%);
  background: var(--card);
  border: 3px solid var(--line);
  border-radius: 18px;
  padding: 1.25rem 1.25rem 1.35rem;
  box-shadow: 0 18px 34px rgba(24, 15, 8, 0.28);
  animation: card-enter 460ms ease both;
}

.riddle-card::before,
.puzzle-next::before {
  content: "";
  position: absolute;
  inset: 8px;
  border: 1px dashed #ba9769;
  border-radius: 12px;
  pointer-events: none;
}

.eyebrow {
  margin: 0;
  font-family: "Courier New", Courier, monospace;
  font-size: 0.78rem;
  letter-spacing: 0.11em;
  text-transform: uppercase;
  color: var(--muted);
}

.card h1 {
  margin: 0.35rem 0 0.65rem;
  font-size: clamp(1.4rem, 3.5vw, 2rem);
  line-height: 1.18;
}

.card p {
  line-height: 1.45;
}

.puzzle-track {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.4rem;
  align-items: center;
  margin: 0.9rem 0 0.8rem;
  padding: 0.64rem 0.8rem;
  border-radius: 10px;
  background: linear-gradient(90deg, #efe2c6 0%, #f7ecd8 100%);
  border: 1px solid #c9ad81;
}

.one-hint {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.75rem;
  grid-template-columns: unset;
  min-height: 74px;
}

.hint-one-icon {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: 2px solid #6f4a25;
  background: radial-gradient(circle at 30% 30%, #fff3da 0%, #e8c790 70%, #d1a764 100%);
  box-shadow: inset 0 3px 0 rgba(255, 255, 255, 0.6), 0 6px 14px rgba(73, 45, 17, 0.28);
  display: grid;
  place-items: center;
}

.hint-one-icon::before {
  content: "1th";
  font-family: "Courier New", Courier, monospace;
  font-size: 1.45rem;
  font-weight: 800;
  color: #5a3b19;
  line-height: 1;
}

.hint-fa-eye {
  font-size: 1.55rem;
  color: #5e3f1f;
  background: linear-gradient(180deg, #fff6e2 0%, #e6c892 100%);
  border: 2px solid #6f4a25;
  border-radius: 12px;
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.7), 0 4px 10px rgba(73, 45, 17, 0.2);
}

.hint-eye-icon {
  width: 64px;
  height: 36px;
  position: relative;
  border: 2px solid #5e3f1f;
  border-radius: 65% 35% 68% 32% / 55% 45% 55% 45%;
  background: linear-gradient(180deg, #fffef9 0%, #f0e0c0 100%);
  box-shadow: inset 0 3px 0 rgba(255, 255, 255, 0.85), 0 4px 10px rgba(73, 45, 17, 0.22);
  transform: rotate(-2deg);
}

.hint-eye-icon::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 20px;
  height: 20px;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: radial-gradient(circle at 35% 32%, #95d1ff 0%, #3d7daf 48%, #122e45 78%);
  border: 1px solid #1b3e5a;
  box-shadow: inset 0 0 0 4px #112133;
}

.hint-eye-icon::after {
  content: "";
  position: absolute;
  left: 57%;
  top: 42%;
  width: 6px;
  height: 6px;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: #ffffff;
}

.hint-panel {
  grid-template-columns: auto 1fr;
  gap: 0.7rem;
}

.hint-icons {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding-top: 0.1rem;
}

.shape {
  display: inline-block;
  width: 15px;
  height: 15px;
  border: 2px solid #6f4a25;
  background: #f5e1bf;
}

.shape-circle {
  border-radius: 50%;
}

.shape-square {
  border-radius: 3px;
}

.shape-triangle {
  width: 0;
  height: 0;
  border-left: 9px solid transparent;
  border-right: 9px solid transparent;
  border-bottom: 15px solid #6f4a25;
  border-top: 0;
  background: transparent;
}

.track-label {
  font-weight: 800;
  color: #5a4029;
}

.track-value {
  color: #4c3827;
  font-size: 0.95rem;
}

.chest {
  position: relative;
  width: min(280px, 100%);
  height: 186px;
  margin: 1.05rem auto;
}

.chest-top,
.chest-bottom {
  border: 3px solid #4f5965;
  background: linear-gradient(145deg, #cfd5de 0%, #9aa5b4 60%, #808b99 100%);
}

.chest-top {
  position: absolute;
  left: 52%;
  top: 28px;
  width: 124px;
  height: 124px;
  border-radius: 16px;
  transform: translateX(-50%);
  transform-origin: center;
  transition: transform 0.6s ease, opacity 0.35s ease;
  box-shadow: inset 0 4px 0 rgba(255, 255, 255, 0.42), 0 8px 16px rgba(39, 48, 58, 0.3);
  z-index: 2;
}

.chest-bottom {
  position: absolute;
  left: 0;
  bottom: 4px;
  width: 100%;
  height: 168px;
  border-radius: 18px;
  box-shadow: inset 0 5px 0 rgba(255, 255, 255, 0.38), 0 10px 20px rgba(25, 31, 39, 0.25);
}

.chest-bottom::before,
.chest-bottom::after {
  content: "";
  position: absolute;
  top: 14px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #6d7785;
  border: 2px solid #4e5763;
}

.chest-bottom::before {
  left: 14px;
}

.chest-bottom::after {
  right: 14px;
}

.chest-lock {
  position: absolute;
  left: 50%;
  top: 72px;
  transform: translateX(-50%);
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, #eef2f7 0%, #b7c0cc 65%, #8f9aaa 100%);
  border: 3px solid #55606e;
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.62);
  transition: opacity 0.25s ease, transform 0.5s ease;
  z-index: 3;
  display: grid;
  place-items: center;
}

.chest-lock i {
  color: #4b5562;
  font-size: 1.05rem;
}

.chest.unlocked .chest-top {
  transform: translateX(-50%) translateX(92px) rotate(10deg);
  opacity: 0.2;
}

.chest.unlocked .chest-lock {
  opacity: 0;
  transform: translateX(-50%) scale(0.6) rotate(160deg);
}

.unlock-form {
  display: grid;
  gap: 0.68rem;
}

.input-wrap {
  position: relative;
}

.unlock-form input {
  width: 100%;
  border: 2px solid #ccb28f;
  border-radius: 10px;
  padding: 0.74rem 0.84rem;
  font-size: 1rem;
  font-family: "Courier New", Courier, monospace;
  letter-spacing: 0.04em;
}

.unlock-form input:focus {
  outline: none;
  border-color: #8b602e;
  box-shadow: 0 0 0 3px rgba(186, 135, 71, 0.25);
}

.helper-text {
  margin: 0;
  font-size: 0.88rem;
  color: var(--muted);
}

button {
  cursor: pointer;
  border: 0;
  border-radius: 10px;
  padding: 0.8rem 0.92rem;
  font-weight: 700;
  font-family: "Courier New", Courier, monospace;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #fff;
  background: linear-gradient(180deg, #c17723 0%, var(--accent) 100%);
  box-shadow: 0 5px 0 #6e3f0f;
  transition: transform 140ms ease, box-shadow 140ms ease, background 140ms ease;
}

button:hover {
  background: linear-gradient(180deg, #d5892f 0%, var(--accent-dark) 100%);
}

button:active {
  transform: translateY(2px);
  box-shadow: 0 3px 0 #6e3f0f;
}

.secondary-btn {
  max-width: 260px;
}

.message {
  min-height: 1.3rem;
  margin: 0.68rem 0 0;
  font-weight: 700;
}

.message.ok {
  color: var(--ok);
}

.message.error {
  color: var(--error);
}

.card-success {
  border-color: #34613f;
  background: linear-gradient(180deg, #f8fff6 0%, #edf8eb 100%);
}

.card-success h1 {
  color: #224f2f;
}

.countdown-widget {
  position: fixed;
  z-index: 1000;
  pointer-events: none;
  transition: all 580ms cubic-bezier(0.2, 0.75, 0.25, 1);
}

.countdown-panel {
  background: linear-gradient(180deg, #fff4de 0%, #efd2a4 100%);
  border: 2px solid #6f4a25;
  border-radius: 14px;
  box-shadow: 0 16px 34px rgba(28, 17, 7, 0.28);
  color: #4a321d;
}

.countdown-title {
  margin: 0;
  font-family: "Courier New", Courier, monospace;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 800;
  text-align: center;
}

.countdown-subtitle {
  margin: 0;
  text-align: center;
  font-size: 0.88rem;
  color: #6e543c;
}

.countdown-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(56px, 1fr));
  gap: 0.45rem;
}

.countdown-cell {
  background: #fff8ea;
  border: 1px solid #c9a775;
  border-radius: 10px;
  padding: 0.36rem 0.28rem;
  text-align: center;
}

.countdown-cell span {
  display: block;
  font-family: "Courier New", Courier, monospace;
  font-weight: 800;
  font-size: 1.14rem;
  line-height: 1;
}

.countdown-cell small {
  display: block;
  margin-top: 0.22rem;
  font-size: 0.71rem;
  text-transform: uppercase;
  color: #70563f;
}

.countdown-fullscreen {
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(24, 14, 6, 0.62);
}

.countdown-fullscreen .countdown-panel {
  width: min(92vw, 640px);
  padding: 1.35rem 1.1rem;
}

.countdown-fullscreen .countdown-title {
  font-size: clamp(1.3rem, 5vw, 2rem);
}

.countdown-fullscreen .countdown-subtitle {
  margin-top: 0.25rem;
  margin-bottom: 0.75rem;
  font-size: clamp(0.9rem, 2.4vw, 1rem);
}

.countdown-fullscreen .countdown-cell span {
  font-size: clamp(1.2rem, 4.1vw, 2rem);
}

.countdown-fullscreen .countdown-cell small {
  font-size: clamp(0.68rem, 2vw, 0.82rem);
}

.countdown-docked {
  top: 10px;
  right: 10px;
}

.countdown-docked .countdown-panel {
  width: min(92vw, 330px);
  padding: 0.58rem 0.64rem;
  box-shadow: 0 10px 20px rgba(28, 17, 7, 0.25);
  animation: countdown-to-corner 700ms cubic-bezier(0.2, 0.76, 0.28, 1) both;
}

.countdown-docked .countdown-title {
  font-size: 0.74rem;
}

.countdown-docked .countdown-subtitle {
  font-size: 0.7rem;
  margin-top: 0.05rem;
  margin-bottom: 0.4rem;
}

.countdown-docked .countdown-grid {
  gap: 0.3rem;
}

.countdown-docked .countdown-cell {
  padding: 0.24rem 0.16rem;
}

.countdown-docked .countdown-cell span {
  font-size: 0.9rem;
}

.countdown-docked .countdown-cell small {
  font-size: 0.62rem;
  margin-top: 0.12rem;
}

.countdown-ended .countdown-panel {
  border-color: #2c7f38;
  background: linear-gradient(180deg, #f8fff8 0%, #dcf3df 100%);
}

@keyframes card-enter {
  from {
    opacity: 0;
    transform: translateY(18px) scale(0.98);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes drift {
  0%,
  100% {
    transform: rotate(12deg) translateY(0);
  }

  50% {
    transform: rotate(16deg) translateY(-10px);
  }
}

@keyframes countdown-to-corner {
  from {
    transform: translate(-32vw, 26vh) scale(1.08);
    opacity: 0.98;
  }

  to {
    transform: translate(0, 0) scale(1);
    opacity: 1;
  }
}

@media (max-width: 480px) {
  .page {
    padding: 1rem;
  }

  .page::before,
  .page::after {
    width: 130px;
    height: 130px;
    border-width: 10px;
  }

  .card {
    padding: 1rem;
    border-width: 2px;
  }

  .chest {
    height: 156px;
  }

  .chest-bottom {
    height: 92px;
  }

  .puzzle-track {
    grid-template-columns: 1fr;
    gap: 0.2rem;
  }

  .hint-panel {
    grid-template-columns: 1fr;
    gap: 0.35rem;
  }

  .secondary-btn,
  button {
    width: 100%;
    max-width: none;
  }

  .countdown-docked {
    top: 8px;
    right: 8px;
  }

  .countdown-docked .countdown-panel {
    width: min(95vw, 305px);
    padding: 0.5rem 0.56rem;
  }

  .countdown-docked .countdown-grid {
    grid-template-columns: repeat(4, minmax(48px, 1fr));
    gap: 0.22rem;
  }
}
