:root {
  color-scheme: dark;
  --ink: #fff8ee;
  --muted: #b7c7df;
  --line: rgba(255, 255, 255, 0.18);
  --panel: rgba(7, 20, 45, 0.96);
  --blue: #54c7ff;
  --store-blue: #1266ff;
  --store-blue-dark: #0a48ba;
  --yellow: #ffd166;
  --green: #42d97b;
  --red: #ff6878;
  --cell-light: #f8f5ec;
  --cell-alt: #eaf3ff;
  --grid-dark: #15335e;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  min-height: 100%;
  margin: 0;
  overflow: hidden;
  background:
    radial-gradient(circle at 13% 12%, rgba(84, 199, 255, 0.24), transparent 27%),
    radial-gradient(circle at 86% 12%, rgba(255, 209, 102, 0.17), transparent 29%),
    linear-gradient(155deg, #06112a 0%, #123873 53%, #071124 100%);
  color: var(--ink);
  touch-action: manipulation;
  user-select: none;
}

button,
input {
  font: inherit;
}

button {
  -webkit-tap-highlight-color: transparent;
}

.shell {
  display: grid;
  width: 100vw;
  height: 100dvh;
  padding: max(7px, env(safe-area-inset-top)) max(7px, env(safe-area-inset-right))
    max(7px, env(safe-area-inset-bottom)) max(7px, env(safe-area-inset-left));
  place-items: center;
}

.game {
  --board-size: min(100%, calc(100dvh - 272px), 548px);
  display: grid;
  grid-template-rows: auto auto auto minmax(0, 1fr) auto;
  gap: clamp(4px, 0.8dvh, 8px);
  width: min(100%, 560px);
  height: min(100%, 940px);
  min-height: 0;
}

.brand-header {
  display: grid;
  min-height: clamp(40px, 7dvh, 62px);
  place-items: center;
  text-align: center;
}

.game-logo {
  color: transparent;
  font-family: "Arial Rounded MT Bold", "Trebuchet MS", system-ui, sans-serif;
  font-size: clamp(1.45rem, min(7.2dvw, 5.6dvh), 3rem);
  font-weight: 1000;
  line-height: 0.92;
  letter-spacing: -0.035em;
  background: linear-gradient(90deg, #fff8ee 0%, #54c7ff 40%, #ffd166 74%, #fff 100%);
  background-clip: text;
  -webkit-background-clip: text;
  filter: drop-shadow(0 4px 0 rgba(3, 10, 24, 0.62)) drop-shadow(0 0 15px rgba(84, 199, 255, 0.26));
  text-transform: uppercase;
}

.site-tag {
  margin-top: 2px;
  color: rgba(255, 248, 238, 0.72);
  font-size: clamp(0.57rem, min(2.2dvw, 1.7dvh), 0.78rem);
  font-weight: 900;
  letter-spacing: 0.08em;
}

.game-hud {
  display: grid;
  gap: clamp(4px, 0.7dvh, 7px);
}

.metrics-row,
.action-row {
  display: grid;
  align-items: center;
  gap: clamp(4px, 1.1dvw, 8px);
}

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

.action-row {
  grid-template-columns: 0.72fr 1.14fr 1.14fr 0.72fr 0.72fr;
}

.metric {
  min-width: 0;
  padding: clamp(4px, 0.7dvh, 7px) 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.09);
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.18);
}

.metric.center {
  text-align: center;
}

.metric.right {
  text-align: right;
}

.metric-label {
  display: block;
  color: var(--muted);
  font-size: clamp(0.57rem, 1.7dvw, 0.69rem);
  font-weight: 850;
  text-transform: uppercase;
}

.metric strong {
  display: block;
  margin-top: 1px;
  overflow: hidden;
  font-size: clamp(0.91rem, min(4.4dvw, 2.4dvh), 1.2rem);
  line-height: 1;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.small-button,
.edit-button,
.number-button,
.primary-button,
.secondary-button,
.arcade-button,
.store-button,
.difficulty-button {
  border-radius: 8px;
  cursor: pointer;
  font-weight: 950;
}

.small-button {
  display: inline-flex;
  min-width: 0;
  min-height: clamp(35px, 5.2dvh, 45px);
  padding: 0 7px;
  border: 0;
  align-items: center;
  justify-content: center;
  gap: 4px;
  background: var(--yellow);
  color: #071225;
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.46), inset 0 -3px 0 rgba(89, 51, 0, 0.2), 0 6px 15px rgba(0, 0, 0, 0.22);
  font-size: clamp(0.72rem, 2.7dvw, 0.9rem);
}

