:root {
  --text-main: #3b2821;
  --text-soft: #735145;

  --board-size: 480px;
  --frame-top-padding: 67px;
  --frame-bottom-padding: 20px;
  --frame-side-padding: 15px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: "Trebuchet MS", "Segoe UI", Tahoma, sans-serif;
  color: var(--text-main);
}

.wrapper {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  height: min(calc(100vh - 60px), 900px);
  width: calc(100vw - 300px);
  background: #d9b09d url("../../images/bg.png") center bottom / cover no-repeat;
}
@media (max-width: 1080px) {
  .wrapper {
    width: 100vw;
  }
}

.couch {
  width: 312px;
  height: 339px;
  background: url("../../images/couch.png") no-repeat center center;
  background-size: cover;
  background-position: right;
  position: absolute;
  left: -110px;
  pointer-events: none;
}

.canvas-animation {
  position: absolute;
  top: -70px;
  left: 64px;
  z-index: 100;
}

.app {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  width: calc(100% - 20px)
}

.game-stage {
  display: flex;
  flex-direction: row;
  align-items: end;
  position: relative;
}

.left-ui {
  align-self: start;
  margin-top: 10px;
}

.left-ui__panel {
  background: url("../../images/panel_ui.png") center / 100% 100% no-repeat;
  width: 209px;
  height: 215px;
  padding: 46px 15px 8px 15px;
}

.left-ui__stat {
  height: 71px;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding-left: 45px;
}

.left-ui__stat--score {
  background: url("../../images/score.png") left center / cover no-repeat;
  background-position: center top;
  width: 181px;
  height: 78px;
}

.left-ui__stat--time {
  background: url("../../images/time.png") left center / cover no-repeat;
  width: 177px;
  height: 71px;
}

.left-ui__value {
  min-width: 74px;
  display: inline-block;
  text-align: center;
  font-weight: 700;
  font-size: 20px;
  color: #ffffff;
}

.left-ui__mascot {
  position: absolute;
  width: 150px;
  left: 20px;
  bottom: 54px;
  pointer-events: none;
}

.left-ui__armchair {
  position: absolute;
  width: 72px;
  left: 112px;
  bottom: 44px;
  pointer-events: none;
}

.panel-frame {
  background-position: center;
  background-size: 100% 100%;
  background-repeat: no-repeat;
}

.panel-frame--board {
  background-image: url("../../images/panel_words.png");
  width: var(--board-size);
  height: var(--board-size);
  padding-top: var(--frame-top-padding);
  padding-bottom: var(--frame-bottom-padding);
  padding-left: var(--frame-side-padding);
  padding-right: var(--frame-side-padding);
  box-sizing: content-box;
}

.panel-frame--clues {
  background-image: url(../../images/panel_solve.png);
  width: 283px;
  height: calc(567px * 0.98);
  box-sizing: border-box;
  padding-top: 55px;
  padding-inline: 13px;
  padding-bottom: 20px;
}

.panel-frame__inner--clues::-webkit-scrollbar {
  width: 6px;
}
.panel-frame__inner--clues::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.1);
}
.panel-frame__inner--clues::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, .4);
  border-radius: 3px;
}


.panel-frame__inner--clues {
  height: 100%;
  overflow-y: auto;
  scroll-behavior: smooth;
}

.board-shell {
  position: relative;
  width: var(--board-size);
  height: var(--board-size);
  margin: 0 auto;
  aspect-ratio: 1 / 1;
}

.board-grid {
  position: absolute;
  inset: 0;
  display: grid;
  gap: 0;
  border: 1px solid #73615e;
  overflow: hidden;
  background: #efe7d5;
  user-select: none;
  touch-action: none;
}

.board-cell {
  display: flex;
  align-items: center;
  justify-content: center;
  border-right: 1px solid #b4aca1;
  border-bottom: 1px solid #b4aca1;
  font-weight: 700;
  color: #3f3937;
  cursor: crosshair;
}

.board-cell:focus-visible {
  outline: 2px solid #84cedd;
  outline-offset: -2px;
  z-index: 1;
}

.board-cell--debug-filler {
  color: transparent;
}

.board-cell-flight {
  position: fixed;
  margin: 0;
  pointer-events: none;
  z-index: 1100;
  transform: translate3d(0, 0, 0);
  opacity: 1;
  will-change: transform, opacity;
  transition:
    transform 300ms cubic-bezier(0.42, 0, 1, 1),
    opacity 300ms linear;
  background-color: #fff;
}

.board-cell-flight--run {
  transform: translate3d(var(--flight-dx), var(--flight-dy), 0);
}

.board-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 2;
}

.board-error {
  margin: 8px 0 0;
  text-align: center;
  color: #8e1d1d;
  font-size: 14px;
}

