html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: #6c3b20;
}

#activity-root {
  width: 100%;
  height: 100%;
  min-height: 100dvh;
}

.feast-game {
  position: relative;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  gap: clamp(4px, 0.8vmin, 8px);
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  padding: clamp(2px, 0.5vmin, 5px);
  box-sizing: border-box;
  container-type: size;
  color: #4d2c19;
  font-family: inherit;
}

.feast-play-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: clamp(7px, 1.2vmin, 12px);
  width: 100%;
  min-width: 0;
  min-height: 0;
}

.feast-grid {
  display: grid;
  grid-template-rows: repeat(3, minmax(0, 1fr));
  gap: clamp(5px, 0.9vmin, 8px);
  width: min(calc(100cqw - 16px), calc(100cqh - 88px), 540px);
  height: auto;
  min-width: 176px;
  max-width: none;
  min-height: 0;
  aspect-ratio: 1;
  padding: 0;
  box-sizing: border-box;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

.feast-game[data-feedback-type]:not([data-feedback-type=""]) .feast-grid {
  width: min(calc(100cqw - 16px), calc(100cqh - 138px), 540px);
}

.feast-game.is-success .feast-grid {
  animation: feast-success-glow 700ms ease-out 1;
}

@keyframes feast-success-glow {
  0% { filter: drop-shadow(0 0 0 rgba(239, 178, 49, 0)); }
  45% { filter: drop-shadow(0 0 18px rgba(239, 178, 49, 0.72)); }
  100% { filter: drop-shadow(0 0 0 rgba(239, 178, 49, 0)); }
}

.feast-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: inherit;
  min-height: 0;
}

.feast-cell {
  position: relative;
  display: grid;
  min-width: 48px;
  min-height: 48px;
  place-items: center;
  overflow: hidden;
  padding: clamp(4px, 0.7vmin, 7px);
  border: 1px solid transparent;
  border-radius: clamp(7px, 1.1vmin, 10px);
  background-color: #d8c09a;
  background-image: url("./assets/place-setting.webp");
  background-position: center;
  background-repeat: no-repeat;
  background-size: cover;
  color: #4d2c19;
  box-sizing: border-box;
  touch-action: manipulation;
}

.feast-cell.is-editable {
  border: 1px dashed rgba(112, 72, 39, 0.7);
  cursor: pointer;
}

.feast-cell.is-editable::after {
  position: absolute;
  inset: 3px;
  border: 1px solid rgba(255, 250, 238, 0.5);
  border-radius: inherit;
  content: "";
  pointer-events: none;
}

.feast-cell.is-fixed {
  border: 2px solid rgba(115, 74, 40, 0.82);
  box-shadow: inset 0 0 0 2px rgba(255, 247, 225, 0.54);
  cursor: default;
}

.feast-food-image {
  display: block;
  width: 62%;
  height: 62%;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  filter: drop-shadow(0 4px 3px rgba(66, 38, 18, 0.28));
  pointer-events: none;
}

.feast-cell .feast-food-apple,
.feast-palette-button .feast-food-apple {
  transform: scale(1.16);
}

.feast-cell .feast-food-pumpkin,
.feast-palette-button .feast-food-pumpkin {
  transform: scale(1.62);
}

.feast-cell .feast-food-corn,
.feast-palette-button .feast-food-corn {
  transform: scale(1.1);
}

.feast-empty-mark {
  width: 38%;
  height: 38%;
  border: 2px dashed rgba(126, 82, 44, 0.64);
  border-radius: 50%;
  box-shadow: inset 0 0 0 1px rgba(255, 250, 238, 0.5);
}

.feast-pin {
  position: absolute;
  z-index: 3;
  top: 3px;
  right: 4px;
  width: 15px;
  height: 20px;
  filter: drop-shadow(0 1px 1px rgba(66, 42, 22, 0.35));
}