.small-button:disabled,
.edit-button:disabled,
.number-button:disabled {
  cursor: default;
  filter: grayscale(0.75);
  opacity: 0.45;
}

.small-button:hover:not(:disabled),
.small-button:focus-visible,
.edit-button:hover:not(:disabled),
.edit-button:focus-visible,
.number-button:hover:not(:disabled),
.number-button:focus-visible {
  filter: brightness(1.1);
}

#hintButton {
  background: linear-gradient(180deg, #dff8ff, #54c7ff 56%, #258bc9);
}

#soundButton,
#pauseButton,
#homeButtonTop {
  padding: 0;
  font-size: clamp(1.05rem, 4.5dvw, 1.35rem);
}

.pause-icon {
  position: relative;
  display: block;
  width: 15px;
  height: 18px;
}

.pause-icon::before,
.pause-icon::after {
  position: absolute;
  top: 1px;
  bottom: 1px;
  width: 5px;
  border-radius: 2px;
  background: currentColor;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.32);
  content: "";
}

.pause-icon::before {
  left: 1px;
}

.pause-icon::after {
  right: 1px;
}

.game-message {
  display: flex;
  width: var(--board-size);
  min-height: clamp(32px, 4.4dvh, 38px);
  margin: 0;
  padding: 2px 8px;
  overflow: hidden;
  border: 0;
  align-self: center;
  align-items: center;
  justify-content: center;
  justify-self: center;
  background: transparent;
  color: #dff5ff;
  font-size: clamp(0.66rem, min(3.2dvw, 1.8dvh), 0.86rem);
  font-weight: 850;
  line-height: 1.22;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.game-message:disabled {
  opacity: 1;
}

.game-message[hidden] {
  display: none !important;
}

.game-message.bad {
  color: #ffd3d8;
}

.game-message.good {
  color: #bfffd8;
}

.game-message.unit-appraisal {
  width: calc(var(--board-size) - clamp(16px, 4vw, 24px));
  max-width: calc(100% - 16px) !important;
  border: 1px solid rgba(255, 255, 255, 0.76);
  border-radius: 8px;
  min-height: clamp(42px, 5.8dvh, 50px);
  margin-block: clamp(3px, 0.6dvh, 6px);
  padding: 5px 10px;
  background: linear-gradient(180deg, #fffdf0, #ffefb0 54%, #e7c15b);
  color: #573600;
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, 0.92),
    inset 0 -3px 0 rgba(126, 78, 0, 0.22),
    0 6px 14px rgba(0, 0, 0, 0.2),
    0 0 12px rgba(255, 210, 70, 0.2);
  font-size: clamp(0.78rem, min(3.8dvw, 2.2dvh), 1.02rem);
  font-weight: 1000;
  line-height: 1.15;
  text-overflow: clip;
  white-space: normal;
}

.game-message.unit-appraisal.clickable {
  cursor: pointer;
}

.game-message.unit-appraisal.clickable:hover,
.game-message.unit-appraisal.clickable:focus-visible {
  background: linear-gradient(180deg, #ffffff, #fff4c5 54%, #f2cf70);
  outline: 3px solid rgba(255, 224, 112, 0.88);
  outline-offset: 2px;
}

.game-message.unit-appraisal.clickable:active {
  transform: translateY(1px);
}

.board-area {
  position: relative;
  display: grid;
  min-height: 0;
  place-items: start center;
}

.sudoku-board {
  display: grid;
  width: var(--board-size);
  max-height: 100%;
  aspect-ratio: 1;
  overflow: hidden;
  border: 3px solid #0b2449;
  border-radius: 10px;
  grid-template-columns: repeat(9, minmax(0, 1fr));
  grid-template-rows: repeat(9, minmax(0, 1fr));
  background: var(--grid-dark);
  box-shadow: 0 17px 38px rgba(0, 0, 0, 0.38), 0 0 0 1px rgba(84, 199, 255, 0.35);
}

.cell {
  position: relative;
  display: grid;
  min-width: 0;
  min-height: 0;
  padding: 0;
  overflow: hidden;
  border: 0;
  border-right: 1px solid rgba(21, 51, 94, 0.34);
  border-bottom: 1px solid rgba(21, 51, 94, 0.34);
  place-items: center;
  background: var(--cell-light);
  color: #1266ff;
  cursor: pointer;
  font-size: clamp(0.92rem, min(7.3dvw, 4.9dvh), 2rem);
  font-weight: 900;
  line-height: 1;
  transition: background 100ms ease, color 100ms ease, transform 100ms ease;
}

.cell:nth-child(3n) {
  border-right: 3px solid var(--grid-dark);
}

.cell:nth-child(9n) {
  border-right: 0;
}

.cell:nth-child(n + 19):nth-child(-n + 27),
.cell:nth-child(n + 46):nth-child(-n + 54) {
  border-bottom: 3px solid var(--grid-dark);
}

.cell:nth-child(n + 73) {
  border-bottom: 0;
}

.cell.box-tint {
  background: var(--cell-alt);
}

.cell.given {
  color: #132b50;
  font-weight: 1000;
}

.cell.peer {
  background: #d9e9fb;
}

.cell.box-tint.peer {
  background: #d1e4f8;
}

.cell.same-value {
  background: #bdeeff;
  color: #0756c8;
}

.cell.selected {
  z-index: 1;
  background: #77d7ff;
  color: #071f45;
  box-shadow: inset 0 0 0 3px #1266ff;
}

.cell.wrong {
  color: #c8192e;
  background: #ffd9dd;
  animation: cellShake 260ms ease-out;
}

.cell.hinted {
  color: #157740;
  background: #c9f6d9;
}

.cell.bronzed:not(.selected):not(.peer):not(.same-value):not(.wrong):not(.hinted) {
  background:
    linear-gradient(
      112deg,
      #b9780b 0%,
      #f5bf37 24%,
      #fff8b8 44%,
      #ffd866 55%,
      #c88b13 76%,
      #ffe68a 100%
    ),
    var(--cell-light);
  background-size: 230% 100%;
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, 0.92),
    inset 0 -2px 0 rgba(112, 68, 0, 0.36),
    inset 0 0 9px rgba(255, 244, 154, 0.5);
  animation: goldSheen 2.8s ease-in-out infinite alternate;
}

.cell.box-tint.bronzed:not(.selected):not(.peer):not(.same-value):not(.wrong):not(.hinted) {
  background:
    linear-gradient(
      112deg,
      #a96608 0%,
      #eaae28 24%,
      #fff3a0 44%,
      #f6c64d 55%,
      #b9760b 76%,
      #ffdc70 100%
    ),
    var(--cell-alt);
  background-size: 230% 100%;
}

.sudoku-board.completed-board {
  border-color: #f7c633;
  box-shadow:
    0 17px 38px rgba(0, 0, 0, 0.38),
    0 0 0 3px rgba(255, 224, 105, 0.72),
    0 0 30px rgba(255, 199, 45, 0.52);
}

.cell.completed-gold {
  background:
    linear-gradient(
      112deg,
      #aa6a05 0%,
      #e8a91c 19%,
      #ffe36f 37%,
      #fffbd0 48%,
      #ffd24a 60%,
      #bb7708 82%,
      #ffe98f 100%
    ) !important;
  background-size: 240% 100% !important;
  color: #3a2504 !important;
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, 0.94),
    inset 0 -2px 0 rgba(92, 51, 0, 0.4),
    inset 0 0 10px rgba(255, 244, 161, 0.62) !important;
  animation: completedGoldSweep 2.25s ease-in-out infinite alternate !important;
}

