:root {
  color-scheme: light;
  --bg: #f7f3ff;
  --card: #ffffff;
  --ink: #243047;
  --muted: #667085;
  --primary: #6c5ce7;
  --primary-dark: #5141c9;
  --line: #d9d6ee;
  --shadow: 0 20px 50px rgba(50, 44, 109, 0.16);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(255, 209, 102, 0.45), transparent 32rem),
    radial-gradient(circle at bottom right, rgba(108, 92, 231, 0.20), transparent 28rem),
    var(--bg);
}

button,
select { font: inherit; }

.app-shell {
  width: min(980px, calc(100% - 32px));
  margin: 0 auto;
  padding: 40px 0;
}

.hero {
  text-align: center;
  margin-bottom: 28px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--primary-dark);
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: clamp(2.2rem, 8vw, 4.8rem);
  line-height: 0.95;
}

.intro {
  max-width: 620px;
  margin: 18px auto 0;
  color: var(--muted);
  font-size: 1.12rem;
}

.controls,
.game-card {
  background: rgba(255, 255, 255, 0.84);
  border: 1px solid rgba(255, 255, 255, 0.75);
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
}

.controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  border-radius: 24px;
  padding: 16px;
  margin-bottom: 20px;
}

.controls label {
  font-weight: 800;
}

select,
button {
  min-height: 44px;
  border-radius: 999px;
  border: 2px solid transparent;
  padding: 0 18px;
}

select {
  background: #fff;
  border-color: var(--line);
  color: var(--ink);
}

button {
  background: var(--primary);
  color: white;
  font-weight: 800;
  cursor: pointer;
  transition: transform 0.15s ease, background 0.15s ease;
}

button:hover:not(:disabled) {
  background: var(--primary-dark);
  transform: translateY(-1px);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

.game-card {
  border-radius: 32px;
  padding: clamp(18px, 4vw, 32px);
}

.status-row {
  display: flex;
  gap: 16px;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 20px;
}

.small-label {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

h2 {
  margin: 0;
  font-size: clamp(1.5rem, 4vw, 2rem);
}

.status {
  max-width: 360px;
  margin: 0;
  color: var(--primary-dark);
  font-weight: 800;
  text-align: right;
}

.board {
  --size: 5;
  display: grid;
  grid-template-columns: repeat(var(--size), minmax(44px, 1fr));
  gap: 8px;
  max-width: min(680px, 100%);
  margin: 0 auto;
  touch-action: manipulation;
}

.cell {
  position: relative;
  aspect-ratio: 1;
  border: 2px solid var(--line);
  border-radius: 18px;
  background: #fbfaff;
  color: var(--ink);
  display: grid;
  place-items: center;
  font-size: clamp(1.2rem, 5vw, 2.3rem);
  font-weight: 900;
  cursor: pointer;
  user-select: none;
  transition: transform 0.12s ease, border-color 0.12s ease, background 0.12s ease;
}

.cell:hover,
.cell:focus-visible {
  border-color: var(--primary);
  outline: none;
  transform: scale(1.02);
}

.arukone-board {
  touch-action: none;
  user-select: none;
}

.arukone-cell {
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
}

.cell.endpoint {
  background: color-mix(in srgb, var(--pair-color) 18%, white);
  border-color: var(--pair-color);
}

.cell.filled {
  background: color-mix(in srgb, var(--pair-color) 30%, white);
  border-color: var(--pair-color);
}

.cell.active {
  box-shadow: inset 0 0 0 4px white, 0 0 0 4px var(--pair-color);
}

.cell.completed::after,
.cell.filled::after {
  content: "";
  position: absolute;
  inset: 40%;
  border-radius: 999px;
  background: var(--pair-color);
  opacity: 0.45;
}

.cell.endpoint::after { display: none; }

.help {
  max-width: 680px;
  margin: 24px auto 0;
  color: var(--muted);
}

.help summary {
  color: var(--ink);
  cursor: pointer;
  font-weight: 900;
}

.help ul { margin-bottom: 0; }

.success-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(36, 48, 71, 0.55);
  backdrop-filter: blur(6px);
  animation: fade-in 0.25s ease;
}

.success-overlay.hidden {
  display: none;
}

.success-modal {
  position: relative;
  overflow: hidden;
  width: min(420px, 100%);
  padding: clamp(30px, 6vw, 44px);
  border-radius: 28px;
  background:
    radial-gradient(circle at top left, rgba(255, 209, 102, 0.22), transparent 34%),
    radial-gradient(circle at bottom right, rgba(17, 138, 178, 0.16), transparent 38%),
    #fff;
  border: 3px solid #06d6a0;
  box-shadow: 0 24px 60px rgba(6, 214, 160, 0.28);
  text-align: center;
  animation: pop-in 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}

#success-title {
  position: relative;
  z-index: 1;
  margin: 52px 0 28px;
  font-size: clamp(2.2rem, 9vw, 3.4rem);
  color: var(--ink);
}