.clues-list {
  max-height: 560px;
  padding-right: 2px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.clue-item {
  background: url("../../images/panel_solve_button.png") center / 100% 100% no-repeat;
  min-height: 51px;
  padding: 10px 7px 8px 12px;
  display: flex;
  align-items: center;
  gap: 6px;
  color: #333;
}

.clue-item--done {
  opacity: 0.55;
}

.clue-item__num {
  font-size: 14px;
  font-weight: 700;
}

.clue-item__text {
  flex: 1;
  min-width: 0;
  font-size: 16px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.clue-solve-btn {
  border: 0;
  width: 63px;
  height: 36px;
  background: url("../../images/solve_button.png") no-repeat;
  background-size: cover;
  color: #ffffff;
  font-size: 11px;
  font-weight: 700;
  text-transform: lowercase;
  cursor: pointer;
}

.clue-solve-btn:hover:not(:disabled) {
  background-image: url("../../images/solve_button_hover.png");
}

.clue-solve-btn:disabled {
  opacity: 0.6;
  cursor: default;
  filter: none!important;
}

.clue-solve-btn--user-found {
  background-image: url("../../images/solve_button_pressed.png");
}

.clue-solve-btn--solved-found {
  background-image: url("../../images/solve_button_pressed_2.png");
}

.clue-solve-btn--user-found:disabled,
.clue-solve-btn--solved-found:disabled {
  opacity: 1;
}

.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;
}

/* Sprite strip at images/vfx.png, each frame is 40x60. */
.vfx-sprite {
  width: 40px;
  height: 60px;
  background-image: url("../../images/vfx.png");
  background-position: 40px 0;
  background-repeat: no-repeat;
  animation: vfx-sprite-play 900ms steps(21) forwards;
  z-index: 1000;
  transform: translate(-50%, -100%)
}

@keyframes vfx-sprite-play {
  to {
    background-position: -800px 0;
  }
}

@media (max-width: 1080px) {
  .game-stage {
    padding-left: 220px;
  }

  .left-ui {
    display: none;
  }
}

@media (max-width: 951px) {
  .game-stage {
    padding-left: 0;
  }

  .couch {
    display: none;
  }
}

@media (max-width: 951px) and (orientation: portrait) {
  .wrapper {
    width: 100vw;
    height: auto;
    min-height: 100vh;
    padding: 8px 0 12px;
  }

  .game-stage {
    display: grid;
    grid-template-rows: auto auto auto;
    grid-template-areas:
      "ui"
      "board"
      "clues";
    justify-items: center;
    align-items: start;
    row-gap: 8px;
    padding-left: 0;
  }

  .left-ui {
    display: block;
    grid-area: ui;
    align-self: end;
    justify-self: center;
    margin-top: 0;
  }

  .panel-frame--board {
    grid-area: board;
    align-self: start;
  }

  .panel-frame--clues {
    grid-area: clues;
    align-self: start;
    width: calc(var(--board-size) + (var(--frame-side-padding) * 2));
    max-width: 100%;
    height: 190px;
    background-image: url("../../images/solve_mobile.png");
    background-size: 100% 100%;
    background-repeat: no-repeat;
    padding: 18px 14px 12px;
    margin-top: -20px;
    box-sizing: border-box;
  }

  .clues-list {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
  }

  .clue-item {
    min-height: auto;
    padding: 6px;
    flex: auto;
    text-align: center;
  }

  .clue-item__num {
    display: none;
  }

  .clue-solve-btn {
    display: none;
  }

  .left-ui__panel {
    background: url("../../images/panel_ui_2.png") center / 100% 100% no-repeat;
    width: 436px;
    height: 98px;
    padding: 14px 32px 10px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 5px;
  }

  .left-ui__stat {
    margin-bottom: 0;
  }

  .left-ui__value {
    font-size: clamp(18px, 5vw, 24px);
  }
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
}

.modal[hidden] {
  display: none;
}

.modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
}

.modal__dialog {
  position: relative;
  width: min(680px, 92vw);
  max-height: 85vh;
  overflow: auto;
  background: #fff;
  border-radius: 14px;
  border: 1px solid #dbeafe;
  box-shadow: 0 20px 48px rgba(0, 0, 0, 0.35);
  padding: 1rem;
}

.modal__line {
  margin: 0.25rem 0;
}

.modal__columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  margin-top: 0.5rem;
}

.modal__subtitle {
  margin: 0 0 0.4rem;
  font-size: 0.9rem;
}

.modal__list {
  margin: 0;
  padding-left: 1.1rem;
  max-height: 28vh;
  overflow: auto;
}

.modal__close-btn {
  margin-top: 0.8rem;
  border: 1px solid #cbd5e1;
  background: #f8fafc;
  border-radius: 8px;
  padding: 0.35rem 0.7rem;
  cursor: pointer;
}
