:root {
  --paper: #f7f5ee;
  --card: #fffdf8;
  --ink: #1e2a32;
  --muted: #637078;
  --line: #d8d9d4;
  --blue: #225ca8;
  --blue-dark: #174477;
  --red: #c9473d;
  --green: #39845a;
  --yellow: #e8bd45;
  --pink: #d98591;
  --shadow: 0 12px 32px rgba(31, 43, 50, 0.09);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  color: var(--ink);
  background: var(--paper);
  font-family: Inter, Arial, sans-serif;
}

button {
  color: inherit;
  font: inherit;
}

button:focus-visible {
  outline: 3px solid rgba(34, 92, 168, 0.3);
  outline-offset: 3px;
}

.site-header {
  width: min(1400px, calc(100% - 40px));
  margin: 0 auto;
  padding: 34px 0 24px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
}

.eyebrow {
  margin: 0 0 7px;
  color: var(--blue-dark);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 8px;
  font-family: Georgia, serif;
  font-size: clamp(34px, 4vw, 56px);
  line-height: 1;
}

h2 {
  margin-bottom: 0;
  font-family: Georgia, serif;
  font-size: 28px;
}

h3 {
  margin-bottom: 12px;
  font-size: 14px;
}

.subtitle {
  max-width: 690px;
  margin-bottom: 0;
  color: var(--muted);
  font-size: 17px;
  line-height: 1.5;
}

.alphabet-button,
.text-button {
  border: 0;
  cursor: pointer;
}

.alphabet-button {
  flex: 0 0 auto;
  padding: 13px 19px;
  border: 1px solid var(--blue-dark);
  border-radius: 10px;
  color: white;
  background: var(--blue-dark);
  font-weight: 700;
}

.alphabet-button:hover {
  background: #0f355e;
}

.game-layout {
  width: min(1400px, calc(100% - 40px));
  margin: 0 auto 50px;
  display: grid;
  grid-template-columns: minmax(450px, 1.25fr) minmax(430px, 1fr);
  gap: 20px;
}

.game-card,
.wardrobe,
.result-panel {
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--card);
  box-shadow: var(--shadow);
}

.game-card {
  position: relative;
  grid-row: span 2;
  min-height: 720px;
  overflow: hidden;
}

.instruction {
  position: absolute;
  top: 18px;
  left: 50%;
  z-index: 10;
  width: max-content;
  max-width: calc(100% - 40px);
  padding: 9px 14px;
  transform: translateX(-50%);
  border: 1px solid #ccd8df;
  border-radius: 30px;
  color: #40515c;
  background: rgba(255, 253, 248, 0.95);
  font-size: 13px;
  font-weight: 700;
  text-align: center;
}

.snow-scene {
  position: relative;
  height: 660px;
  overflow: hidden;
  background: #e9f0f3;
  transition: box-shadow 0.2s ease;
}

.snow-scene::before,
.snow-scene::after {
  content: "";
  position: absolute;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.9);
}

.snow-scene::before {
  top: 85px;
  left: 12%;
  width: 7px;
  height: 7px;
  box-shadow: 90px 74px white, 280px -10px white, 390px 94px white, 510px 18px white, 55px 235px white, 470px 260px white;
}

.snow-scene::after {
  right: 14%;
  top: 145px;
  width: 4px;
  height: 4px;
  box-shadow: -120px 28px white, 120px 90px white, -360px 130px white, 20px 250px white;
}

.snow-scene.drop-active {
  box-shadow: inset 0 0 0 4px var(--blue);
}

.ground {
  position: absolute;
  right: -8%;
  bottom: -70px;
  left: -8%;
  height: 230px;
  border-radius: 50% 50% 0 0;
  background: #fff;
}

.snowman {
  position: absolute;
  bottom: 90px;
  left: 50%;
  width: 330px;
  height: 470px;
  transform: translateX(-50%);
}

.snowman-base {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  user-select: none;
  pointer-events: none;
}

.snowball {
  position: absolute;
  left: 50%;
  border: 2px solid #c7d1d6;
  border-radius: 50%;
  background: #fffefa;
  box-shadow: inset -14px -12px 0 #edf1f1;
  transform: translateX(-50%);
}

.snowball-body {
  bottom: 0;
  width: 245px;
  height: 260px;
}

.snowball-head {
  bottom: 225px;
  z-index: 3;
  width: 185px;
  height: 185px;
}

.eye,
.button-dot,
.smile {
  position: absolute;
  border-radius: 50%;
  background: #29343a;
}

.eye {
  top: 57px;
  width: 12px;
  height: 15px;
}

