:root{
  --sand-1:#8a6234;
  --sand-2:#4a3218;
  --sand-3:#b8894a;
  --gold:#d4a13d;
  --gold-bright:#f0c866;
  --gold-dim:#8a6a28;
  --gold-line:rgba(212,161,61,.4);
  --lapis:#1e4d6b;
  --lapis-bright:#3a7ca8;
  --turquoise:#2a8a7a;
  --cream:#f2e4c4;
  --cream-dim:rgba(242,228,196,.75);
  --ink:#241a0d;
  --lose:#a8433f;
  --win:#4a9a6a;
  --accent: var(--gold);
  --accent-ink: var(--ink);
}

/* Safari applies its own native styling to <button> elements, which
   overrides border-radius and custom backgrounds. Resetting appearance
   fixes this on desktop and iOS Safari, and is a no-op elsewhere. */
button{
  -webkit-appearance:none;
  appearance:none;
}



*{ box-sizing:border-box; }
html,body{ margin:0; padding:0; }
body{
  background:var(--sand-2);
  color:var(--cream);
  font-family:'Inter',sans-serif;
  min-height:100vh;
  display:flex; flex-direction:column;
}

/* ---------------- header ---------------- */
header{
  background:linear-gradient(180deg,var(--sand-1),var(--sand-2));
  border-bottom:2px solid var(--gold-line);
}
.header-inner{
  display:flex; align-items:center; justify-content:space-between;
  padding:12px 18px; flex-wrap:wrap;
}
.header-inner > *{ margin-right:10px; }
.header-inner > *:last-child{ margin-right:0; }
.brand-cluster .title{
  font-family:'Cinzel',serif; font-weight:600; font-size:24px; letter-spacing:.03em;
  color:var(--gold-bright); text-shadow:0 2px 10px rgba(212,161,61,.3);
}
.hud{ display:flex; align-items:center; }
.hud > *{ margin-left:14px; }
.hud > *:first-child{ margin-left:0; }
.stat{ text-align:right; }
.stat label{ display:block; font-size:9px; letter-spacing:.1em; text-transform:uppercase; color:var(--cream-dim); }
.stat .val{ font-size:16px; font-weight:600; color:var(--gold-bright); }
.icon-btn{
  min-width:44px; padding:5px 8px; border-radius:9px; border:1.5px solid var(--gold-line);
  background:rgba(0,0,0,.28); color:var(--cream); cursor:pointer;
  display:flex; flex-direction:column; align-items:center; justify-content:center;
}
.icon-btn .icon-glyph{ font-size:15px; line-height:1; }
.icon-btn .icon-label{ font-size:8px; letter-spacing:.05em; text-transform:uppercase; margin-top:2px; color:var(--cream-dim); }
.icon-btn:hover:not(:disabled){ border-color:var(--gold); }
.icon-btn:disabled{ opacity:.3; cursor:default; }

/* ---------------- board / chamber ---------------- */
.board-wrap{
  flex:1; display:flex; flex-direction:column; align-items:center;
  position:relative; padding:20px 12px 10px; overflow:hidden;
}

/* Signature visual: warm torchlight glows from either side of the
   chamber, casting long pools of light toward the pyramid and
   fading into shadow at the edges — grounded directly in the
   "torch-lit tomb chamber" framing rather than a generic vignette. */
.torch-glow-left, .torch-glow-right{
  position:absolute; top:10%; width:45%; height:70%;
  background:radial-gradient(ellipse at center, rgba(240,168,80,.20), transparent 68%);
  pointer-events:none; z-index:0;
}
.torch-glow-left{ left:-10%; }
.torch-glow-right{ right:-10%; }

.chamber{
  position:relative; width:100%; max-width:640px;
  background:
    linear-gradient(180deg, rgba(0,0,0,.15), rgba(0,0,0,.35)),
    repeating-linear-gradient(0deg, var(--sand-1) 0px, var(--sand-1) 38px, var(--sand-3) 39px, var(--sand-1) 40px),
    var(--sand-1);
  border:3px solid var(--gold-dim);
  border-radius:14px;
  box-shadow:0 25px 60px rgba(0,0,0,.55), inset 0 0 80px rgba(0,0,0,.5), inset 0 2px 4px rgba(240,198,102,.15);
  padding:34px 14px 18px;
  z-index:1;
}
.chamber::before{
  content:'';
  position:absolute; top:0; left:14px; right:14px; height:8px;
  background:repeating-linear-gradient(90deg,
    var(--gold-bright) 0px, var(--gold-bright) 14px,
    var(--lapis-bright) 14px, var(--lapis-bright) 28px,
    var(--turquoise) 28px, var(--turquoise) 42px);
  border-radius:0 0 4px 4px;
  opacity:.85;
}

.pyramid{ position:relative; width:100%; height:340px; margin:0 auto; }

