@font-face {
  font-family: Rubik;
  src: url("./fonts/Rubik-Regular.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: Rubik;
  src: url("./fonts/Rubik-Bold.woff2") format("woff2");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Lilita One";
  src: url("./fonts/LilitaOne-Regular.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

html {
  font-synthesis: none;
  height: 100%;
  overflow: hidden;
}
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #e7c98a;
  color: #1c140e;
  font-family: Rubik, sans-serif;
  font-weight: 400;
}
#app {
  background: linear-gradient(#f3d7a4 0 20%, #0c3c58 20% 78%, #c2a36a 78%);
}
body.playing {
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}
button, input, summary {
  font-family: inherit;
  font-synthesis: none;
}
button:focus-visible, a:focus-visible, summary:focus-visible, input:focus-visible, label:focus-within {
  outline: 3px solid #ffbf1f;
  outline-offset: 2px;
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

#app {
  box-sizing: border-box;
  width: 100%;
  height: 100%;
  overflow: hidden;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  display: flex;
  align-items: center;
  justify-content: center;
}
#frame {
  position: relative;
  background: #0c3c58;
  overflow: hidden;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.28);
}
#frame.boiling::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  box-shadow: inset 0 0 0 6px #a32030;
}
#view, #title-view {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}
#title-view { z-index: 0; }
#view { z-index: 1; }

