:root {
  --plum: #411D4B;
  --purple: #77398E;
  --aqua: #93CCD3;
  --yellow: #E3DB49;
  --mist: #DFF0F2;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--plum);
  color: var(--plum);
  font-family: "Atkinson Hyperlegible", sans-serif;
  overflow: hidden;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}

/* A long press on a button must not select text, drag an image, or open the copy menu. */
img {
  -webkit-user-drag: none;
  user-select: none;
  -webkit-touch-callout: none;
}

button, a, .round, .long, .pick {
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

.round .bg, .long .bg, .pick .bg { pointer-events: none; }

canvas {
  display: block;
  width: 100%;
  height: 100%;
}

#ui {
  position: fixed;
  top: 0;
  bottom: 0;
  pointer-events: none;
  container-type: inline-size;
  z-index: 2;
}

#hud {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding: calc(8px + env(safe-area-inset-top)) 8px 0;
}

#hearts {
  display: flex;
  align-items: center;
  gap: 2px;
}

/* Hearts with the health meter under them. */
.life {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
}

/* Ten blocks of health for the heart he is on. */
#health {
  display: flex;
  gap: 2px;
  padding: 2px;
  border-radius: 5px;
  background: rgba(20, 8, 24, 0.75);
  border: 2px solid var(--plum);
}

#health span {
  width: 6px;
  height: 9px;
  border-radius: 2px;
  transition: background-color 0.2s ease, opacity 0.2s ease;
}

#health span.good { background: #6BD35A; }
#health span.low { background: var(--yellow); }
#health span.danger { background: #E2493B; }
#health span.gone { background: #4a3a50; opacity: 0.6; }

.heart {
  height: 22px;
  width: auto;
  display: block;
}

.heart.off {
  filter: grayscale(1) brightness(0.75);
  opacity: 0.45;
}

.score-wrap {
  position: relative;
  height: 40px;
  flex: 0 0 auto;
}

.score-wrap > img:first-child {
  height: 100%;
  width: auto;
  display: block;
}

.score-mark {
  position: absolute;
  left: 7%;
  top: 50%;
  height: 54%;
  width: auto;
  transform: translateY(-50%);
}

#score {
  position: absolute;
  top: 16%;
  bottom: 16%;
  right: 5%;
  width: 52%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: "Bebas Neue", sans-serif;
  font-size: 26px;
  line-height: 1;
  color: var(--yellow);
  letter-spacing: 0.5px;
}

.slot {
  position: relative;
  width: 44px;
  height: 46px;
  flex: 0 0 auto;
}

.slot-bg {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.slot-icon {
  position: absolute;
  left: 50%;
  top: 48%;
  width: 52%;
  height: auto;
  transform: translate(-50%, -50%);
  opacity: 0.38;
}

.slot.on .slot-icon { opacity: 1; }

.hint-wrap {
  position: relative;
  width: min(100%, 520px);
  margin: 4px auto 0;
}

.hint-wrap img {
  width: 100%;
  height: auto;
  display: block;
}

#hint, #picker-title {
  position: absolute;
  inset: 0;
  margin: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 16% 2px;
  text-align: center;
  color: var(--yellow);
  font-size: 16px;
  line-height: 1.2;
}

#controls {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  padding: 0 14px calc(10px + env(safe-area-inset-bottom));
  pointer-events: none;
}

#controls[hidden] { display: none; }

.round {
  position: relative;
  display: block;
  width: 48px;
  height: 51px;
  padding: 0;
  border: 0;
  background: none;
  pointer-events: auto;
  cursor: pointer;
  text-decoration: none;
}

.round.home {
  width: 38px;
  height: 40px;
  margin-bottom: 4px;
}

.round .bg {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.round .glyph {
  position: absolute;
  left: 50%;
  top: 46%;
  width: 44%;
  height: auto;
  transform: translate(-50%, -50%);
  pointer-events: none;
}

#veil {
  position: fixed;
  inset: 0;
  z-index: 4;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  background: rgba(65, 29, 75, 0.35);
}

#veil[hidden] { display: none; }

.dialog {
  position: relative;
  width: min(440px, 94vw);
  background: url("../assets/panel-dialog.png") center / 100% 100% no-repeat;
  padding: 86px 28px 22px;
  text-align: center;
}

/* The ribbon art's front band runs from 4% to 78% of its height, between the tails. */
.dlg-ribbon {
  position: absolute;
  left: 50%;
  top: 10px;
  transform: translateX(-50%);
  width: min(390px, 90%);
  container-type: inline-size;
}

.dlg-ribbon img {
  width: 100%;
  height: auto;
  display: block;
}

.dialog h1 {
  position: absolute;
  left: 10%;
  right: 10%;
  top: 6%;
  height: 70%;
  margin: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding-top: 0.08em;
  font-family: "Bebas Neue", sans-serif;
  font-weight: 400;
  font-size: 10.5cqw;
  letter-spacing: 0.02em;
  color: var(--yellow);
  line-height: 1;
  white-space: nowrap;
}

#dlg-body p {
  margin: 0 0 10px;
  font-size: 17px;
  line-height: 1.35;
  color: var(--plum);
}

.long {
  position: relative;
  width: 210px;
  height: 64px;
  margin: 6px auto 0;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
}

.long .bg {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.long span {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: "Bebas Neue", sans-serif;
  font-size: 32px;
  letter-spacing: 0.4px;
  color: var(--yellow);
  pointer-events: none;
}

@container (min-width: 380px) {
  .heart { height: 26px; }
  .score-wrap { height: 50px; }
  #score { font-size: 30px; }
  .slot { width: 56px; height: 59px; }
  #hint { font-size: 17px; }
}

#picker {
  position: absolute;
  left: 8px;
  right: 8px;
  top: 18%;
  z-index: 5;
  pointer-events: auto;
  text-align: center;
}
#picker[hidden] { display: none !important; }
#picker-row {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-top: 4px;
}
.pick {
  position: relative;
  width: 58px;
  height: 62px;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
}
.pick .bg { width: 100%; height: 100%; object-fit: contain; display: block; }
.pick .glyph {
  position: absolute;
  left: 50%;
  top: 48%;
  width: 68%;
  height: 68%;
  object-fit: contain;
  transform: translate(-50%, -50%);
  pointer-events: none;
}

@container (min-width: 520px) {
  .heart { height: 30px; }
  .score-wrap { height: 56px; }
  #score { font-size: 34px; }
  .slot { width: 58px; height: 60px; }
  .round { width: 52px; height: 55px; }
  .round.home { width: 42px; height: 44px; }
}
