* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: Arial, Helvetica, sans-serif;
  background: #101820;
  color: #f6f7f8;
  overflow-x: hidden;
}

body::before,
body::after {
  content: "";
  position: fixed;
  inset: 0;
}

body::before {
  z-index: -2;
  background: url("assets/shaman_dance_bg.webp") center / cover no-repeat;
  animation:
    backgroundFadeIn 1200ms ease-out both,
    backgroundSway 16s ease-in-out infinite alternate;
}

body::after {
  z-index: -1;
  background: rgba(16, 24, 32, 0.62);
}

.game-shell {
  position: relative;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  padding: 24px 18px;
}

.game-title {
  margin: 0;
  line-height: 0;
}

.game-title img {
  display: block;
  width: min(468px, 90vw);
  height: auto;
}

.game-layout {
  width: 532px;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 20px;
}

.game-body {
  display: grid;
  grid-template-columns: 316px 196px;
  align-items: start;
  gap: 20px;
}

.board-frame {
  position: relative;
  z-index: 2;
  width: 316px;
  height: 616px;
  max-width: 100%;
  padding: 8px;
  justify-self: center;
  filter: drop-shadow(0 8px 12px rgba(0, 0, 0, 0.35));
}

.board-frame::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  border: 8px solid transparent;
  border-image: url("assets/info-panel-wood.webp") 160 round;
  filter: brightness(1.45) contrast(1.18) saturate(1.12);
  box-shadow:
    inset 0 0 0 1px rgba(255, 229, 155, 0.56),
    inset 0 0 12px rgba(241, 154, 55, 0.2),
    0 0 0 1px rgba(255, 197, 91, 0.42),
    0 0 16px rgba(0, 0, 0, 0.45);
}

#game-board {
  position: relative;
  z-index: 2;
  display: block;
  width: 300px;
  height: 600px;
  max-width: 100%;
  background: transparent;
}

.game-status {
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 3;
  transform: translate(-50%, -50%);
  width: 270px;
  padding: 22px 14px;
  text-align: center;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 32px;
  font-weight: 700;
  line-height: 1;
  letter-spacing: 0;
  text-transform: uppercase;
  color: #ffe9a5;
  background:
    linear-gradient(rgba(255, 205, 116, 0.18), rgba(74, 28, 9, 0.16)),
    url("assets/info-panel-wood.webp") center / 100% 100% no-repeat;
  border: 6px solid transparent;
  border-image: url("assets/info-panel-wood.webp") 160 round;
  border-radius: 8px;
  box-shadow:
    inset 0 0 0 1px rgba(255, 229, 155, 0.54),
    inset 0 0 18px rgba(0, 0, 0, 0.58),
    0 10px 18px rgba(0, 0, 0, 0.58);
  text-shadow:
    0 2px 1px rgba(0, 0, 0, 0.98),
    0 0 10px rgba(216, 148, 50, 0.3);
  filter: brightness(1.14) contrast(1.08) saturate(1.08);
}

.game-status::before {
  content: "";
  position: absolute;
  inset: 8px;
  pointer-events: none;
  border: 1px solid rgba(241, 189, 98, 0.54);
  border-radius: 4px;
  box-shadow:
    inset 0 0 16px rgba(0, 0, 0, 0.48),
    0 0 0 1px rgba(66, 29, 10, 0.7);
}

.game-status[hidden] {
  display: none;
}

.game-status.is-fading-out {
  opacity: 0;
  transition: opacity 220ms ease-out;
}

.scoreboard-panel {
  position: absolute;
  left: calc(50% + 108px);
  top: 50%;
  z-index: 4;
  width: min(430px, calc(100vw - 28px));
  min-height: 360px;
  padding: 24px 20px 20px;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  gap: 14px;
  color: #fff0b2;
  background:
    linear-gradient(rgba(255, 205, 116, 0.2), rgba(74, 28, 9, 0.18)),
    url("assets/info-panel-wood.webp") center / 100% 100% no-repeat;
  border: 6px solid transparent;
  border-image: url("assets/info-panel-wood.webp") 160 round;
  border-radius: 8px;
  box-shadow:
    inset 0 0 0 1px rgba(255, 229, 155, 0.5),
    inset 0 0 20px rgba(0, 0, 0, 0.62),
    0 12px 20px rgba(0, 0, 0, 0.6);
  font-family: Georgia, "Times New Roman", serif;
  filter: brightness(1.14) contrast(1.08) saturate(1.08);
}

