body {
  padding: 0;
  margin: 0;
  width: 100%;
  background: #ffffff;
  -webkit-touch-callout: none;
  user-select: none;
}

.codeword-shell {
  max-width: 540px;
  margin: 0 auto;
  padding: 0 10px;
}

.codeword-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: #212529;
}

.daily-difficulty-bar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 3px;
  border-radius: 999px;
  background: #f1f3f5;
  border: 1px solid #dee2e6;
}

.daily-diff-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border: 1px solid transparent;
  background: transparent;
  color: #495057;
  border-radius: 999px;
  padding: 2px 12px;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.12s ease, color 0.12s ease, border-color 0.12s ease, box-shadow 0.12s ease;
}

.daily-diff-btn:hover:not(.active) {
  color: #212529;
  background: rgba(255, 255, 255, 0.65);
}

.daily-diff-btn.active[data-difficulty="easy"] {
  background: #d4edda;
  border-color: #b1dfbb;
  color: #155724;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
}

.daily-diff-btn.active[data-difficulty="medium"] {
  background: #fff3cd;
  border-color: #ffe69c;
  color: #856404;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
}

.daily-diff-btn.active[data-difficulty="hard"] {
  background: #f8d7da;
  border-color: #f1aeb5;
  color: #721c24;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
}

.daily-diff-check {
  font-size: 0.72rem;
  font-weight: 800;
  color: #137333;
}

.puzzle-meta {
  position: relative;
  min-height: 1.4rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 6px;
}

.daily-picker-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 1px 8px;
  border-radius: 999px;
  border: 1px solid #dee2e6;
  background: #f8f9fa;
  color: #343a40;
  font-size: 0.78rem;
  font-weight: 700;
  line-height: 1.35;
  cursor: pointer;
  transition: background-color 0.12s ease, border-color 0.12s ease, color 0.12s ease;
}

.daily-picker-btn:hover {
  background: #e9ecef;
  border-color: #adb5bd;
  color: #212529;
}

.daily-picker-btn.is-archive {
  background: #fff3cd;
  border-color: #ffe69c;
  color: #856404;
}

.daily-picker-btn.is-open {
  border-color: #495057;
}

.daily-picker-caret {
  font-size: 0.7rem;
  line-height: 1;
  opacity: 0.8;
  transition: transform 0.12s ease;
}

.daily-picker-btn.is-open .daily-picker-caret {
  transform: rotate(180deg);
}

.daily-archive-popover {
  position: absolute;
  top: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  width: min(94vw, 332px);
  background: #ffffff;
  border: 1px solid #ced4da;
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.14);
  z-index: 1050;
  overflow: hidden;
  text-align: left;
}

.daily-archive-header {
  padding: 6px 12px;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: #6c757d;
  background: #f8f9fa;
  border-bottom: 1px solid #e9ecef;
}

.daily-archive-list {
  max-height: 232px;
  overflow-y: auto;
}

.daily-archive-item {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 7px 12px;
  border: none;
  border-bottom: 1px solid #f1f3f5;
  background: #ffffff;
  color: #212529;
  cursor: pointer;
  text-align: left;
  transition: background-color 0.1s ease;
}

.daily-archive-item:last-child {
  border-bottom: none;
}

.daily-archive-item:hover {
  background: #f8f9fa;
}

.daily-archive-item.active {
  background: #eef6ff;
}

.daily-archive-item-main {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.daily-archive-num {
  font-size: 0.81rem;
  font-weight: 700;
  color: #212529;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.daily-archive-date {
  font-size: 0.75rem;
  color: #6c757d;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.daily-archive-today-pill {
  display: inline-block;
  padding: 0 5px;
  border-radius: 999px;
  font-size: 0.66rem;
  font-weight: 700;
  background: #e7f5ff;
  color: #1864ab;
  white-space: nowrap;
}

.daily-archive-tiers {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  flex-shrink: 0;
}

.daily-archive-tier-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 17px;
  height: 17px;
  border-radius: 4px;
  font-size: 0.65rem;
  font-weight: 700;
  border: 1px solid #dee2e6;
  background: #f8f9fa;
  color: #adb5bd;
}

.daily-archive-tier-pill.is-solved {
  border-color: #b7e1cd;
  background: #e6f4ea;
  color: #137333;
}

.solved-badge {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
  background-color: #e6f4ea;
  color: #137333;
}