.eye-left { left: 51px; }
.eye-right { right: 51px; }

.carrot {
  position: absolute;
  top: 82px;
  left: 86px;
  width: 0;
  height: 0;
  border-top: 8px solid transparent;
  border-bottom: 8px solid transparent;
  border-left: 60px solid #d97831;
  transform: rotate(8deg);
}

.smile {
  top: 118px;
  width: 6px;
  height: 6px;
}

.smile-one { left: 67px; }
.smile-two { left: 89px; top: 124px; }
.smile-three { left: 111px; }

.button-dot {
  left: 50%;
  width: 14px;
  height: 14px;
  transform: translateX(-50%);
}

.dot-one { top: 85px; }
.dot-two { top: 133px; }

.arm {
  position: absolute;
  bottom: 190px;
  z-index: 1;
  width: 125px;
  height: 7px;
  border-radius: 5px;
  background: #79563e;
}

.arm-left { left: -2px; transform: rotate(-19deg); }
.arm-right { right: -2px; transform: rotate(19deg); }

.worn-slot {
  position: absolute;
  z-index: 7;
  pointer-events: auto;
  cursor: pointer;
}

.worn-slot:empty {
  display: none;
}

.worn-hat {
  top: 27px;
  left: 80px;
}

.worn-hat .hat-art {
  width: 140px;
  height: 98px;
  transform: rotate(-5deg);
}

.worn-scarf {
  top: 160px;
  left: 102px;
  transform: rotate(-5deg);
}

.worn-scarf .scarf-art {
  width: 160px;
  height: 128px;
}

.worn-broom {
  top: 235px;
  left: -10px;
  transform: rotate(-17deg);
}

.worn-broom .broom-art {
  width: 108px;
  height: 145px;
}

.worn-lantern {
  top: 262px;
  right: 6px;
}

.worn-lantern .lantern-art {
  width: 86px;
  height: 114px;
}

.scene-actions {
  padding: 18px;
  text-align: center;
}

.text-button {
  padding: 4px;
  color: var(--blue-dark);
  background: transparent;
  font-size: 14px;
  font-weight: 700;
}

.text-button:hover {
  text-decoration: underline;
}

.wardrobe {
  padding: 24px;
}

.panel-heading {
  margin-bottom: 22px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
}

.drag-hint {
  color: var(--muted);
  font-size: 12px;
}

.item-group + .item-group {
  margin-top: 22px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
}

.items-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 9px;
}

.items-row-three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.items-row-four {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.wardrobe-item {
  min-height: 110px;
  padding: 10px 7px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  cursor: grab;
  touch-action: none;
  user-select: none;
  transition: border-color 0.16s ease, transform 0.16s ease, background 0.16s ease;
}

.wardrobe-item:hover {
  border-color: #9caab2;
  transform: translateY(-2px);
}

.wardrobe-item.selected {
  border-color: var(--blue);
  background: #f1f6fb;
  box-shadow: inset 0 0 0 1px var(--blue);
}

.wardrobe-item.compact {
  min-height: 114px;
  font-size: 11px;
  line-height: 1.3;
}

.item-art {
  position: relative;
  display: block;
  flex: 0 0 auto;
}

.item-art img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
  pointer-events: none;
  user-select: none;
}

.hat-art {
  width: 78px;
  height: 60px;
}

.hat-art::before {
  content: none;
}

.hat-art::after {
  content: none;
}

.hat-red img,
.hat-blue img,
.hat-green img {
  filter: none;
}

.broom-art {
  width: 62px;
  height: 78px;
}

.cross,
.mini-cross {
  position: absolute;
  z-index: 3;
  display: block;
}

.cross {
  top: 50%;
  left: 50%;
  width: 55px;
  height: 6px;
  border-radius: 4px;
  background: #1f2529;
  transform: translate(-50%, -50%) rotate(45deg);
}

.cross::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: inherit;
  transform: rotate(90deg);
}

.lantern-art {
  width: 58px;
  height: 80px;
}

.lantern-art::before {
  content: none;
}

.lantern-art::after {
  content: none;
}

.lantern-art i {
  display: none;
}

.lantern-art .cross {
  width: 60px;
}

.scarf-art {
  width: 78px;
  height: 76px;
}

.scarf-art::before {
  content: none;
}

.scarf-art::after {
  content: none;
}

.mini-cross {
  right: 8%;
  width: 31%;
  height: 5px;
  border-radius: 3px;
  background: #20272b;
  transform: rotate(45deg);
}