.fireworks {
  position: absolute;
  inset: 14px 18px auto;
  height: 120px;
  pointer-events: none;
}

.fireworks span,
.fireworks span::before,
.fireworks span::after {
  position: absolute;
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: var(--spark-color, #ffd166);
  box-shadow:
    0 -30px 0 var(--spark-color, #ffd166),
    22px -22px 0 var(--spark-color, #ffd166),
    30px 0 0 var(--spark-color, #ffd166),
    22px 22px 0 var(--spark-color, #ffd166),
    0 30px 0 var(--spark-color, #ffd166),
    -22px 22px 0 var(--spark-color, #ffd166),
    -30px 0 0 var(--spark-color, #ffd166),
    -22px -22px 0 var(--spark-color, #ffd166);
  animation: firework-burst 1.35s ease-out infinite;
}

.fireworks span::before,
.fireworks span::after {
  content: "";
  inset: 0;
  transform: rotate(22deg);
}

.fireworks span::after {
  transform: rotate(45deg);
}

.fireworks span:nth-child(1) { left: 18%; top: 54px; --spark-color: #ef476f; }
.fireworks span:nth-child(2) { left: 48%; top: 26px; --spark-color: #ffd166; animation-delay: 0.22s; }
.fireworks span:nth-child(3) { right: 16%; top: 58px; --spark-color: #118ab2; animation-delay: 0.42s; }
.fireworks span:nth-child(4) { left: 32%; top: 82px; --spark-color: #06d6a0; animation-delay: 0.62s; }
.fireworks span:nth-child(5) { right: 32%; top: 88px; --spark-color: #8338ec; animation-delay: 0.82s; }
.fireworks span:nth-child(6) { left: 66%; top: 38px; --spark-color: #ff9f1c; animation-delay: 1s; }

.success-actions {
  position: relative;
  z-index: 1;
  display: flex;
  justify-content: space-between;
  gap: 18px;
}

.success-icon-button {
  width: 72px;
  height: 72px;
  border-radius: 24px;
  font-size: 2rem;
  line-height: 1;
  background: #fff;
  border: 3px solid var(--line);
  color: var(--primary-dark);
  box-shadow: 0 10px 22px rgba(36, 48, 71, 0.12);
}

.success-icon-button:hover:not(:disabled) {
  background: #f4f1ff;
  transform: translateY(-2px);
}

.success-icon-button.primary {
  margin-left: auto;
  background: #06d6a0;
  border-color: #06d6a0;
  color: #fff;
}

.success-icon-button.primary:hover:not(:disabled) {
  background: #05b888;
}

.cell.board-won.completed,
.cell.board-won.filled {
  animation: pulse-win 1.2s ease infinite;
}

@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes pop-in {
  from {
    opacity: 0;
    transform: scale(0.85) translateY(12px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

@keyframes pulse-win {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.03); }
}

@keyframes firework-burst {
  0% {
    opacity: 0;
    transform: scale(0.12);
  }
  18% {
    opacity: 1;
  }
  70% {
    opacity: 0.8;
  }
  100% {
    opacity: 0;
    transform: scale(1.05);
  }
}

@media (prefers-reduced-motion: reduce) {
  .success-overlay,
  .success-modal,
  .fireworks span,
  .fireworks span::before,
  .fireworks span::after {
    animation: none;
  }
}

.start-panel {
  display: grid;
  gap: 18px;
  max-width: 680px;
  margin: 0 auto;
  padding: clamp(22px, 5vw, 34px);
  border-radius: 28px;
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid rgba(255, 255, 255, 0.75);
  box-shadow: var(--shadow);
  text-align: center;
}

.start-copy {
  display: grid;
  gap: 12px;
}

.start-copy h2,
.start-copy p {
  margin: 0;
}

.rules-list {
  display: grid;
  gap: 8px;
  margin: 4px 0 0;
  padding-left: 1.3rem;
  color: var(--muted);
  text-align: left;
}

.start-panel label {
  font-size: clamp(1.25rem, 4vw, 1.65rem);
  font-weight: 900;
}

.start-panel select {
  width: 100%;
  min-height: 54px;
  text-align: center;
  font-weight: 800;
}

.start-panel p,
.puzzle-description {
  margin: 0;
  color: var(--muted);
}

.puzzle-description {
  max-width: 520px;
  margin-top: 6px;
  font-weight: 700;
}

body.puzzle-active {
  height: 100vh;
  overflow: hidden;
}

body.puzzle-active .app-shell {
  width: 100%;
  height: 100vh;
  padding: 10px;
  display: flex;
  flex-direction: column;
}

body.puzzle-active .hero,
body.puzzle-active #start-panel {
  display: none;
}

.game-panel {
  min-height: 0;
  flex: 1;
  display: grid;
  grid-template-rows: minmax(0, 1fr);
}

.game-panel[hidden] {
  display: none;
}

body.puzzle-active .controls {
  display: none;
}

body.puzzle-active .game-card {
  min-height: 0;
  height: 100%;
  display: grid;
  grid-template-rows: max-content minmax(0, 1fr);
  padding: clamp(8px, 1.8vh, 18px);
  overflow: hidden;
  border-radius: 22px;
}

body.puzzle-active .status-row {
  position: relative;
  z-index: 2;
  justify-content: center;
  margin-bottom: clamp(10px, 2vh, 18px);
  text-align: center;
}

body.puzzle-active .small-label,
body.puzzle-active .puzzle-description,
body.puzzle-active .status,
body.puzzle-active .help {
  display: none;
}

body.puzzle-active #puzzle-title {
  display: inline-block;
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.92);
  color: var(--muted);
  font-size: clamp(0.86rem, 2.5vw, 1.05rem);
  font-weight: 900;
  letter-spacing: 0.03em;
  box-shadow: 0 6px 18px rgba(50, 44, 109, 0.08);
}

body.puzzle-active .board {
  width: min(calc(100vw - 36px), calc(100vh - 78px));
  max-width: 860px;
  align-self: center;
  touch-action: none;
}


@media (max-width: 640px) {
  .app-shell { width: min(100% - 20px, 980px); padding: 20px 0; }
  .controls { align-items: stretch; flex-direction: column; }
  .controls > * { width: 100%; }
  .status-row { flex-direction: column; }
  .status { text-align: left; }
  .board { gap: 5px; }
  .cell { border-radius: 12px; }

  body.puzzle-active .app-shell {
    padding: 6px;
  }

  body.puzzle-active .game-card {
    padding: 8px;
  }

  body.puzzle-active .board {
    width: min(calc(100vw - 28px), calc(100vh - 64px));
    gap: 5px;
  }
}

.selection-grid {
  display: grid;
  gap: 16px;
}

.selection-grid > div {
  display: grid;
  gap: 8px;
}

.icon-button {
  width: 52px;
  min-width: 52px;
  min-height: 52px;
  padding: 0;
  display: inline-grid;
  place-items: center;
  font-size: 1.55rem;
  line-height: 1;
  box-shadow: 0 10px 24px rgba(108, 92, 231, 0.2);
}

body.puzzle-active .game-panel {
  grid-template-rows: auto minmax(0, 1fr);
  gap: 8px;
}

body.puzzle-active .controls {
  display: flex;
  justify-content: center;
  width: fit-content;
  max-width: calc(100vw - 20px);
  margin: 0 auto 4px;
  padding: 8px;
  border-radius: 999px;
  gap: 8px;
}

body.puzzle-active .icon-button {
  width: clamp(44px, 10vw, 54px);
  min-width: clamp(44px, 10vw, 54px);
  min-height: clamp(44px, 10vw, 54px);
  font-size: clamp(1.2rem, 5vw, 1.55rem);
}

body.puzzle-active .board {
  width: min(calc(100vw - 36px), calc(100vh - 164px));
}

@media (max-width: 640px) {
  body.puzzle-active .controls {
    flex-direction: row;
    align-items: center;
  }

  body.puzzle-active .controls > * {
    width: clamp(44px, 10vw, 54px);
  }

  body.puzzle-active .board {
    width: min(calc(100vw - 28px), calc(100vh - 154px));
  }
}

.home-panel {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 22px;
  max-width: 900px;
  margin: 0 auto;
}

.game-choice-card {
  display: grid;
  gap: 18px;
  padding: clamp(22px, 4vw, 30px);
  border-radius: 30px;
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid rgba(255, 255, 255, 0.75);
  box-shadow: var(--shadow);
  text-align: center;
}

.game-choice-card h2,
.game-choice-card p {
  margin: 0;
}

.game-choice-card p:not(.small-label) {
  color: var(--muted);
  font-weight: 700;
}

.preview {
  width: min(220px, 100%);
  aspect-ratio: 1;
  margin: 0 auto;
  display: grid;
  padding: 12px;
  border-radius: 24px;
  background: #fbfaff;
  border: 3px solid var(--line);
}

.arukone-preview {
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.arukone-preview span,
.sudoku-preview span {
  display: grid;
  place-items: center;
  border-radius: 14px;
  background: white;
  border: 2px solid var(--line);
  font-weight: 900;
  font-size: 1.35rem;
}

.arukone-preview span:nth-child(1),
.arukone-preview span:nth-child(3) {
  color: #ef476f;
  border-color: #ef476f;
  background: #fff0f4;
}

.arukone-preview span:nth-child(4),
.arukone-preview span:nth-child(6) {
  color: #118ab2;
  border-color: #118ab2;
  background: #edf9fd;
}

.arukone-preview span:nth-child(7),
.arukone-preview span:nth-child(9) {
  color: #06d6a0;
  border-color: #06d6a0;
  background: #eafff9;
}

.line-dot {
  position: relative;
  background: #ffe4ec !important;
  border-color: #ef476f !important;
}

.line-dot::before {
  content: "";
  width: 70%;
  height: 8px;
  border-radius: 999px;
  background: #ef476f;
}

.line-dot.blue {
  background: #edf9fd !important;
  border-color: #118ab2 !important;
}

.line-dot.blue::before { background: #118ab2; }
.line-dot.green {
  background: #eafff9 !important;
  border-color: #06d6a0 !important;
}
.line-dot.green::before { background: #06d6a0; }

.sudoku-preview {
  grid-template-columns: repeat(6, 1fr);
  gap: 3px;
  padding: 7px;
}

.sudoku-preview span {
  border-radius: 7px;
  font-size: 0.95rem;
}

.sudoku-preview span:nth-child(2n + 1) {
  background: #f4f1ff;
}

.choose-game-button {
  width: 100%;
}

.level-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(118px, 1fr));
  gap: 14px;
}

.level-tile {
  min-height: 112px;
  border-radius: 22px;
  display: grid;
  place-items: center;
  gap: 4px;
  padding: 12px;
  background: #fff;
  color: var(--ink);
  border: 3px solid var(--line);
  box-shadow: 0 12px 26px rgba(50, 44, 109, 0.10);
}

.level-tile span {
  font-size: clamp(1.2rem, 5vw, 1.75rem);
  font-weight: 950;
}

.level-tile small {
  color: var(--muted);
  font-weight: 850;
}

.level-tile.easy { border-color: #06d6a0; }
.level-tile.medium { border-color: #ffd166; }
.level-tile.hard { border-color: #ef476f; }
.level-tile.extreme { border-color: #8338ec; }

.level-tile:hover:not(:disabled) {
  color: white;
}

.sudoku-board {
  gap: 6px;
  background: var(--ink);
  border: 4px solid var(--ink);
  border-radius: 20px;
  overflow: hidden;
}

.sudoku-cell {
  border-radius: 10px;
  border-color: #ffffff;
  background: #ffffff;
  font-size: clamp(1.6rem, 7vw, 3rem);
}

.sudoku-cell.box-edge-right {
  margin-right: 4px;
}

.sudoku-cell.box-edge-bottom {
  margin-bottom: 4px;
}

.sudoku-cell.given {
  background: #fff4cf;
  border-color: #ffd166;
  color: #8a5a00;
  cursor: default;
}

.sudoku-cell.selected {
  outline: 5px solid var(--primary);
  outline-offset: -5px;
}

.sudoku-cell.conflict {
  background: #ffe5ea;
  border-color: #ef476f;
  color: #b0002a;
}

.number-pad[hidden] {
  display: none;
}

.number-pad {
  position: fixed;
  z-index: 20;
  display: grid;
  grid-template-columns: repeat(3, minmax(48px, 62px));
  justify-content: center;
  gap: 8px;
  margin: 0;
  padding: 10px;
  border: 2px solid var(--primary);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.97);
  box-shadow: 0 16px 36px rgba(36, 48, 71, 0.22);
}

.number-pad button {
  min-height: 52px;
  border-radius: 14px;
  font-size: 1.45rem;
}

.number-pad .clear-number-button {
  grid-column: 1 / -1;
  background: #ef476f;
  font-size: 1rem;
}

.number-pad .clear-number-button:hover:not(:disabled) {
  background: #b0002a;
}

body.puzzle-active .number-pad {
  margin: 0;
}

body.puzzle-active .sudoku-board {
  width: min(calc(100vw - 36px), calc(100vh - 190px));
}

body.puzzle-active #level-panel,
body.puzzle-active #home-panel {
  display: none;
}

@media (max-width: 720px) {
  .home-panel {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .level-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .level-tile {
    min-height: 94px;
  }

  body.puzzle-active .sudoku-board {
    width: min(calc(100vw - 28px), calc(100vh - 178px));
  }
}

[hidden] {
  display: none !important;
}

a.choose-game-button,
a.icon-button {
  min-height: 44px;
  border-radius: 999px;
  border: 2px solid transparent;
  padding: 0 18px;
  background: var(--primary);
  color: white;
  font-weight: 800;
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.15s ease, background 0.15s ease;
}

a.choose-game-button:hover,
a.icon-button:hover,
a.choose-game-button:focus-visible,
a.icon-button:focus-visible {
  background: var(--primary-dark);
  transform: translateY(-1px);
  outline: none;
}

a.choose-game-button {
  display: grid;
  place-items: center;
}

a.icon-button {
  padding: 0;
}

/* Erweiterungen für die grosse Rätselsammlung */
.home-panel {
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  max-width: 1120px;
}
.preview span { min-width: 0; }
.sea-preview { grid-template-columns: repeat(5, 1fr); gap: 5px; }
.sea-preview span {
  display: grid; place-items: center; border-radius: 10px; background: #fff; border: 2px solid var(--line); font-weight: 900;
}
.sea-preview span { background: #e9f8ff; color: #118ab2; }

.difficulty-group { display: grid; gap: 10px; text-align: left; }
.difficulty-group h3 { margin: 8px 0 0; color: var(--primary-dark); font-size: 1.2rem; }
.difficulty-levels { display: grid; grid-template-columns: repeat(auto-fit, minmax(112px, 1fr)); gap: 12px; }
.level-tile.solved { position: relative; background: #f0fff9; }
.level-tile.solved::after { content: "★"; position: absolute; top: 8px; right: 12px; color: #06a77d; font-size: 1.2rem; }
.count-board {
  grid-template-columns: repeat(var(--size), minmax(34px, 1fr));
  gap: 5px;
  align-items: stretch;
}
.count-label, .count-corner {
  min-height: 38px;
  display: grid;
  place-items: center;
  padding: 4px;
  border-radius: 12px;
  background: #fff4cf;
  border: 2px solid #ffd166;
  color: #8a5a00;
  font-weight: 950;
  font-size: clamp(0.82rem, 2.6vw, 1.15rem);
  text-align: center;
}
.bimaru-cell { background: #e9f8ff; border-color: #b9e8fb; color: #118ab2; }
.bimaru-cell.animal { background: #dffbed; border-color: #06d6a0; font-size: clamp(1.1rem, 4vw, 2rem); }
.bimaru-cell.water { background: #dff3ff; color: #118ab2; }

body.puzzle-active .count-board {
  width: min(calc(100vw - 36px), calc(100vh - 170px), 760px);
}

@media (max-width: 640px) {
  .difficulty-levels { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .count-board { gap: 3px; }
  .count-label, .count-corner { min-height: 30px; border-radius: 9px; padding: 2px; }
  .cell { min-width: 0; }
}

.selection-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
}

.selection-back-button {
  display: inline-grid;
  place-items: center;
  min-height: 50px;
  border-radius: 999px;
  border: 3px solid var(--primary);
  padding: 0 22px;
  background: #fff;
  color: var(--primary-dark);
  font-weight: 950;
  text-decoration: none;
  box-shadow: 0 10px 22px rgba(50, 44, 109, 0.12);
}

.selection-back-button:hover,
.selection-back-button:focus-visible {
  background: #f4f1ff;
  transform: translateY(-1px);
  outline: none;
}

.home-back-button {
  border-color: #06d6a0;
  color: #047c5d;
}

.difficulty-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 18px;
}

.difficulty-card {
  min-height: 190px;
  display: grid;
  place-items: center;
  gap: 8px;
  padding: 18px;
  border-radius: 30px;
  background: #fff;
  color: var(--ink);
  border: 5px solid var(--line);
  box-shadow: 0 18px 32px rgba(50, 44, 109, 0.12);
}

.difficulty-card.easy { border-color: #06d6a0; background: #effff8; }
.difficulty-card.medium { border-color: #ffd166; background: #fff8df; }
.difficulty-card.hard { border-color: #ef476f; background: #fff0f4; }
.difficulty-card.extreme { border-color: #8338ec; background: #f4edff; }

.difficulty-card:hover:not(:disabled),
.difficulty-card:focus-visible {
  color: var(--ink);
  transform: translateY(-4px) scale(1.02);
  outline: 4px solid rgba(108, 92, 231, 0.22);
}

.difficulty-icon {
  font-size: clamp(3rem, 9vw, 4.5rem);
  line-height: 1;
}

.difficulty-name {
  font-size: clamp(1.55rem, 5vw, 2.2rem);
  font-weight: 950;
}

.difficulty-card small {
  color: var(--muted);
  font-weight: 900;
}

@media (max-width: 760px) {
  .difficulty-grid {
    grid-template-columns: 1fr;
  }

  .difficulty-card {
    min-height: 132px;
    grid-template-columns: auto 1fr;
    justify-items: start;
    text-align: left;
  }

  .difficulty-card small {
    grid-column: 2;
  }
}

@media (max-width: 520px) {
  .selection-actions,
  .selection-back-button {
    width: 100%;
  }
}

button.selection-back-button:hover:not(:disabled),
button.selection-back-button:focus-visible {
  background: #f4f1ff;
  color: var(--primary-dark);
}

.kakuro-preview {
  grid-template-columns: repeat(4, 1fr);
  background: #f8f5ef;
}

.kakuro-preview span {
  position: relative;
  background: #fff;
  border-color: #d6c7b2;
  color: #3d405b;
  font-size: 0.8rem;
}

.kakuro-preview .clue {
  background: linear-gradient(135deg, #b7b7b2 49%, #fefefe 50%);
  color: #1f2933;
  align-items: flex-start;
  justify-content: flex-start;
  padding: 4px;
}

.kakuro-board {
  gap: 0;
  max-width: min(720px, 100%);
  border: 2px solid #222;
  background: #222;
}

.kakuro-cell {
  border: 1px solid #222;
  border-radius: 0;
  font-size: clamp(1.15rem, 4vw, 2rem);
}

.kakuro-entry {
  background: #fffdf8;
  color: var(--ink);
}

.kakuro-entry.selected {
  background: #fff1c2;
  box-shadow: inset 0 0 0 4px #ffd166;
}

.kakuro-entry.conflict {
  background: #ffe2e2;
  color: #b00020;
}

.kakuro-clue {
  cursor: default;
  background: #aeb3b0;
  overflow: hidden;
}

.kakuro-clue.has-clue::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(45deg, transparent calc(50% - 1px), #4a4a4a 50%, transparent calc(50% + 1px));
}

.kakuro-down,
.kakuro-across {
  position: absolute;
  z-index: 1;
  color: #111;
  font-size: clamp(0.62rem, 2.2vw, 1.05rem);
  font-weight: 800;
  line-height: 1;
}

.kakuro-down {
  left: 18%;
  bottom: 14%;
}

.kakuro-across {
  right: 14%;
  top: 14%;
}

.kakuro-cell:hover {
  transform: none;
}

.hidoku-preview {
  grid-template-columns: repeat(4, 1fr);
  gap: 5px;
  background: #f8fbff;
}

.hidoku-preview span {
  display: grid;
  place-items: center;
  border-radius: 10px;
  background: #fff;
  border: 2px solid #c9d7f2;
  color: #243047;
  font-size: 1rem;
  font-weight: 950;
}

.hidoku-preview span:not(:empty) {
  background: #eef4ff;
  border-color: #3a86ff;
  color: #1f4ea3;
}

.hidoku-board {
  gap: 0;
  max-width: min(720px, 100%);
  border: 3px solid #243047;
  background: #243047;
  border-radius: 18px;
  overflow: hidden;
  touch-action: none;
  user-select: none;
}

.hidoku-cell {
  border: 1px solid #243047;
  border-radius: 0;
  background: #ffffff;
  color: var(--ink);
  font-size: clamp(1.25rem, 5vw, 2.35rem);
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
}

.hidoku-cell.given {
  background: #eaf2ff;
  border-color: #3a86ff;
  color: #1f4ea3;
  cursor: default;
}

.hidoku-cell.selected {
  background: #fff1c2;
  box-shadow: inset 0 0 0 5px #ffd166;
}

.hidoku-cell.conflict {
  background: #ffe5ea;
  color: #b0002a;
}

.hidoku-cell:hover {
  transform: none;
}

.number-pad {
  grid-template-columns: repeat(var(--pad-cols, 3), minmax(48px, 62px));
}

.number-pad.hidoku-pad {
  grid-template-columns: repeat(var(--pad-cols, 4), minmax(42px, 56px));
  max-width: min(94vw, 420px);
  max-height: min(52vh, 360px);
  overflow: auto;
}

.number-pad.hidoku-pad button {
  min-height: 44px;
  font-size: 1.05rem;
}

body.puzzle-active .hidoku-board {
  width: min(calc(100vw - 36px), calc(100vh - 190px), 760px);
}

@media (max-width: 640px) {
  .number-pad.hidoku-pad {
    grid-template-columns: repeat(var(--pad-cols, 4), minmax(36px, 1fr));
    gap: 5px;
    padding: 7px;
  }

  .number-pad.hidoku-pad button {
    min-height: 38px;
    padding: 0 8px;
    font-size: 0.95rem;
  }

  body.puzzle-active .hidoku-board {
    width: min(calc(100vw - 28px), calc(100vh - 178px));
  }
}

.shikaku-preview {
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
  padding: 8px;
}

.shikaku-preview span {
  display: grid;
  place-items: center;
  min-width: 0;
  border: 2px solid rgba(36, 48, 71, 0.18);
  color: var(--ink);
  font-size: 0.98rem;
  font-weight: 900;
}

.shikaku-preview b {
  margin-left: 2px;
  font-size: 0.8rem;
}

.shikaku-preview .pen { border-radius: 9px; }
.shikaku-preview .pen-a { background: #fff0c7; }
.shikaku-preview .pen-b { background: #dff8ef; }
.shikaku-preview .pen-c { background: #e6f0ff; }
.shikaku-preview .pen-d { background: #ffe0e8; }
.shikaku-preview .pen-e { background: #eee8ff; }
.shikaku-preview .pen-f { background: #e9f8ff; }

.shikaku-board {
  gap: 4px;
  max-width: min(720px, 100%);
  touch-action: none;
  user-select: none;
}

.shikaku-cell {
  border-radius: 12px;
  border-width: 2px;
  background: #fffdf7;
  font-size: clamp(0.95rem, 3.5vw, 1.55rem);
  display: flex;
  flex-direction: column;
  gap: 1px;
  align-items: center;
  justify-content: center;
  min-width: 0;
  -webkit-tap-highlight-color: transparent;
}

.shikaku-cell.clue {
  border-color: #5141c9;
  color: var(--ink);
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.86);
}

.shikaku-cell.selected {
  outline: 4px solid #ff9f1c;
  outline-offset: 2px;
  transform: scale(1.02);
}

.shikaku-cell.region {
  border-color: rgba(36, 48, 71, 0.46);
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.72);
}

.shikaku-animal {
  line-height: 1;
  font-size: 0.95em;
}

.shikaku-number {
  line-height: 1;
  padding: 1px 7px 2px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.86);
  font-weight: 950;
}

.shikaku-cell.shikaku-drag-preview {
  border-color: #ff9f1c;
  background:
    linear-gradient(rgba(255, 159, 28, 0.24), rgba(255, 159, 28, 0.24)),
    #fff8e8;
  box-shadow: inset 0 0 0 3px rgba(255, 255, 255, 0.82), 0 0 0 2px rgba(255, 159, 28, 0.38);
  transform: scale(1.01);
}

.shikaku-cell.shikaku-drag-preview.valid {
  border-color: #06d6a0;
  background:
    linear-gradient(rgba(6, 214, 160, 0.22), rgba(6, 214, 160, 0.22)),
    #f0fff9;
}

.shikaku-region-1 { background: #fff0c7; }
.shikaku-region-2 { background: #dff8ef; }
.shikaku-region-3 { background: #e6f0ff; }
.shikaku-region-4 { background: #ffe0e8; }
.shikaku-region-5 { background: #eee8ff; }
.shikaku-region-6 { background: #e5f9dc; }
.shikaku-region-7 { background: #ffead7; }
.shikaku-region-8 { background: #dff7fb; }
.shikaku-region-9 { background: #f9e4ff; }
.shikaku-region-10 { background: #edf2d4; }
.shikaku-region-11 { background: #f4e7d3; }
.shikaku-region-12 { background: #e3ecff; }

body.puzzle-active .shikaku-board {
  width: min(calc(100vw - 32px), calc(100vh - 172px));
}

body.puzzle-active .shikaku-cell {
  border-radius: clamp(8px, 2vw, 14px);
}

@media (max-width: 640px) {
  .shikaku-board { gap: 3px; }
  body.puzzle-active .shikaku-board {
    width: min(calc(100vw - 24px), calc(100vh - 160px));
  }
  .shikaku-cell {
    border-radius: 9px;
    font-size: clamp(0.8rem, 4vw, 1.2rem);
  }
  .shikaku-number { padding-inline: 5px; }
}