.timer-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 1px 8px;
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  background-color: #f1f3f5;
  border: 1px solid #dee2e6;
  color: #495057;
}

.timer-badge.timer-running {
  background-color: #e7f5ff;
  border-color: #a5d8ff;
  color: #1864ab;
}

.timer-badge.timer-locked {
  background-color: #e6f4ea;
  border-color: #b7e1cd;
  color: #137333;
}

.unranked-badge {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 999px;
  font-size: 0.74rem;
  font-weight: 700;
  background-color: #fff3cd;
  color: #856404;
}

.board-holder {
  display: flex;
  justify-content: center;
  margin: 8px 0 6px 0;
}

.codeword-board {
  display: grid;
  grid-template-columns: repeat(13, 1fr);
  grid-template-rows: repeat(13, 1fr);
  width: min(95vw, 468px);
  height: min(95vw, 468px);
  border: 2px solid #2b3035;
  border-radius: 4px;
  background: #2b3035;
  gap: 1px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.12);
  touch-action: manipulation;
}

.cw-cell {
  position: relative;
  border: none;
  padding: 0;
  margin: 0;
  background: #ffffff;
  color: #212529;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  touch-action: manipulation;
  transition: background-color 0.08s ease;
}

.cw-cell.cw-block {
  background: #2b3035;
  cursor: default;
}

.cw-cell.cw-given {
  background: #e3f5e8;
}

.cw-cell.cw-in-word {
  background: #b8dcff;
}

.cw-cell.cw-given.cw-in-word {
  background: #a8dfc8;
}

.cw-cell.cw-same-num {
  background: #ffe680;
}

.cw-cell.cw-selected {
  background: #ffd43b;
  box-shadow: inset 0 0 0 2.5px #1864ab;
  z-index: 2;
}

.cw-cell.cw-hinted:not(.cw-selected) {
  box-shadow: inset 0 0 0 2px #228be6;
}

.cw-cell.cw-conflict {
  background: #ffe3e3;
  color: #c92a2a;
}

.cw-cell.cw-conflict.cw-selected {
  background: #ffc9c9;
  box-shadow: inset 0 0 0 2px #c92a2a;
}

.cw-cell.cw-hint-remove {
  background: #ffd8a8;
  box-shadow: inset 0 0 0 2px #d9480f;
}

@keyframes cw-dup-pulse-0 {
  0% {
    background: #ffc9c9;
    box-shadow: inset 0 0 0 2.5px #e03131, 0 0 0 2px rgba(224, 49, 49, 0.35);
    transform: scale(1);
  }
  22% {
    background: #ffa8a8;
    box-shadow: inset 0 0 0 2.5px #c92a2a, 0 0 0 3px rgba(224, 49, 49, 0.45);
    transform: scale(1.08);
  }
  46% {
    background: #ffc9c9;
    box-shadow: inset 0 0 0 2.5px #e03131, 0 0 0 1px rgba(224, 49, 49, 0.25);
    transform: scale(1.02);
  }
  70% {
    background: #ffa8a8;
    box-shadow: inset 0 0 0 2.5px #c92a2a, 0 0 0 3px rgba(224, 49, 49, 0.4);
    transform: scale(1.06);
  }
  100% {
    transform: scale(1);
  }
}

@keyframes cw-dup-pulse-1 {
  0% {
    background: #ffc9c9;
    box-shadow: inset 0 0 0 2.5px #e03131, 0 0 0 2px rgba(224, 49, 49, 0.35);
    transform: scale(1);
  }
  22% {
    background: #ffa8a8;
    box-shadow: inset 0 0 0 2.5px #c92a2a, 0 0 0 3px rgba(224, 49, 49, 0.45);
    transform: scale(1.08);
  }
  46% {
    background: #ffc9c9;
    box-shadow: inset 0 0 0 2.5px #e03131, 0 0 0 1px rgba(224, 49, 49, 0.25);
    transform: scale(1.02);
  }
  70% {
    background: #ffa8a8;
    box-shadow: inset 0 0 0 2.5px #c92a2a, 0 0 0 3px rgba(224, 49, 49, 0.4);
    transform: scale(1.06);
  }
  100% {
    transform: scale(1);
  }
}

.cw-cell.cw-dup-flash {
  z-index: 3;
}

.cw-cell.cw-dup-flash-0 {
  animation: cw-dup-pulse-0 0.72s ease-out;
}