.cell.completed-gold:nth-child(3n + 2) {
  animation-delay: -0.75s !important;
}

.cell.completed-gold:nth-child(3n) {
  animation-delay: -1.5s !important;
}

.notes-grid {
  position: absolute;
  inset: 2px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  align-items: center;
  justify-items: center;
  color: #2a609b;
  font-size: clamp(0.32rem, min(2.1dvw, 1.35dvh), 0.68rem);
  font-weight: 850;
  line-height: 1;
}

.celebration {
  position: absolute;
  inset: 0;
  z-index: 4;
  overflow: hidden;
  pointer-events: none;
}

.unit-celebration {
  position: absolute;
  top: var(--unit-y, 50%);
  left: var(--unit-x, 50%);
  z-index: 5;
  max-width: 84%;
  padding: 7px 13px;
  border: 1px solid rgba(255, 255, 255, 0.84);
  border-radius: 999px;
  background: rgba(244, 249, 255, 0.88);
  color: #082958;
  box-shadow: 0 7px 22px rgba(0, 0, 0, 0.3), 0 0 20px rgba(84, 199, 255, 0.28);
  font-family: "Trebuchet MS", "Segoe UI", sans-serif;
  font-size: clamp(0.86rem, 4vw, 1.18rem);
  font-weight: 1000;
  line-height: 1.1;
  text-align: center;
  text-wrap: balance;
  opacity: 0;
  pointer-events: none;
  backdrop-filter: blur(3px);
  transform: translate(-50%, -40%) scale(0.8);
}