/* ---------------- cards ---------------- */
.card{
  position:absolute;
  width:52px; height:72px; border-radius:6px;
  background:linear-gradient(155deg,#fffaf0,var(--cream));
  border:1.5px solid rgba(0,0,0,.3);
  display:flex; flex-direction:column; align-items:center; justify-content:center;
  font-family:'IBM Plex Mono',monospace; font-weight:700; font-size:17px;
  color:var(--ink);
  box-shadow:0 4px 10px rgba(0,0,0,.45);
  transform:translateX(var(--x-offset,0));
  transition:transform .15s ease, box-shadow .15s ease, opacity .2s ease;
  cursor:default;
  user-select:none;
}
.card.red{ color:var(--lose); }
.card .card-suit{ font-size:15px; line-height:1; margin-top:2px; }

.card.covered{
  filter:brightness(.4) saturate(.5);
  box-shadow:0 2px 5px rgba(0,0,0,.4);
}
.card.exposed{ cursor:pointer; }
.card.exposed:hover{ transform:translateX(var(--x-offset,0)) translateY(-4px); box-shadow:0 8px 16px rgba(0,0,0,.5); }
.card.exposed.playable-king{ box-shadow:0 4px 10px rgba(0,0,0,.45), 0 0 0 2px var(--gold-bright); }
.card.selected{
  transform:translateX(var(--x-offset,0)) translateY(-8px);
  box-shadow:0 10px 20px rgba(0,0,0,.55), 0 0 0 3px var(--gold-bright);
}
.card.removed{ opacity:0; transform:translateX(var(--x-offset,0)) scale(.5) translateY(20px); pointer-events:none; }
.card.hint-glow{ box-shadow:0 4px 10px rgba(0,0,0,.45), 0 0 0 3px var(--turquoise); }

/* ---------------- stock / waste ---------------- */
.stock-row{
  display:flex; align-items:center; justify-content:center;
  margin-top:10px; position:relative;
}
.stock-row > *{ margin-right:16px; }
.stock-row > *:last-child{ margin-right:0; }
.pile-slot{
  position:relative; width:52px; height:72px; border-radius:6px;
  border:2px dashed var(--gold-line);
  display:flex; align-items:center; justify-content:center;
}
.stock-slot{ cursor:pointer; background:rgba(0,0,0,.2); }
.stock-slot:hover{ border-color:var(--gold); }
.stock-slot .card{ position:absolute; top:0; right:0; bottom:0; left:0; margin:auto; }
.pile-count{
  position:absolute; bottom:-18px; left:50%; transform:translateX(-50%);
  font-size:10px; color:var(--cream-dim);
}
.waste-slot .card{ position:relative; }
.redeal-hint{
  position:absolute; right:-4px; bottom:-22px; font-size:10px; color:var(--gold-dim);
  white-space:nowrap;
}

/* ---------------- action row ---------------- */
.action-row{ display:flex; margin-top:22px; padding-bottom:10px; }
.action-row > *{ margin-right:10px; }
.action-row > *:last-child{ margin-right:0; }
.btn{
  padding:11px 22px; border-radius:11px; border:1.5px solid var(--gold-line);
  background:rgba(0,0,0,.28); color:var(--cream);
  font-family:'Inter',sans-serif; font-weight:700; font-size:13px;
  cursor:pointer;
}
.btn:hover:not(:disabled){ border-color:var(--gold); background:rgba(0,0,0,.42); }
.btn:disabled{ opacity:.35; cursor:default; }
.btn-primary{
  background:linear-gradient(155deg,var(--gold-bright),var(--gold));
  color:var(--ink); border-color:transparent;
}
.btn-primary:hover:not(:disabled){ filter:brightness(1.08); }
.btn-hint{
  background:linear-gradient(155deg,#4ab5a0,var(--turquoise));
  color:var(--cream); border-color:transparent;
}
.btn-hint:hover:not(:disabled){ filter:brightness(1.1); }

/* ---------------- overlays ---------------- */
.panel-overlay{
  display:none; position:fixed; top:0; right:0; bottom:0; left:0;
  background:rgba(0,0,0,.68); align-items:center; justify-content:center;
  z-index:50; padding:20px;
}
.panel-overlay.open{ display:flex; }
.panel-card{
  background:var(--sand-1); border:2px solid var(--gold-line); border-radius:16px;
  max-width:420px; width:100%; max-height:82vh; overflow-y:auto;
}
.panel-header{
  display:flex; justify-content:space-between; align-items:center;
  padding:16px 18px; border-bottom:1px solid var(--gold-line);
}
.panel-header h2{ font-family:'Cinzel',serif; font-size:20px; color:var(--gold-bright); margin:0; }
.panel-close{ background:none; border:none; color:var(--cream); font-size:22px; cursor:pointer; }
.panel-body{ padding:16px 18px; font-size:13px; line-height:1.6; color:var(--cream-dim); }
.panel-body h3{ color:var(--gold-bright); font-size:14px; margin:14px 0 4px; }
.panel-body h3:first-child{ margin-top:0; }
.settings-row{ display:flex; justify-content:space-between; align-items:center; padding:10px 0; }
.panel-body .btn{ width:100%; margin-top:10px; }

.result-card{ text-align:center; padding:32px 26px; }
.result-title{ font-family:'Cinzel',serif; font-size:24px; margin:0 0 10px; }
.win-title{ color:var(--gold-bright); text-shadow:0 0 20px rgba(240,198,102,.4); }
.lose-title{ color:var(--gold-bright); }
.result-sub{ font-size:13px; color:var(--cream-dim); margin-bottom:20px; }

/* ---------------- mobile ---------------- */
@media (max-width:480px){
  .brand-cluster .title{ font-size:19px; }
  .hud > *{ margin-left:8px; }
  .card{ width:40px; height:56px; font-size:13px; }
  .card .card-suit{ font-size:12px; }
  .pyramid{ height:270px; }
  .pile-slot{ width:40px; height:56px; }
}