.cw-cell.cw-dup-flash-1 {
  animation: cw-dup-pulse-1 0.72s ease-out;
}

@keyframes cw-locked-shake-0 {
  0% {
    background: #ffc9c9;
    box-shadow: inset 0 0 0 2.5px #e03131, 0 0 0 2px rgba(224, 49, 49, 0.35);
    transform: translateX(0);
  }
  18% {
    background: #ffa8a8;
    box-shadow: inset 0 0 0 2.5px #c92a2a, 0 0 0 2px rgba(224, 49, 49, 0.4);
    transform: translateX(-4px);
  }
  36% {
    background: #ffa8a8;
    box-shadow: inset 0 0 0 2.5px #c92a2a, 0 0 0 2px rgba(224, 49, 49, 0.4);
    transform: translateX(4px);
  }
  56% {
    background: #ffc9c9;
    box-shadow: inset 0 0 0 2.5px #e03131;
    transform: translateX(-3px);
  }
  76% {
    background: #ffc9c9;
    box-shadow: inset 0 0 0 2.5px #e03131;
    transform: translateX(2.5px);
  }
  100% {
    transform: translateX(0);
  }
}

@keyframes cw-locked-shake-1 {
  0% {
    background: #ffc9c9;
    box-shadow: inset 0 0 0 2.5px #e03131, 0 0 0 2px rgba(224, 49, 49, 0.35);
    transform: translateX(0);
  }
  18% {
    background: #ffa8a8;
    box-shadow: inset 0 0 0 2.5px #c92a2a, 0 0 0 2px rgba(224, 49, 49, 0.4);
    transform: translateX(-4px);
  }
  36% {
    background: #ffa8a8;
    box-shadow: inset 0 0 0 2.5px #c92a2a, 0 0 0 2px rgba(224, 49, 49, 0.4);
    transform: translateX(4px);
  }
  56% {
    background: #ffc9c9;
    box-shadow: inset 0 0 0 2.5px #e03131;
    transform: translateX(-3px);
  }
  76% {
    background: #ffc9c9;
    box-shadow: inset 0 0 0 2.5px #e03131;
    transform: translateX(2.5px);
  }
  100% {
    transform: translateX(0);
  }
}

.cw-cell.cw-locked-flash {
  z-index: 4;
}

.cw-cell.cw-locked-flash-0 {
  animation: cw-locked-shake-0 0.45s ease-out;
}

.cw-cell.cw-locked-flash-1 {
  animation: cw-locked-shake-1 0.45s ease-out;
}

.cw-cell.cw-solved {
  background: #ebfbee;
}

.cw-cell.cw-solved.cw-given {
  background: #d3f9d8;
}

.cw-cell-num {
  position: absolute;
  top: 1px;
  left: 2px;
  font-size: clamp(7px, 1.9vw, 9.5px);
  font-weight: 700;
  line-height: 1;
  color: #6c757d;
  font-variant-numeric: tabular-nums;
  pointer-events: none;
}

.cw-cell.cw-given .cw-cell-num {
  color: #2b6e3f;
}

.cw-cell.cw-in-word .cw-cell-num {
  color: #2b4c7e;
}

.cw-cell.cw-same-num .cw-cell-num,
.cw-cell.cw-selected .cw-cell-num {
  color: #212529;
}

.cw-cell-letter {
  margin-top: 5px;
  font-size: clamp(12px, 3.4vw, 17px);
  font-weight: 800;
  line-height: 1;
  letter-spacing: -0.01em;
  pointer-events: none;
}

.cw-cell.cw-given .cw-cell-letter {
  color: #0f6b2f;
}

.cw-cell.cw-hinted .cw-cell-letter {
  color: #1971c2;
}

.cw-cell.cw-conflict .cw-cell-letter {
  color: #c92a2a;
}

.cw-cell.cw-dup-flash .cw-cell-letter,
.cw-cell.cw-dup-flash .cw-cell-num,
.cw-cell.cw-locked-flash .cw-cell-letter,
.cw-cell.cw-locked-flash .cw-cell-num {
  color: #b02525;
}

.letter-bank {
  display: flex;
  flex-direction: column;
  gap: 5px;
  max-width: 468px;
  margin-left: auto;
  margin-right: auto;
}

.letter-bank-row {
  display: flex;
  justify-content: center;
  gap: 4px;
}