.unit-celebration.show {
  animation: unitCelebrationPop 1150ms ease-out forwards;
}

.champion-message {
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 7;
  width: calc(100% - 24px);
  max-width: calc(var(--board-size) - 24px);
  padding: clamp(12px, 3vw, 18px);
  border: 2px solid #ffe578;
  border-radius: 10px;
  background:
    linear-gradient(135deg, rgba(85, 45, 0, 0.96), rgba(16, 28, 54, 0.96)),
    #172848;
  color: #fff1a8;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.34),
    0 9px 30px rgba(0, 0, 0, 0.48),
    0 0 24px rgba(255, 209, 74, 0.42);
  font-size: clamp(1rem, 4.8vw, 1.7rem);
  font-weight: 1000;
  line-height: 1.18;
  text-align: center;
  text-wrap: balance;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, -50%);
}

.champion-message[hidden] {
  display: none;
}

.champion-message.show {
  animation: championMessage 5500ms ease-out both;
}

.confetti {
  position: absolute;
  left: var(--x);
  top: -18px;
  width: 8px;
  height: 14px;
  border: 1px solid rgba(24, 31, 48, 0.28);
  border-radius: 1px;
  background: var(--color);
  box-shadow: inset 1px 1px 0 rgba(255, 255, 255, 0.48), 0 1px 1px rgba(0, 0, 0, 0.22);
  opacity: 0;
  transform: rotate(var(--rotate));
  animation: confettiFall var(--duration) ease-out var(--delay) forwards;
}

.confetti.mini {
  top: var(--y);
  width: 7px;
  height: 11px;
  animation-name: miniConfettiFall;
}

.confetti:nth-child(3n) {
  width: 10px;
  height: 10px;
  clip-path: polygon(50% 0, 100% 100%, 0 100%);
}

.confetti:nth-child(4n) {
  width: 6px;
  height: 15px;
}

.number-panel {
  display: grid;
  gap: clamp(4px, 0.65dvh, 6px);
}

.record-win-button {
  width: 100%;
  min-height: 50px;
  padding: 8px 14px;
  border: 2px solid #fff0a3;
  border-radius: 9px;
  background: linear-gradient(180deg, #fff6ad 0%, #ffd34f 42%, #d99a12 100%);
  color: #382000;
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, 0.86),
    inset 0 -3px 0 rgba(104, 59, 0, 0.28),
    0 7px 18px rgba(255, 193, 39, 0.32);
  cursor: pointer;
  font-size: clamp(0.92rem, 3.7vw, 1.08rem);
  font-weight: 1000;
  letter-spacing: 0.01em;
}

.record-win-button:hover,
.record-win-button:focus-visible {
  background: linear-gradient(180deg, #fffbd0 0%, #ffe277 42%, #e6aa24 100%);
  outline: 3px solid rgba(255, 241, 161, 0.58);
  outline-offset: 2px;
}

.record-win-button[hidden] {
  display: none;
}

.number-pad {
  display: grid;
  grid-template-columns: repeat(9, minmax(0, 1fr));
  gap: clamp(3px, 0.8dvw, 6px);
}

.number-button {
  min-width: 0;
  min-height: clamp(36px, 5.4dvh, 48px);
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.56);
  background: linear-gradient(180deg, #fafdff, #cceaff 54%, #72c8f7);
  color: #0b3f97;
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.9), inset 0 -3px 0 rgba(18, 102, 255, 0.18), 0 6px 14px rgba(0, 0, 0, 0.2);
  font-size: clamp(1rem, min(6vw, 3.2dvh), 1.45rem);
}