.scoreboard-panel[hidden] {
  display: none;
}

.scoreboard-panel h2 {
  margin: 0;
  text-align: center;
  font-size: 28px;
  line-height: 1;
  letter-spacing: 0;
  text-transform: uppercase;
  text-shadow:
    0 2px 1px rgba(0, 0, 0, 0.98),
    0 0 8px rgba(241, 189, 98, 0.25);
}

.scoreboard-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 7px;
  font-family: "Courier New", Courier, monospace;
  font-size: 15px;
  font-weight: 700;
  line-height: 1.2;
}

.scoreboard-row {
  display: grid;
  grid-template-columns: 30px 42px 92px 118px;
  gap: 8px;
  align-items: center;
  justify-content: center;
  padding: 5px 6px;
  color: #ffe9a5;
  background: rgba(8, 4, 2, 0.34);
  border: 1px solid rgba(241, 189, 98, 0.3);
  box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.42);
  text-shadow: 0 1px 1px rgba(0, 0, 0, 0.95);
  white-space: nowrap;
}

.scoreboard-row span {
  overflow: hidden;
}

.scoreboard-initials-input {
  width: 38px;
  min-height: 24px;
  padding: 1px 3px;
  font-family: "Courier New", Courier, monospace;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
  color: #ffe9a5;
  background: rgba(8, 4, 2, 0.56);
  border: 1px solid rgba(241, 189, 98, 0.48);
  outline: none;
}

.scoreboard-initials-input:focus {
  border-color: #ffe9a5;
  box-shadow: 0 0 0 2px rgba(255, 233, 165, 0.18);
}

.new-game-button {
  min-height: 36px;
  padding: 7px 10px;
  border: 1px solid rgba(255, 229, 155, 0.46);
  border-radius: 4px;
  color: #fff0b2;
  background:
    linear-gradient(rgba(255, 205, 116, 0.24), rgba(74, 28, 9, 0.26)),
    rgba(95, 48, 18, 0.9);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 14px;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  text-shadow: 0 2px 1px rgba(0, 0, 0, 0.95);
  box-shadow:
    inset 0 0 10px rgba(0, 0, 0, 0.34),
    0 4px 7px rgba(0, 0, 0, 0.34);
}

.new-game-button:hover {
  border-color: rgba(255, 233, 165, 0.78);
  filter: brightness(1.08);
}

.new-game-button {
  width: 100%;
  margin-top: auto;
  min-height: 42px;
  font-size: 19px;
  text-transform: uppercase;
}

.game-info {
  position: relative;
  z-index: 1;
  width: 196px;
  height: 616px;
  display: grid;
  grid-template-rows: repeat(4, 1fr);
  gap: 14px;
}

.info-section {
  min-height: 0;
  padding: 20px 18px 17px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  background:
    linear-gradient(rgba(255, 205, 116, 0.2), rgba(104, 46, 13, 0.08)),
    url("assets/info-panel-wood.webp") center / 100% 100% no-repeat;
  border-radius: 6px;
  filter: drop-shadow(0 8px 12px rgba(0, 0, 0, 0.35));
}

.info-section h2 {
  margin: 0 0 7px;
  line-height: 0;
  text-align: center;
}

.info-section h2 img {
  width: 100%;
  max-width: 132px;
  height: auto;
  filter:
    brightness(1.22)
    contrast(1.2)
    drop-shadow(0 2px 1px rgba(0, 0, 0, 0.95));
}

.number-display {
  min-height: 54px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  max-width: 100%;
  overflow: hidden;
}

