/* Klondike Solitaire Treasures — The Sunken Vault
   Deep-abyss table, gold filigree, glass panels. No external assets. */

:root {
  --gold: #d8b24a;
  --gold-hi: #f3df9a;
  --gold-dim: rgba(216, 178, 74, .38);
  --abyss: #07202b;
  --abyss-2: #0b3140;
  --ink: #1d2b33;
  --ivory: #faf6ec;
  --crimson: #c0392b;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: Georgia, 'Palatino Linotype', 'Times New Roman', serif;
  background: #f4efe3;
  color: var(--ink);
  -webkit-tap-highlight-color: transparent;
}

/* ---------- page chrome ---------- */

.site-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 20px;
  border-bottom: 1px solid rgba(29, 43, 51, .12);
}
.logo { font-weight: bold; font-size: 20px; text-decoration: none; color: var(--ink); }
.logo span { color: #0b6a7e; }
.site-nav { font-size: 14px; color: #6b7a83; }
.site-nav a { color: #0b6a7e; text-decoration: none; }
.site-nav em { font-style: normal; color: var(--ink); }

.main { max-width: 1060px; margin: 0 auto; padding: 18px 16px 60px; }
.main h1 { font-size: 30px; margin: 10px 0 4px; letter-spacing: .5px; }
.tagline { color: #5c6d77; margin: 0 0 18px; font-style: italic; }

.article { margin-top: 34px; max-width: 860px; }
.article h2 { font-size: 22px; border-bottom: 2px solid var(--gold-dim); padding-bottom: 6px; }
.article h3 { font-size: 17px; margin: 18px 0 6px; }
.article p, .article li { font-size: 15px; line-height: 1.65; color: #33434c; }
.article table { border-collapse: collapse; width: 100%; font-size: 14px; margin: 10px 0; }
.article th, .article td { border: 1px solid rgba(29,43,51,.18); padding: 7px 10px; text-align: left; }
.article th { background: rgba(216,178,74,.14); }
.faq dt { font-weight: bold; margin-top: 14px; }
.faq dd { margin: 4px 0 0; color: #33434c; font-size: 15px; line-height: 1.6; }

/* ---------- stage ---------- */

.stage-wrap { display: flex; justify-content: center; }
.stage {
  position: relative;
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 1020px;
  height: min(78vh, 700px);
  min-height: 460px;
  border-radius: 18px;
  overflow: hidden;
  background:
    radial-gradient(120% 90% at 50% -10%, rgba(64, 160, 170, .28), transparent 60%),
    radial-gradient(90% 70% at 50% 115%, rgba(10, 60, 75, .55), transparent 55%),
    linear-gradient(180deg, #0d3543 0%, #082631 55%, #051a23 100%);
  box-shadow: 0 24px 60px rgba(4, 24, 32, .45), inset 0 0 0 1px rgba(216, 178, 74, .25);
  user-select: none;
  touch-action: none;
}
#boardWrap { flex: 1; position: relative; }
.stage::before {
  content: '';
  position: absolute; inset: 0;
  background: repeating-linear-gradient(60deg, transparent 0 46px, rgba(255,255,255,.012) 46px 48px);
  pointer-events: none;
}

/* ---------- board ---------- */

#board { position: absolute; inset: 0; }
#board.dimmed { filter: brightness(.55) saturate(.8); }

.slot {
  position: absolute;
  border-radius: calc(var(--cw, 70px) * .1);
  border: 1px solid rgba(216, 178, 74, .3);
  background: rgba(3, 18, 25, .45);
  box-shadow: inset 0 2px 10px rgba(0, 0, 0, .5);
}
.slot.hint-dst { border-color: var(--gold-hi); box-shadow: 0 0 16px rgba(243, 223, 154, .8), inset 0 0 10px rgba(243,223,154,.4); }

.stock-slot .stock-orn {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: calc(var(--cw, 70px) * .42);
  color: rgba(216, 178, 74, .4);
  text-shadow: 0 0 14px rgba(216, 178, 74, .3);
}
.stock-slot .recycle-ico {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: calc(var(--cw, 70px) * .5);
  color: var(--gold-hi);
  animation: spinPulse 1.6s ease-in-out infinite;
}
@keyframes spinPulse { 0%, 100% { transform: scale(1); opacity: .75; } 50% { transform: scale(1.16); opacity: 1; } }

.act-tag {
  position: absolute;
  font-size: 12px; letter-spacing: 2.5px; text-transform: uppercase;
  color: rgba(243, 223, 154, .75);
  text-shadow: 0 0 8px rgba(216, 178, 74, .4);
  white-space: nowrap; pointer-events: none;
}

.found-slot { display: flex; align-items: center; justify-content: center; }
.found-slot .found-ghost {
  font-size: calc(var(--cw, 70px) * .4);
  opacity: .22; filter: grayscale(.6);
  transition: opacity .5s, filter .5s, transform .5s;
}
.found-slot .found-gem { display: none; }
.found-slot.sealed { border-color: var(--gold-hi); box-shadow: 0 0 22px rgba(243, 223, 154, .55), inset 0 0 14px rgba(243, 223, 154, .3); }
.found-slot.sealed .found-ghost { opacity: 1; filter: none; transform: scale(1.12); }
.found-slot.seal-flash::after {
  content: ''; position: absolute; inset: -4px; border-radius: inherit;
  border: 2px solid var(--gold-hi);
  animation: sealRing 1.5s ease-out forwards;
}
@keyframes sealRing {
  0% { transform: scale(1); opacity: 1; }
  100% { transform: scale(2.1); opacity: 0; }
}

/* ---------- cards ---------- */

.card {
  position: absolute;
  perspective: 900px;
  transition: left .3s cubic-bezier(.35, .9, .3, 1), top .3s cubic-bezier(.35, .9, .3, 1);
  cursor: pointer;
  will-change: left, top;
}
.card.no-anim { transition: none; }
.card.dragging { transition: none; cursor: grabbing; }
.card.hint-src .front { box-shadow: 0 0 0 2px var(--gold-hi), 0 0 18px rgba(243, 223, 154, .9); }

.card-inner {
  position: absolute; inset: 0;
  transform-style: preserve-3d;
  transition: transform .32s ease;
  border-radius: calc(var(--cw, 70px) * .095);
}
.card.up .card-inner { transform: rotateY(0deg); }
.card:not(.up) .card-inner { transform: rotateY(180deg); }

.face {
  position: absolute; inset: 0;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  border-radius: inherit;
  overflow: hidden;
}
.face.front {
  background: linear-gradient(155deg, #fffdf6 0%, #f7f1df 70%, #efe6cc 100%);
  border: 1px solid rgba(90, 70, 20, .35);
  box-shadow: 0 2px 6px rgba(0, 0, 0, .35);
  color: #17242c;
}
.card.red .face.front { color: var(--crimson); }
.face.back {
  transform: rotateY(180deg);
  background:
    radial-gradient(circle at 50% 50%, rgba(243, 223, 154, .16) 0 12%, transparent 13%),
    repeating-linear-gradient(45deg, rgba(216, 178, 74, .12) 0 6px, transparent 6px 12px),
    repeating-linear-gradient(-45deg, rgba(216, 178, 74, .12) 0 6px, transparent 6px 12px),
    linear-gradient(160deg, #123c4d, #082631);
  border: 1px solid rgba(216, 178, 74, .5);
  box-shadow: 0 2px 6px rgba(0, 0, 0, .4);
}
.back-orn {
  position: absolute; inset: calc(var(--cw, 70px) * .07);
  border: 1px solid rgba(216, 178, 74, .55);
  border-radius: calc(var(--cw, 70px) * .05);
}
.back-orn::after {
  content: '❖';
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: calc(var(--cw, 70px) * .34);
  color: rgba(243, 223, 154, .65);
}

.corner {
  position: absolute;
  display: flex; flex-direction: column; align-items: center;
  line-height: 1;
  font-family: 'Times New Roman', serif;
}
.corner b { font-size: calc(var(--cw, 70px) * .21); }
.corner i { font-style: normal; font-size: calc(var(--cw, 70px) * .18); margin-top: 1px; }
.corner.tl { top: calc(var(--cw, 70px) * .055); left: calc(var(--cw, 70px) * .07); }
.corner.br { bottom: calc(var(--cw, 70px) * .055); right: calc(var(--cw, 70px) * .07); transform: rotate(180deg); }
.pip {
  position: absolute; top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  font-size: calc(var(--cw, 70px) * .5);
  opacity: .9;
  text-shadow: 0 1px 0 rgba(255, 255, 255, .6);
}

/* ---------- sparkles ---------- */

.spark {
  position: absolute;
  width: 7px; height: 7px;
  border-radius: 50%;
  background: radial-gradient(circle, #fff7d8 0%, var(--gold) 55%, transparent 75%);
  pointer-events: none;
  animation: sparkFly 1s ease-out forwards;
  z-index: 2000;
}
@keyframes sparkFly {
  0% { transform: translate(0, 0) scale(1); opacity: 1; }
  100% { transform: translate(var(--dx), var(--dy)) scale(.2); opacity: 0; }
}

/* ---------- HUD ---------- */

.hud {
  position: relative;
  display: flex; align-items: center; gap: 8px;
  padding: 9px 12px;
  z-index: 1500;
  flex-wrap: wrap;
  background: linear-gradient(180deg, rgba(3, 16, 22, .55), rgba(3, 16, 22, .25));
  border-bottom: 1px solid rgba(216, 178, 74, .22);
}
.hud-chip {
  background: rgba(3, 18, 25, .6);
  border: 1px solid rgba(216, 178, 74, .35);
  color: var(--gold-hi);
  font-size: 13px;
  padding: 5px 11px;
  border-radius: 999px;
  backdrop-filter: blur(4px);
  white-space: nowrap;
}
.hud .spacer { flex: 1; pointer-events: none; }
.hud-btn {
  background: linear-gradient(180deg, rgba(216, 178, 74, .92), rgba(176, 134, 38, .92));
  border: 1px solid rgba(243, 223, 154, .8);
  color: #241a05;
  font-family: inherit;
  font-weight: bold;
  font-size: 13px;
  padding: 6px 13px;
  border-radius: 999px;
  cursor: pointer;
  transition: transform .15s, box-shadow .15s;
}
.hud-btn:hover { transform: translateY(-1px); box-shadow: 0 4px 14px rgba(216, 178, 74, .4); }
.hud-btn:active { transform: translateY(0); }
.hud-btn.ghost {
  background: rgba(3, 18, 25, .55);
  color: var(--gold-hi);
  border-color: rgba(216, 178, 74, .45);
}
#btnFinish {
  background: linear-gradient(180deg, #7ee0c0, #2fa383);
  border-color: #b8f4e0; color: #03251c;
  animation: glowPulse 1.4s ease-in-out infinite;
}
@keyframes glowPulse { 0%, 100% { box-shadow: 0 0 8px rgba(126, 224, 192, .5); } 50% { box-shadow: 0 0 22px rgba(126, 224, 192, .95); } }

/* ---------- overlays ---------- */

.overlay {
  position: absolute; inset: 0;
  z-index: 3000;
  display: flex; align-items: center; justify-content: center;
  background: rgba(3, 15, 21, .72);
  backdrop-filter: blur(3px);
  padding: 18px;
}
.panel {
  background: linear-gradient(170deg, #0e3a4a, #072431);
  border: 1px solid rgba(216, 178, 74, .55);
  border-radius: 16px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, .6), inset 0 0 40px rgba(216, 178, 74, .06);
  padding: 26px 30px;
  max-width: 560px;
  width: 100%;
  max-height: 92%;
  overflow-y: auto;
  text-align: center;
  color: #d9e6ea;
}
.panel h2 {
  margin: 4px 0 10px;
  font-size: 24px;
  color: var(--gold-hi);
  letter-spacing: 1px;
}
.panel .emblem { font-size: 44px; margin-bottom: 4px; filter: drop-shadow(0 0 12px rgba(243, 223, 154, .5)); }
.panel p { font-size: 14.5px; line-height: 1.65; color: #b8cdd4; }
.panel .btn-row { display: flex; gap: 10px; justify-content: center; margin-top: 18px; flex-wrap: wrap; }
.panel .btn-row .hud-btn { font-size: 14px; padding: 9px 18px; }

.win-stars { font-size: 40px; letter-spacing: 6px; margin: 6px 0; }
.win-stars b { color: var(--gold-hi); text-shadow: 0 0 16px rgba(243, 223, 154, .8); }
.win-stars i { font-style: normal; color: rgba(216, 178, 74, .28); }

#menuTitle {
  font-size: 34px;
  margin: 2px 0 2px;
  background: linear-gradient(180deg, #f7e6ae, #cf9f3a);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-shadow: 0 2px 18px rgba(216, 178, 74, .25);
}
#menuSub { margin-top: 0; font-style: italic; }

.act-row { text-align: left; margin: 14px 0; }
.act-title { font-size: 14px; color: var(--gold-hi); letter-spacing: 1.2px; margin: 0 0 8px; text-transform: uppercase; }
.act-nodes { display: flex; gap: 8px; flex-wrap: wrap; }
.lv-node {
  width: 52px; height: 58px;
  border-radius: 10px;
  border: 1px solid rgba(216, 178, 74, .5);
  background: rgba(3, 18, 25, .55);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  font-size: 17px; color: #e8f2f5;
  cursor: pointer;
  transition: transform .15s, box-shadow .15s;
}
.lv-node:hover { transform: translateY(-2px); box-shadow: 0 6px 16px rgba(216, 178, 74, .35); }
.lv-node.locked { opacity: .38; cursor: default; filter: grayscale(.7); }
.lv-node.locked:hover { transform: none; box-shadow: none; }
.lv-node.done { background: linear-gradient(180deg, rgba(216, 178, 74, .3), rgba(3, 18, 25, .6)); }
.lv-stars { font-size: 9px; letter-spacing: 1px; margin-top: 3px; }
.lv-stars b { color: var(--gold-hi); }
.lv-stars i { font-style: normal; color: rgba(216, 178, 74, .3); }

#flashMsg {
  position: absolute;
  left: 50%; bottom: 16px;
  transform: translateX(-50%) translateY(8px);
  background: rgba(3, 18, 25, .85);
  border: 1px solid rgba(216, 178, 74, .5);
  color: var(--gold-hi);
  font-size: 14px;
  padding: 8px 16px;
  border-radius: 999px;
  opacity: 0;
  transition: opacity .25s, transform .25s;
  pointer-events: none;
  z-index: 3500;
  max-width: 90%;
  text-align: center;
}
#flashMsg.show { opacity: 1; transform: translateX(-50%) translateY(0); }

[hidden] { display: none !important; }

/* ---------- responsive ---------- */

@media (max-width: 640px) {
  .main h1 { font-size: 23px; }
  .stage { height: min(72vh, 640px); min-height: 430px; border-radius: 12px; }
  .hud { padding: 7px 8px; gap: 5px; }
  .hud-chip { font-size: 11px; padding: 4px 8px; }
  .hud-btn { font-size: 11px; padding: 5px 9px; }
  .act-tag { display: none; }
  .panel { padding: 20px 16px; }
}