.number-button.complete {
  border-color: rgba(66, 217, 123, 0.7);
  background: linear-gradient(180deg, #dfffe9, #83eaaa);
  color: #1d7140;
}

.edit-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.edit-button {
  min-height: clamp(34px, 4.9dvh, 42px);
  border: 1px solid var(--line);
  background: linear-gradient(180deg, #ffffff, #d8e8f8 55%, #a6c5e5);
  color: #102746;
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.82), inset 0 -3px 0 rgba(14, 50, 91, 0.14), 0 5px 12px rgba(0, 0, 0, 0.2);
}

.notes-button.active {
  border-color: #ffd166;
  background: linear-gradient(180deg, #fff2b8, #ffd166 58%, #e3a51c);
}

.overlay {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding: max(10px, env(safe-area-inset-top)) 16px max(10px, env(safe-area-inset-bottom));
  overflow: auto;
  background: rgba(3, 8, 20, 0.76);
  backdrop-filter: blur(9px);
}

.overlay.show {
  display: flex;
}

.panel {
  width: min(100%, 410px);
  max-height: calc(100dvh - 20px);
  margin: auto;
  padding: 18px;
  overflow: auto;
  overscroll-behavior: contain;
  border: 1px solid var(--line);
  border-radius: 12px;
  background:
    linear-gradient(180deg, rgba(18, 102, 255, 0.2), rgba(255, 209, 102, 0.06)),
    var(--panel);
  box-shadow: 0 22px 62px rgba(0, 0, 0, 0.5);
}

.home-mode .panel {
  padding: clamp(18px, 4.5vw, 24px);
}

.home-mode .panel > .arcade-button:first-child {
  margin-top: 0;
  margin-bottom: 18px;
}

.home-mode .kicker {
  margin-bottom: 8px;
  letter-spacing: 0.055em;
}

.home-mode #overlayTitle {
  font-size: clamp(1.55rem, 8vw, 2.5rem);
  line-height: 1.06;
  letter-spacing: -0.035em;
  white-space: nowrap;
}

.home-mode #overlayText {
  margin-top: 13px;
}

.kicker,
.score-form label,
.home-scores h2,
.rules-panel h2 {
  display: block;
  margin: 0 0 6px;
  color: var(--blue);
  font-size: 0.74rem;
  font-weight: 950;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: clamp(1.9rem, 8dvw, 3rem);
  line-height: 0.96;
}

.panel > p:not(.kicker):not(.score-invitation) {
  margin: 11px 0 0;
  color: var(--muted);
  line-height: 1.38;
}

.difficulty-picker {
  display: grid;
  gap: 8px;
  margin-top: 16px;
}

.difficulty-button {
  display: grid;
  min-height: 58px;
  padding: 8px 12px;
  border: 1px solid rgba(255, 255, 255, 0.24);
  align-content: center;
  background: rgba(255, 255, 255, 0.09);
  color: var(--ink);
  text-align: left;
}

.difficulty-button strong {
  font-size: 1.04rem;
}

.difficulty-button span {
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 800;
}

.difficulty-button.easy {
  border-left: 8px solid var(--green);
}

.difficulty-button.medium {
  border-left: 8px solid var(--yellow);
}

.difficulty-button.hard {
  border-left: 8px solid var(--red);
}

.difficulty-button:hover,
.difficulty-button:focus-visible {
  border-color: var(--blue);
  background: rgba(84, 199, 255, 0.16);
}

.primary-button,
.secondary-button,
.arcade-button,
.store-button {
  width: 100%;
  min-height: 45px;
  margin-top: 10px;
  padding: 0 16px;
}

.primary-button {
  border: 0;
  background: linear-gradient(180deg, #dff8ff, #54c7ff 52%, #248ecb);
  color: #071225;
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.56), inset 0 -4px 0 rgba(7, 57, 96, 0.2), 0 8px 18px rgba(0, 0, 0, 0.25);
}

