* { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
  height: 100%; background: #050407; overflow: hidden; color: #e9dcc2;
  font-family: 'Palatino Linotype', 'Book Antiqua', Palatino, Georgia, serif;
  user-select: none; -webkit-user-select: none; -webkit-tap-highlight-color: transparent;
}
img { -webkit-user-drag: none; user-drag: none; }

/* The stage is a fixed 1792 x 1024 canvas that ui.js scales to fit the window. */
#stage { position: absolute; width: 1792px; height: 1024px; transform-origin: 0 0; background: #0d0a10; overflow: hidden; }

/* ---------- left panel ---------- */
#left { position: absolute; left: 0; top: 0; width: 768px; height: 1024px; display: flex; flex-direction: column;
  background: linear-gradient(#130e17, #0a070d); border-right: 3px solid #2a2030; }

#hud { height: 140px; padding: 20px 26px 0; background: #0b080d; border-bottom: 3px solid #251b2b; flex: none; }
.hudrow { display: flex; align-items: center; }
.lbl, .stat { font-variant: small-caps; letter-spacing: .04em; color: #d9ccb0; }
.lbl { font-size: 36px; width: 160px; flex: none; }
.bar { position: relative; height: 40px; border: 3px solid #8a120e; border-radius: 6px; background: #0a0506; overflow: hidden; }
.bar.player { flex: 1; }
.fill { position: absolute; left: 0; top: 0; bottom: 0; width: 100%; background: linear-gradient(#b3180f, #7d0d08); transition: width .35s ease-out; }
.barText { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 30px; color: #f4e9d2; text-shadow: 0 1px 3px #000; }
.stats { margin-top: 8px; justify-content: space-between; }
.stat { font-size: 30px; white-space: nowrap; }
.stat b { font-weight: normal; font-size: 40px; color: #f1e3c0; font-variant: normal; }
#usedWrap { font-size: 22px; opacity: .8; }
#usedWrap b { font-size: 28px; }

#phase { height: 34px; flex: none; display: flex; align-items: center; justify-content: space-between; padding: 0 26px;
  font-size: 20px; letter-spacing: .16em; text-transform: uppercase; color: #a89878; }
#restart { background: none; border: 1px solid #4a3a52; color: #8d7e6a; font: inherit; font-size: 14px; letter-spacing: .08em;
  padding: 3px 10px; border-radius: 4px; cursor: pointer; text-transform: uppercase; }
#restart:hover { color: #e9dcc2; border-color: #8a7a92; }

/* ---------- cards ---------- */
#cards { flex: 1; display: flex; flex-direction: column; padding: 0 22px; min-height: 0; }
.card { position: relative; flex: 1; min-height: 0; margin-bottom: 14px; border: 3px solid var(--accent); border-radius: 6px;
  background: color-mix(in srgb, var(--accent) 16%, #0c0910); display: flex; flex-direction: column; overflow: hidden; touch-action: none; cursor: pointer; }
.card.ready { box-shadow: 0 0 0 2px #e8c862, 0 0 22px 2px rgba(232, 200, 98, .45); }
.cardHead { height: 52px; flex: none; display: flex; background: var(--accent); }
.cardName { flex: 1; padding-left: 16px; font-size: 38px; font-style: italic; font-variant: small-caps; line-height: 52px; color: #f4ead4; white-space: nowrap; }
.cardTab { min-width: 215px; padding: 0 16px; background: #8f1010; text-align: right; font-size: 34px; font-style: italic; line-height: 52px; color: #f6ead0; white-space: nowrap; }
.cardBody { flex: 1; display: flex; min-height: 0; }
.info { width: 300px; flex: none; border-right: 2px solid rgba(255, 255, 255, .07); display: flex; flex-direction: column; justify-content: center;
  align-items: center; text-align: center; padding: 6px 10px; gap: 6px; }
.req { font-size: 26px; font-style: italic; font-variant: small-caps; color: #d6c9ad; line-height: 1.2; }
.req small { display: block; font-size: 24px; color: #a99c82; }
.note { font-size: 24px; font-style: italic; font-variant: small-caps; color: #e6c24f; line-height: 1.15; }
.live { min-height: 26px; font-size: 20px; color: #bfe0a6; letter-spacing: .02em; }
.live.warn { color: #f19b8c; }
.slots { flex: 1; display: flex; align-items: center; justify-content: center; gap: 16px; }
.slot { position: relative; width: 84px; height: 84px; border: 3px solid rgba(255, 255, 255, .13); border-radius: 12px; background: rgba(0, 0, 0, .38);
  display: flex; align-items: center; justify-content: center; }
.slot.over { border-color: #e8c862; background: rgba(232, 200, 98, .14); }
.card.cardOver { filter: brightness(1.12); }
.flipBtn { position: absolute; right: 0; bottom: 0; width: 60px; height: 60px; background: rgba(140, 118, 88, .85); border: none; border-top-left-radius: 8px;
  color: #f1e5cb; font-size: 36px; cursor: pointer; z-index: 4; line-height: 60px; text-align: center; }
.flipBtn:hover { background: rgba(172, 146, 108, .95); }
.holdfill { position: absolute; left: 0; bottom: 0; height: 9px; width: 0; background: linear-gradient(90deg, #c59a2e, #ffe08a); pointer-events: none; }
.card.holding { filter: brightness(1.15); }
.card.holding .holdfill { width: 100%; transition: width var(--hold, 1000ms) linear; }
.card.shake { animation: shake .3s; }
@keyframes shake { 0%, 100% { transform: translateX(0); } 20% { transform: translateX(-9px); } 40% { transform: translateX(8px); } 60% { transform: translateX(-6px); } 80% { transform: translateX(4px); } }

/* ---------- dice ---------- */
#diceRow { height: 176px; flex: none; display: flex; align-items: flex-end; justify-content: space-evenly; padding: 0 20px 26px;
  background: linear-gradient(#150f1c, #0e0914); border-top: 3px solid #2a2030; }
.dieWrap { --d: 100px; position: relative; width: var(--d); height: var(--d); flex: none; touch-action: none; cursor: grab; }
.dieWrap .die { position: absolute; inset: 0; border-radius: 14%; border: 2px solid #3a3040; background-size: 600% 100%; background-repeat: no-repeat;
  box-shadow: 0 3px 8px rgba(0, 0, 0, .65); overflow: hidden; }
.dieWrap.powered .die { border-color: #cba84e; }
.die .num { position: absolute; inset: 0; display: none; align-items: center; justify-content: center; font-size: calc(var(--d) * .6); color: #1a1420; font-weight: bold; }
.die.noart .num { display: flex; }
.die.rolled { animation: rolled .4s ease-out; }
@keyframes rolled { 0% { transform: rotate(-28deg) scale(1.18); } 55% { transform: rotate(14deg) scale(.95); } 100% { transform: none; } }
.dieWrap.dragging { opacity: .3; }
.dieWrap.ghost { position: absolute; z-index: 50; pointer-events: none; cursor: grabbing; filter: drop-shadow(0 8px 12px rgba(0, 0, 0, .7)); }
.ind { position: absolute; left: 50%; top: -26px; width: 16px; height: 16px; margin-left: -8px; border-radius: 50%; z-index: 3; cursor: pointer;
  background: #d8b24f; border: 2px solid #7c6221; box-shadow: 0 0 6px rgba(216, 178, 79, .8); }
.ind::after { content: ''; position: absolute; inset: -9px; }
.ind.spent { background: #4b4650; border-color: #2c2830; box-shadow: none; cursor: default; }
.slot .dieWrap { --d: 74px; cursor: grab; }
.slot .ind { top: -9px; width: 13px; height: 13px; margin-left: -6px; }
.dieWrap.frozen { cursor: not-allowed; }
.dieWrap.frozen .die { filter: saturate(.55) brightness(.9); border-color: #8fd0ff; box-shadow: 0 0 14px rgba(120, 200, 255, .75); }
.dieWrap.frozen .die::after { content: ''; position: absolute; inset: 0; background: url(images/frozen.png) center / 100% 100% no-repeat; }

/* ---------- viewport ---------- */
#viewport { position: absolute; left: 768px; top: 0; width: 1024px; height: 1024px; overflow: hidden; background: #000; }
#bg { position: absolute; left: 0; top: 0; width: 1024px; height: 1024px; }
#creature { position: absolute; left: 192px; top: 192px; width: 640px; height: 640px; }
#creature.shake { animation: creatureShake .25s; }
@keyframes creatureShake { 0%, 100% { transform: translateX(0); } 25% { transform: translateX(-12px); } 50% { transform: translateX(10px); } 75% { transform: translateX(-6px); } }
#stunBanner { position: absolute; display: none; max-width: 620px; pointer-events: none; transform: translate(-50%, -50%); animation: pulse 1.8s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { transform: translate(-50%, -50%) scale(.9, .9); } 50% { transform: translate(-50%, -50%) scale(1.1, 1.1); } }

#enemyHud { position: absolute; left: 162px; top: 44px; width: 700px; height: 140px; background: rgba(5, 4, 6, .82); padding: 12px 50px 0; text-align: center; }
#enemyName { font-size: 52px; font-variant: small-caps; letter-spacing: .04em; color: #efe3c6; line-height: 70px; }
.bar.enemy { height: 40px; margin-top: 6px; }
#attackInfo { position: absolute; left: 162px; top: 198px; width: 700px; display: none; padding: 10px 18px; text-align: center; font-size: 28px; font-style: italic;
  color: #f2d9a4; background: rgba(60, 12, 10, .8); border: 2px solid #8f1010; }
#attackInfo small { display: block; font-size: 20px; color: #cdb88f; margin-top: 2px; }

#flash { position: absolute; inset: 0; pointer-events: none; opacity: 0; }
#flash.red { background: rgba(200, 10, 10, .6); animation: flashFade var(--flashMs, 300ms) ease-out; }
#flash.white { background: rgba(255, 255, 255, .6); animation: flashFade var(--flashMs, 300ms) ease-out; }
#flash.gold { background: rgba(255, 205, 60, .55); animation: flashFade var(--flashMs, 300ms) ease-out; }
@keyframes flashFade { from { opacity: 1; } to { opacity: 0; } }

#log { position: absolute; left: 0; right: 0; bottom: 0; padding: 90px 50px 30px; pointer-events: none; opacity: 0; transition: opacity 1s ease;
  background: linear-gradient(rgba(0, 0, 0, 0), rgba(0, 0, 0, .8) 55%); font-size: 29px; font-style: italic; line-height: 1.35; color: #f0e4c8; text-shadow: 0 2px 4px #000; }
#log.show { opacity: 1; transition: opacity .15s ease; }
#log .line.old { opacity: .55; }

#overlay { position: absolute; inset: 0; display: none; align-items: center; justify-content: center; background: rgba(0, 0, 0, .55); z-index: 20; }
#panel { width: 640px; padding: 40px 44px; border: 3px solid #6b4e2e; background: #130e17; text-align: center; box-shadow: 0 10px 40px rgba(0, 0, 0, .8); }
#panel h2 { font-size: 46px; font-variant: small-caps; font-weight: normal; letter-spacing: .05em; color: #f1e3c0; margin-bottom: 18px; }
#panel p { font-size: 26px; line-height: 1.5; color: #d6c9ad; }
#panel p b { color: #f1e3c0; font-weight: normal; }
#panel button { margin-top: 28px; padding: 12px 36px; font: inherit; font-size: 28px; font-variant: small-caps; color: #1a1208; background: linear-gradient(#e6c565, #b88d2c);
  border: none; border-radius: 6px; cursor: pointer; }
#panel button:hover { filter: brightness(1.1); }