#hud {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: auto;
  min-height: 15.625%;
  z-index: 3;
  pointer-events: none;
  display: block;
  padding: 4px 84px 4px 8px;
  box-sizing: border-box;
  color: #f7f4ec;
  background: rgba(16, 28, 36, 0.94);
}
body.left-hand #hud { padding: 4px 8px 4px 84px; }
.meter-block { min-width: 0; width: 100%; display: flex; flex-direction: column; }
.meter-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.meter-label, .score-label {
  font-size: 14px;
  line-height: 1.05;
  font-weight: 700;
}
#tier-readout {
  font-size: 16px;
  font-weight: 700;
  line-height: 1.05;
}
#delta {
  min-height: 13px;
  font-size: 12px;
  font-weight: 700;
  color: #ffe08a;
  text-align: right;
}
.score-block { text-align: right; align-self: start; }
#score { font-size: 15px; font-weight: 700; line-height: 1.05; }
.meter-bar {
  display: flex;
  align-items: stretch;
  gap: 4px;
  margin-top: 2px;
  width: 100%;
}
.meter-track {
  position: relative;
  display: flex;
  flex: 1 1 auto;
  min-width: 0;
  height: 16px;
  background: #102028;
  border-radius: 4px;
  overflow: hidden;
}
.zone { height: 100%; }
.zone-content { width: 30%; background: radial-gradient(#d7efe0 1.1px, transparent 1.3px) 0 0 / 6px 6px, #1f6b45; }
.zone-peeved { width: 30%; background: repeating-linear-gradient(45deg, #e6c15a 0 6px, #8a6a12 6px 12px); }
.zone-cranky { width: 25%; background: repeating-linear-gradient(45deg, #f08a3c 0 3px, #8a3d12 3px 6px); }
.zone-boiling { width: 15%; background: repeating-linear-gradient(45deg, #e8d0d4 0 3px, transparent 3px 6px), repeating-linear-gradient(-45deg, #e8d0d4 0 3px, transparent 3px 6px), #8e1e2c; }
.snap-cap {
  flex: 0 0 36px;
  display: grid;
  place-items: center;
  font-size: 11px;
  font-weight: 700;
  background: #1a1214;
  color: #f7f4ec;
  border: 2px solid #f7f4ec;
  border-radius: 4px;
  box-sizing: border-box;
}
.tick {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 2px;
  background: #f7f4ec;
  transform: translateX(-1px);
  z-index: 2;
  pointer-events: none;
}
#tick-30 { left: 30%; }
#tick-60 { left: 60%; }
#tick-85 { left: 85%; }
#pointer {
  position: absolute;
  top: -4px;
  width: 16px;
  height: 14px;
  margin-left: -8px;
  z-index: 5;
  background: #1c140e;
  clip-path: polygon(50% 100%, 0 0, 100% 0);
  pointer-events: none;
}
#pointer::after {
  content: "";
  position: absolute;
  left: 2px;
  right: 2px;
  top: 0;
  bottom: 2px;
  background: #f7f4ec;
  clip-path: polygon(50% 100%, 0 0, 100% 0);
}
.zone-names {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 1px 6px;
  width: 100%;
  margin-top: 1px;
  font-size: 12px;
  line-height: 1.1;
  color: #d5dee4;
}
.zone-names span {
  flex: 0 0 auto;
  white-space: nowrap;
  overflow: visible;
  text-overflow: clip;
}
.zone-names .is-current { font-weight: 700; color: #ffffff; }

#pause-shield {
  position: absolute;
  top: 0;
  right: 0;
  z-index: 6;
  padding: 8px;
  pointer-events: auto;
}
body.left-hand #pause-shield { right: auto; left: 0; }
#pause {
  width: 64px;
  height: 48px;
  min-width: 64px;
  min-height: 48px;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
}
#pause span {
  display: grid;
  place-items: center;
  width: 62px;
  height: 46px;
  margin: 1px;
  border-radius: 10px;
  background: #f7f4ec;
  color: #1c140e;
  font-size: 11px;
  font-weight: 700;
  border: 2px solid #1c140e;
  box-sizing: border-box;
  white-space: nowrap;
  overflow: hidden;
}

.panel {
  position: absolute;
  z-index: 4;
  left: 16px;
  right: 16px;
}
.title-ui {
  position: absolute;
  z-index: 4;
  top: 16px;
  left: 12px;
  right: 12px;
  text-align: center;
  pointer-events: none;
}
h1 {
  margin: 0;
  font-family: "Lilita One", sans-serif;
  font-weight: 400;
  font-size: 52px;
  line-height: 0.86;
  color: #f6f1e3;
  text-shadow: 0 3px 0 #2a2118, 2px 0 0 #2a2118, -2px 0 0 #2a2118, 0 -2px 0 #2a2118;
}
h1 .sir { display: block; font-size: 28px; letter-spacing: 0.08em; }
.subtitle {
  margin: 8px 0 0;
  font-size: 18px;
  font-weight: 700;
  color: #1c140e;
  background: rgba(246, 241, 227, 0.88);
  display: inline-block;
  padding: 2px 10px;
  border-radius: 8px;
}
.menu {
  position: absolute;
  z-index: 4;
  left: 16px;
  right: 16px;
  bottom: 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.menu button, .stack button, .opt {
  min-height: 48px;
  border-radius: 14px;
  border: 2px solid #1c140e;
  font-size: 20px;
  font-weight: 700;
  cursor: pointer;
}
#btn-endless {
  background: #f2c14e;
  color: #1c140e;
  padding: 8px 12px;
}
#btn-daily { background: #f7f4ec; color: #1c140e; padding: 8px 12px; }
.row { display: flex; gap: 10px; }
.row button { flex: 1; background: #f7f4ec; color: #1c140e; min-height: 48px; }
.btn-sub { display: block; font-size: 14px; font-weight: 400; }

.sheet {
  position: absolute;
  z-index: 5;
  inset: 24px 12px;
  background: #f7f4ec;
  color: #1c140e;
  border-radius: 16px;
  border: 2px solid #1c140e;
  padding: 16px;
  overflow: auto;
  box-sizing: border-box;
}
.sheet h2 { margin: 0 0 8px; font-size: 22px; }
#sheet-settings .sheet-back {
  position: sticky;
  top: 0;
  z-index: 1;
  display: block;
  margin-top: 0;
}
.sheet button, #btn-dismiss {
  min-height: 48px;
  min-width: 48px;
  margin-top: 8px;
  background: #f2c14e;
  border: 2px solid #1c140e;
  border-radius: 12px;
  font-size: 18px;
  font-weight: 700;
  padding: 8px 14px;
}
.sheet p, .sheet li { font-size: 17px; line-height: 1.35; }
.opt {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  background: #fff;
  margin: 8px 0;
}
.opt input { width: 22px; height: 22px; }
.help-note { font-size: 15px; }
.credits { font-size: 14px; color: #3d342c; }

#cast-layer, #event-label, #pause-cover, #resume-layer {
  position: absolute;
  z-index: 4;
  left: 12px;
  right: 12px;
  text-align: center;
  pointer-events: none;
}
#cast-layer { top: 28%; }
#hint, #cast-label, #bite-line, #shake-line, #resume-layer p {
  display: inline-block;
  margin: 4px 0;
  padding: 6px 10px;
  background: #1c140e;
  color: #f7f4ec;
  border-radius: 10px;
  font-size: 17px;
  font-weight: 700;
}
#cast-bar {
  height: 14px;
  background: #102028;
  border-radius: 7px;
  overflow: hidden;
  margin: 8px 40px;
}
#cast-fill { height: 100%; width: 0; background: #f2c14e; }
#event-label { top: 32%; }
#pause-cover {
  inset: 0;
  z-index: 2;
  display: grid;
  place-items: center;
  background: #0b2e42;
  color: #f7f4ec;
  font-size: 22px;
  font-weight: 700;
  pointer-events: auto;
}
#resume-layer {
  inset: auto 12px 42%;
  z-index: 4;
}
#summary {
  inset: 0;
  z-index: 8;
  border-radius: 0;
}
#summary details > summary {
  min-height: 48px;
  display: flex;
  align-items: center;
  font-size: 17px;
  font-weight: 700;
  cursor: pointer;
}
#summary .again {
  min-height: 56px;
  width: 100%;
  background: #f2c14e;
  border-radius: 14px;
  border: 2px solid #1c140e;
  font-size: 22px;
  font-weight: 700;
}
.hidden { display: none !important; }

@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; }
}
body.reduced #title-view { animation: none; }
.refused {
  font-family: Rubik, sans-serif;
  padding: 24px;
  font-size: 18px;
}
