/* Duskward handheld shell: dark plum body, brass trim, ember buttons. */
:root {
  --body-top: #29262b;
  --body-bottom: #19171c;
  --bezel: #121214;
  --brass: #d49e4d;
  --brass-dim: rgba(212, 158, 77, 0.35);
  --brass-faint: rgba(212, 158, 77, 0.12);
  --ember: #e87333;
  --ember-down: #b6582a;
  --key: #0d0d0f;
  --scale: 2;          /* set by duskward.js: CSS px per game pixel */
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--body-bottom);
  color: var(--brass);
  font-family: ui-rounded, "SF Pro Rounded", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  overscroll-behavior: none;
}

body {
  background: linear-gradient(180deg, var(--body-top), var(--body-bottom)) fixed;
  touch-action: manipulation;
}

.handheld {
  width: 100%;
  max-width: 480px;
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  padding: max(10px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 34px;
  padding: 0 4px;
}
.mark {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-weight: 800;
  font-size: 13px;
  letter-spacing: 0.32em;
  color: var(--brass);
  opacity: 0.85;
}
.mark svg { width: 10px; height: 14px; fill: var(--brass); }

.sound {
  width: 34px;
  height: 34px;
  border: 1px solid var(--brass-dim);
  border-radius: 10px;
  background: var(--bezel);
  display: grid;
  place-items: center;
  cursor: pointer;
  padding: 0;
}
.sound svg { width: 18px; height: 18px; fill: none; stroke: var(--brass); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.sound .spk { fill: var(--brass); }
.sound .x { display: none; }
.sound.muted .wave { display: none; }
.sound.muted .x { display: inline; }
.sound:focus-visible { outline: 2px solid var(--brass); outline-offset: 2px; }

.bezel {
  align-self: center;
  margin-top: 6px;
  padding: 14px 14px 10px;
  background: var(--bezel);
  border: 1px solid var(--brass-dim);
  border-radius: 18px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.03);
}

.screen {
  position: relative;
  width: calc(160px * var(--scale));
  height: calc(144px * var(--scale));
  background: #000;
}
#screen {
  display: block;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

.loading {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  background: radial-gradient(ellipse at 50% 30%, #283468 0%, #141a38 55%, #0c1024 100%);
  transition: opacity 0.35s ease;
}
.loading.done { opacity: 0; pointer-events: none; }
.loading-title { font-weight: 900; letter-spacing: 0.4em; font-size: 18px; color: #f8d068; text-shadow: 0 0 18px rgba(248, 208, 104, 0.5); padding-left: 0.4em; }
.bar { width: 55%; height: 6px; border-radius: 3px; background: rgba(212, 158, 77, 0.18); overflow: hidden; }
.bar i { display: block; height: 100%; width: 0; background: var(--brass); transition: width 0.15s linear; }
.loading-note { font-size: 12px; letter-spacing: 0.08em; color: rgba(212, 158, 77, 0.8); text-align: center; padding: 0 16px; }

.hud {
  display: flex;
  align-items: center;
  gap: 6px;
  height: 26px;
  margin-top: 8px;
  padding: 0 4px;
}
.hud .flame { width: 9px; height: 12px; fill: var(--brass); flex: none; }
.place {
  font-weight: 850;
  font-size: 12px;
  letter-spacing: 0.17em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}
.spacer { flex: 1; }
.time svg { width: 14px; height: 14px; display: none; vertical-align: middle; }
.time .moon { fill: var(--brass); }
.time .sun { fill: var(--brass); stroke: var(--brass); stroke-width: 1.4; stroke-linecap: round; }
.time.night .moon, .time.day .sun { display: inline-block; opacity: 0.85; }
.embers { display: inline-flex; gap: 3px; margin-left: 4px; }
.embers i {
  width: 7px;
  height: 10px;
  background: var(--brass);
  opacity: 0.2;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 16'%3E%3Cpath d='M6 0c1 3 5 5 5 10a5 5 0 0 1-10 0c0-3 2-4 3-7 1 2 1.5 3 1.5 4.5C7 5.5 6.5 3 6 0z'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 16'%3E%3Cpath d='M6 0c1 3 5 5 5 10a5 5 0 0 1-10 0c0-3 2-4 3-7 1 2 1.5 3 1.5 4.5C7 5.5 6.5 3 6 0z'/%3E%3C/svg%3E") center / contain no-repeat;
}
.embers i.lit { opacity: 1; }

/* ---- controls ---- */
.controls {
  position: relative;
  flex: 1;
  min-height: 230px;
  max-height: 340px;
  margin-top: 14px;
  touch-action: none;
  cursor: pointer;
}

.dpad {
  position: absolute;
  left: 25%;
  top: 42%;
  width: var(--pad);
  height: var(--pad);
  transform: translate(-50%, -50%);
  --pad: min(40vw, 150px, 26vh);
}
.dpad .ring { position: absolute; inset: -12%; border-radius: 50%; background: var(--brass-faint); }
.dpad .cross, .dpad .cross::before {
  position: absolute;
  background: var(--key);
  border-radius: 7px;
  box-shadow: 0 3px 0 rgba(0, 0, 0, 0.5);
}
.dpad .cross { left: 29%; top: 0; width: 42%; height: 100%; }
.dpad .cross::before { content: ""; left: -69%; top: 29%; width: 238%; height: 42%; box-shadow: none; }
.dpad .dot {
  position: absolute;
  width: 10px;
  height: 10px;
  margin: -5px 0 0 -5px;
  border-radius: 50%;
  background: var(--brass);
  opacity: 0.35;
  transition: opacity 0.05s;
}
.dpad .dot.up { left: 50%; top: 19%; }
.dpad .dot.down { left: 50%; top: 81%; }
.dpad .dot.left { left: 19%; top: 50%; }
.dpad .dot.right { left: 81%; top: 50%; }
.dpad .dot.on { opacity: 1; }

.face { position: absolute; inset: 0; pointer-events: none; }
.btn {
  position: absolute;
  width: var(--btn);
  height: var(--btn);
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: var(--ember);
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.45);
  --btn: min(17vw, 64px, 11vh);
}
.btn.a { left: 84%; top: 34%; }
.btn.b { left: 66%; top: 50%; }
.btn span {
  position: absolute;
  top: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  font-weight: 900;
  font-size: 15px;
  color: var(--brass);
}
.btn.on { background: var(--ember-down); box-shadow: 0 1px 0 rgba(0, 0, 0, 0.45); margin-top: 3px; }

.pills {
  position: absolute;
  left: 0;
  right: 0;
  top: 82%;
  display: flex;
  justify-content: center;
  gap: 28px;
  pointer-events: none;
}
.pill {
  width: 64px;
  height: 22px;
  border-radius: 11px;
  background: var(--key);
  position: relative;
}
.pill span {
  position: absolute;
  top: calc(100% + 4px);
  left: 50%;
  transform: translateX(-50%);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.06em;
  color: rgba(212, 158, 77, 0.8);
}
.pill.on { background: var(--brass); }

.keys {
  margin: 12px 0 0;
  font-size: 12px;
  line-height: 1.6;
  text-align: center;
  color: rgba(212, 158, 77, 0.65);
}
.keys b { color: var(--brass); font-weight: 800; }

/* Keyboard-and-mouse screens: the touch controls stay (they're clickable) but shrink. */
@media (hover: hover) and (pointer: fine) {
  .handheld { max-width: 620px; }
  .controls { min-height: 200px; max-height: 240px; }
  .dpad { --pad: 132px; }
  .btn { --btn: 58px; }
  .btn.a { left: 80%; }
  .btn.b { left: 64%; }
  .dpad { left: 27%; }
}
@media (hover: none), (pointer: coarse) {
  .keys { display: none; }
}

.noscript { text-align: center; padding: 40px 16px; }
