@import url("https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600;700&family=Fraunces:opsz,wght@9..144,500;9..144,600;9..144,700&display=swap");
:root {
  --ink: #253f35;
  --paper: #faf8ed;
  --ground: #a8ad70;
  --accent: #e3ac4c;
  --line: #d9ddce;
  font-family: "DM Sans", sans-serif;
  color: var(--ink);
  background: var(--ground);
  font-synthesis: none;
}
* {
  box-sizing: border-box;
}
body {
  background: var(--ground);
  margin: 0;
  overflow: hidden;
}
button,
a {
  -webkit-tap-highlight-color: transparent;
}
button {
  font: inherit;
  color: inherit;
  cursor: pointer;
  touch-action: manipulation;
}
button:focus-visible,
a:focus-visible,
canvas:focus-visible {
  outline: 3px solid #bc632e;
  outline-offset: 4px;
}
button {
  border: 0;
}
button:hover {
  filter: brightness(0.96);
}
[hidden] {
  display: none !important;
}
#app {
  height: 100svh;
  height: 100dvh;
  position: relative;
}
#playfield {
  position: absolute;
  inset: 0;
  overflow: hidden;
  isolation: isolate;
  background: var(--ground);
}
#game {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  outline: none;
  image-rendering: pixelated;
}
.masthead {
  position: absolute;
  z-index: 2;
  top: max(20px, env(safe-area-inset-top));
  left: max(24px, env(safe-area-inset-left));
  right: max(24px, env(safe-area-inset-right));
  display: flex;
  align-items: center;
  justify-content: flex-end;
  pointer-events: none;
  gap: 20px;
}
.menu-button {
  pointer-events: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  padding: 0;
  background: #faf8edf0;
  box-shadow: 0 2px 8px #243e3520;
}
.menu-lines {
  position: relative;
  width: 18px;
  height: 14px;
  border-top: 2px solid;
  border-bottom: 2px solid;
}
.menu-lines::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 4px;
  border-top: 2px solid;
}
.welcome {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: max(24px, env(safe-area-inset-top))
    max(24px, env(safe-area-inset-right)) max(24px, env(safe-area-inset-bottom))
    max(24px, env(safe-area-inset-left));
  color: #fffbed;
  background: radial-gradient(ellipse at center, #203e3545, transparent 72%);
  text-shadow:
    0 2px 4px #203e35a6,
    0 0 24px #203e3570;
  pointer-events: none;
  transition:
    opacity 0.8s ease,
    visibility 0s 0.8s;
}
.welcome.dismissed {
  opacity: 0;
  visibility: hidden;
}
.welcome h1 {
  font:
    600 clamp(38px, 8vw, 88px)/1.06 Fraunces,
    Georgia,
    serif;
  letter-spacing: -0.035em;
  margin: 0;
}
.welcome h1 span {
  display: block;
}
.welcome p {
  margin: 22px 0 0;
  font-size: clamp(13px, 2vw, 17px);
  letter-spacing: 0.1em;
}
.start-prompt {
  pointer-events: auto;
  margin-top: 40px;
  min-height: 48px;
  padding: 12px 24px;
  background: transparent;
  color: inherit;
  font-size: 14px;
  letter-spacing: 0.06em;
  text-shadow: inherit;
  animation: invitation-pulse 2.8s ease-in-out infinite;
}
.welcome.dismissed .start-prompt {
  animation: none;
}
@keyframes invitation-pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.6;
  }
}
.eyebrow {
  font-size: 10px;
  letter-spacing: 1.7px;
  font-weight: 700;
  color: #73765c;
}
.primary {
  background: #2c4d3c;
  color: #fffdf0;
  padding: 15px 20px;
  border-radius: 12px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  width: 100%;
  min-height: 48px;
}
.primary span {
  font-size: 22px;
}
kbd {
  font:
    600 10px "DM Sans",
    sans-serif;
  border: 1px solid #c8cebb;
  background: #fff9;
  padding: 4px 5px;
  border-radius: 4px;
}
.interact {
  position: absolute;
  z-index: 4;
  top: 0;
  left: 0;
  width: max-content;
  max-width: calc(100% - 24px);
  min-height: 44px;
  padding: 8px 12px;
  display: flex;
  align-items: center;
  gap: 6px;
  border: 1px solid #fffdf3;
  border-radius: 17px;
  background: #fff9e9;
  box-shadow:
    0 3px 0 #38544430,
    0 5px 16px #263f3120;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.2;
  white-space: nowrap;
  will-change: transform;
}
.interact::after {
  content: "";
  position: absolute;
  left: var(--tip-x, 50%);
  bottom: -6px;
  width: 10px;
  height: 10px;
  background: #fff9e9;
  border-right: 1px solid #fffdf3;
  border-bottom: 1px solid #fffdf3;
  transform: translateX(-50%) rotate(45deg);
  border-radius: 0 0 3px 0;
}
.interact.prompt-below::after {
  top: -6px;
  bottom: auto;
  transform: translateX(-50%) rotate(225deg);
}
.interact > span:first-child {
  display: grid;
  place-items: center;
  width: 25px;
  height: 25px;
  border-radius: 50%;
  background: #e9edd8;
  color: #a96822;
  font-size: 17px;
}
.interact kbd {
  font-size: 9px;
  padding: 3px 4px;
}
.toast {
  opacity: 0;
  visibility: hidden;
  position: absolute;
  left: 50%;
  top: max(86px, calc(env(safe-area-inset-top) + 70px));
  transform: translate(-50%, -10px);
  background: #263f35ed;
  color: #fffbed;
  border-radius: 18px;
  padding: 10px 16px;
  font-size: 13px;
  transition:
    opacity 0.25s,
    transform 0.25s;
  max-width: min(480px, calc(100% - 40px));
  width: max-content;
  text-align: center;
  pointer-events: none;
}
.toast.visible {
  opacity: 1;
  visibility: visible;
  transform: translate(-50%, 0);
}
.joystick {
  display: none;
}
dialog {
  color: var(--ink);
  background: var(--paper);
  border: 1px solid #fff;
  border-radius: 22px;
  padding: 35px;
  width: min(540px, calc(100% - 32px));
  max-height: 85dvh;
  overflow: auto;
  box-shadow: 0 30px 100px #142c3b50;
}
dialog::backdrop {
  background: #152e336b;
  backdrop-filter: blur(5px);
}
dialog h2 {
  font:
    500 34px/1.15 Fraunces,
    Georgia,
    serif;
  margin: 12px 0 20px;
  letter-spacing: -1px;
}
dialog p {
  font-size: 16px;
  line-height: 1.7;
  color: #687561;
}
.close-button {
  position: absolute;
  right: 14px;
  top: 14px;
  background: #e9eddc;
  border-radius: 50%;
  width: 34px;
  height: 34px;
  font-size: 24px;
}
.note-list {
  display: grid;
  gap: 9px;
}
.note {
  display: flex;
  gap: 14px;
  align-items: center;
  border: 1px solid #dbe0cf;
  padding: 13px;
  border-radius: 10px;
}
.note > span {
  font-size: 25px;
  width: 30px;
  text-align: center;
}
.note b {
  font-size: 14px;
}
.note small {
  display: block;
  margin-top: 4px;
  color: #7c866f;
  font-size: 12px;
  line-height: 1.5;
}
.note.locked {
  opacity: 0.65;
}
.season-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.season-choice {
  background: #eaf0dc;
  border: 2px solid transparent;
  border-radius: 12px;
  padding: 21px 15px;
  font-weight: 600;
  font-size: 16px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.season-choice[aria-pressed="true"] {
  border-color: #446445;
}
.season-choice > span {
  font-size: 25px;
}
.automatic {
  width: 100%;
  margin-top: 13px;
  padding: 14px;
  background: #e8ddbd;
  border-radius: 10px;
}
.map-canvas {
  width: 100%;
  border-radius: 10px;
  background: #aabb7a;
  image-rendering: pixelated;
}
.map-legend {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  font-size: 12px;
  margin: 12px 0;
  color: #6e7c62;
}
.help-keys {
  display: grid;
  gap: 10px;
}
.help-keys > div {
  background: #eaf0dc;
  border-radius: 8px;
  padding: 12px 15px;
  font-size: 14px;
}
.dialog-icon {
  font-size: 40px;
}
.subtle-button {
  width: 100%;
  padding: 13px;
  margin-top: 12px;
  border: 1px solid var(--line);
  background: transparent;
  border-radius: 8px;
  font-size: 14px;
}

.close-button {
  width: 44px;
  height: 44px;
}
.back-button {
  background: transparent;
  padding: 0 0 0 2px;
  min-height: 44px;
  margin: -12px 0 12px;
  font-size: 13px;
  font-weight: 600;
}
.back-button:not([hidden]) + .close-button + .eyebrow {
  display: block;
}
.menu-list {
  display: grid;
  margin: 4px 0 24px;
}
.menu-list button {
  display: grid;
  grid-template-columns: 1fr auto 20px;
  align-items: center;
  gap: 12px;
  text-align: left;
  background: transparent;
  border-bottom: 1px solid var(--line);
  min-height: 62px;
  padding: 12px 0;
  font-size: 15px;
  font-weight: 600;
}
.menu-list small {
  font-size: 12px;
  color: #6e7965;
  font-weight: 400;
}
.sound-toggle {
  width: 20px;
  height: 12px;
  background: #c7cebd;
  border-radius: 10px;
  position: relative;
}
.sound-toggle::after {
  content: "";
  position: absolute;
  width: 8px;
  height: 8px;
  top: 2px;
  left: 2px;
  border-radius: 50%;
  background: #fff;
}
[aria-pressed="true"] .sound-toggle {
  background: #2c4d3c;
}
[aria-pressed="true"] .sound-toggle::after {
  left: 10px;
}
@media (max-width: 760px), (pointer: coarse), (max-height: 550px) {
  .masthead {
    top: max(16px, env(safe-area-inset-top));
    left: max(18px, env(safe-area-inset-left));
    right: max(18px, env(safe-area-inset-right));
  }
  .joystick {
    display: block;
    position: absolute;
    bottom: max(22px, calc(env(safe-area-inset-bottom) + 12px));
    right: max(20px, env(safe-area-inset-right));
    width: 112px;
    height: 112px;
    border-radius: 50%;
    background: #263f3524;
    border: 1px solid #fff8;
    touch-action: none;
  }
  .joystick-ring {
    position: absolute;
    inset: 15px;
    border: 1px solid #fff3;
    border-radius: 50%;
    pointer-events: none;
  }
  .stick {
    position: absolute;
    width: 40px;
    height: 40px;
    background: #faf8eddb;
    box-shadow: 0 2px 5px #2f4f3125;
    border-radius: 50%;
    left: 35px;
    top: 35px;
    pointer-events: none;
  }
  .direction {
    position: absolute;
    background: transparent;
    width: 44px;
    height: 44px;
    padding: 0;
    touch-action: none;
  }
  .direction::after {
    content: "";
    position: absolute;
    width: 5px;
    height: 5px;
    border-top: 1px solid #faf8edb3;
    border-left: 1px solid #faf8edb3;
    left: 19px;
    top: 19px;
  }
  .up {
    left: 33px;
    top: -10px;
  }
  .up::after {
    transform: rotate(45deg);
  }
  .down {
    left: 33px;
    bottom: -10px;
  }
  .down::after {
    transform: rotate(225deg);
  }
  .left {
    left: -10px;
    top: 33px;
  }
  .left::after {
    transform: rotate(-45deg);
  }
  .right {
    right: -10px;
    top: 33px;
  }
  .right::after {
    transform: rotate(135deg);
  }
  .interact kbd {
    display: none;
  }
  .toast {
    font-size: 12px;
  }
  dialog {
    padding: 30px 23px 24px;
    max-height: calc(
      100dvh - 40px - env(safe-area-inset-top) - env(safe-area-inset-bottom)
    );
  }
  dialog h2 {
    font-size: 29px;
  }
}
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition: none !important;
    animation: none !important;
    scroll-behavior: auto !important;
  }
}

.movement-actions {
  display: none;
}
@media (max-width: 760px), (pointer: coarse), (max-height: 550px) {
  .movement-actions {
    display: flex;
    position: absolute;
    left: max(18px, env(safe-area-inset-left));
    bottom: max(26px, calc(env(safe-area-inset-bottom) + 16px));
    gap: 10px;
  }
  .movement-actions button {
    width: 56px;
    height: 60px;
    padding: 4px;
    background: #faf8eddf;
    color: #294f40;
    border: 1px solid #fff9;
    border-radius: 22px;
    touch-action: manipulation;
  }
  .movement-actions span {
    display: block;
    font-size: 26px;
    line-height: 30px;
  }
  .movement-actions small {
    font-size: 10px;
  }
  .movement-actions button[aria-pressed="true"] {
    background: #294f40;
    color: #fff4cf;
  }
}
