:root {
  --ink: #2c1810;
  --paper: #f4e7d0;
  --paper-deep: #e7d3b0;
  --berbere: #a8281f;
  --berbere-dark: #7e1c16;
  --gold: #c9842a;
  --muted: rgba(44, 24, 16, 0.68);
  --room: #140e0b;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
}

body {
  height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  overscroll-behavior: none;
  background:
    radial-gradient(ellipse 80% 50% at 50% 0%, #3a241c 0%, transparent 55%),
    var(--room);
  color: var(--paper);
  font-family: "Noto Sans Ethiopic", "Nyala", "Abyssinica SIL", sans-serif;
  padding:
    max(12px, env(safe-area-inset-top))
    max(12px, env(safe-area-inset-right))
    max(10px, env(safe-area-inset-bottom))
    max(12px, env(safe-area-inset-left));
  user-select: none;
  -webkit-user-select: none;
}

#frame {
  position: relative;
  width: min(960px, 100%);
  max-height: 100%;
  display: flex;
  flex-direction: column;
}

#stage {
  position: relative;
  height: min(640px, calc(100dvh - 72px));
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

canvas {
  display: block;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 100%;
  background: #1a100c;
  border-radius: 8px;
  box-shadow:
    0 0 0 1px rgba(244, 231, 208, 0.12),
    0 18px 40px rgba(0, 0, 0, 0.4);
  touch-action: none;
}

canvas:focus {
  outline: none;
}

#overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 18px;
  overflow: auto;
  background: rgba(18, 10, 8, 0.46);
}

#overlay.hidden { display: none; }

#overlay.clear {
  background: rgba(18, 10, 8, 0.28);
}

.menu {
  width: min(540px, 100%);
  background:
    radial-gradient(ellipse at 10% 0%, rgba(255, 248, 230, 0.65), transparent 46%),
    linear-gradient(180deg, #f8efdf 0%, var(--paper) 38%, var(--paper-deep) 100%);
  color: var(--ink);
  padding: 26px 26px 20px;
  border-radius: 4px;
  box-shadow:
    0 16px 50px rgba(0, 0, 0, 0.35),
    inset 0 0 0 1px rgba(90, 48, 24, 0.14);
  position: relative;
}

.menu::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 8px;
  background: var(--berbere);
}

.hidden { display: none !important; }

.eyebrow {
  margin: 8px 0 0;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.08em;
}

h1 {
  margin: 0;
  font-size: 72px;
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.03em;
}

.menu h2 {
  margin: 6px 0 0;
  font-size: 28px;
  line-height: 1.2;
}

.latin {
  margin: 4px 0 0;
  font-family: Fraunces, Georgia, serif;
  font-size: 22px;
  font-weight: 560;
}

.latin em {
  font-weight: 560;
  font-style: italic;
  color: var(--muted);
}

.lede {
  margin: 12px 0 0;
  font-size: 16px;
  line-height: 1.45;
}

.recipes {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px 22px;
  margin: 16px 0 18px;
  padding-top: 14px;
  border-top: 1px solid rgba(44, 24, 16, 0.16);
}

.recipes h2 {
  font-size: 18px;
  margin: 0 0 4px;
}

.recipes p {
  margin: 0;
  font-size: 14px;
  line-height: 1.4;
}

.meta {
  margin-top: 6px !important;
  color: var(--gold);
  font-weight: 600;
  font-size: 12px !important;
}

button {
  appearance: none;
  font: 700 16px "Noto Sans Ethiopic", sans-serif;
  color: #f8efe2;
  background: var(--berbere);
  border: 0;
  border-radius: 3px;
  padding: 11px 16px;
  cursor: pointer;
}

button:hover { background: var(--berbere-dark); }

button:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 3px;
}

.fine {
  margin: 10px 0 0;
  font-size: 12px;
  color: var(--muted);
}

.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin: 16px 0 18px;
}

.stats div {
  background: rgba(44, 24, 16, 0.05);
  padding: 8px 8px 6px;
}

