/* Deadlock Deck: El Reloj Anatómico — alchemical gothic skin for the DOM layer.
   Dark stone and iron, brass and verdigris accents, ember highlights.
   Palette from PRODUCT.md 5.5. No web fonts, no images, no dependencies. */

:root {
  --void: #0d0b12;
  --stone: #141019;
  --iron: #241f2e;
  --iron-2: #3a3346;
  --bone: #d9cdb4;
  --bone-dim: #9a8f79;
  --rot: #3f5c46;
  --verd: #4e8c7a;
  --brass: #b08d3f;
  --brass-lit: #e0c069;
  --ember: #d8622b;
  --blood: #7a1f22;
  --violet: #5b3a72;
  --font: "Lucida Console", "Cascadia Mono", Consolas, "DejaVu Sans Mono", "Courier New", monospace;
  --tap: 44px;
}

*, *::before, *::after { box-sizing: border-box; }

/* index.html ships #dialog and #toast with the hidden attribute, and #combat-bar /
   #explore-bar are hidden by DD.UI.setMode the same way. */
[hidden] { display: none !important; }

html, body {
  height: 100%;
  margin: 0;
  overflow: hidden;                     /* the page itself never scrolls, ever */
  background: var(--void);
  color: var(--bone);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.25;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior: none;
}

body {
  background:
    radial-gradient(120% 70% at 50% 0%, #221b2c 0%, var(--void) 65%),
    repeating-linear-gradient(0deg, rgba(217, 205, 180, .014) 0 1px, transparent 1px 3px);
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
}

#app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  max-width: 1500px;
  margin: 0 auto;
  overflow: hidden;
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
}

button { font-family: inherit; touch-action: manipulation; }
:focus-visible { outline: 2px solid var(--verd); outline-offset: 2px; }

/* ------------------------------------------------------------------ HUD */

#hud {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 0 0 auto;
  padding: calc(6px + env(safe-area-inset-top)) 10px 6px;
  background: linear-gradient(#241d2e, #171320);
  border-bottom: 2px solid var(--iron-2);
  box-shadow: inset 0 -2px 0 #000, 0 6px 18px rgba(0, 0, 0, .6);
}

#clock-value {
  display: block;
  min-width: 3.6em;
  font-size: 26px;
  letter-spacing: .06em;
  color: var(--bone);
  text-shadow: 0 0 10px rgba(217, 205, 180, .22);
}

#clock.low #clock-value {
  color: var(--ember);
  text-shadow: 0 0 12px rgba(216, 98, 43, .85);
}
#clock.low { animation: clock-pulse .85s steps(2, end) infinite; }

@keyframes clock-pulse { 50% { opacity: .35; } }

#vitals {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1 1 auto;
  min-width: 0;
}

#hp-bar {
  position: relative;
  flex: 1 1 auto;
  min-width: 84px;
  height: 18px;
  background: #170d10;
  border: 1px solid #4a2b2c;
  box-shadow: inset 0 0 0 1px #000;
  overflow: hidden;
}

#hp-fill {
  display: block;
  height: 100%;
  width: 100%;
  background: linear-gradient(#b32f31, var(--blood));
  box-shadow: inset 0 -6px 8px rgba(0, 0, 0, .5);
  transition: width .18s steps(6, end);
}

#hp-bar.low #hp-fill { background: linear-gradient(var(--ember), #7a2413); }

#hp-text {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  text-shadow: 0 1px 0 #000, 0 0 6px #000;
}

#cycle-text {
  color: var(--brass);
  font-size: 12px;
  white-space: nowrap;
}

#btn-sound {
  flex: 0 0 auto;
  width: var(--tap);
  height: var(--tap);
  font-size: 20px;
  color: var(--brass-lit);
  background: linear-gradient(#2a2334, #181320);
  border: 1px solid var(--iron-2);
  border-bottom-width: 3px;
  cursor: pointer;
}

#btn-sound.off { color: #5d5766; }
#btn-sound.off::after {
  content: "";
  position: absolute;
  inset: 0;
  margin: 6px 4px;
  border-top: 2px solid var(--blood);
  transform: rotate(-32deg);
  pointer-events: none;
}
#btn-sound { position: relative; }

/* Same brass plate as the sound button, one notch narrower: it carries two letters. */
#btn-lang {
  flex: 0 0 auto;
  width: var(--tap);
  height: var(--tap);
  font-size: 13px;
  letter-spacing: .08em;
  color: var(--brass-lit);
  background: linear-gradient(#2a2334, #181320);
  border: 1px solid var(--iron-2);
  border-bottom-width: 3px;
  cursor: pointer;
}

/* ----------------------------------------------------------------- stage */

#stage {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 6px;
  background: #0a0810;
  box-shadow: inset 0 0 90px #000;
  overflow: hidden;
}