.key-btn {
  position: relative;
  flex: 1 1 0;
  max-width: 46px;
  min-height: 38px;
  padding: 2px 2px;
  border-radius: 6px;
  border: 1px solid #ced4da;
  background: #ffffff;
  color: #212529;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  touch-action: manipulation;
  box-shadow: 0 1px 1px rgba(0, 0, 0, 0.05);
  transition: background-color 0.1s ease, border-color 0.1s ease, opacity 0.1s ease;
}

.key-btn:hover:not(:disabled):not([aria-disabled="true"]) {
  background: #f1f3f5;
  border-color: #adb5bd;
}

.key-btn:active:not(:disabled):not([aria-disabled="true"]) {
  transform: translateY(1px);
}

.key-btn.key-used {
  background: #c4ccd4;
  color: #495057;
  border-color: #adb5bd;
  box-shadow: none;
  cursor: not-allowed;
}

.key-btn.key-given {
  background: #23633b;
  color: #ebfef0;
  border-color: #194a2b;
  box-shadow: none;
  cursor: not-allowed;
}

.key-btn.key-conflict {
  background: #ffe3e3;
  color: #c92a2a;
  border-color: #fa5252;
}

@keyframes key-dup-pulse-0 {
  0% {
    background: #ffc9c9;
    border-color: #e03131;
    box-shadow: 0 0 0 2px rgba(224, 49, 49, 0.35);
    transform: scale(1);
  }
  25% {
    background: #ffa8a8;
    border-color: #c92a2a;
    box-shadow: 0 0 0 3px rgba(224, 49, 49, 0.45);
    transform: scale(1.07);
  }
  55% {
    background: #ffc9c9;
    border-color: #e03131;
    box-shadow: 0 0 0 2px rgba(224, 49, 49, 0.3);
    transform: scale(1.03);
  }
  100% {
    transform: scale(1);
  }
}

@keyframes key-dup-pulse-1 {
  0% {
    background: #ffc9c9;
    border-color: #e03131;
    box-shadow: 0 0 0 2px rgba(224, 49, 49, 0.35);
    transform: scale(1);
  }
  25% {
    background: #ffa8a8;
    border-color: #c92a2a;
    box-shadow: 0 0 0 3px rgba(224, 49, 49, 0.45);
    transform: scale(1.07);
  }
  55% {
    background: #ffc9c9;
    border-color: #e03131;
    box-shadow: 0 0 0 2px rgba(224, 49, 49, 0.3);
    transform: scale(1.03);
  }
  100% {
    transform: scale(1);
  }
}

.key-btn.key-dup-flash {
  z-index: 2;
  color: #b02525;
}

.key-btn.key-dup-flash-0 {
  animation: key-dup-pulse-0 0.72s ease-out;
}

.key-btn.key-dup-flash-1 {
  animation: key-dup-pulse-1 0.72s ease-out;
}

.key-btn.key-direction,
.key-btn.key-backspace {
  max-width: 58px;
  flex: 1.35 1 0;
  font-size: 0.9rem;
  font-weight: 700;
  background: #f8f9fa;
}

.key-btn.key-direction:not(:disabled) {
  background: #eef6ff;
  border-color: #a5d8ff;
  color: #1864ab;
}

.key-btn.key-direction:hover:not(:disabled) {
  background: #d0ebff;
  border-color: #74c0fc;
}

.key-btn.key-direction:disabled {
  color: #adb5bd;
  border-color: #e9ecef;
  box-shadow: none;
  cursor: default;
}

.key-dir-icon {
  width: 17px;
  height: 17px;
  display: block;
}

.key-main {
  font-size: 0.9rem;
  font-weight: 800;
  line-height: 1.05;
}

.key-sub {
  font-size: 0.58rem;
  font-weight: 700;
  line-height: 1;
  color: #6c757d;
  min-height: 0.6rem;
  font-variant-numeric: tabular-nums;
}

.key-btn.key-used .key-sub {
  color: #5c646d;
}

.key-btn.key-given .key-sub {
  color: #b2f2bb;
}

.key-btn.key-conflict .key-sub,
.key-btn.key-dup-flash .key-sub {
  color: #c92a2a;
}

#hint-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  vertical-align: middle;
}

.hint-cooldown-spinner {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  display: block;
}

.hint-spinner-track {
  fill: none;
  stroke: currentColor;
  stroke-width: 2.6;
  opacity: 0.25;
}

