/* Look: a pastel dawn sky of Geulah (from the game logo): lavender and sky blue, golden light, soft white cloud panels. */
:root {
  --ink: #3a2470;
  --ink-soft: #6a5a9a;
  --purple: #6b3fd1;
  --purple-2: #8f5cf0;
  --lav: #f3eeff;
  --lav-2: #e4d9ff;
  --gold: #f7b928;
  --gold-2: #e08a00;
  --gold-soft: #fff1c2;
  --cream: #fffaf0;
  --red: #e8435a;
  --panel: rgba(255, 255, 255, 0.88);
  --shadow: 0 8px 24px rgba(58, 36, 112, 0.28);
  --ui: Fredoka, Assistant, Arial, sans-serif;
  --title: Fredoka, Assistant, Arial, sans-serif;
  --pasuk: "Frank Ruhl Libre", "David", serif;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #6f86e0; color: var(--ink); font-family: var(--ui); }
body { user-select: none; -webkit-user-select: none; touch-action: none; }
canvas#game { position: fixed; inset: 0; width: 100vw; height: 100vh; display: block; cursor: crosshair; }
button { font-family: inherit; color: inherit; border: 0; background: none; cursor: pointer; }

/* ---------- HUD ---------- */
.hud { position: fixed; left: 0; right: 0; display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; padding: 10px 14px; pointer-events: none; z-index: 5; opacity: 0; transition: opacity .5s; }
body.playing .hud { opacity: 1; }
#hudTop { top: 0; padding-top: max(10px, env(safe-area-inset-top)); }
#hudBottom { bottom: 0; align-items: flex-end; padding-bottom: max(10px, env(safe-area-inset-bottom)); }
.hud-group { pointer-events: auto; display: flex; align-items: center; gap: 10px; background: var(--panel); border: 3px solid #fff; border-radius: 22px; padding: 7px 12px; backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); box-shadow: var(--shadow); }
.lbl { font-size: 13px; color: var(--ink-soft); font-weight: 600; }
.bar { height: 9px; border-radius: 9px; background: var(--lav-2); overflow: hidden; }
.bar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--gold-2), var(--gold), #ffe58a); border-radius: 9px; transition: width .4s; }

.score-group { padding: 5px; gap: 10px; }
.temple-card { padding: 0; border-radius: 16px; overflow: hidden; border: 3px solid var(--gold); line-height: 0; box-shadow: 0 0 16px rgba(255, 200, 80, 0.55); }
.temple-card canvas { width: 96px; height: 62px; display: block; }
.score-box { display: flex; flex-direction: column; gap: 2px; min-width: 92px; padding-inline-end: 6px; }
.score-box b { font-size: 32px; font-weight: 700; line-height: 1; color: var(--purple); text-shadow: 0 2px 0 #fff, 0 3px 8px rgba(247, 185, 40, .45); }

.clock { flex-direction: column; align-items: stretch; gap: 5px; min-width: 190px; }
.clock-top { display: flex; justify-content: space-between; gap: 12px; font-size: 15px; font-weight: 500; }
.clock-top b { font-family: var(--title); font-size: 18px; font-weight: 700; color: var(--purple); }
.bar.day i { background: linear-gradient(90deg, #7cc8ff, #ffd36b 75%, #ff8f6b); }
.fest { font-size: 13px; font-weight: 700; text-align: center; background: var(--gold-soft); border: 2px solid var(--gold); border-radius: 10px; padding: 1px 8px; color: #8a5200; }
.fest.done { background: #d8f7e4; border-color: #3cc47c; color: #17683c; }

.speed { direction: ltr; display: flex; gap: 4px; background: var(--lav); border-radius: 14px; padding: 3px; }
.speed button { min-width: 40px; height: 34px; border-radius: 11px; font-size: 13px; letter-spacing: -2px; color: var(--purple); opacity: .7; }
.speed button.on { background: linear-gradient(180deg, #ffd65a, var(--gold)); color: var(--ink); opacity: 1; font-weight: 700; box-shadow: 0 3px 0 var(--gold-2); }
.icon-btn { width: 40px; height: 40px; border-radius: 14px; font-size: 19px; background: var(--lav); color: var(--purple); }
.icon-btn.off { opacity: .45; filter: grayscale(1); }
#audioBtns { position: fixed; z-index: 20; inset-inline-start: 12px; bottom: 12px; display: flex; gap: 6px; }
body.playing #audioBtns { bottom: auto; top: 50%; transform: translateY(-50%); flex-direction: column; inset-inline-start: 10px; }
#audioBtns .icon-btn { background: var(--panel); border: 3px solid #fff; box-shadow: var(--shadow); }

.tokens { display: flex; gap: 7px; }
.token { width: 30px; height: 30px; border-radius: 50%; border: 3px dashed rgba(107, 63, 209, 0.4); transition: transform .2s; }
.token.used { border: 3px solid #fff; background: radial-gradient(circle at 35% 30%, rgba(255, 255, 255, .7), var(--c) 55%); box-shadow: 0 0 0 2px var(--c), 0 3px 8px rgba(58, 36, 112, .3); }
.token.used:hover { transform: scale(1.12); }
.token.used:hover::after { content: '✕'; display: block; font-size: 13px; font-weight: 700; color: #fff; text-shadow: 0 1px 3px #000; }

.items { gap: 8px; }
.item, .stat { display: grid; grid-template-columns: auto auto; grid-template-rows: auto auto; align-items: center; column-gap: 6px; padding: 4px 10px; border-radius: 16px; background: var(--lav); min-width: 64px; }
.item { cursor: grab; touch-action: none; border: 2px solid var(--lav-2); transition: transform .15s; }
.item:hover { transform: translateY(-2px) rotate(-2deg); }
.item:active { cursor: grabbing; }
.item.gold { border-color: var(--gold); background: var(--gold-soft); box-shadow: 0 0 12px rgba(247, 185, 40, .4); }
.item.empty { opacity: .45; }
.item .ic, .stat .ic { font-size: 24px; grid-row: span 2; }
.item b, .stat b { font-size: 19px; font-weight: 700; line-height: 1; color: var(--ink); }
.item small, .stat small { font-size: 11px; color: var(--ink-soft); white-space: nowrap; }

.bump { animation: bump .6s; }
@keyframes bump { 0% { transform: scale(1); } 30% { transform: scale(1.2) rotate(-4deg); box-shadow: 0 0 26px rgba(255, 205, 90, .9); } 100% { transform: scale(1); } }

/* ---------- messages ---------- */
.tip, .toast { position: fixed; left: 50%; transform: translate(-50%, 12px); z-index: 8; pointer-events: none; opacity: 0; transition: opacity .35s, transform .35s; text-align: center; font-weight: 600; max-width: min(92vw, 620px); }
.tip { top: 120px; font-size: 19px; background: #fff; color: var(--ink); border: 3px solid var(--purple-2); padding: 10px 22px; border-radius: 26px; box-shadow: 0 10px 30px rgba(58, 36, 112, .35); }
.toast { bottom: 110px; font-size: 16px; color: #fff; background: linear-gradient(180deg, var(--purple-2), var(--purple)); border: 3px solid #fff; padding: 8px 20px; border-radius: 22px; box-shadow: 0 8px 26px rgba(58, 36, 112, .4); }
.toast.warn { background: linear-gradient(180deg, #ff6b7d, var(--red)); }
.toast.gold { background: linear-gradient(180deg, #ffe17a, var(--gold)); color: var(--ink); }
.toast.city { background: linear-gradient(180deg, #6ec3ff, #3a8fe0); }
.tip.show, .toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- menu ---------- */
.menu { position: fixed; inset: 0; z-index: 10; display: none; align-items: center; justify-content: center; padding: 16px; overflow: auto; background: radial-gradient(ellipse at 50% 38%, rgba(255, 236, 190, .18), rgba(80, 50, 160, .5) 80%); }
.menu.show { display: flex; }
.menu-inner { text-align: center; max-width: 820px; width: 100%; margin: auto; animation: rise .9s ease-out; }
@keyframes rise { from { transform: translateY(20px); opacity: 0; } to { transform: none; opacity: 1; } }
.logo { display: block; width: min(100%, 760px, calc((100vh - 330px) * 3.03)); min-width: min(100%, 300px); height: auto; aspect-ratio: 1600 / 528; margin: 0 auto 10px; border-radius: 28px; border: 4px solid #fff; box-shadow: 0 14px 40px rgba(58, 36, 112, .45), 0 0 40px rgba(255, 215, 120, .35); animation: float 5s ease-in-out infinite; object-fit: cover; }
@keyframes float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-7px); } }
.pasuk { display: inline-block; font-family: var(--pasuk); font-weight: 700; font-size: clamp(18px, 2.5vw, 25px); color: #fff3c4; margin: 2px 0 4px; padding: 5px 22px 6px; border-radius: 999px; background: rgba(70, 40, 150, .62); border: 2px solid rgba(255, 220, 140, .55); text-shadow: 0 2px 6px rgba(30, 10, 70, .7); }
.pasuk small { display: block; font-family: var(--ui); font-weight: 500; font-size: 13px; opacity: .9; margin-top: 2px; }
h1 { font-family: var(--title); font-weight: 700; font-size: clamp(36px, 6vw, 60px); margin: 0; line-height: 1.05; color: #fff; text-shadow: 0 3px 0 var(--purple), 0 6px 0 #4a2a9e, 0 10px 20px rgba(40, 20, 90, .5); }
html[lang="en"] .logo { width: min(100%, 700px, calc((100vh - 400px) * 3.03)); }
html[lang="he"] .menu h1 { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.subtitle { font-size: clamp(16px, 2.2vw, 21px); font-weight: 600; color: #fff; margin: 6px 0 14px; text-shadow: 0 2px 0 rgba(70, 40, 150, .8), 0 2px 10px rgba(58, 36, 112, .9); }
.choose { font-weight: 600; color: #fff; margin: 0 0 10px; text-shadow: 0 2px 6px rgba(58, 36, 112, .8); }
.modes { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-bottom: 14px; }
.mode { display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 14px 12px 12px; border-radius: 28px; background: linear-gradient(180deg, #fff, var(--lav)); border: 4px solid #fff; color: var(--ink); box-shadow: 0 6px 0 var(--lav-2), 0 14px 30px rgba(58, 36, 112, .35); transition: transform .2s, box-shadow .2s; }
.mode:hover { transform: translateY(-5px) scale(1.02); box-shadow: 0 6px 0 var(--gold), 0 18px 36px rgba(58, 36, 112, .4), 0 0 26px rgba(255, 215, 120, .6); }
.mode:active { transform: translateY(1px); }
.mode .mi { font-size: 38px; filter: drop-shadow(0 3px 2px rgba(58, 36, 112, .25)); }
.mode:hover .mi { animation: wiggle .6s; }
@keyframes wiggle { 0%, 100% { transform: rotate(0); } 25% { transform: rotate(-10deg); } 75% { transform: rotate(10deg); } }
.mode b { font-family: var(--title); font-weight: 700; font-size: 22px; color: var(--purple); }
.mode small { font-size: 14px; color: var(--ink-soft); }
.mode em { font-style: normal; font-weight: 600; font-size: 13px; color: var(--gold-2); min-height: 16px; }
.copy { font-size: 12px; color: #fff; opacity: .75; margin-top: 14px; text-shadow: 0 1px 4px rgba(58, 36, 112, .8); }

.btn { display: inline-block; padding: 10px 28px; margin: 6px; border-radius: 999px; font-size: 18px; font-weight: 700; background: linear-gradient(180deg, #ffe17a, var(--gold)); color: var(--ink); box-shadow: 0 5px 0 var(--gold-2), 0 10px 20px rgba(58, 36, 112, .3); transition: transform .12s, filter .15s, box-shadow .12s; }
.btn:hover { transform: translateY(-2px); filter: brightness(1.05); }
.btn:active { transform: translateY(3px); box-shadow: 0 2px 0 var(--gold-2), 0 4px 10px rgba(58, 36, 112, .3); }
.btn:disabled { opacity: .45; cursor: default; transform: none; }
.btn.ghost { background: #fff; color: var(--purple); box-shadow: 0 5px 0 var(--lav-2), 0 10px 20px rgba(58, 36, 112, .2); }

/* ---------- overlays ---------- */
.overlay { position: fixed; inset: 0; z-index: 30; display: none; align-items: center; justify-content: center; padding: 16px; background: rgba(60, 35, 130, .45); backdrop-filter: blur(5px); -webkit-backdrop-filter: blur(5px); }
.overlay.show { display: flex; animation: fade .3s; }
@keyframes fade { from { background-color: rgba(60, 35, 130, 0); } to { background-color: rgba(60, 35, 130, .45); } }
.panel { width: min(92vw, 440px); max-height: 92vh; overflow: auto; text-align: center; color: var(--ink); background: linear-gradient(180deg, #fff 30%, var(--lav)); border: 5px solid #fff; border-radius: 32px; padding: 22px; box-shadow: 0 0 0 3px var(--lav-2), 0 24px 60px rgba(40, 20, 90, .5); animation: pop .4s cubic-bezier(.2, 1.5, .4, 1); }
.panel.wide { width: min(94vw, 700px); }
.panel.small { width: min(92vw, 380px); }
@keyframes pop { from { transform: scale(.85); } to { transform: none; } }
.panel h2 { font-family: var(--title); font-weight: 700; font-size: 32px; margin: 6px 0 10px; color: var(--purple); }
.panel p { font-size: 17px; margin: 6px 0; line-height: 1.45; }
.panel canvas { width: 100%; height: auto; border-radius: 20px; display: block; border: 3px solid #fff; box-shadow: 0 4px 14px rgba(58, 36, 112, .2); }
.row { display: flex; justify-content: center; flex-wrap: wrap; }
.how-grid { display: grid; grid-template-columns: 1.5fr 1fr; gap: 14px; align-items: center; text-align: start; }
.how-list { margin: 0; padding-inline-start: 18px; font-size: 15.5px; line-height: 1.5; }
.how-list li { margin-bottom: 7px; }
.how-list li::marker { color: var(--gold); }
.how-list b { color: var(--purple); }
.how-list .warn { color: #c62f4a; }
.big-score { margin: 10px 0; }
.big-score b { display: block; font-size: 64px; font-weight: 700; color: var(--purple); line-height: 1; text-shadow: 0 4px 0 var(--gold); }
.best { color: var(--gold-2); font-weight: 700; }

.shabbos .panel { color: var(--cream); background: linear-gradient(180deg, #34298a, #1d1858); box-shadow: 0 0 0 3px rgba(255, 215, 120, .6), 0 24px 60px rgba(20, 10, 60, .6); border-color: #4a3cae; }
.shabbos .panel h2 { color: #ffd65a; }
.gift { font-weight: 700; color: #cfe9ff; }
.fest-line { color: #ffe39a; font-weight: 700; }
.pick { font-weight: 700; margin-top: 12px !important; }
.upgrades { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin: 10px 0 14px; }
.upgrade { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 14px 10px; border-radius: 22px; color: var(--ink); background: linear-gradient(180deg, #fff, var(--lav)); border: 3px solid #fff; box-shadow: 0 5px 0 rgba(255, 255, 255, .25); transition: transform .2s, background .2s, opacity .2s; }
.upgrade:hover { transform: translateY(-4px) scale(1.02); }
.upgrade .ui { font-size: 34px; }
.upgrade b { font-size: 17px; font-weight: 700; color: var(--purple); }
.upgrade small { font-size: 13px; color: var(--ink-soft); }
.upgrade.chosen { background: linear-gradient(180deg, #fff8dc, #ffe48a); border-color: var(--gold); box-shadow: 0 0 24px rgba(255, 215, 120, .8); }
.upgrade.off { opacity: .35; pointer-events: none; }

/* ---------- small screens ---------- */
@media (max-width: 760px) {
  .hud { padding: 6px 8px; gap: 6px; }
  .hud-group { padding: 4px 8px; gap: 6px; border-radius: 16px; border-width: 2px; }
  .temple-card canvas { width: 64px; height: 42px; }
  .score-box { min-width: 60px; }
  .score-box b { font-size: 23px; }
  .clock { min-width: 120px; }
  .clock-top { font-size: 12px; }
  .clock-top b { font-size: 14px; }
  .speed button { min-width: 30px; height: 30px; }
  .icon-btn { width: 34px; height: 34px; font-size: 16px; }
  #hudBottom { flex-wrap: wrap; justify-content: center; }
  .token { width: 24px; height: 24px; }
  .item, .stat { min-width: 50px; padding: 3px 7px; }
  .item small, .stat small { display: none; }
  .item .ic, .stat .ic { font-size: 19px; }
  #hudBottom .lbl { display: none; }
  .logo { border-radius: 20px; border-width: 3px; }
  .modes { grid-template-columns: 1fr; gap: 10px; }
  .mode { flex-direction: row; flex-wrap: wrap; justify-content: center; column-gap: 8px; padding: 9px; border-radius: 22px; }
  .mode .mi { font-size: 28px; }
  .mode small { width: 100%; }
  .how-grid { grid-template-columns: 1fr; }
  .how-grid canvas { display: none; }
  .tip { top: 90px; font-size: 16px; }
  .toast { bottom: 120px; font-size: 14px; }
}
@media (max-height: 560px) {
  .modes { grid-template-columns: repeat(3, 1fr); }
  .mode small { display: none; }
  h1 { font-size: 34px; }
  .subtitle { margin: 4px 0 8px; }
}
@media (max-width: 520px) {
  #hudTop .hud-group { padding: 4px 6px; }
  .temple-card canvas { width: 50px; height: 33px; }
  .score-box { min-width: 40px; padding: 0; }
  .score-box .lbl { display: none; }
  .clock { min-width: 0; flex: 1; }
  .clock-top { flex-direction: column; gap: 0; align-items: center; }
  .speed { padding: 2px; gap: 2px; }
  .speed button { min-width: 26px; height: 28px; font-size: 11px; }
  #btnMenu { width: 30px; height: 30px; }
  .tip { top: 76px; font-size: 15px; }
}
@media (prefers-reduced-motion: reduce) {
  .logo, .mode:hover .mi { animation: none; }
}

/* hub card picture (?cover=1) */
body.cover .hud, body.cover #audioBtns, body.cover .toast, body.cover .tip { display: none !important; }
.cover-title { position: fixed; top: 18px; left: 0; right: 0; text-align: center; z-index: 9; pointer-events: none; }
.cover-title h1 { font-size: 78px; }
.cover-title p { margin: 0; font-size: 21px; font-weight: 700; color: #fff; text-shadow: 0 2px 8px rgba(58, 36, 112, .9); }