.praise-mode .panel {
  border-color: rgba(255, 220, 92, 0.78);
  text-align: center;
  box-shadow: 0 22px 62px rgba(0, 0, 0, 0.5), 0 0 30px rgba(255, 199, 45, 0.22);
}

.praise-mode #overlayTitle {
  color: #ffe477;
  font-size: clamp(2.15rem, 9.5vw, 3.35rem);
  line-height: 1;
  text-wrap: balance;
}

.praise-mode #overlayText {
  color: #fff7d1;
  font-size: clamp(1.08rem, 4.6vw, 1.34rem);
  font-weight: 850;
  line-height: 1.42;
  text-wrap: balance;
}

#overlay.praise-mode #primaryButton {
  border: 2px solid #fff0a3 !important;
  background:
    linear-gradient(
      112deg,
      #aa6a05 0%,
      #e8a91c 19%,
      #ffe36f 37%,
      #fffbd0 48%,
      #ffd24a 60%,
      #bb7708 82%,
      #ffe98f 100%
    ) !important;
  background-size: 240% 100% !important;
  color: #3a2504 !important;
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, 0.94),
    inset 0 -3px 0 rgba(92, 51, 0, 0.4),
    0 8px 20px rgba(255, 199, 45, 0.32) !important;
  text-shadow: none !important;
  animation: completedGoldSweep 2.25s ease-in-out infinite alternate !important;
}

.secondary-button,
.arcade-button,
.store-button {
  border: 1px solid var(--line);
  color: #fff8ee;
}

.secondary-button {
  background: linear-gradient(180deg, #55b7f1, #2b9ee8 56%, #1473ba);
}

.arcade-button {
  background: #1f75c5;
}

.store-button {
  background: linear-gradient(180deg, #2b74c7, #16539d 58%, #0c3975);
}

.thing-button {
  border-color: rgba(84, 199, 255, 0.72);
}

.score-form {
  display: grid;
  grid-template-columns: minmax(4.2rem, 4.9rem) minmax(0, 1fr) auto;
  gap: 6px 8px;
  align-items: end;
  margin-top: 14px;
}

.score-invitation {
  grid-column: 1 / -1;
  margin: 0 0 5px;
  color: var(--yellow);
  font-weight: 900;
}

.score-form label[for="initialsInput"] {
  grid-column: 1;
  grid-row: 2;
}

.score-form label[for="cityInput"] {
  grid-column: 2;
  grid-row: 2;
}

.initials-row {
  display: contents;
}

.initials-row input,
.city-input {
  min-height: 43px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.09);
  color: var(--ink);
  font-weight: 900;
  padding: 0 10px;
}

.initials-row input {
  grid-column: 1;
  grid-row: 3;
  width: 4.8rem;
  min-width: 0;
  text-align: center;
  text-transform: uppercase;
}

.city-input {
  grid-column: 2;
  grid-row: 3;
  width: 100%;
  min-width: 0;
}

.score-form button[type="submit"] {
  grid-column: 3;
  grid-row: 3;
  min-width: 4rem;
}

.score-form datalist {
  display: none;
}

.high-score {
  grid-column: 1 / -1;
  min-height: 1.25em;
  margin: 0;
  color: var(--muted);
  font-weight: 800;
}

.rules-panel {
  margin-top: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 11px;
  background: rgba(255, 255, 255, 0.06);
}

.rules-panel ul {
  margin: 7px 0 0;
  padding-left: 1.15rem;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.35;
}

.rules-panel li + li {
  margin-top: 6px;
}

.home-scores {
  max-height: 180px;
  margin-top: 14px;
  padding: 10px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
}

.home-scores ol {
  margin: 0;
  padding: 0;
  list-style-position: inside;
  font-variant-numeric: tabular-nums;
}

.home-scores li {
  overflow: hidden;
  color: var(--ink);
  font-size: 0.79rem;
  font-weight: 800;
  line-height: 1.42;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.home-scores.victory-reveal {
  animation: hallOfFameReveal 1500ms ease-out;
}

.home-scores li.just-posted {
  margin: 3px 0;
  padding: 5px 7px;
  border: 1px solid rgba(255, 209, 102, 0.78);
  border-radius: 6px;
  background: linear-gradient(90deg, rgba(255, 209, 102, 0.2), rgba(84, 199, 255, 0.12));
  box-shadow: inset 0 0 14px rgba(255, 209, 102, 0.08);
}

.difficulty-badge {
  display: inline-block;
  min-width: 3.8em;
  margin-right: 0.25em;
  border-radius: 999px;
  padding: 0.08em 0.42em;
  color: #071225;
  font-size: 0.72em;
  font-weight: 1000;
  text-align: center;
  text-transform: uppercase;
}

.difficulty-badge.easy {
  background: var(--green);
}

.difficulty-badge.medium {
  background: var(--yellow);
}

.difficulty-badge.hard {
  background: var(--red);
  color: #fff;
}

.difficulty-picker[hidden],
.score-form[hidden],
.rules-panel[hidden],
.home-scores[hidden],
.primary-button[hidden],
.secondary-button[hidden],
.store-button[hidden],
.arcade-button[hidden] {
  display: none;
}

@keyframes cellShake {
  0%,
  100% {
    transform: translateX(0);
  }
  30% {
    transform: translateX(-5px);
  }
  65% {
    transform: translateX(5px);
  }
}

@keyframes goldSheen {
  from {
    background-position: 0% 50%;
  }
  to {
    background-position: 100% 50%;
  }
}

@keyframes completedGoldSweep {
  from {
    background-position: 0% 50%;
  }
  to {
    background-position: 100% 50%;
  }
}

@keyframes confettiFall {
  0% {
    opacity: 0;
    transform: translateY(-15px) rotate(var(--rotate)) scale(0.55);
  }
  12% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: translateY(110dvh) rotate(calc(var(--rotate) + 560deg)) scale(1);
  }
}

@keyframes miniConfettiFall {
  0% {
    opacity: 0;
    transform: translate(0, 0) rotate(var(--rotate)) scale(0.55);
  }
  12% {
    opacity: 1;
  }
  84% {
    top: var(--floor-y);
    opacity: 1;
    transform: translate(var(--drift-x), -100%) rotate(calc(var(--rotate) + 290deg)) scale(0.9);
  }
  100% {
    top: var(--floor-y);
    opacity: 0;
    transform: translate(var(--drift-x), -100%) rotate(calc(var(--rotate) + 340deg)) scale(0.9);
  }
}

@keyframes championMessage {
  0%,
  90.909% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -56%) scale(0.98);
  }
}

