:root {
  --wordle-green: #6aaa64;
  --wordle-yellow: #c9b458;
  --wordle-gray: #787c7e;
  --tile-border: #d3d6da;
  --basket-rim: #7a5230;
  --basket-fill: #b98552;
  --token-bg: #f2e8cf;
  --token-target: #f6c453;
}

body {
  background:
    radial-gradient(circle at 0% 0%, rgba(0, 0, 0, 0.5) 0%, transparent 48%),
    radial-gradient(circle at 100% 100%, rgba(0, 0, 0, 0.45) 0%, transparent 46%),
    linear-gradient(135deg, rgba(236, 72, 153, 0.2) 25%, transparent 25%) 0 0 / 54px 54px,
    linear-gradient(225deg, rgba(168, 85, 247, 0.18) 25%, transparent 25%) 0 0 / 54px 54px,
    linear-gradient(315deg, rgba(217, 70, 239, 0.2) 25%, transparent 25%) 0 0 / 54px 54px,
    linear-gradient(45deg, rgba(168, 85, 247, 0.14) 25%, transparent 25%) 0 0 / 54px 54px,
    radial-gradient(circle at 18% 22%, rgba(251, 113, 133, 0.32), transparent 42%),
    radial-gradient(circle at 84% 10%, rgba(232, 121, 249, 0.28), transparent 38%),
    radial-gradient(circle at 50% 85%, rgba(147, 51, 234, 0.24), transparent 45%),
    linear-gradient(150deg, #190028 0%, #3c0658 36%, #5b0a79 64%, #2b0243 100%);
  min-height: 100vh;
  position: relative;
}

body::before,
body::after {
  content: "";
  position: fixed;
  top: 0;
  bottom: 0;
  width: clamp(18px, 4vw, 42px);
  z-index: 0;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.2), transparent 28%),
    linear-gradient(180deg, #14171c 0%, #0e1116 50%, #1f2630 100%);
  border-left: 2px solid #6b7280;
  border-right: 2px solid #111827;
  box-shadow:
    inset 0 0 18px rgba(255, 255, 255, 0.08),
    inset 0 0 22px rgba(0, 0, 0, 0.5);
}

body::before {
  left: 0;
}

body::after {
  right: 0;
}

main.container {
  padding-bottom: 6rem;
  position: relative;
  z-index: 1;
}

.machine-viewport {
  border-left: 6px solid rgba(45, 55, 72, 0.9);
  border-right: 6px solid rgba(45, 55, 72, 0.9);
  box-shadow:
    inset 10px 0 22px rgba(0, 0, 0, 0.34),
    inset -10px 0 22px rgba(0, 0, 0, 0.34);
  background:
    linear-gradient(180deg, rgba(10, 10, 14, 0.72), rgba(5, 5, 8, 0.78));
  backdrop-filter: blur(1px);
}

.arcade-heading {
  display: inline-block;
  padding: 0.5rem 1.25rem 0.55rem;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.86);
  border: 3px solid #ffffff;
  box-shadow:
    0 10px 20px rgba(0, 0, 0, 0.35),
    0 0 14px rgba(0, 0, 0, 0.3);
}

.arcade-title {
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: #e9d5ff;
  -webkit-text-stroke: 1.3px #facc15;
  text-shadow:
    0 3px 0 rgba(0, 0, 0, 0.55);
}

.arcade-subtitle {
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #f5d0fe;
  -webkit-text-stroke: 0.9px #facc15;
  text-shadow:
    0 2px 0 rgba(0, 0, 0, 0.5);
}

#board {
  display: grid;
  gap: 0.35rem;
  width: min(360px, 92vw);
  padding: 0.45rem;
  border: 3px solid #ffffff;
  outline: 8px solid #000000;
  border-radius: 0.45rem;
  background: #2b2f36;
}

.row-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 0.35rem;
}