.hint-spinner-arc {
  fill: none;
  stroke: currentColor;
  stroke-width: 2.6;
  stroke-linecap: butt;
}

.hint-cooldown-spinner.hint-spinner-indeterminate {
  animation: hint-spinner-rotate 0.8s linear infinite;
}

.hint-cooldown-spinner.hint-spinner-indeterminate .hint-spinner-arc {
  stroke-linecap: round;
}

@keyframes hint-spinner-rotate {
  to {
    transform: rotate(360deg);
  }
}

.status-banner {
  max-width: 468px;
  margin: 10px auto;
  text-align: center;
  font-size: 0.9rem;
}

.faq-holder {
  max-width: 468px;
  margin: 8px auto 0 auto;
}

.controls-card {
  background: #f8f9fa;
  border: 1px solid #e9ecef;
  border-radius: 8px;
}

.leaderboard-section {
  max-width: 468px;
  margin: 10px auto;
}

.leaderboard-submit-box {
  background: #f8f9fa;
  border: 1px solid #dee2e6;
  border-radius: 8px;
  padding: 8px 10px;
  text-align: center;
}

.leaderboard-submit-form {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  flex-wrap: wrap;
}

.leaderboard-nickname-input {
  max-width: 180px;
  font-weight: 600;
}

.leaderboard-submit-status {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 2px 10px;
}

.leaderboard-submit-feedback {
  color: #495057;
}

.leaderboard-submit-feedback.feedback-error {
  color: #c92a2a;
}

.leaderboard-submit-feedback.feedback-ok {
  color: #137333;
  font-weight: 600;
}

.leaderboard-remove-btn {
  border: none;
  background: transparent;
  padding: 0;
  font-size: 0.78rem;
  font-weight: 600;
  color: #6c757d;
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
  transition: color 0.12s ease;
}

.leaderboard-remove-btn:hover:not(:disabled),
.leaderboard-remove-btn:focus-visible:not(:disabled) {
  color: #c92a2a;
}

.leaderboard-remove-btn:disabled {
  opacity: 0.6;
  cursor: default;
}

.leaderboard-card {
  border: 1px solid #dee2e6;
  border-radius: 8px;
  background: #ffffff;
  overflow: hidden;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.04);
}

.leaderboard-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 12px 2px 12px;
  background: #f8f9fa;
}

.leaderboard-card-title {
  font-size: 0.86rem;
  font-weight: 700;
  color: #212529;
}

.leaderboard-count-badge {
  font-size: 0.74rem;
  font-weight: 600;
  color: #6c757d;
}

.leaderboard-card-subtitle {
  padding: 0 12px 6px 12px;
  font-size: 0.72rem;
  color: #6c757d;
  background: #f8f9fa;
  border-bottom: 1px solid #e9ecef;
}

.leaderboard-body {
  max-height: 240px;
  overflow-y: auto;
}

.leaderboard-empty {
  padding: 12px;
  text-align: center;
  font-size: 0.82rem;
  color: #6c757d;
}

.leaderboard-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.81rem;
  font-variant-numeric: tabular-nums;
}

.leaderboard-table th {
  padding: 5px 10px;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  color: #6c757d;
  border-bottom: 1px solid #e9ecef;
  background: #fcfcfd;
}

.leaderboard-table td {
  padding: 5px 10px;
  border-bottom: 1px solid #f1f3f5;
  color: #212529;
}

.leaderboard-table tr:last-child td {
  border-bottom: none;
}

.leaderboard-table .col-rank {
  width: 40px;
  text-align: center;
  font-weight: 700;
  color: #495057;
}

.leaderboard-table .col-player {
  text-align: left;
  font-weight: 600;
}

.leaderboard-table .col-num {
  width: 68px;
  text-align: right;
}

.leaderboard-table .col-time {
  width: 82px;
  text-align: right;
  font-weight: 600;
}

.leaderboard-row-you td {
  background: #edf7ed;
}

.leaderboard-you-pill {
  display: inline-block;
  margin-left: 5px;
  padding: 0 5px;
  border-radius: 999px;
  font-size: 0.68rem;
  font-weight: 700;
  background: #137333;
  color: #ffffff;
  vertical-align: middle;
}

.leaderboard-separator td {
  text-align: center;
  padding: 2px 10px;
  font-size: 0.72rem;
  color: #868e96;
  background: #f8f9fa;
}
