* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { width: 100%; height: 100%; overflow: hidden; background: #050b0b; touch-action: none; user-select: none; -webkit-user-select: none; }
body { font-family: "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif; color: #e9dcb4; }
#stage { position: absolute; left: 50%; top: 50%; width: 960px; height: 720px; transform-origin: 0 0; overflow: hidden; background: #0b1717; box-shadow: 0 0 60px #000; }
#game { position: absolute; inset: 0; width: 960px; height: 720px; display: block; cursor: crosshair; }
.hidden { display: none !important; }

.screen { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px; opacity: 0; pointer-events: none; transition: opacity .35s ease; }
.screen.show { opacity: 1; pointer-events: auto; }
.screen.dim { background: rgba(3, 10, 10, .72); }
.temple-bg { position: absolute; inset: 0; z-index: -1;
  background:
    radial-gradient(ellipse at 50% 40%, rgba(25,211,211,.12), transparent 60%),
    repeating-linear-gradient(0deg, rgba(0,0,0,.25) 0 2px, transparent 2px 60px),
    repeating-linear-gradient(90deg, rgba(0,0,0,.2) 0 2px, transparent 2px 90px),
    linear-gradient(160deg, #102a2a, #0a1414 55%, #141a17);
  border: 14px solid transparent;
  border-image: repeating-linear-gradient(45deg, #8a6a22 0 10px, #2c3a33 10px 20px, #1fae5b 20px 22px, #2c3a33 22px 32px) 14;
}
.title { font-size: 58px; letter-spacing: 6px; text-align: center; color: #f5c84a;
  text-shadow: 0 3px 0 #6b4a0e, 0 6px 0 #2a1d06, 0 0 30px rgba(25,211,211,.45); font-weight: bold; }
.title.small { font-size: 32px; letter-spacing: 4px; }
.marble-row { display: flex; gap: 14px; }
.marble-row canvas { width: 46px; height: 46px; animation: bob 2s ease-in-out infinite; }
@keyframes bob { 50% { transform: translateY(-6px); } }

.panel { position: relative; padding: 28px 40px; border-radius: 18px; display: flex; flex-direction: column; align-items: center; gap: 14px;
  background: linear-gradient(170deg, #34413b, #1c2724 60%, #141c1a);
  border: 3px solid #8a6a22; box-shadow: inset 0 0 0 4px #1c2724, inset 0 0 0 6px rgba(25,211,211,.35), 0 18px 40px rgba(0,0,0,.6); }
.menu-panel { min-width: 380px; }
.info-panel { min-width: 420px; max-width: 560px; text-align: center; font-size: 18px; line-height: 1.45; }
.info-panel.wide { max-width: 680px; }
.info-panel h2 { font-size: 36px; color: #f5c84a; letter-spacing: 4px; text-shadow: 0 3px 0 #2a1d06; }
.info-panel h2.danger { color: #ff6a5a; }
.big-num { font-size: 46px; color: #19d3d3; font-weight: bold; text-shadow: 0 0 14px rgba(25,211,211,.5); }
.controls { list-style: none; text-align: left; background: rgba(0,0,0,.25); padding: 12px 18px; border-radius: 10px; border: 1px solid rgba(245,200,74,.3); }
.btn-row { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; }

.stone-btn { min-width: 240px; min-height: 52px; padding: 10px 26px; font-family: inherit; font-size: 22px; font-weight: bold; letter-spacing: 3px; color: #f5e6b8; cursor: pointer;
  background: linear-gradient(180deg, #4b5a52, #2b3732 55%, #1f2925); border: 2px solid #b8913a; border-radius: 12px;
  box-shadow: 0 5px 0 #0d1312, inset 0 1px 0 rgba(255,255,255,.18); text-shadow: 0 2px 0 #000; transition: transform .1s, box-shadow .1s, filter .15s; }
.btn-row .stone-btn { min-width: 170px; }
.stone-btn:hover { filter: brightness(1.2); box-shadow: 0 5px 0 #0d1312, 0 0 18px rgba(25,211,211,.55), inset 0 1px 0 rgba(255,255,255,.2); color: #fff; }
.stone-btn:active { transform: translateY(4px); box-shadow: 0 1px 0 #0d1312; }
.stone-btn:focus-visible { outline: 3px solid #19d3d3; outline-offset: 3px; }

.loading-panel { padding: 20px 50px 30px; }
.progress { width: 420px; height: 22px; border-radius: 11px; background: #0b1110; border: 2px solid #8a6a22; overflow: hidden; }
#loadBar { height: 100%; width: 0; background: linear-gradient(90deg, #1fae5b, #19d3d3, #f5c84a); transition: width .15s; }

#hud { position: absolute; left: 0; right: 0; top: 0; height: 54px; display: flex; align-items: center; justify-content: space-between; padding: 0 16px; gap: 16px;
  background: linear-gradient(180deg, rgba(20,30,28,.95), rgba(20,30,28,.6)); border-bottom: 2px solid #8a6a22; }
.hud-left { display: flex; align-items: center; gap: 10px; }
.icon-btn { width: 42px; height: 42px; border-radius: 50%; font: bold 18px Georgia, serif; color: #f5e6b8; cursor: pointer;
  background: radial-gradient(circle at 40% 35%, #5b6a62, #222c28); border: 2px solid #b8913a; }
.icon-btn:hover { box-shadow: 0 0 12px rgba(25,211,211,.6); }
.icon-btn:focus-visible { outline: 3px solid #19d3d3; }
.icon-btn.off { opacity: .45; text-decoration: line-through; }
.hud-level { font-size: 20px; letter-spacing: 3px; color: #f5c84a; margin-left: 6px; }
.hud-meter { flex: 1; max-width: 300px; height: 12px; border-radius: 6px; background: #0b1110; border: 1px solid #8a6a22; overflow: hidden; }
#meterFill { height: 100%; width: 0; background: linear-gradient(90deg, #1fae5b, #ffd23f, #d7263d); }
.hud-score { font-size: 20px; letter-spacing: 2px; color: #e9dcb4; }
#hudScore { display: inline-block; min-width: 90px; text-align: right; color: #19d3d3; font-size: 26px; font-weight: bold; }
.swap-btn { position: absolute; left: 18px; bottom: 18px; width: 110px; height: 56px; border-radius: 14px; font: bold 18px Georgia, serif; color: #f5e6b8; cursor: pointer;
  background: linear-gradient(180deg, #4b5a52, #1f2925); border: 2px solid #b8913a; box-shadow: 0 4px 0 #0d1312; }
.swap-btn:active { transform: translateY(3px); box-shadow: none; }