@keyframes unitCelebrationPop {
  0% {
    opacity: 0;
    transform: translate(-50%, -35%) scale(0.78);
  }
  14%,
  68% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -68%) scale(0.92);
  }
}

@keyframes hallOfFameReveal {
  0% {
    border-color: rgba(255, 209, 102, 0.95);
    box-shadow: 0 0 0 0 rgba(255, 209, 102, 0.48);
    transform: translateY(8px);
  }
  35% {
    box-shadow: 0 0 0 5px rgba(255, 209, 102, 0.12), 0 0 24px rgba(255, 209, 102, 0.18);
  }
  100% {
    border-color: var(--line);
    box-shadow: none;
    transform: translateY(0);
  }
}

@media (max-height: 720px) {
  .brand-header {
    min-height: 34px;
  }

  .site-tag {
    display: none;
  }

  .game {
    --board-size: min(100%, calc(100dvh - 234px), 548px);
    gap: 3px;
  }

  .game-message {
    min-height: 28px;
  }

  .metric {
    padding-block: 3px;
  }

  .small-button {
    min-height: 33px;
  }

  .number-button {
    min-height: 34px;
  }

  .edit-button {
    min-height: 32px;
  }

  .home-mode .panel {
    padding: 15px;
  }

  .home-mode .panel > .arcade-button:first-child {
    margin-bottom: 12px;
  }

  .home-mode #overlayText {
    margin-top: 9px;
  }
}

@media (max-width: 360px) {
  .action-with-text span:last-child {
    display: none;
  }

  .action-row {
    grid-template-columns: repeat(5, 1fr);
  }

  .cell {
    font-size: clamp(0.85rem, 7.1vw, 1.35rem);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