.stats dt {
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.stats dd {
  margin: 2px 0 0;
  font-family: Fraunces, Georgia, serif;
  font-size: 28px;
  font-weight: 560;
}

.pause-card {
  background: var(--paper);
  color: var(--ink);
  padding: 18px 22px 14px;
  border-radius: 4px;
  text-align: center;
  min-width: 180px;
}

.pause-card p {
  margin: 0;
  font-size: 28px;
  font-weight: 700;
}

#dock {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: baseline;
  flex: 0 0 auto;
  padding: 10px 2px 0;
  min-width: 0;
}

#hint {
  margin: 0;
  min-width: 0;
  font-size: 16px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#keys {
  margin: 0;
  flex: 0 0 auto;
  font-size: 12px;
  opacity: 0.7;
  white-space: nowrap;
}

#touch {
  display: none;
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 4;
}

body.touch-ui #touch { display: block; }

body.touch-ui:not(.show-controls) #touch {
  visibility: hidden;
}

body.touch-ui { touch-action: none; }

body.touch-ui #keys { display: none; }

body.touch-ui #dock {
  justify-content: center;
  padding-left: 124px;
  padding-right: 124px;
}

#stick {
  position: absolute;
  left: 0;
  bottom: 0;
  width: 112px;
  height: 112px;
  border-radius: 50%;
  pointer-events: auto;
  touch-action: none;
  background:
    radial-gradient(circle at 50% 45%, rgba(244, 231, 208, 0.16), rgba(244, 231, 208, 0.05) 62%, transparent 63%),
    rgba(36, 22, 16, 0.72);
  box-shadow: inset 0 0 0 2px rgba(240, 193, 74, 0.45);
}

#knob {
  position: absolute;
  left: 36px;
  top: 36px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: #f4e7d0;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.35);
}

#use, #pause-btn {
  position: absolute;
  pointer-events: auto;
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
}

#use {
  right: 4px;
  bottom: 14px;
  width: 84px;
  height: 84px;
  border-radius: 50%;
  padding: 0;
  font-size: 18px;
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.35);
}

#pause-btn {
  right: 18px;
  bottom: 108px;
  min-width: 64px;
  min-height: 36px;
  padding: 8px 10px;
  font-size: 13px;
  color: #f4e7d0;
  background: rgba(36, 22, 16, 0.82);
  box-shadow: inset 0 0 0 1px rgba(244, 231, 208, 0.28);
}

#turn {
  display: none;
}

@media (max-width: 720px) {
  h1 { font-size: 56px; }
  .recipes, .stats { grid-template-columns: 1fr 1fr; }
}

@media (max-height: 520px) {
  body {
    padding:
      env(safe-area-inset-top)
      env(safe-area-inset-right)
      env(safe-area-inset-bottom)
      env(safe-area-inset-left);
  }

  #stage {
    height: calc(100dvh - 34px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
  }

  #dock { padding-top: 4px; }

  #hint { font-size: 14px; }

  #overlay { padding: 8px; }

  .menu {
    width: min(640px, 100%);
    padding: 12px 16px 12px;
  }

  .eyebrow { margin-top: 4px; }

  h1 { font-size: 40px; }

  .latin { font-size: 16px; }

  .lede {
    margin-top: 4px;
    font-size: 13px;
    line-height: 1.35;
  }

  .recipes {
    margin: 8px 0 10px;
    padding-top: 8px;
    gap: 8px 16px;
  }

  .recipes p { font-size: 12px; }

  .menu h2 { font-size: 22px; margin-top: 2px; }

  .stats { margin: 8px 0 10px; }

  .stats dd { font-size: 22px; }

  .fine { margin-top: 6px; }
}

@media (orientation: portrait) and (max-width: 820px) {
  #turn {
    display: grid;
    place-items: center;
    align-content: center;
    gap: 6px;
    position: fixed;
    inset: 0;
    z-index: 30;
    background: #140e0b;
    text-align: center;
    padding: 24px;
  }

  .turn-title {
    margin: 0;
    font-size: 64px;
    font-weight: 700;
    line-height: 1;
  }

  #turn p:last-child {
    margin: 8px 0 0;
    font-size: 18px;
  }
}