.feast-pin-head {
  position: absolute;
  top: 0;
  left: 2px;
  width: 11px;
  height: 11px;
  border: 2px solid #684526;
  border-radius: 50%;
  background: #c99543;
  box-sizing: border-box;
  box-shadow: inset 1px 1px 0 rgba(255, 241, 195, 0.66);
}

.feast-pin-stem {
  position: absolute;
  top: 10px;
  left: 6px;
  width: 2px;
  height: 8px;
  background: #684526;
  transform: rotate(15deg);
  transform-origin: top;
}

.feast-cell.is-offending-line {
  box-shadow: inset 0 0 0 3px rgba(164, 49, 41, 0.72);
}

.feast-cell.is-duplicate,
.feast-cell.is-offending-cell {
  outline: 5px solid #b8322b;
  outline-offset: -6px;
}

.feast-cell.is-duplicate::before,
.feast-cell.is-offending-cell::before {
  position: absolute;
  z-index: 4;
  top: 3px;
  left: 4px;
  width: 21px;
  height: 21px;
  border-radius: 50%;
  background: #b8322b;
  color: #fff;
  content: "!";
  font: 700 16px/21px sans-serif;
  text-align: center;
  box-shadow: 0 1px 3px rgba(66, 30, 24, 0.35);
}

.feast-cell:focus-visible,
.feast-palette-button:focus-visible {
  outline: 4px solid #173d63;
  outline-offset: 2px;
  box-shadow: 0 0 0 3px #fff8e9;
}

.feast-palette {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(10px, 1.8vmin, 16px);
  min-height: clamp(56px, 8.6vmin, 78px);
}

.feast-palette-button {
  position: relative;
  display: grid;
  width: clamp(56px, 8.6vmin, 78px);
  height: clamp(56px, 8.6vmin, 78px);
  place-items: center;
  padding: 3px;
  border: 2px solid #b69a78;
  border-radius: 15px;
  background: #fffaf0;
  cursor: pointer;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.92),
    0 4px 9px rgba(75, 43, 21, 0.2);
  box-sizing: border-box;
  touch-action: none;
}

.feast-palette-button .feast-food-image {
  width: 82%;
  height: 82%;
}

.feast-palette-button.is-selected {
  outline: 4px solid #b8791f;
  outline-offset: 2px;
  background: #fff3d5;
  transform: translateY(-2px);
}

.feast-palette-button.is-selected::after {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 14px;
  height: 8px;
  border-bottom: 3px solid #3f6b32;
  border-left: 3px solid #3f6b32;
  content: "";
  transform: rotate(-45deg);
}

.feast-feedback {
  display: grid;
  grid-template-columns: 32px auto minmax(0, 1fr);
  align-items: center;
  justify-self: stretch;
  gap: 8px;
  min-height: 42px;
  max-width: 620px;
  margin-inline: auto;
  padding: 5px 10px;
  border: 2px solid #ad6d3b;
  border-radius: 14px;
  background: #fff7e8;
  box-sizing: border-box;
  box-shadow: 0 3px 9px rgba(79, 44, 20, 0.13);
}

.feast-feedback[hidden] {
  display: none;
}

.feast-feedback[data-has-symbol="false"] {
  grid-template-columns: 32px minmax(0, 1fr);
}

.feast-feedback[data-type="row"],
.feast-feedback[data-type="column"],
.feast-feedback[data-type="empty"],
.feast-feedback[data-type="protected"] {
  border-color: #a9322c;
  background: #fff3e0;
}

.feast-feedback[data-type="success"] {
  border-color: #4e733d;
  background: #f3f6df;
}

.feast-feedback-mark {
  position: relative;
  display: grid;
  width: 28px;
  height: 28px;
  place-items: center;
  border: 3px solid #a9322c;
  border-radius: 50%;
  background: #fff;
  box-sizing: border-box;
}

.feast-feedback-mark-line,
.feast-feedback-mark-line::after {
  display: block;
  width: 3px;
  height: 11px;
  border-radius: 2px;
  background: #a9322c;
  content: "";
}

.feast-feedback-mark-line::after {
  height: 3px;
  margin-top: 2px;
}

