:root {
  font-family: "Segoe UI", "Noto Sans JP", Meiryo, sans-serif;
  color: #fff;
  background: #5942bd;
  font-synthesis: none;
  --gap: 5px;
  --radius: 9px;
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
  min-height: 100svh;
  background:
    radial-gradient(ellipse at 50% 36%, #8663e36b 0, transparent 55%),
    radial-gradient(ellipse at 15% 95%, #574cdc 0, transparent 60%),
    linear-gradient(150deg, #6146c9 0, #5640b4 55%, #5942bd 100%);
  background-attachment: fixed;
}
button {
  font: inherit;
  cursor: pointer;
  color: inherit;
  border: 0;
  -webkit-tap-highlight-color: transparent;
}
button:disabled {
  cursor: default;
  opacity: 0.4;
}
button:focus-visible,
[tabindex]:focus-visible {
  outline: 2px solid #c0ffe9;
  outline-offset: 5px;
}
button:hover:not(:disabled) {
  filter: brightness(1.15);
}
.app {
  width: min(100%, 510px);
  min-height: 100svh;
  margin: auto;
  padding: max(22px, env(safe-area-inset-top)) 25px
    max(22px, env(safe-area-inset-bottom));
}
.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.icon-button {
  width: 47px;
  height: 47px;
  display: grid;
  place-items: center;
  background: #ffffff06;
  border: 1.5px solid #b8caff70;
  border-radius: 50%;
  box-shadow: inset 0 0 10px #d1c5ff08;
  flex-shrink: 0;
}
.icon-button svg {
  width: 25px;
  height: 25px;
  fill: none;
  stroke: #fffffff0;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.best-pill {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  min-width: 170px;
  padding: 5px 24px;
  border: 1.5px solid #b8caff70;
  border-radius: 40px;
  background: #ffffff06;
}
.crown {
  color: #ffe793;
  font-size: 31px;
  text-shadow: 0 0 12px #ffc77770;
  line-height: 1;
}
.best-label {
  font-size: 9px;
  font-weight: 600;
  color: #eee8ff;
  letter-spacing: 1px;
}
#best {
  display: block;
  font-size: 22px;
  line-height: 1.1;
  letter-spacing: 0.5px;
  font-variant-numeric: tabular-nums;
}
.scorebar {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 31px 0 29px;
}
.eyebrow {
  display: block;
  font-size: 9px;
  font-weight: 650;
  letter-spacing: 2.3px;
  color: #d5c9fc;
}
#score {
  display: block;
  font-size: clamp(64px, 18vw, 88px);
  line-height: 1.2;
  font-weight: 750;
  letter-spacing: -3px;
  text-shadow:
    0 4px 10px #28136645,
    0 0 28px #ffffff18;
  font-variant-numeric: tabular-nums;
}
.score-caption {
  font-size: 10px;
  letter-spacing: 3px;
  color: #e0d3ff;
  margin-top: 3px;
}
.board-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 9px;
  color: #eee4ff;
  padding: 0 5px 12px;
}
.board-heading > span:last-child {
  letter-spacing: 2px;
  color: #d2c3fc;
}
.connection {
  display: flex;
  align-items: center;
  gap: 4px;
}
.connection i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--light);
  box-shadow: 0 0 6px var(--glow);
}
.connection span {
  margin-left: 6px;
  letter-spacing: 1px;
}
.board-wrap {
  position: relative;
  padding: 8px;
  border: 1px solid #eee0ff65;
  border-radius: 17px;
  background: linear-gradient(140deg, #e1c6ff12, #9b80de13);
  box-shadow:
    inset 0 0 18px #c8abff18,
    0 0 0 4px #dfc7ff04,
    0 14px 45px #2c147d2e;
}
.board {
  display: grid;
  grid-template-columns: repeat(var(--size, 8), minmax(0, 1fr));
  gap: var(--gap);
  aspect-ratio: 1;
  touch-action: none;
  user-select: none;
  border-radius: 8px;
}
.cell {
  position: relative;
  aspect-ratio: 1;
  min-width: 0;
  border-radius: var(--radius);
  background: #dccaff0b;
  box-shadow: inset 0 0 0 1px #e4cfff0b;
}
.block {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius);
  background: linear-gradient(145deg, var(--top), var(--bottom));
  border: 1px solid var(--light);
  box-shadow:
    inset 0 1px 5px #ffffff90,
    inset 0 -2px 9px var(--glow),
    0 0 7px var(--glow),
    0 4px 8px #25105730;
  user-select: none;
}
.c0 {
  --top: #f3a4d980;
  --bottom: #d877cc70;
  --light: #ffd5f3;
  --glow: #ffaae66b;
}
.c1 {
  --top: #9bc5ff85;
  --bottom: #69a5dc65;
  --light: #c9e8ff;
  --glow: #99d5ff6b;
}
.c2 {
  --top: #ffdc9b90;
  --bottom: #e5b36970;
  --light: #fff0bf;
  --glow: #ffe0996b;
}
.c3 {
  --top: #96eacda0;
  --bottom: #6fcbaa75;
  --light: #ccffed;
  --glow: #99ffd16b;
}
.symbol {
  color: #fff9;
  font-size: clamp(9px, 2.7vw, 13px);
  font-weight: 700;
  line-height: 1;
  text-shadow: 0 0 4px #ffffff65;
}
.preview {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: visible;
  z-index: 3;
}
.preview .block {
  inset: auto;
  opacity: 0.65;
  outline: 2px solid #d4ffef;
  outline-offset: 1px;
  box-shadow: 0 0 15px #d6ffe87a;
}
.preview.invalid .block {
  opacity: 0.48;
  outline: 2px dashed #ffc1d3;
}
.preview.invalid .block:after {
  content: "×";
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: #fff;
  font-size: 26px;
  background: #95357f8f;
  border-radius: inherit;
}
.message {
  min-height: 40px;
  padding: 14px 0 9px;
  text-align: center;
  font-size: 10px;
  color: #e9e0ff;
  letter-spacing: 0.4px;
}
.message.error {
  color: #ffccd8;
}
.hand-area {
  padding: 10px 4px 0;
}
.hand-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 3px;
}
.hand-heading > span:last-child {
  font-size: 9px;
  color: #d1c0f6;
}
.hand {
  display: grid;
  grid-template-columns: repeat(var(--hand-size, 3), 1fr);
  gap: 12px;
  margin-top: 9px;
}
.piece-slot {
  position: relative;
  height: 110px;
  display: grid;
  place-items: center;
  padding: 8px 0 15px;
  background: transparent;
  border-radius: 18px;
  touch-action: none;
  user-select: none;
}
.piece-slot.selected {
  background: radial-gradient(ellipse at center, #ecdaff15, transparent 75%);
}
.piece-slot.selected:after {
  content: "";
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: #e5d3ff;
  box-shadow: 0 0 9px #f6cfff;
  position: absolute;
  bottom: 4px;
}
.piece-slot.dragging .piece-art {
  opacity: 0.2;
}
.piece-slot.used {
  color: #c8b9f465;
  font-size: 18px;
  opacity: 0.6;
}
.piece-art {
  position: relative;
  pointer-events: none;
  --unit: 40px;
  width: calc(var(--cols) * var(--unit));
  height: calc(var(--rows) * var(--unit));
}
.piece-art .block {
  inset: auto;
  left: calc(var(--col) * var(--unit));
  top: calc(var(--row) * var(--unit));
  width: calc(var(--unit) - 2px);
  height: calc(var(--unit) - 2px);
  border-radius: 9px;
}
.piece-art .symbol {
  font-size: 11px;
}
.slot-number {
  position: absolute;
  bottom: 1px;
  right: 9px;
  font-size: 8px;
  color: #dbcdff70;
}
.footnote {
  margin: 14px 0 0;
  text-align: center;
  font-size: 9px;
  line-height: 1.9;
  letter-spacing: 0.4px;
  color: #d5c7f5;
}
.small-only {
  display: none;
}
footer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 34px;
  color: #eee4ff;
}
.brand {
  font-size: 13px;
  letter-spacing: 0.5px;
  font-weight: 700;
}
.brand-mark {
  display: flex;
  gap: 2px;
  transform: rotate(-12deg);
}
.brand-mark i {
  width: 9px;
  height: 11px;
  border: 1px solid #e0fff0;
  background: #9bf3cd99;
  border-radius: 2px;
  box-shadow: 0 0 6px #d0ffe540;
}
.brand-mark i + i {
  border-color: #ffeac4;
  background: #f6d28a99;
}
.footer-note {
  font-size: 7px;
  letter-spacing: 1.3px;
  color: #cbbbf2;
  margin-left: 3px;
}
.drag-piece {
  position: fixed;
  pointer-events: none;
  z-index: 10;
  opacity: 0.9;
  filter: drop-shadow(0 5px 9px #26145f30);
}
.drag-piece[hidden] {
  display: none;
}
.score-pop {
  pointer-events: none;
  position: absolute;
  left: 0;
  right: 0;
  top: 40%;
  text-align: center;
  color: #e7fff7;
  font-size: 45px;
  font-weight: 800;
  text-shadow:
    0 0 20px #b1ffcf,
    0 3px 5px #392578;
  z-index: 4;
  opacity: 0;
}
.score-pop.show {
  animation: score-pop 0.7s ease-out;
}
.placed {
  animation: place 0.19s ease-out;
}
.clearing {
  animation: clear 0.23s ease-in forwards;
}
dialog {
  border: 1px solid #decaff75;
  border-radius: 23px;
  padding: 30px;
  max-width: 420px;
  width: calc(100% - 32px);
  max-height: calc(100svh - 40px);
  background: linear-gradient(150deg, #7960cf, #553ca8);
  color: #fff;
  box-shadow:
    inset 0 0 25px #cfb0ff12,
    0 25px 100px #1b104b60;
}
dialog::backdrop {
  background: #170d476b;
  backdrop-filter: blur(7px);
}
dialog h2 {
  font-size: 21px;
  line-height: 1.6;
  margin: 15px 0;
}
dialog p {
  font-size: 12px;
  line-height: 1.9;
  color: #eee4ff;
}
.dialog-close:not(.primary) {
  position: absolute;
  right: 13px;
  top: 8px;
  background: transparent;
  width: 38px;
  height: 38px;
  font-size: 25px;
  color: #f1e5ff;
}
.primary,
.secondary {
  min-height: 44px;
  padding: 12px 18px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 650;
}
.primary {
  background: linear-gradient(150deg, #b2eeda, #85cdcf);
  color: #37376b;
  border: 1px solid #daffef;
  box-shadow: 0 0 15px #c3ffee1f;
}
.secondary {
  background: #d5bfff20;
  border: 1px solid #dbc4ff4d;
}
.dialog-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 24px;
}
dialog > .primary,
dialog > .secondary {
  display: block;
  width: 100%;
  margin-top: 14px;
}
.keyboard-help {
  border-top: 1px solid #e0d0ff30;
  padding-top: 15px;
  font-size: 10px !important;
}
.final-score {
  text-align: center;
  margin: 22px 0;
}
.final-score strong {
  display: block;
  font-size: 56px;
  margin-top: 8px;
}
@keyframes place {
  from {
    transform: scale(0.8);
  }
  70% {
    transform: scale(1.06);
  }
  to {
    transform: scale(1);
  }
}
@keyframes clear {
  0% {
    transform: scale(1);
    opacity: 1;
  }
  40% {
    transform: scale(1.06);
    filter: brightness(1.6);
  }
  100% {
    transform: scale(0.3);
    opacity: 0;
  }
}
@keyframes score-pop {
  0% {
    opacity: 0;
    transform: scale(0.8);
  }
  25%,
  60% {
    opacity: 1;
    transform: scale(1);
  }
  100% {
    opacity: 0;
    transform: scale(1.1);
  }
}
@media (max-width: 520px) {
  .app {
    padding: max(18px, env(safe-area-inset-top)) 20px
      max(20px, env(safe-area-inset-bottom));
  }
  .scorebar {
    padding: 23px 0;
  }
  .toolbar {
    gap: 12px;
  }
  .icon-button {
    width: 43px;
    height: 43px;
  }
  .best-pill {
    min-width: 155px;
    padding: 5px 18px;
  }
  .board-wrap {
    padding: 6px;
    border-radius: 14px;
  }
  .piece-art {
    --unit: 36px;
  }
  .piece-slot {
    height: 97px;
  }
  footer {
    margin-top: 28px;
  }
}
@media (max-width: 360px) {
  :root {
    --gap: 4px;
    --radius: 7px;
  }
  .app {
    padding-left: 14px;
    padding-right: 14px;
  }
  .best-pill {
    min-width: 140px;
    padding: 5px 12px;
  }
  .toolbar {
    gap: 8px;
  }
  .scorebar {
    padding: 19px 0;
  }
  .piece-art {
    --unit: 32px;
  }
  .piece-slot {
    height: 90px;
  }
  .footnote {
    font-size: 8px;
  }
  .small-only {
    display: block;
  }
  .footer-note {
    font-size: 6px;
    letter-spacing: 0.7px;
  }
}
@media (prefers-reduced-motion: reduce) {
  *,
  *:before,
  *:after {
    animation: none !important;
    transition: none !important;
  }
}
