/* Seshat: The Painted Duat — shell styles. Egyptian lapis + gold + papyrus. */
* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --lapis: #122b52;
  --lapis-deep: #0a1a35;
  --gold: #d9a441;
  --gold-bright: #f0c064;
  --papyrus: #e9d7a7;
  --ink: #2b2318;
}

html, body { height: 100%; }

body {
  font-family: Georgia, "Times New Roman", serif;
  background: var(--lapis-deep);
  color: var(--papyrus);
  overflow: hidden;
  -webkit-user-select: none; user-select: none;
  -webkit-tap-highlight-color: transparent;
}

#app { position: fixed; inset: 0; display: flex; flex-direction: column; }

.hidden { display: none !important; }

/* gentle gold sheen that keeps every filmed scene alive */
#screenGame::after {
  content: '';
  position: absolute; inset: 0;
  background: linear-gradient(115deg, transparent 42%, rgba(240, 192, 100, 0.06) 50%, transparent 58%);
  background-size: 300% 300%;
  animation: sheen 7s ease-in-out infinite;
  pointer-events: none;
  z-index: 1;
}
@keyframes sheen { 0%, 100% { background-position: 0% 0%; } 50% { background-position: 100% 100%; } }

.brand, #screenChapters h2, .act-head {
  animation: glowpulse 2.6s ease-in-out infinite;
}
@keyframes glowpulse {
  0%, 100% { text-shadow: 0 2px 0 #6e4d12, 0 5px 18px rgba(217, 164, 65, 0.35); }
  50% { text-shadow: 0 2px 0 #6e4d12, 0 5px 30px rgba(240, 192, 100, 0.75); }
}
.hieroglyphs { animation: hyppo 2.2s ease-in-out infinite; }
@keyframes hyppo { 0%, 100% { opacity: 0.55; } 50% { opacity: 1; } }

/* ---------------- screens ---------------- */
.screen {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  background:
    radial-gradient(1200px 700px at 50% -10%, rgba(217, 164, 65, 0.14), transparent 60%),
    radial-gradient(900px 600px at 85% 110%, rgba(63, 184, 175, 0.10), transparent 60%),
    var(--lapis-deep);
  padding: 18px;
  text-align: center;
  overflow: auto;
}

.brand {
  font-size: clamp(30px, 6vw, 52px);
  letter-spacing: 0.06em;
  color: var(--gold-bright);
  text-shadow: 0 2px 0 #6e4d12, 0 5px 18px rgba(217, 164, 65, 0.35);
  margin-bottom: 4px;
}
.brand small { display: block; font-size: clamp(13px, 2.4vw, 18px); letter-spacing: 0.34em; color: #cdb87e; margin-top: 8px; }

.hieroglyphs {
  font-size: clamp(20px, 4vw, 30px);
  letter-spacing: 0.5em;
  color: rgba(217, 164, 65, 0.65);
  margin: 14px 0 22px;
}

.menu-btns { display: flex; flex-direction: column; gap: 12px; width: min(320px, 86vw); }

.btn {
  font-family: inherit;
  font-size: 17px;
  padding: 13px 22px;
  border-radius: 12px;
  border: 1px solid rgba(217, 164, 65, 0.55);
  background: linear-gradient(180deg, rgba(217, 164, 65, 0.22), rgba(217, 164, 65, 0.08));
  color: var(--gold-bright);
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease, background 0.12s ease;
  letter-spacing: 0.04em;
}
.btn:hover { transform: translateY(-1px); box-shadow: 0 6px 18px rgba(217, 164, 65, 0.22); background: linear-gradient(180deg, rgba(217, 164, 65, 0.32), rgba(217, 164, 65, 0.12)); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: linear-gradient(180deg, #d9a441, #a8741b); color: #201503; font-weight: bold; border-color: #f0c064; }
.btn.primary:hover { box-shadow: 0 8px 24px rgba(217, 164, 65, 0.45); }
.btn.locked { opacity: 0.45; cursor: default; }
.btn:disabled { opacity: 0.45; cursor: default; }

#menuBest { margin-top: 20px; font-size: 13px; color: #a89467; letter-spacing: 0.06em; }

/* ---------------- chapter map ---------------- */
#screenChapters { justify-content: flex-start; padding-top: 22px; }
#screenChapters h2 { color: var(--gold-bright); letter-spacing: 0.1em; font-size: 24px; margin-bottom: 14px; }
#chapterGrid { width: min(760px, 94vw); text-align: left; }
.act-head { color: #cdb87e; font-size: 15px; letter-spacing: 0.08em; margin: 16px 0 8px; border-bottom: 1px solid rgba(217, 164, 65, 0.25); padding-bottom: 6px; }
.act-head .act-no { color: var(--gold-bright); font-size: 18px; margin-right: 6px; }
.act-head small { color: #8d7c54; font-style: italic; margin-left: 8px; }
.ch-row { display: grid; grid-template-columns: repeat(8, 1fr); gap: 8px; }
.ch-btn {
  position: relative;
  font-family: inherit;
  aspect-ratio: 1;
  border-radius: 10px;
  border: 1px solid rgba(217, 164, 65, 0.4);
  background: rgba(217, 164, 65, 0.08);
  color: var(--papyrus);
  cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px;
  overflow: hidden;
  transition: background 0.12s ease, transform 0.12s ease;
}
.ch-btn:hover { background: rgba(217, 164, 65, 0.22); transform: translateY(-1px); }
.ch-btn b { font-size: 17px; color: var(--gold-bright); }
.ch-btn i { font-size: 8.5px; font-style: italic; color: #b7a272; line-height: 1.15; padding: 0 3px; text-align: center; }
.ch-btn em { font-size: 8px; font-style: normal; color: var(--gold-bright); letter-spacing: 0.1em; }
.ch-btn.locked { opacity: 0.4; cursor: default; font-size: 16px; }
@media (max-width: 560px) { .ch-row { grid-template-columns: repeat(6, 1fr); } .ch-btn i { display: none; } }

#btnBackMenu { margin: 22px auto 0; width: min(320px, 80vw); }

/* ---------------- game screen ---------------- */
#screenGame {
  display: flex; flex-direction: column;
  align-items: stretch; justify-content: flex-start;
  padding: 0; text-align: left; overflow: hidden;
}
.hud {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px;
  background: linear-gradient(180deg, #16305d, #0e2143);
  border-bottom: 2px solid rgba(217, 164, 65, 0.45);
  flex-wrap: wrap;
}
.hud-name { font-size: 15px; color: var(--gold-bright); letter-spacing: 0.04em; flex: 1 1 auto; min-width: 140px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hud-stat { font-size: 14px; color: #cdb87e; white-space: nowrap; }
.hud-stat b { color: #ffd34d; font-weight: normal; }

.progress-wrap { flex: 2 1 180px; height: 14px; background: rgba(0, 0, 0, 0.4); border-radius: 8px; overflow: hidden; border: 1px solid rgba(217, 164, 65, 0.35); position: relative; }
.progress-fill { height: 100%; width: 0%; background: linear-gradient(90deg, #a8741b, var(--gold-bright)); transition: width 0.18s ease; border-radius: 8px; }
.progress-pct { position: absolute; inset: 0; font-size: 10px; color: #fff; text-align: center; line-height: 14px; text-shadow: 0 1px 2px rgba(0,0,0,.6); }

.hud button {
  font-family: inherit; font-size: 14px;
  background: rgba(217, 164, 65, 0.16);
  border: 1px solid rgba(217, 164, 65, 0.45);
  color: var(--gold-bright);
  border-radius: 8px; padding: 6px 12px; cursor: pointer;
}
.hud button:disabled { opacity: 0.4; cursor: default; }
.hud button:hover:not(:disabled) { background: rgba(217, 164, 65, 0.3); }
#btnSound.muted { opacity: 0.55; text-decoration: line-through; }

#board-wrap { flex: 1 1 auto; position: relative; min-height: 0; }
#board { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; cursor: crosshair; }

.palette {
  display: flex; gap: 8px; justify-content: center;
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom, 0px));
  background: linear-gradient(180deg, #0e2143, #0a1a35);
  border-top: 2px solid rgba(217, 164, 65, 0.45);
  flex-wrap: wrap;
}
.chip {
  position: relative;
  width: 52px; height: 58px;
  border-radius: 12px;
  border: 2px solid transparent;
  background: rgba(255, 255, 255, 0.05);
  cursor: pointer;
  padding: 0;
  transition: transform 0.12s ease, border-color 0.12s ease, box-shadow 0.12s ease;
}
.chip canvas { position: absolute; inset: 0; margin: auto; }
.chip span {
  position: absolute; top: -6px; right: -4px;
  font-size: 10px; font-family: Georgia, serif;
  background: #201503; color: var(--gold-bright);
  border-radius: 50%; width: 17px; height: 17px; line-height: 17px;
  border: 1px solid rgba(217, 164, 65, 0.5);
}
.chip:hover { transform: translateY(-2px); }
.chip.sel {
  border-color: var(--gold-bright);
  box-shadow: 0 0 0 2px rgba(217, 164, 65, 0.35), 0 6px 16px rgba(217, 164, 65, 0.3);
  transform: translateY(-3px);
}

/* ---------------- modals ---------------- */
.modal {
  position: absolute; inset: 0;
  background: rgba(5, 10, 22, 0.72);
  display: flex; align-items: center; justify-content: center;
  z-index: 40;
  padding: 16px;
}
.modal-box {
  width: min(520px, 92vw);
  background: linear-gradient(180deg, #142d58, #0e2143);
  border: 1px solid rgba(217, 164, 65, 0.55);
  border-radius: 16px;
  padding: 26px 26px 22px;
  text-align: center;
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.6);
  animation: pop 0.22s ease;
  max-height: 88vh; overflow: auto;
}
@keyframes pop { from { transform: scale(0.92); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.modal-box h3 { color: var(--gold-bright); font-size: 21px; letter-spacing: 0.05em; margin-bottom: 2px; }
.modal-act { font-size: 11px; letter-spacing: 0.22em; text-transform: uppercase; color: #8d7c54; margin-bottom: 14px; }
.modal-story { font-size: 15px; line-height: 1.65; color: #e3d3a5; font-style: italic; margin-bottom: 12px; }
.modal-tip { font-size: 12.5px; color: #7ec8c2; margin-bottom: 18px; }
.modal-btns { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }

#resStars { font-size: 34px; color: var(--gold-bright); letter-spacing: 0.14em; margin: 6px 0 8px; text-shadow: 0 2px 10px rgba(217,164,65,.4); }
#resStars .dim { color: rgba(217, 164, 65, 0.25); }
#resTime { font-size: 14px; color: #cdb87e; margin-bottom: 4px; }
#resCoins { font-size: 15px; color: #ffd34d; margin-bottom: 4px; }
#resSell { font-size: 13px; color: #a89467; font-style: italic; margin-bottom: 18px; }

/* ---------------- toast ---------------- */
#toast {
  position: fixed; left: 50%; bottom: 92px; transform: translateX(-50%) translateY(16px);
  background: rgba(20, 45, 88, 0.95);
  border: 1px solid rgba(217, 164, 65, 0.5);
  color: var(--papyrus);
  font-size: 13.5px;
  padding: 9px 18px; border-radius: 20px;
  opacity: 0; pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
  z-index: 60;
  max-width: 86vw; text-align: center;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* narrow phones: HUD tightens */
@media (max-width: 480px) {
  .hud-name { font-size: 13px; }
  .palette { gap: 5px; padding-left: 6px; padding-right: 6px; }
  .chip { width: 41px; height: 47px; }
  .chip canvas { transform: scale(0.8); }
}
}