.mini-cross::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: inherit;
  transform: rotate(90deg);
}

.mini-cross.top { top: 34%; }
.mini-cross.bottom { top: auto; bottom: 12%; }

.site-footer {
  width: min(1400px, calc(100% - 40px));
  margin: -25px auto 30px;
  color: var(--muted);
  font-size: 12px;
  text-align: right;
}

.site-footer a,
.site-footer code {
  color: var(--blue-dark);
}

.result-panel {
  padding: 24px;
  min-height: 230px;
}

.result-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.selected-letter {
  width: 58px;
  height: 58px;
  flex: 0 0 auto;
  border: 2px solid var(--blue-dark);
  border-radius: 50%;
  color: var(--blue-dark);
  font-family: Georgia, serif;
  font-size: 35px;
  font-weight: 700;
  line-height: 54px;
  text-align: center;
}

.empty-result,
.result-note {
  margin: 15px 0 0;
  color: var(--muted);
  line-height: 1.5;
}

.property-list {
  margin: 18px 0 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  list-style: none;
}

.property-list li {
  padding: 7px 10px;
  border: 1px solid #cfd8dd;
  border-radius: 8px;
  background: #f5f8f9;
  font-size: 14px;
  font-weight: 700;
}

.letters-result {
  margin-top: 20px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.letter-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.letter-chip {
  min-width: 36px;
  padding: 6px 8px;
  border: 1px solid #bfc9cf;
  border-radius: 8px;
  background: white;
  font-family: Georgia, serif;
  font-size: 18px;
  font-weight: 700;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal.open {
  display: flex;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(21, 28, 32, 0.58);
}

.modal-dialog {
  position: relative;
  z-index: 1;
  width: min(690px, 100%);
  max-height: calc(100vh - 40px);
  padding: 30px;
  overflow: auto;
  border-radius: 18px;
  background: var(--card);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.28);
}

.modal-close {
  position: absolute;
  top: 15px;
  right: 17px;
  width: 38px;
  height: 38px;
  border: 0;
  border-radius: 50%;
  background: #ecece8;
  cursor: pointer;
  font-size: 27px;
  line-height: 1;
}

.modal-description,
.alphabet-note {
  color: var(--muted);
  line-height: 1.5;
}

.modal-description {
  margin: 9px 45px 22px 0;
}

.alphabet-grid {
  display: grid;
  grid-template-columns: repeat(11, 1fr);
  gap: 7px;
}

.alphabet-letter {
  aspect-ratio: 1;
  border: 1px solid #bcc7cd;
  border-radius: 8px;
  background: #fff;
  cursor: pointer;
  font-family: Georgia, serif;
  font-size: 21px;
  font-weight: 700;
}

.alphabet-letter:hover {
  border-color: var(--blue);
  color: white;
  background: var(--blue);
}

.alphabet-letter.special {
  color: #6d757a;
  background: #efefeb;
}

.alphabet-note {
  margin: 19px 0 0;
  font-size: 13px;
}

.drag-ghost {
  position: fixed;
  z-index: 200;
  width: 96px;
  min-height: 88px;
  padding: 10px;
  display: none;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--blue);
  border-radius: 14px;
  background: white;
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.2);
  pointer-events: none;
  transform: translate(-50%, -50%);
}

.drag-ghost.visible {
  display: flex;
}

.drag-ghost .item-art {
  transform: scale(1.08);
}

@media (max-width: 1100px) {
  .game-layout {
    grid-template-columns: 1fr;
  }

  .game-card {
    grid-row: auto;
  }

  .items-row-four {
    grid-template-columns: repeat(4, minmax(90px, 1fr));
  }
}

@media (max-width: 650px) {
  .site-header,
  .game-layout {
    width: min(100% - 24px, 1400px);
  }

  .site-header {
    padding-top: 24px;
    align-items: flex-start;
    flex-direction: column;
  }

  .game-card {
    min-height: 615px;
  }

  .snow-scene {
    height: 555px;
  }

  .snowman {
    bottom: 55px;
    transform: translateX(-50%) scale(0.82);
    transform-origin: bottom center;
  }

  .wardrobe,
  .result-panel {
    padding: 18px;
  }

  .panel-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .items-row-three {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .items-row-four {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .alphabet-grid {
    grid-template-columns: repeat(6, 1fr);
  }

  .modal-dialog {
    padding: 24px 18px;
  }
}

@media (max-width: 430px) {
  .wardrobe-item {
    min-height: 104px;
    font-size: 12px;
  }

  .snowman {
    transform: translateX(-50%) scale(0.72);
  }
}