.tile {
  aspect-ratio: 1 / 1;
  border: 2px solid var(--tile-border);
  border-radius: 0.35rem;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: clamp(1.25rem, 2.8vw, 1.7rem);
  font-weight: 700;
  text-transform: uppercase;
  user-select: none;
  background: #2f343d;
  color: #e5e7eb;
}

.tile.filled {
  border-color: #878a8c;
}

.tile.correct {
  background: var(--wordle-green);
  border-color: var(--wordle-green);
  color: #fff;
}

.tile.present {
  background: var(--wordle-yellow);
  border-color: var(--wordle-yellow);
  color: #fff;
}

.tile.absent {
  background: var(--wordle-gray);
  border-color: var(--wordle-gray);
  color: #fff;
}

.crane-machine {
  position: relative;
  width: min(760px, 96vw);
  border: 2px solid #c8ccd0;
  border-radius: 0.5rem;
  padding: 0.75rem;
  background: #2a2f37;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.06);
}

.crane-layout {
  width: min(1060px, 98vw);
}

.arcade-drop-button,
.arcade-shake-button {
  width: 112px;
  height: 112px;
  border-radius: 999px;
  color: #fff;
  font-weight: 900;
  letter-spacing: 0.04em;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
  flex: 0 0 auto;
}

.arcade-drop-button {
  border: 6px solid #6e0d0d;
  background: radial-gradient(circle at 30% 30%, #ff5e5e 0%, #d91f1f 58%, #960f0f 100%);
  box-shadow:
    0 10px 0 #6e0d0d,
    0 14px 20px rgba(0, 0, 0, 0.25);
}

.arcade-shake-button {
  border: 6px solid #0b3a72;
  background: radial-gradient(circle at 30% 30%, #5bc0ff 0%, #1d7ae3 58%, #0f4fa3 100%);
  box-shadow:
    0 10px 0 #0b3a72,
    0 14px 20px rgba(0, 0, 0, 0.25);
}

.arcade-drop-button:active {
  transform: translateY(4px);
  box-shadow:
    0 6px 0 #6e0d0d,
    0 9px 15px rgba(0, 0, 0, 0.25);
}

.arcade-shake-button:active {
  transform: translateY(4px);
  box-shadow:
    0 6px 0 #0b3a72,
    0 9px 15px rgba(0, 0, 0, 0.25);
}

.claw-track {
  height: 72px;
  position: relative;
  z-index: 2;
  border: 1px dashed #b8bdc3;
  border-radius: 0.35rem;
  margin-bottom: 0.65rem;
  overflow: visible;
  background: linear-gradient(180deg, #eef3f7 0%, #f8fbff 100%);
}

.machine-upper {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  gap: 0.85rem;
  align-items: start;
}

.play-field {
  min-width: 0;
}

.claw {
  position: absolute;
  top: 8px;
  left: 0;
  --drop-depth: 24px;
  width: 56px;
  height: 220px;
  transform: translateX(-50%);
  transition: left 180ms ease;
  color: #475569;
  pointer-events: none;
}

.claw-cable {
  width: 2px;
  height: var(--drop-depth);
  margin: 0 auto;
  background: #748292;
  transition: height 360ms ease;
}

.crane-machine.dropping .claw {
  --drop-depth: 190px;
}

.claw-grip {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 44px;
  margin: 2px auto 0;
  font-size: 1.4rem;
  font-weight: 800;
  line-height: 1;
}

.claw-grip span {
  transition: transform 140ms ease;
}

.claw.holding .claw-grip span:first-child {
  transform: translateX(3px);
}

.claw.holding .claw-grip span:last-child {
  transform: translateX(-3px);
}

.claw-cargo {
  width: 28px;
  height: 28px;
  border: 2px solid #ccb78a;
  background: var(--token-bg);
  border-radius: 50%;
  display: none;
  align-items: center;
  justify-content: center;
  margin: 3px auto 0;
  font-weight: 800;
  font-size: 1.8rem;
  color: #111;
}

.claw.holding .claw-cargo {
  display: flex;
}

.basket-bin {
  position: relative;
  height: 220px;
  border: 10px solid var(--basket-rim);
  border-top-width: 16px;
  border-radius: 14px 14px 40px 40px;
  overflow: hidden;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.25), transparent 30%),
    repeating-linear-gradient(-12deg,
      #b98552 0,
      #b98552 10px,
      #9f6f44 10px,
      #9f6f44 20px);
}

.basket-letter {
  position: absolute;
  width: 32px;
  height: 32px;
  border: 2px solid #ccb78a;
  background: var(--token-bg);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  text-transform: uppercase;
  font-weight: 800;
  font-size: 1.9rem;
  user-select: none;
  transform: translate(-999px, -999px);
  z-index: 3;
}

.basket-letter.target {
  box-shadow: 0 0 0 3px rgba(246, 196, 83, 0.75);
}

.basket-letter.grabbed {
  opacity: 0.2;
}

.basket-letter.correct {
  background: var(--wordle-green);
  border-color: var(--wordle-green);
  color: #fff;
}

.basket-letter.present {
  background: var(--wordle-yellow);
  border-color: var(--wordle-yellow);
  color: #fff;
}

.basket-letter.absent {
  background: var(--wordle-gray);
  border-color: var(--wordle-gray);
  color: #fff;
}

.guess-panel {
  border: 2px solid #c8ccd0;
  border-radius: 0.5rem;
  background: rgba(47, 52, 61, 0.96);
  padding: 0.7rem;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.05);
  color: #e5e7eb;
}

.guess-panel-title {
  font-weight: 700;
  margin-bottom: 0.55rem;
}

.guess-indicator {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 0.3rem;
}

.guess-slot {
  aspect-ratio: 1 / 1;
  border: 2px solid var(--tile-border);
  border-radius: 0.3rem;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  text-transform: uppercase;
  background: #2f343d;
  color: #e5e7eb;
}

.guess-slot.filled {
  border-color: #878a8c;
}

.panel-action-btn {
  width: 100%;
  margin-top: 0.65rem;
}

.joystick-wrap {
  margin-top: 0;
}

.joystick-label {
  margin-bottom: 0.45rem;
}

.joystick-base {
  width: 120px;
  height: 120px;
  margin: 0 auto 0.5rem;
  border-radius: 999px;
  border: 6px solid #1f2937;
  background: radial-gradient(circle at 30% 30%, #4b5563 0%, #1f2937 75%);
  position: relative;
  touch-action: none;
  flex: 0 0 auto;
}

.joystick-stick {
  width: 46px;
  height: 46px;
  border-radius: 999px;
  border: 3px solid #0f172a;
  background: radial-gradient(circle at 30% 30%, #dbeafe 0%, #94a3b8 72%, #64748b 100%);
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  transition: transform 70ms linear;
}

.bucket-controls {
  width: calc(100% + 1.5rem);
  margin: 0.75rem -0.75rem -0.75rem;
  padding: 0.95rem 1rem 1.05rem;
  border-top: 4px solid #9ca3af;
  background: linear-gradient(180deg, #6b7280 0%, #4b5563 52%, #374151 100%);
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, 0.35),
    inset 0 -2px 0 rgba(0, 0, 0, 0.35);
  display: flex;
  justify-content: space-evenly;
  align-items: center;
  gap: 2rem;
  flex-wrap: nowrap;
}

.control-unit {
  display: grid;
  grid-template-rows: auto 1fr auto;
  align-items: center;
  justify-items: center;
  gap: 0.35rem;
  min-height: 210px;
  width: 200px;
  text-align: center;
}

.joystick-unit {
  grid-template-rows: auto 1fr auto;
}

.control-hint {
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: rgba(226, 232, 240, 0.9);
  text-align: center;
  align-self: end;
}

.control-unit>button,
.joystick-base {
  justify-self: center;
}

.joystick-label {
  margin: 0 0 0.45rem;
  text-align: center;
}

.control-unit:not(.joystick-unit)>button {
  margin-top: 2.1rem;
}

@keyframes machine-shake {
  0% {
    transform: translate3d(0, 0, 0);
  }

  10% {
    transform: translate3d(-8px, 2px, 0);
  }

  20% {
    transform: translate3d(8px, -2px, 0);
  }

  30% {
    transform: translate3d(-7px, 2px, 0);
  }

  40% {
    transform: translate3d(7px, -2px, 0);
  }

  50% {
    transform: translate3d(-6px, 1px, 0);
  }

  60% {
    transform: translate3d(6px, -1px, 0);
  }

  70% {
    transform: translate3d(-5px, 1px, 0);
  }

  80% {
    transform: translate3d(5px, -1px, 0);
  }

  90% {
    transform: translate3d(-3px, 0, 0);
  }

  100% {
    transform: translate3d(0, 0, 0);
  }
}

.machine-viewport.screen-shake {
  animation: machine-shake 460ms linear 1;
}

.bucket-controls .joystick-wrap {
  margin: 0;
}

.console-divider {
  width: min(980px, 96%);
  height: 16px;
  margin: 0.8rem auto 0.6rem;
  border-radius: 999px;
  border: 2px solid #9ca3af;
  background:
    linear-gradient(180deg, #1f2937 0%, #111827 55%, #0b0f17 100%);
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, 0.18),
    0 3px 10px rgba(0, 0, 0, 0.35);
}

.watermark {
  margin-top: 0.7rem;
  font-size: 0.86rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: rgba(229, 231, 235, 0.75);
}

@media (max-width: 860px) {

  body::before,
  body::after {
    width: 14px;
  }

  main.container {
    padding-left: 0.35rem;
    padding-right: 0.35rem;
    padding-bottom: 5rem;
  }

  .machine-viewport {
    border-left-width: 4px;
    border-right-width: 4px;
  }

  .arcade-heading {
    padding: 0.42rem 0.75rem 0.5rem;
    max-width: 96%;
  }

  .arcade-title {
    font-size: clamp(1.15rem, 6.2vw, 1.65rem);
    letter-spacing: 0.08em;
  }

  .arcade-subtitle {
    font-size: clamp(0.68rem, 2.9vw, 0.84rem);
    letter-spacing: 0.04em;
  }

  .crane-machine {
    width: 100%;
    padding: 0.55rem;
  }

  .machine-upper {
    grid-template-columns: 1fr;
    gap: 0.6rem;
  }

  .guess-panel {
    width: min(96%, 460px);
    margin: 0 auto;
  }

  .bucket-controls {
    width: calc(100% + 1.1rem);
    margin: 0.6rem -0.55rem -0.55rem;
    padding: 0.75rem 0.55rem 0.85rem;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.75rem;
  }

  .control-unit {
    width: min(45vw, 185px);
    min-height: 0;
    grid-template-rows: auto auto;
    gap: 0.3rem;
  }

  .control-unit:not(.joystick-unit)>button {
    margin-top: 0;
  }

  .joystick-unit {
    width: min(92vw, 360px);
    order: 3;
    grid-template-rows: auto auto auto;
  }

  .arcade-drop-button,
  .arcade-shake-button {
    width: 88px;
    height: 88px;
    font-size: 0.88rem;
  }

  .joystick-base {
    width: 98px;
    height: 98px;
  }

  .joystick-stick {
    width: 40px;
    height: 40px;
  }

  .control-hint {
    font-size: 0.72rem;
  }

  #board {
    outline-width: 6px;
  }

  .console-divider {
    width: 98%;
  }
}

@media (max-width: 520px) {

  body::before,
  body::after {
    width: 10px;
  }

  .arcade-drop-button,
  .arcade-shake-button {
    width: 82px;
    height: 82px;
  }

  .joystick-base {
    width: 90px;
    height: 90px;
  }

  .guess-panel {
    width: 100%;
  }
}