/* חדר בריחה: הסוד של הספרייה */
.csg-stage[data-csg-game="heder-bricha"] { --er: #7a4a1f; --er-deep: #3b2312; --er-gold: #c9a24a; }
html.er-lock { overflow: hidden; }

.er-hud { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.er-chip { display: inline-flex; align-items: center; gap: 6px; padding: 6px 14px; border-radius: 999px; background: var(--er-deep); color: #fff; font-weight: 700; font-size: 15px; }
.er-chip b { font-variant-numeric: tabular-nums; font-size: 17px; }
.er-seals { display: inline-flex; gap: 6px; margin-inline-start: auto; }
.er-seals span { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 50%; background: var(--csg-soft); border: 2px dashed #b9a68a; font-size: 17px; filter: grayscale(1); opacity: .55; transition: all .3s ease; }
.er-seals span.is-open { filter: none; opacity: 1; border: 2px solid var(--er-gold); background: #fff4d6; }

.er-wrap { position: relative; border-radius: 18px; overflow: hidden; box-shadow: 0 16px 40px rgb(43 20 10 / 30%); background: #3b2312; }
.er-room { display: block; width: 100%; height: auto; font-family: Rubik, Arial, sans-serif; }
.er-spot { cursor: pointer; outline: none; transition: filter .2s ease; }
.er-spot:hover, .er-spot:focus-visible { filter: brightness(1.25) drop-shadow(0 0 6px #ffd98a); }
.er-spot:not(.is-done) { animation: er-glow 3.2s ease-in-out infinite; }
.er-spot[data-spot="portraits"] { animation-delay: .4s; }
.er-spot[data-spot="pesukim"] { animation-delay: .8s; }
.er-spot[data-spot="manuscript"] { animation-delay: 1.2s; }
.er-spot[data-spot="gematria"] { animation-delay: 1.6s; }
.er-spot[data-spot="door"] { animation-delay: 2s; }
@keyframes er-glow { 0%, 80%, 100% { filter: none; } 90% { filter: brightness(1.18) drop-shadow(0 0 5px #ffd98a); } }
.er-seal circle { fill: #2a180b; stroke: #8b6a3e; stroke-width: 2; transition: all .3s ease; }
.er-seal text { opacity: .35; }
.er-seal.is-open circle { fill: #fff4d6; stroke: #c9a24a; stroke-width: 3; }
.er-seal.is-open text { opacity: 1; }
.er-door { transform-box: fill-box; transform-origin: right center; transition: transform 1.2s ease; }
.er-room.is-open .er-door { transform: perspective(600px) rotateY(70deg); fill: #ffe6a6; }
@media (prefers-reduced-motion: reduce) { .er-spot:not(.is-done) { animation: none; } }

.er-intro { position: absolute; inset: 0; display: grid; place-items: center; padding: 16px; background: rgb(20 10 4 / 72%); backdrop-filter: blur(2px); }
.er-intro[hidden] { display: none; }
.er-intro__card { max-width: 460px; text-align: center; color: #fff; }
.er-intro__card h2 { margin: 0 0 10px; font-size: clamp(26px, 6vw, 38px); font-weight: 800; color: #ffe6a6; }
.er-intro__card p { margin: 0 0 10px; font-size: clamp(14px, 3.6vw, 17px); line-height: 1.55; color: rgb(255 255 255 / 88%); }
.er-intro__card .csg-btn { margin-top: 6px; }
.er-kicker { margin: 0 0 4px !important; font-weight: 800; font-size: 14px; color: var(--er-gold) !important; }
.er-best { margin-top: 10px !important; font-weight: 700; color: var(--er-gold) !important; font-size: 14px !important; }
.er-help { margin: 10px 0 0; text-align: center; color: var(--csg-muted); font-size: 14.5px; }

.er-modal { position: fixed; inset: 0; z-index: 9999; display: grid; place-items: center; padding: 14px; background: rgb(20 10 4 / 65%); overflow-y: auto; }
.er-modal[hidden] { display: none; }
.er-modal__card { position: relative; width: min(100%, 640px); max-height: calc(100dvh - 28px); overflow-y: auto; background: #fbf5e6; color: #2b1a0c; border-radius: 20px; padding: 24px 22px 20px; box-shadow: 0 24px 60px rgb(0 0 0 / 40%); border: 3px solid var(--er-gold); animation: er-pop .25s ease both; }
@keyframes er-pop { from { opacity: 0; transform: scale(.94); } to { opacity: 1; transform: none; } }
.er-modal__card h3 { margin: 0 0 8px; font-size: clamp(20px, 4.6vw, 25px); font-weight: 800; line-height: 1.3; }
.er-modal__card p { margin: 0 0 12px; line-height: 1.55; }
.er-close { position: absolute; top: 10px; left: 10px; width: 36px; height: 36px; border-radius: 50%; border: 0; background: rgb(0 0 0 / 8%); font-size: 16px; cursor: pointer; color: inherit; }
.er-actions { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-top: 12px; }
.er-actions .csg-btn { margin-inline-start: auto; font-size: 17px; padding: 11px 24px; }
.er-actions--center { justify-content: center; }
.er-actions--center .csg-btn { margin-inline-start: 0; }
.er-hint { border: 0; background: none; font: inherit; font-weight: 800; color: var(--er); cursor: pointer; padding: 4px 0; }
.er-hint:disabled { opacity: .5; cursor: default; }
.er-msg { padding: 10px 14px; border-radius: 12px; font-weight: 700; margin-top: 4px !important; }
.er-msg[hidden] { display: none; }
.er-msg.is-good { background: #e3f6ea; color: #13532f; }
.er-msg.is-bad { background: #fdeceb; color: #7d1f1a; }

.er-frames { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.er-frames li { display: flex; gap: 12px; align-items: flex-start; background: #fff; border-radius: 12px; padding: 10px 12px; border: 1px solid #e6d8b8; }
.er-frames p { margin: 0 0 6px !important; font-size: 15px; }
.er-frame { flex: none; display: grid; place-items: center; width: 38px; height: 46px; border: 3px solid var(--er-gold); background: #3a3530; color: #ffe6a6; font-weight: 800; border-radius: 3px; }
.er-frames select { font: inherit; font-size: 15px; padding: 6px 10px; border-radius: 10px; border: 2px solid #d9c9a0; background: #fffdf6; min-width: 180px; max-width: 100%; color: inherit; }
.er-frames select.is-bad, .er-gap.is-bad { border-color: #d6453d !important; background: #fdeceb; }

.er-psk p { font-size: 18px; line-height: 2.1; background: #fff; border-radius: 12px; padding: 8px 14px; border: 1px solid #e6d8b8; }
.er-gap { font: inherit; font-weight: 800; min-width: 86px; padding: 0 10px; border: 2px dashed #b9a68a; border-radius: 8px; background: #fffaf0; color: #8a6420; cursor: pointer; line-height: 1.7; }
.er-gap.is-filled { border-style: solid; border-color: var(--er-gold); color: #2b1a0c; }
.er-words { display: flex; flex-wrap: wrap; gap: 8px; margin: 4px 0 6px; }
.er-word { font: inherit; font-size: 17px; font-weight: 800; padding: 6px 14px; border-radius: 10px; border: 2px solid #d9c9a0; background: #fff; cursor: pointer; color: inherit; }
.er-word.is-picked { background: var(--er); border-color: var(--er); color: #fff; }

.er-big { color: var(--er); font-size: 1.2em; white-space: nowrap; }
.er-table { display: grid; grid-template-columns: repeat(auto-fill, minmax(46px, 1fr)); gap: 5px; margin-bottom: 12px; direction: rtl; }
.er-table span { display: flex; flex-direction: column; align-items: center; background: #fff; border: 1px solid #e6d8b8; border-radius: 8px; padding: 3px 0; font-size: 12px; color: #6b5a40; font-variant-numeric: tabular-nums; }
.er-table b { font-size: 19px; color: #2b1a0c; }
.er-code { display: flex; gap: 10px; flex-wrap: wrap; }
.er-code input { flex: 1; min-width: 140px; font: inherit; font-size: 20px; font-weight: 800; padding: 10px 14px; border-radius: 12px; border: 2px solid #d9c9a0; background: #fff; color: inherit; text-align: center; }
.er-code .csg-btn { font-size: 17px; padding: 10px 22px; }

.er-cipher { font-family: "Frank Ruhl Libre", "David", serif; font-size: clamp(24px, 6vw, 34px); font-weight: 700; letter-spacing: .08em; text-align: center; background: #efe1bd; border: 2px solid #c9a24a; border-radius: 10px; padding: 12px; color: #4a2a0a; word-spacing: .4em; }
.er-cipher--plain { background: #fff4d6; }
.er-key { display: grid; grid-template-columns: repeat(auto-fill, minmax(70px, 1fr)); gap: 5px; margin-bottom: 12px; }
.er-key span { text-align: center; background: #fff; border: 1px solid #e6d8b8; border-radius: 8px; padding: 4px 0; font-size: 18px; font-weight: 800; }

.er-books { display: flex; gap: 6px; justify-content: center; align-items: flex-end; flex-wrap: wrap; padding: 14px 10px 0; background: linear-gradient(#5a3416, #5a3416) bottom / 100% 10px no-repeat; margin-bottom: 12px; }
.er-book { width: 52px; height: 168px; border: 0; border-radius: 4px 4px 2px 2px; background: var(--b); color: #f5e3b0; cursor: pointer; font: inherit; font-weight: 800; font-size: 15px; box-shadow: inset 4px 0 0 rgb(255 255 255 / 12%), inset -4px 0 0 rgb(0 0 0 / 18%); margin-bottom: 10px; transition: transform .15s ease; }
.er-book:nth-child(odd) { height: 150px; }
.er-book span { writing-mode: vertical-rl; display: inline-block; padding: 8px 0; border-top: 2px solid #e8c76a; border-bottom: 2px solid #e8c76a; }
.er-book:hover { transform: translateY(-8px); }

.er-seal-list { list-style: none; margin: 0 0 14px; padding: 0; display: grid; gap: 8px; }
.er-seal-list li { display: flex; align-items: center; gap: 10px; background: #fff; border: 1px solid #e6d8b8; border-radius: 12px; padding: 10px 12px; font-weight: 700; }
.er-seal-list li span { font-size: 22px; filter: grayscale(1); opacity: .6; }
.er-seal-list li b { margin-inline-start: auto; font-size: 14px; color: #7d1f1a; }
.er-seal-list li.is-open span { filter: none; opacity: 1; }
.er-seal-list li.is-open b { color: #13532f; }

.er-solved { text-align: center; }
.er-solved > span { display: block; font-size: 52px; line-height: 1.2; margin-bottom: 4px; }
.er-stars { font-size: 44px; color: #f2b632; letter-spacing: 4px; line-height: 1.1; margin-bottom: 6px; }
.er-stars i { font-style: normal; color: #e0d4b8; }

@media (max-width: 640px) {
	.er-intro { position: relative; inset: auto; backdrop-filter: none; background: #2a180b; padding: 20px 16px 22px; }
	.er-wrap:has(.er-intro:not([hidden])) .er-room { opacity: .75; }
	.er-seals span { width: 32px; height: 32px; font-size: 15px; }
}

/* ---------- Three rooms ---------- */
.er-chip--room { background: var(--er-gold); color: #2b1a0c; }
.er-rooms { display: flex; gap: 6px; justify-content: center; flex-wrap: wrap; margin-top: 12px; }
.er-rooms button { font: inherit; font-size: 14px; font-weight: 800; padding: 6px 14px; border-radius: 999px; border: 2px solid rgb(255 230 166 / 45%); background: transparent; color: #ffe6a6; cursor: pointer; }
.er-rooms button.is-on { background: #ffe6a6; color: #2b1a0c; border-color: #ffe6a6; }
.er-rooms button:disabled { opacity: .45; cursor: not-allowed; }
.er-unlock { background: #fff4d6; border: 2px dashed var(--er-gold); border-radius: 12px; padding: 8px 12px; font-weight: 700; }
.er-small { font-size: 13.5px; color: #6b5a40; margin-bottom: 6px !important; }

.er-frame--label { width: auto; min-width: 74px; height: auto; min-height: 40px; padding: 4px 8px; font-size: 15px; white-space: nowrap; }

.er-order { margin: 0 0 12px; padding: 0; list-style: none; counter-reset: ord; display: grid; gap: 6px; }
.er-order li { counter-increment: ord; display: flex; align-items: center; gap: 10px; background: #fff; border: 1px solid #e6d8b8; border-radius: 10px; padding: 6px 10px; min-height: 44px; }
.er-order li::before { content: counter(ord); flex: none; display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; background: var(--er); color: #fff; font-weight: 800; }
.er-order li span { color: #b9a68a; }
.er-order li button { font: inherit; font-weight: 800; border: 0; background: #fff4d6; border-radius: 8px; padding: 5px 10px; cursor: pointer; color: inherit; }
.er-actions .csg-btn:disabled { opacity: .45; cursor: default; }

.er-tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; width: min(100%, 330px); margin: 0 auto 12px; padding: 6px; background: #c9a24a; border-radius: 8px; }
.er-tile { padding: 0; border: 0; background: none; cursor: pointer; aspect-ratio: 1; outline: 3px solid transparent; outline-offset: -3px; transition: transform .12s ease; }
.er-tile svg { display: block; width: 100%; height: 100%; }
.er-tile.is-picked { outline-color: #e04b3f; transform: scale(.94); }
.er-tiles.is-done { gap: 0; transition: gap .4s ease; }

.er-drawers { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; padding: 12px; background: #6b4a2a; border-radius: 10px; margin-bottom: 12px; }
.er-drawer { font: inherit; font-size: 22px; font-weight: 800; padding: 14px 0 10px; border: 3px solid #3b2312; border-radius: 6px; background: #8b6239; color: #fff4d6; cursor: pointer; position: relative; }
.er-drawer::after { content: ""; display: block; width: 26px; height: 6px; margin: 6px auto 0; border-radius: 3px; background: #c9a24a; }
.er-drawer:hover { transform: translateY(2px); }