.feast-feedback[data-type="success"] .feast-feedback-mark {
  border-color: #476c39;
}

.feast-feedback[data-type="success"] .feast-feedback-mark-line {
  width: 12px;
  height: 7px;
  margin-top: -3px;
  border-bottom: 3px solid #476c39;
  border-left: 3px solid #476c39;
  background: transparent;
  transform: rotate(-45deg);
}

.feast-feedback[data-type="success"] .feast-feedback-mark-line::after {
  display: none;
}

.feast-feedback-symbol {
  width: 32px;
  height: 32px;
  object-fit: contain;
}

.feast-feedback-copy {
  min-width: 0;
  font-size: clamp(13px, 1.9vmin, 17px);
  font-weight: 600;
  line-height: 1.18;
}

.feast-tutorial-hand {
  position: absolute;
  z-index: 30;
  width: clamp(54px, 8vmin, 72px);
  height: auto;
  pointer-events: none;
  filter: drop-shadow(0 4px 5px rgba(70, 38, 17, 0.28));
  transition: left 760ms cubic-bezier(0.22, 0.75, 0.25, 1), top 760ms cubic-bezier(0.22, 0.75, 0.25, 1), transform 180ms ease;
}

.feast-tutorial-hand.is-moving {
  transform: translate(-2px, 1px) rotate(-4deg);
}

.feast-tutorial-hand[hidden] {
  display: none;
}

.feast-drag-ghost {
  position: fixed;
  z-index: 1000;
  max-width: none;
  pointer-events: none;
  transform: translate(-50%, -62%);
  filter: drop-shadow(0 7px 8px rgba(48, 27, 13, 0.34));
}

body.feast-dragging {
  cursor: grabbing;
  user-select: none;
}

.feast-game.is-demo .feast-palette-button,
.feast-game.is-demo .feast-cell {
  cursor: default;
}

@media (orientation: landscape) and (max-height: 640px) {
  .feast-game {
    grid-template-rows: minmax(0, 1fr) auto;
  }

  .feast-play-area {
    flex-direction: row;
    gap: 8px;
  }

  .feast-grid {
    width: min(calc(100cqh - 16px), calc(100cqw - 112px), 300px);
    height: auto;
  }

  .feast-game[data-feedback-type]:not([data-feedback-type=""]) .feast-grid {
    width: min(calc(100cqh - 60px), calc(100cqw - 112px), 300px);
  }

  .feast-palette {
    flex-direction: column;
    gap: 5px;
    min-height: 0;
  }
}

@media (max-width: 430px) and (orientation: portrait) {
  .feast-grid {
    width: min(calc(100cqw - 16px), calc(100cqh - 88px), 390px);
    height: auto;
  }

  .feast-game[data-feedback-type]:not([data-feedback-type=""]) .feast-grid {
    width: min(calc(100cqw - 16px), calc(100cqh - 138px), 390px);
  }

  .feast-palette {
    min-height: 52px;
  }

  .feast-palette-button {
    width: 52px;
    height: 52px;
  }

  .feast-feedback {
    min-height: 38px;
    grid-template-columns: 28px auto minmax(0, 1fr);
    padding: 3px 7px;
  }

  .feast-feedback-copy {
    font-size: 13px;
  }
}

@media (max-height: 520px) {
  .feast-game {
    gap: 2px;
  }

  .feast-palette-button {
    width: 50px;
    height: 50px;
  }

  .feast-feedback {
    min-height: 34px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .feast-tutorial-hand,
  .feast-palette-button.is-selected {
    transition: none;
    transform: none;
  }

  .feast-game.is-success .feast-grid {
    animation: none;
  }
}

@media (forced-colors: active) {
  .feast-cell.is-fixed {
    border-style: double;
  }

  .feast-cell.is-editable {
    border-style: dashed;
  }

  .feast-cell.is-offending-line,
  .feast-cell.is-duplicate,
  .feast-cell.is-offending-cell {
    forced-color-adjust: none;
    outline: 4px solid Highlight;
  }
}