#scene {
  display: block;
  box-sizing: content-box;                /* keeps the integer pixel scale exact */
  max-width: 100%;
  max-height: 100%;
  aspect-ratio: 16 / 9;
  image-rendering: pixelated;
  background: var(--void);
  box-shadow: 0 0 26px rgba(176, 141, 63, .18), 0 0 0 1px #2b2433;
}

#vignette {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(ellipse at 50% 50%, rgba(0, 0, 0, 0) 45%, rgba(0, 0, 0, .62) 100%);
}

/* -------------------------------------------------------------- anatomy */

#anatomy {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 6px;
  flex: 0 0 auto;
  padding: 6px 8px;
  background: linear-gradient(#181320, #100d15);
  border-top: 2px solid var(--iron-2);
  box-shadow: inset 0 2px 0 rgba(0, 0, 0, .8);
}

.slot {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  padding: 3px 5px 4px;
  background: #100d15;
  border: 1px solid #2a2434;
  border-left: 3px solid var(--tint, #4b4356);
  box-shadow: inset 0 0 10px rgba(0, 0, 0, .6);
}

.slot-label {
  font-size: 9px;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--bone-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.slot-limb {
  font-size: 11px;
  color: var(--bone);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.heat {
  position: relative;
  display: block;
  height: 10px;
  background: #07060b;
  border: 1px solid #2a2434;
  overflow: hidden;
}

.heat-fill {
  display: block;
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--verd), var(--brass) 55%, var(--ember));
  transition: width .18s steps(8, end);
}

.heat-num {
  position: absolute;
  right: 2px;
  top: 0;
  font-size: 9px;
  font-weight: 400;
  color: #cdc1a8;
  text-shadow: 0 1px 0 #000, 0 0 4px #000;
}

.slot.hot {
  border-color: var(--ember);
  box-shadow: inset 0 0 12px rgba(216, 98, 43, .35);
}
.slot.hot .heat-num { color: var(--ember); }

.slot.stump { border-left-color: var(--blood); background: #120a0e; }
.slot.stump .slot-limb { color: #95808a; }

.mark {
  position: absolute;
  top: 2px;
  right: 3px;
  padding: 0 3px;
  font-size: 8px;
  letter-spacing: .08em;
  color: var(--bone);
  background: var(--blood);
  box-shadow: 0 0 6px rgba(122, 31, 34, .9);
}

/* ----------------------------------------------------------- combat bar */

#combat-bar {
  display: flex;
  flex-direction: column;
  gap: 5px;
  flex: 0 0 auto;
  padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
  background: linear-gradient(#1c1623, #100d15);
  border-top: 2px solid var(--iron-2);
}

#combat-top {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

#energy-text {
  flex: 0 0 auto;
  padding: 3px 7px;
  font-size: 12px;
  color: var(--brass-lit);
  white-space: nowrap;
  background: #1d1508;
  border: 1px solid var(--brass);
}

#combat-log {
  flex: 1 1 auto;
  min-width: 0;
  font-size: 10px;
  line-height: 1.3;
  color: var(--bone-dim);
}

.logline {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.logline:last-child { color: var(--bone); }

#btn-end-turn {
  flex: 0 0 auto;
  min-height: var(--tap);
  padding: 0 12px;
  font-size: 12px;
  color: var(--bone);
  background: linear-gradient(#3a2a1c, #241708);
  border: 1px solid var(--brass);
  border-bottom-width: 3px;
  cursor: pointer;
}
#btn-end-turn:hover { color: var(--brass-lit); background: linear-gradient(#4a3620, #2c1c0a); }

#hand {
  display: flex;
  gap: 6px;
  padding: 2px;
  overflow-x: auto;
  overflow-y: hidden;
  overscroll-behavior-x: contain;
  scroll-snap-type: x proximity;
  scrollbar-width: thin;
}

.card {
  flex: 0 0 auto;
  width: 126px;
  min-height: 76px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 6px;
  text-align: left;
  font-size: 11px;
  color: var(--bone);
  background: linear-gradient(#251e30, #171320);
  border: 1px solid var(--iron-2);
  border-bottom-width: 3px;
  box-shadow: inset 0 0 14px rgba(0, 0, 0, .55), 0 2px 0 #000;
  cursor: pointer;
  scroll-snap-align: start;
}

.card:hover:not(:disabled) { border-color: var(--brass); transform: translateY(-1px); }
.card:active:not(:disabled) { transform: translateY(1px); }
.card:disabled { opacity: .4; filter: grayscale(.7); cursor: not-allowed; }

.card.warn {
  border-color: var(--ember);
  box-shadow: 0 0 0 1px var(--ember), 0 0 14px rgba(216, 98, 43, .45);
}

.card-top { display: flex; align-items: center; gap: 5px; }

.card-cost {
  flex: 0 0 auto;
  width: 20px;
  height: 20px;
  display: grid;
  place-items: center;
  font-size: 12px;
  color: #1a1206;
  background: radial-gradient(circle at 35% 30%, var(--brass-lit), var(--brass) 60%, #6b5320);
  border-radius: 50%;
  box-shadow: inset 0 0 0 1px #000;
}

.card-name {
  flex: 1 1 auto;
  min-width: 0;
  font-size: 11px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.card-heat { flex: 0 0 auto; font-size: 10px; font-weight: 700; color: var(--ember); }
.card.warn .card-heat { text-shadow: 0 0 7px var(--ember); }

.card-text { font-size: 10px; line-height: 1.3; color: var(--bone-dim); }

/* ----------------------------------------------------------- explore bar */

#explore-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  flex: 0 0 auto;
  padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
  background: linear-gradient(#1c1623, #100d15);
  border-top: 2px solid var(--iron-2);
}

#explore-mid {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  min-width: 0;
}

#explore-bar button {
  width: 48px;
  height: 48px;
  min-width: var(--tap);
  min-height: var(--tap);
  font-size: 18px;
  color: var(--bone);
  background: linear-gradient(#2a2334, #181320);
  border: 1px solid var(--iron-2);
  border-bottom-width: 3px;
  cursor: pointer;
}
#explore-bar button.open { border-color: var(--brass); color: var(--brass-lit); }
#explore-bar button.open:hover { background: linear-gradient(#342a44, #1d1727); }
#explore-bar button:disabled { opacity: .28; cursor: not-allowed; }

#room-label {
  max-width: 46vw;
  font-size: 12px;
  color: var(--brass);
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* --------------------------------------------------------------- dialog */

#dialog {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 14px;
  background: rgba(6, 5, 10, .84);
}

#dialog-panel {
  width: min(560px, 100%);
  max-height: 86dvh;
  overflow-y: auto;
  padding: 14px;
  background: linear-gradient(#211a2b, #141019);
  border: 2px solid var(--brass);
  box-shadow: 0 0 0 4px #0a0810, 0 14px 44px #000, inset 0 0 44px rgba(0, 0, 0, .7);
}

#dialog-title {
  margin: 0 0 8px;
  font-size: 15px;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--brass-lit);
}

