:root {
  --soil: #6b4f2a;
  --grass: #7a8f3c;
  --grass-light: #8ba044;
  --fence: #a67c4e;
  --sky: #f2e8c9;
  --paprika: #b8402e;
  --ink: #2b2118;
  --paper: #f7efd8;
  --leaf: #4f6f31;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  width: 100%;
  height: 100%;
  background: var(--ink);
  color: var(--ink);
  overflow: hidden;
  font-family: Georgia, "Times New Roman", serif;
}

body { overscroll-behavior: none; }

button, a { font: inherit; }

button:focus-visible,
a:focus-visible,
canvas:focus-visible {
  outline: 4px solid #fff;
  outline-offset: 4px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

#top, #stage {
  position: relative;
  width: 100vw;
  height: 100svh;
  min-height: 480px;
}

#stage {
  display: grid;
  place-items: center;
  background:
    linear-gradient(90deg, transparent 0 46%, rgb(163 133 78 / .55) 46% 54%, transparent 54%),
    var(--grass);
  isolation: isolate;
}

#game {
  display: block;
  width: min(100vw, calc(100svh * 1.5));
  height: min(100svh, calc(100vw / 1.5));
  max-width: 100vw;
  max-height: 100svh;
  background: var(--grass);
  touch-action: none;
  user-select: none;
}

#hud {
  position: fixed;
  z-index: 4;
  top: max(10px, env(safe-area-inset-top));
  left: max(10px, env(safe-area-inset-left));
  right: max(10px, env(safe-area-inset-right));
  display: flex;
  justify-content: space-between;
  gap: 8px;
  pointer-events: none;
  font: 700 14px/1.1 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-variant-numeric: tabular-nums;
}

.plate {
  min-width: 78px;
  padding: 7px 10px;
  background: color-mix(in srgb, var(--paper) 94%, transparent);
  border: 2px solid var(--ink);
  box-shadow: 3px 3px 0 rgb(0 0 0 / .35);
  text-align: center;
}

.language {
  position: fixed;
  z-index: 8;
  right: max(14px, env(safe-area-inset-right));
  bottom: max(14px, env(safe-area-inset-bottom));
  display: flex;
  gap: 6px;
  align-items: center;
  padding: 7px 10px;
  background: rgb(43 33 24 / .86);
  color: var(--paper);
  border: 1px solid rgb(247 239 216 / .45);
  font: 700 12px/1 ui-monospace, SFMono-Regular, Menlo, monospace;
  letter-spacing: .08em;
}

.language a { color: inherit; text-decoration: none; }
.language a[aria-current="page"] { color: #f5c959; text-decoration: underline; text-underline-offset: 3px; }

#overlay {
  position: fixed;
  z-index: 6;
  inset: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-items: center;
  padding: 72px clamp(16px, 5vw, 72px) 62px;
  background-image:
    linear-gradient(90deg, rgb(24 18 12 / .85) 0%, rgb(24 18 12 / .57) 42%, rgb(24 18 12 / .12) 72%),
    url("/assets/village.jpg");
  background-position: center;
  background-size: cover;
}

#overlay[hidden] { display: none; }

#card {
  width: 100%;
  min-width: 0;
  max-width: 560px;
  justify-self: start;
  max-height: calc(100svh - 124px);
  overflow: auto;
  padding: clamp(24px, 4vw, 42px);
  background: rgb(247 239 216 / .96);
  border: 3px solid var(--ink);
  box-shadow: 10px 10px 0 rgb(0 0 0 / .55);
}

.kicker {
  margin: 0 0 12px;
  color: var(--leaf);
  font: 800 11px/1.2 ui-monospace, SFMono-Regular, Menlo, monospace;
  letter-spacing: .12em;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  max-width: 12ch;
  font-size: clamp(36px, 7vw, 72px);
  line-height: .9;
  letter-spacing: -.055em;
  text-wrap: balance;
}

h1 span, h1 strong { display: block; }
h1 strong { color: var(--paprika); font-weight: 700; }

html[lang="en"] h1 { font-size: clamp(34px, 6.2vw, 64px); }

.quote {
  margin: 18px 0 22px;
  padding-left: 14px;
  border-left: 4px solid var(--paprika);
  font-size: clamp(15px, 2vw, 18px);
  font-style: italic;
}

#intro p, #result p {
  margin: 0 0 10px;
  max-width: 52ch;
  font-size: 15px;
  line-height: 1.45;
}

.controls {
  padding-top: 4px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px !important;
}

#start {
  min-height: 48px;
  margin-top: 18px;
  padding: 10px 24px;
  cursor: pointer;
  background: var(--paprika);
  color: var(--paper);
  border: 3px solid var(--ink);
  box-shadow: 4px 4px 0 var(--ink);
  font-size: 18px;
  font-weight: 800;
}

#start:active { transform: translate(3px, 3px); box-shadow: 1px 1px 0 var(--ink); }

#verdict { margin-top: 4px !important; font-size: 24px !important; font-weight: 800; }
#flavor { font-style: italic; }

.footnote {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  margin-top: 24px;
  padding-top: 14px;
  border-top: 1px solid rgb(43 33 24 / .3);
  color: rgb(43 33 24 / .72);
  font: 11px/1.3 ui-monospace, SFMono-Regular, Menlo, monospace;
}

.footnote a { color: inherit; text-underline-offset: 3px; }

@media (max-width: 640px) {
  #top, #stage { min-height: 420px; }
  #overlay {
    align-items: end;
    padding: 68px 12px 58px;
    background-image:
      linear-gradient(0deg, rgb(24 18 12 / .75) 0%, rgb(24 18 12 / .15) 78%),
      url("/assets/village.jpg");
    background-position: 62% center;
  }
  #card {
    max-height: min(72svh, 650px);
    padding: 22px 20px;
    box-shadow: 6px 6px 0 rgb(0 0 0 / .55);
  }
  h1 { font-size: clamp(28px, 9vw, 44px); }
  html[lang="en"] h1 { font-size: clamp(26px, 8.5vw, 40px); }
  .quote { margin: 12px 0 14px; }
  #intro p, #result p { font-size: 14px; line-height: 1.38; }
  .plate { min-width: 0; padding: 6px 7px; font-size: 11px; }
  .plate span:nth-child(2):not(.sr-only) { display: none; }
  .footnote { flex-direction: column; gap: 4px; }
}

@media (max-height: 650px) and (min-width: 641px) {
  #overlay { padding-top: 60px; padding-bottom: 48px; }
  #card { max-height: calc(100svh - 100px); padding: 20px 24px; }
  h1 { font-size: 46px; }
  .quote { margin: 10px 0 12px; }
  #intro p, #result p { font-size: 13px; }
  #start { margin-top: 10px; }
  .footnote { margin-top: 14px; padding-top: 9px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; animation: none !important; }
}

@media print {
  .language, #hud, #game, #start { display: none !important; }
  html, body, #top, #stage { height: auto; min-height: 0; overflow: visible; background: white; }
  #overlay { position: static; display: block; min-height: 0; background: white; padding: 0; }
  #card { max-height: none; box-shadow: none; }
}
