* {
  box-sizing: border-box;
  /* cache-bust: 2026-04-17-v3 */
}

body {
  margin: 0;
  padding: 14px;
  font-family: "Trebuchet MS", "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  background: #FFC907;
  color: #050200;
}

button,
input,
select,
textarea {
  font-family: inherit;
}

.container {
  max-width: 1240px;
  margin: 0 auto;
  background: #FF902A;
  border-top: 5px solid #FF902A;
  border-radius: 4px;
  padding: 10px;

  border: 2px solid #FF902A;
  box-shadow: 0 2px 14px rgb(1, 0, 6);
}

.top-bar {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 14px;
}

h1 {
  margin: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 1.4rem;

}

h1 img {
  height: 28px;
  width: auto;
}

.game-title {
  position: relative;
  justify-self: center;
  width: 100%;
  text-align: center;
}

.logo-hover-wrap,
.title-hover-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.cw-logo {
  height: 32px;
  width: auto;
}

.cw-logo-alt {
  width: 156px;
  height: 32px;
  object-fit: contain;
  object-position: left center;
}

.top-bar .logo-hover-wrap:first-child {
  justify-self: start;
}

.top-bar .logo-hover-wrap:last-child {
  justify-self: end;
}

.title-hover-wrap {
  margin-left: 0;
}

.game-title-text {
  font-size: 1.27rem;
  line-height: 1;
}

.qr-popover {
  position: absolute;
  top: calc(100% + 10px);
  left: 0;
  z-index: 20;
  display: none;
  width: max-content;
  max-width: min(88vw, 300px);
  padding: 8px;
  background: #FF902A;
  border: 2px solid #FF902A;
  border-radius: 4px;
  box-shadow: 0 2px 14px rgb(1, 0, 6);
  text-align: center;
}

.qr-popover-right {
  left: auto;
  right: 0;
}

.qr-popover img {
  width: 150px;
  height: 150px;
  object-fit: contain;
  display: block;
  margin: 0 auto 6px;
  border: 2px solid #FF902A;
  border-radius: 4px;
  background: #ffffff;
}

.qr-popover a {
  color: #FFC907;
  font-size: 0.76rem;
  font-weight: 700;
  text-decoration: underline;
  word-break: break-word;
}

.logo-hover-wrap:hover .qr-popover,
.logo-hover-wrap:focus-within .qr-popover,
.title-hover-wrap:hover .qr-popover,
.title-hover-wrap:focus-within .qr-popover {
  display: block;
}

.stats {
  display: grid;
  grid-template-columns: repeat(5, minmax(100px, 1fr));
  gap: 10px;
  margin: 12px 0;

  box-shadow: 0 2px 14px rgb(1, 0, 6);

}

.stats p {
  margin: 0;
  padding: 5px;
  background: #FF902A;
  border-radius: 2px;
  font-weight: 700;
  text-align: center;
  box-shadow: 0 2px 14px rgb(1, 0, 6);
  border: 2px solid #FF902A;

}

.message {
  min-height: 24px;
  margin-bottom: 4px;
  font-weight: 700;
  text-align: center;
  border-radius: 3px;
  border: 2px solid #FF902A;
  box-shadow: 0 2px 14px rgb(1, 0, 6);
}

.message.win {
  color: #159a48;
}

.message.loss {
  color: #f5402c;
}

.controls {
  display: flex;
  justify-content: center;
  gap: 4px;
  margin-top: 8px;
}

button {
  padding: 4px;
  border: 2px solid #FF902A;
  border-radius: 3px;
  padding: 3px 10px;
  color: #FF902A;
  background: #FFC907;
  font-weight: 700;
  box-shadow: 0 2px 14px rgb(1, 0, 6);
  border: 2px solid #FF902A;
  cursor: pointer;
}

#reset-game {
  background: #FFC907;
  border: 2px solid #FF902A;
  border-radius: 2px;
  box-shadow: 0 2px 14px rgb(1, 0, 6);
}

.game-layout {
  display: grid;
  grid-template-columns: 1fr 2fr 1fr;
  gap: 12px;
}

.panel {
  background: #FF902A;
  border: 2px solid #FF902A;
  border-radius: 3px;
  padding: 5px;
  box-shadow: 0 2px 14px rgb(1, 0, 6);
}

.panel h2 {
  margin-top: 0;
  margin-bottom: 8px;
  font-size: 1rem;
  box-shadow: 0 2px 14px rgb(1, 0, 6);
}

.instructions ul {
  margin: 0;
  padding-left: 10px;
  font-size: 0.85rem;
  line-height: 1.35;

}

.rules-section {
  margin-bottom: 10px;
  padding: 6px;
  border: 1px solid #FF902A;
  border-radius: 2px;
  background: #fff9da;
}

.rules-section h3 {
  margin: 0 0 6px 0;
  font-size: 0.9rem;
  font-weight: 700;
  color: #050200;
}

.rules-section ul {
  margin: 0;
  padding-left: 16px;
  font-size: 0.8rem;
  line-height: 1.3;
}

.rules-section li {
  margin-bottom: 4px;
}

.difficulty-controls {
  margin-top: 10px;
  padding-top: 8px;
  display: grid;
  gap: 6px;
}

.instructions .difficulty-controls {
  padding-top: 8px;
  border-top: 2px solid #FF902A;
}

.difficulty-controls label {
  font-size: 0.85rem;
  font-weight: 700;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.difficulty-controls input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 8px;
  border-radius: 8px;
  background: #FFC907;
  border: 2px solid #FF902A;
  box-shadow: 0 2px 14px rgb(1, 0, 6);
  cursor: pointer;
}