#dialog-body {
  margin: 0 0 12px;
  font-size: 13px;
  color: var(--bone);
}

#dialog-options { display: flex; flex-direction: column; gap: 8px; }

#dialog-options button {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-height: var(--tap);
  padding: 8px 10px;
  text-align: left;
  font-size: 13px;
  color: var(--bone);
  background: linear-gradient(#251e30, #171320);
  border: 1px solid var(--iron-2);
  border-left: 3px solid var(--verd);
  cursor: pointer;
}
#dialog-options button:hover {
  border-color: var(--brass);
  background: linear-gradient(#2d2439, #1c1623);
}

.option-sub { font-size: 11px; color: var(--bone-dim); }

/* ---------------------------------------------------------------- toast */

#toast {
  position: fixed;
  left: 50%;
  top: calc(env(safe-area-inset-top) + 62px);
  z-index: 50;
  max-width: min(92vw, 520px);
  padding: 8px 14px;
  transform: translateX(-50%);
  font-size: 12px;
  text-align: center;
  color: var(--bone);
  background: rgba(16, 13, 21, .96);
  border: 1px solid var(--brass);
  box-shadow: 0 8px 24px #000;
  opacity: 0;
  transition: opacity .18s linear;
  pointer-events: none;
}
#toast.show { opacity: 1; }

/* ----------------------------------------------------------- responsive */

/* Narrow phones: two rows of three slots, tighter chrome, still 44px targets. */
@media (max-width: 760px) {
  #anatomy { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 4px; padding: 4px 6px; }
  .slot-limb { font-size: 10px; }
  #clock-value { font-size: 22px; }
  #cycle-text { font-size: 11px; }
  #combat-log { font-size: 9px; }
  .card { width: 116px; min-height: 72px; }
  #scene { max-height: 46vh; }
}

/* Short viewports (landscape phones, small laptops): trim the chrome further. */
@media (max-height: 620px) {
  #anatomy { padding: 3px 6px; }
  .slot { padding: 2px 4px 3px; }
  .slot-limb { font-size: 10px; }
  #combat-bar { padding: 4px 6px; gap: 3px; }
  .card { min-height: 64px; }
  #scene { max-height: 42vh; }
}

/* Desktop: roomier type and a hand that wraps instead of scrolling. */
@media (min-width: 1000px) {
  html, body { font-size: 15px; }
  #hand { flex-wrap: wrap; justify-content: center; overflow-x: visible; }
  .card { width: 148px; min-height: 86px; }
  .card-name { font-size: 12px; }
  .card-text { font-size: 11px; }
  #room-label { max-width: 30vw; }
  #clock-value { font-size: 30px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
  }
  .card:hover:not(:disabled) { transform: none; }
}
