* { box-sizing: border-box; }
html, body {
  margin: 0; height: 100%; background: #0b0810; overflow: hidden;
  font-family: 'Alegreya', Georgia, serif; color: #2a1608;
  -webkit-user-select: none; user-select: none; touch-action: none;
  -webkit-tap-highlight-color: transparent;
  font-variant-numeric: lining-nums;
}
button { font-family: inherit; color: inherit; }
#wrap { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; }
#game { position: relative; width: 1280px; height: 720px; flex: none; transform-origin: center; overflow: hidden; background: #000; }
#cv { position: absolute; left: 0; top: 0; width: 1280px; height: 720px; }
#ui, #modal { position: absolute; left: 0; top: 0; width: 1280px; height: 686px; pointer-events: none; }
#ui > *, #modal > * { pointer-events: auto; }
#ui > .hud, #ui > .logo, #ui > .tip, #ui > .toast, #ui > .record { pointer-events: none; }
.hud > *, .record > * { pointer-events: auto; }

/* ---------- bottom bar ---------- */
#bottombar {
  position: absolute; left: 0; right: 0; bottom: 0; height: 34px; background: #0e0b10;
  display: flex; align-items: center; gap: 30px; padding: 0 22px; border-top: 2px solid #2a1a2a;
}
.bb { background: none; border: 0; text-decoration: none; color: #e8dcc0; font: 600 13px 'Cinzel', serif; letter-spacing: 2px; cursor: pointer; padding: 6px 0; }
.bb:hover { color: #ffd23a; }
.bb-right { margin-left: auto; color: #8a7a6a; font: 600 12px 'Cinzel', serif; letter-spacing: 2px; }

/* ---------- common ---------- */
.parch {
  background: linear-gradient(135deg, #f8e0b4 0%, #ecbd7e 45%, #cf8f52 100%);
  border: 3px solid #2a1608; border-radius: 8px 16px 10px 14px;
  box-shadow: 0 6px 0 rgba(0,0,0,.35), inset 0 0 34px rgba(120,60,10,.35);
  color: #2a1608;
}
.btn {
  font: 700 22px 'Cinzel', serif; letter-spacing: 1px;
  background: linear-gradient(#f4a868, #c8582e 55%, #8a2e16);
  border: 3px solid #2a1608; border-radius: 14px; color: #fff6e0;
  text-shadow: 0 2px 0 #4a1a08; padding: 10px 30px; cursor: pointer; min-width: 280px;
  box-shadow: 0 5px 0 #2a1608, inset 0 2px 0 rgba(255,255,255,.4);
  transition: filter .12s, transform .08s;
}
.btn:hover { filter: brightness(1.12); }
.btn:active { transform: translateY(3px); box-shadow: 0 2px 0 #2a1608; }
.btn.big { font-size: 30px; padding: 12px 30px; }
.btn.alt { background: linear-gradient(#8ab0e8, #3a62b8 55%, #1a3478); text-shadow: 0 2px 0 #0a1a48; }
.dim { color: #6a4a2a; font-style: italic; font-size: 16px; }
.ptitle { font: 700 15px 'Cinzel', serif; letter-spacing: 2px; margin: 10px 0 6px; color: #3a1a08; }

.toast {
  position: absolute; left: 50%; top: 150px; transform: translateX(-50%); padding: 10px 24px; border-radius: 12px;
  background: rgba(20,10,4,.88); color: #ffe08a; font: 700 21px 'Alegreya', serif; border: 2px solid #ffd23a;
  transition: opacity .4s; max-width: 900px; text-align: center; white-space: nowrap;
}
.toast.out { opacity: 0; }

/* ---------- modal ---------- */
.mback { position: absolute; inset: 0; background: rgba(10,4,2,.55); display: flex; align-items: center; justify-content: center; }
.mbox { position: relative; width: 640px; max-height: 640px; padding: 20px 28px 22px; }
.mbox.small { width: 420px; }
.mbox.mid { width: 700px; }
.mbox.wide { width: 980px; }
.mbox.win { box-shadow: 0 6px 0 rgba(0,0,0,.35), 0 0 60px rgba(255,210,60,.6), inset 0 0 34px rgba(120,60,10,.35); }
.mtitle { font: 900 30px 'Cinzel', serif; letter-spacing: 3px; text-transform: uppercase; margin-bottom: 10px; text-align: center; }
.mbody { max-height: 560px; overflow-y: auto; padding-right: 6px; font-size: 19px; }
.mclose {
  position: absolute; right: -16px; top: -16px; width: 46px; height: 46px; border-radius: 50%; cursor: pointer;
  background: radial-gradient(circle at 38% 32%, #f49a6a, #c8402a 58%, #7a1a0e); border: 3px solid #3a1208;
  color: #fff6e0; font: 900 20px 'Alegreya', serif; box-shadow: 0 4px 0 rgba(0,0,0,.4);
}
.mclose:hover { filter: brightness(1.15); }
.menu { display: flex; flex-direction: column; gap: 14px; align-items: center; }
.menu.row { flex-direction: row; justify-content: center; margin-top: 18px; }
.menu.row .btn { min-width: 220px; }
.drow { display: flex; justify-content: space-between; padding: 6px 4px; border-bottom: 1px dashed rgba(42,22,8,.35); font-size: 20px; }
.endq { text-align: center; font: italic 700 21px 'Alegreya', serif; margin: 0 0 12px; }
.stars { text-align: center; font-size: 40px; color: #ffb81a; text-shadow: 0 2px 0 #6a3a08, 0 0 14px rgba(255,210,60,.8); margin-top: 10px; }
.stars span { font: 800 22px 'Alegreya', serif; color: #6a3a08; text-shadow: none; }

/* ---------- title ---------- */
.logo { position: absolute; left: 0; right: 0; top: 60px; text-align: center; }
.logo-main {
  font: 900 108px/1.05 'Cinzel', serif; letter-spacing: 4px; color: #ffcf3a;
  text-shadow: 0 4px 0 #8a4a08, 0 8px 0 #1b1009, 0 0 40px rgba(255,190,80,.6);
  -webkit-text-stroke: 3px #3a1a04;
}
.logo-sub { font: 700 28px 'Cinzel', serif; letter-spacing: 6px; color: #fff6e0; margin-top: 6px; text-shadow: 0 3px 0 #1b1009; }
#ui > .menu { position: absolute; left: 50%; top: 300px; transform: translateX(-50%); }
.record { position: absolute; left: 0; right: 0; bottom: 18px; display: flex; justify-content: center; gap: 30px; }
.record span { background: rgba(20,10,4,.7); color: #ffe08a; border: 2px solid #ffd23a; border-radius: 10px; padding: 5px 16px; font: 700 19px 'Alegreya', serif; }

.mcards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; padding: 14px 10px 8px; }
.mcard {
  position: relative; text-align: left; padding: 18px 18px 22px; border: 3px solid #2a1608; border-radius: 14px; cursor: pointer;
  background: linear-gradient(#fff2d4, #f0c88a); box-shadow: 0 5px 0 #2a1608; min-height: 190px; transition: transform .1s, filter .1s;
}
.mcard:hover:not([disabled]) { transform: translateY(-3px); filter: brightness(1.06); }
.mcard.soon { filter: grayscale(.7); opacity: .75; cursor: default; }
.mc-t { font: 900 24px 'Cinzel', serif; margin-bottom: 8px; }
.mc-d { font: 600 18px/1.3 'Alegreya', serif; }
.mc-soon { position: absolute; right: -8px; top: -12px; background: #c8402a; color: #fff6e0; font: 800 15px 'Cinzel', serif; padding: 4px 12px; border-radius: 8px; border: 2px solid #2a1608; transform: rotate(6deg); }
.dlist { display: flex; flex-direction: column; gap: 10px; }
.drow-btn {
  display: grid; grid-template-columns: 150px 1fr 112px; align-items: center; gap: 14px; text-align: left; cursor: pointer;
  padding: 12px 16px; border: 3px solid #2a1608; border-radius: 12px; background: linear-gradient(#fff2d4, #f0c88a); box-shadow: 0 4px 0 #2a1608;
}
.drow-btn:hover { filter: brightness(1.07); transform: translateY(-2px); }
.drow-btn b { font: 900 22px 'Cinzel', serif; }
.drow-btn span { font: 600 17px 'Alegreya', serif; }
.drow-btn em { font-style: normal; color: #d88a10; font-size: 22px; text-align: right; text-shadow: 0 1px 0 #6a3a08; }
.d-easy b { color: #2a7a2a; } .d-normal b { color: #2a4a9a; } .d-hard b { color: #a8401a; } .d-impossible b { color: #8a0a2a; }

.howgrid { display: grid; grid-template-columns: 1.25fr 1fr; gap: 26px; }
.howto { margin: 0; padding-left: 22px; }
.howto li { margin: 8px 0; line-height: 1.3; }
.krow { display: flex; align-items: center; gap: 10px; margin: 5px 0; font-size: 17px; }
kbd { min-width: 64px; text-align: center; background: #2a1608; color: #ffe08a; border-radius: 6px; padding: 2px 8px; font: 700 14px 'Alegreya', serif; box-shadow: 0 2px 0 #000; }
.tri { font-size: 17px; line-height: 1.3; }
.credits { font-size: 21px; line-height: 1.5; white-space: pre-line; text-align: center; }

/* ---------- HUD ---------- */
.hud { position: absolute; left: 0; top: 0; right: 0; }
.hpanel {
  position: absolute; top: 6px; padding: 8px 12px;
  background: linear-gradient(#d8a868, #b8803e); border: 3px solid #2a1608; border-radius: 10px;
  box-shadow: 0 4px 0 rgba(0,0,0,.35), inset 0 0 18px rgba(90,40,0,.35), inset 0 2px 0 rgba(255,240,200,.4);
}
.hpanel.left { left: 8px; width: 262px; }
.hpanel.mid { left: 278px; width: 404px; }
.hpanel.right { right: 8px; padding: 7px 8px; }
.res { display: flex; align-items: center; gap: 8px; font: 800 26px/1.1 'Alegreya', serif; color: #2a1608; }
.res .ico { width: 30px; height: 30px; }
.res .ico svg { width: 100%; height: 100%; }
.res .inc { font: 700 15px 'Alegreya', serif; color: #2a5a10; margin-left: auto; }
.res.xp { font-size: 20px; margin-top: 2px; }
.xplbl { display: inline-block; width: 30px; text-align: center; font: 900 15px 'Cinzel', serif; color: #8a1a10; }
.agebar { position: relative; height: 20px; border: 2.5px solid #2a1608; border-radius: 10px; background: #5a2a10; overflow: hidden; margin-top: 5px; }
.agebar .fill { position: absolute; left: 0; top: 0; bottom: 0; background: linear-gradient(#ffe27a, #e8a020); transition: width .25s; }
.agebar span { position: relative; display: block; text-align: center; font: 800 13px/15px 'Alegreya', serif; color: #fff6e0; text-shadow: 0 1px 0 #1b1009, 0 0 3px #1b1009; }
.agename { font: 800 14px 'Cinzel', serif; letter-spacing: 1px; color: #3a1a08; margin-top: 4px; text-align: center; white-space: nowrap; overflow: hidden; }

.qrow { display: flex; gap: 6px; align-items: center; }
.qbar { position: relative; flex: 1; height: 24px; border: 2.5px solid #2a1608; border-radius: 6px; background: rgba(255,240,210,.5); overflow: hidden; }
.qbar .fill { position: absolute; left: 0; top: 0; bottom: 0; background: linear-gradient(#ff8a6a, #c8302a); }
.qtext { position: relative; display: block; padding-left: 8px; font: 700 15px/19px 'Alegreya', serif; color: #2a1608; white-space: nowrap; }
.sbtn { width: 38px; height: 26px; border: 2.5px solid #2a1608; border-radius: 6px; background: #f8e0b4; font: 800 14px 'Alegreya', serif; cursor: pointer; padding: 0; }
.sbtn:hover { background: #ffd23a; }
.qslots { display: flex; gap: 6px; margin: 5px 0; }
.qs { width: 36px; height: 36px; border: 2.5px solid #2a1608; border-radius: 6px; background: rgba(255,240,210,.35) center/contain no-repeat; }
.qs.on { background-color: #fff2d4; cursor: pointer; }
.qs.on:hover { background-color: #ffb0a0; }
.minimap { display: block; width: 378px; height: 28px; border: 2.5px solid #2a1608; border-radius: 6px; cursor: pointer; }
.hpanel.mid .qslots { float: left; margin-right: 8px; }
.hpanel.mid .minimap { margin-top: 5px; }

.brow { display: flex; gap: 4px; align-items: center; }
.sep { width: 2px; height: 50px; background: rgba(42,22,8,.4); margin: 0 3px; }
.abtn {
  position: relative; width: 56px; height: 72px; padding: 0; cursor: pointer; overflow: hidden;
  border: 3px solid #2a1608; border-radius: 9px; background: linear-gradient(#fff4dc, #e8c08a);
  box-shadow: 0 3px 0 #2a1608, inset 0 2px 0 rgba(255,255,255,.6); transition: transform .08s, filter .1s;
}
.abtn:hover { filter: brightness(1.08); transform: translateY(-2px); }
.abtn:active { transform: translateY(2px); box-shadow: 0 1px 0 #2a1608; }
.abtn .aico { position: absolute; left: 2px; right: 2px; top: 2px; height: 50px; display: flex; align-items: center; justify-content: center; }
.abtn .aico img { max-width: 100%; max-height: 100%; }
.abtn .aico svg { width: 40px; height: 40px; }
.abtn .acost { position: absolute; left: 0; right: 0; bottom: 0; height: 18px; background: #2a1608; color: #ffd860; font: 800 13px/18px 'Alegreya', serif; text-align: center; }
.abtn .ahot { position: absolute; left: 2px; top: 1px; font: 800 11px 'Alegreya', serif; color: #6a3a10; }
.abtn .acd { position: absolute; left: 0; right: 0; top: 0; bottom: 18px; pointer-events: none; }
.abtn.off { filter: grayscale(.75) brightness(.82); }
.abtn.off:hover { transform: none; }
.abtn.unit.live { box-shadow: 0 3px 0 #2a1608, 0 0 12px #ffd23a; }
.abtn.age.ready, .abtn.special.ready { background: linear-gradient(#fff6b0, #ffc23a); animation: pulse 1s infinite alternate; }
.abtn.special { background: linear-gradient(#f4dcff, #c89ae8); }
@keyframes pulse { from { box-shadow: 0 3px 0 #2a1608, 0 0 4px #ffd23a; } to { box-shadow: 0 3px 0 #2a1608, 0 0 18px #ffd23a; } }

.tip {
  position: absolute; top: 102px; width: 300px; padding: 10px 14px; border-radius: 10px; opacity: 0; transition: opacity .1s; z-index: 5;
  background: rgba(24,12,4,.94); border: 2px solid #ffd23a; color: #fff6e0; font: 600 16px/1.3 'Alegreya', serif;
}
.tip.on { opacity: 1; }
.tip b { font: 800 19px 'Alegreya', serif; color: #ffe08a; }
.tip p { margin: 6px 0 0; }
.tip .trow { display: flex; justify-content: space-between; border-bottom: 1px dashed rgba(255,224,138,.25); padding: 2px 0; }
.tip .trow span { color: #d8c8a8; }
.tip .good { color: #8ae86a; } .tip .bad { color: #ff9a8a; } .tip .dim { color: #c8b898; font-size: 14px; }
.tip .cls { font-style: normal; font-size: 13px; padding: 1px 7px; border-radius: 6px; margin-left: 4px; background: #5a4a3a; color: #fff; }
.tip .cls.inf { background: #3a6ab8; } .tip .cls.rng { background: #3a8a3a; } .tip .cls.hvy { background: #a8501a; } .tip .cls.hero { background: #b8901a; }

.tmenu { position: absolute; top: 96px; right: 230px; width: 330px; padding: 10px 14px; }
.tmenu .ttl { font: 900 18px 'Cinzel', serif; letter-spacing: 2px; margin-bottom: 4px; }
.trow2 { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 6px 0; border-bottom: 1px dashed rgba(42,22,8,.35); font: 700 16px 'Alegreya', serif; }
.trow2.locked { opacity: .85; }
.tnote { font-size: 13px; color: #5a3a1a; margin-top: 6px; }
.buy {
  font: 700 14px 'Alegreya', serif; padding: 5px 8px; border-radius: 8px; border: 2.5px solid #1b1009; cursor: pointer; white-space: nowrap;
  background: linear-gradient(#8ae06a, #3a9a2a); color: #fff; text-shadow: 0 1px 0 #1a4a0a;
}
.buy:hover:not([disabled]) { filter: brightness(1.1); }
.buy[disabled] { filter: grayscale(.8); cursor: default; }
.buy.sell { background: linear-gradient(#ffd06a, #d88a1a); text-shadow: 0 1px 0 #6a3a08; }

/* ---------- rotate overlay ---------- */
#rotate { display: none; position: fixed; inset: 0; background: rgba(10,6,12,.94); color: #ffe08a; z-index: 10; flex-direction: column; align-items: center; justify-content: center; font: 700 22px 'Alegreya', serif; text-align: center; padding: 30px; }
#rotate div { font-size: 80px; animation: spin 2.5s infinite; }
#rotate.show { display: flex; }
@keyframes spin { 0%, 30% { transform: rotate(0); } 60%, 100% { transform: rotate(90deg); } }