.difficulty-controls input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid #FF902A;
  background: #FF902A;
  box-shadow: 0 2px 14px rgb(1, 0, 6);
}

.difficulty-controls input[type="range"]::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid #FF902A;
  background: #FF902A;
  box-shadow: 0 2px 14px rgb(1, 0, 6);
}

.difficulty-controls input[type="range"]::-moz-range-track {
  height: 8px;
  border-radius: 8px;
  background: #FFC907;
  border: 2px solid #FF902A;
}

.board-wrap {
  display: flex;
  justify-content: center;
}

.game-grid {
  width: min(52vw, 480px);
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
  padding: 6px;
  border: 2px solid #FF902A;
  border-radius: 4px;
  background: #FFC907;
  box-shadow: 0 2px 14px rgb(1, 0, 6);
}

.grid-cell {
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  aspect-ratio: 1;
  border: 2px solid #FF902A;
  border-radius: 2px;
  background: #00defb;
  margin: 0;
  min-width: 0;
  min-height: 0;
  padding: 0;
  font-size: 0;
  line-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 14px rgb(1, 0, 6);
}

.grid-cell.active-cell {
  background: #fff9da;
  border: 2px solid #FF902A;
  border-radius: 3px;
}

.grid-cell.center-lock {
  background: #94a5b6;
  border: 2px dashed #FF902A;
  border-radius: 2px;
  box-shadow: 0 2px 14px rgb(1, 0, 6);
  opacity: 0.35;
  pointer-events: none;
}

.grid-cell.non-playable {
  opacity: 0.25;
  pointer-events: none;
}

.grid-cell.hit-anim {
  animation: descend-cell 0.3s ease forwards;
}

.grid-cell.hit-fail {
  box-shadow: inset 0 0 0 999px rgba(245, 64, 44, 0.72), 0 2px 14px rgb(1, 0, 6);
}

.grid-cell.hit-success {
  box-shadow: inset 0 0 0 999px rgba(255, 144, 42, 0.72), 0 2px 14px rgb(1, 0, 6);
}

.token.spin-ccw {
  animation: spin-ccw 0.3s linear;
}

@keyframes descend-cell {
  from {
    transform: translateY(0);
  }
  to {
    transform: translateY(16px);
  }
}

@keyframes spin-ccw {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(-360deg);
  }
}

.token {
  width: 72%;
  height: 72%;
  object-fit: contain;
  pointer-events: none;
  border: 2px solid #FF902A;
  border-radius: 3px;
}

.inventory-row {
  display: grid;
  grid-template-columns: 30px 1fr auto;
  align-items: center;
  gap: 6px;
  margin-bottom: 5px;
  font-size: 0.9rem;
  border: 2px solid #FF902A;
  border-radius: 1px;
  box-shadow: 0 2px 14px rgb(1, 0, 6);

}

.inventory-row img {
  width: 30px;
  height: 30px;
  object-fit: contain;
  border-radius: 1px;
  background: #00defb;
  border: 1px solid #FF902A;

}

.percent-block {
  margin-top: 10px;
  border-top: 3px solid #1407a1;
  padding-top: 5px;
  font-size: 0.9rem;
}

.inventory-section {
  margin-bottom: 12px;
  padding: 5px;
  border: 2px solid #FF902A;
  border-radius: 3px;
  background: #00defb;
}

.inventory-header {
  font-weight: 700;
  font-size: 0.95rem;
  text-align: center;
  margin-bottom: 8px;
  padding-bottom: 5px;
  border-bottom: 2px solid #FF902A;
}

.legend {
  margin-top: 10px;
  display: flex;
  justify-content: center;
  gap: 10px;
}

.legend img {
  width: 34px;
  height: 34px;
  object-fit: contain;
}

.token-stats-container {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 10px;
}

.token-stats {
  background: #FF902A;
  border: 2px solid #FF902A;
  border-radius: 3px;
  padding: 8px;
  box-shadow: 0 2px 14px rgb(1, 0, 6);
  font-size: 0.9rem;
}

.token-stats p {
  margin: 4px 0;
  font-weight: 700;
}

.token-stats-container .difficulty-controls {
  background: #FF902A;
  border: 2px solid #FF902A;
  border-radius: 3px;
  padding: 8px;
  box-shadow: 0 2px 14px rgb(1, 0, 6);
}

.game-grid.win-grid {
  background: #00ffd0;
}

.game-grid.loss-grid {
  background: #7ce900;
}

@media (max-width: 980px) {
  .stats {
    grid-template-columns: repeat(2, minmax(120px, 1fr));
  }

  .top-bar {
    grid-template-columns: 1fr;
    justify-items: center;
  }

  .top-bar .logo-hover-wrap:first-child,
  .top-bar .logo-hover-wrap:last-child {
    justify-self: center;
  }

  .game-layout {
    grid-template-columns: 1fr;

  border: 2px solid #FF902A;
  border-radius: 3px;
  box-shadow: 0 2px 14px rgb(1, 0, 6);
  }

  .game-grid {
    width: min(85vw, 480px);

  border: 2px solid #FF902A;
  border-radius: 3px;
  box-shadow: 0 2px 14px rgb(1, 0, 6);
  }

  .title-hover-wrap {
    margin-left: 14px;
  }

  .qr-popover {
    max-width: min(92vw, 270px);
  }

  .qr-popover img {
    width: 130px;
    height: 130px;
  }

}