.number-display img {
  width: 32px;
  height: 43px;
  flex: 0 0 auto;
  object-fit: contain;
  filter:
    brightness(1.32)
    contrast(1.28)
    drop-shadow(0 2px 1px rgba(0, 0, 0, 0.98));
}

.number-display img + img {
  margin-left: -8px;
}

.number-display[data-digit-count="1"] img {
  width: 35px;
  height: 46px;
}

.number-display[data-digit-count="4"] img,
.number-display[data-digit-count="5"] img {
  width: 30px;
}

.number-display[data-digit-count="6"] img,
.number-display[data-digit-count="7"] img {
  width: 28px;
}

.next-piece-preview {
  display: block;
  width: 96px;
  height: 72px;
  margin: 0 auto;
  background: rgba(8, 4, 2, 0.42);
  border: 1px solid rgba(241, 189, 98, 0.35);
  box-shadow: inset 0 0 16px rgba(0, 0, 0, 0.55);
}

.credit-bar {
  width: 100%;
  min-height: 44px;
  padding: 11px 18px 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 15px;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: 0;
  color: #fff0b2;
  background:
    linear-gradient(rgba(255, 205, 116, 0.18), rgba(104, 46, 13, 0.1)),
    url("assets/info-panel-wood.webp") center / 100% 100% no-repeat;
  border: 1px solid rgba(241, 189, 98, 0.48);
  border-radius: 6px;
  box-shadow:
    inset 0 0 0 1px rgba(255, 229, 155, 0.26),
    inset 0 0 12px rgba(0, 0, 0, 0.45),
    0 8px 12px rgba(0, 0, 0, 0.35);
  text-shadow:
    0 2px 1px rgba(0, 0, 0, 0.98),
    0 0 8px rgba(241, 189, 98, 0.22);
}

@media (max-width: 560px) {
  .game-shell {
    justify-content: flex-start;
    padding: 18px 12px;
  }

  .game-layout {
    width: 100%;
  }

  .game-body {
    width: 100%;
    grid-template-columns: 1fr;
    justify-items: center;
  }

  .game-info {
    width: 100%;
    height: auto;
    max-width: 300px;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: none;
    gap: 8px;
  }

  .info-section {
    min-height: 98px;
    padding: 16px 10px 13px;
  }

  .info-section h2 img {
    max-width: 92px;
  }

  .number-display {
    min-height: 40px;
  }

  .number-display img {
    width: 24px;
    height: 33px;
  }

  .number-display img + img {
    margin-left: -6px;
  }

  .number-display[data-digit-count="1"] img {
    width: 26px;
    height: 35px;
  }

  .number-display[data-digit-count="4"] img,
  .number-display[data-digit-count="5"] img,
  .number-display[data-digit-count="6"] img,
  .number-display[data-digit-count="7"] img {
    width: 22px;
  }

  .game-status {
    width: calc(100% - 38px);
    padding: 19px 12px;
    font-size: 27px;
  }

  .scoreboard-panel {
    left: 50%;
    width: min(360px, calc(100vw - 24px));
    padding: 22px 12px 18px;
  }

  .scoreboard-list {
    font-size: 12px;
  }

  .scoreboard-row {
    grid-template-columns: 24px 32px 72px 92px;
    gap: 5px;
    padding: 5px 4px;
  }

  .scoreboard-initials-input {
    width: 32px;
    min-height: 22px;
    font-size: 12px;
  }

  .credit-bar {
    width: min(300px, 100%);
    align-self: center;
    max-width: 300px;
    min-height: 42px;
    padding: 10px 12px;
    font-size: 14px;
  }

  .info-section:last-child {
    grid-column: 1 / -1;
  }
}

@keyframes backgroundFadeIn {
  0% {
    opacity: 0;
  }

  100% {
    opacity: 1;
  }
}

@keyframes backgroundSway {
  0% {
    transform: scale(1.05) translate(-18px, -8px);
  }

  50% {
    transform: scale(1.06) translate(18px, 8px);
  }

  100% {
    transform: scale(1.05) translate(-10px, 14px);
  }
}

@media (prefers-reduced-motion: reduce) {
  body::before {
    animation: none;
  }
}
