.tile-grid {
  display: grid;
  grid-template-columns: repeat(var(--n), 1fr);
  gap: 9px;
  max-width: 420px;
  margin: auto;
  position: relative;
}
.tile {
  aspect-ratio: 1;
  border-radius: 12px;
  background: var(--game-color);
  border: 2px solid transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  padding: 0;
  color: var(--game-ink);
  font-size: 26px;
  touch-action: manipulation;
  transition:
    background 0.15s,
    transform 0.15s,
    opacity 0.15s;
}
.tile:hover:not(:disabled) {
  transform: translateY(-1px);
}
.tile.chosen,
.tile.hinted {
  box-shadow: 0 0 0 3px var(--game-ink);
  z-index: 1;
}
.tile:disabled {
  opacity: 1;
}
.color-grid {
  gap: 7px;
}
.color-grid .tile {
  border-radius: 9px;
  color: #fff;
}
.color-grid .chosen {
  outline: 3px solid white;
  outline-offset: -7px;
  box-shadow: none;
}
.gradient-reference {
  max-width: 160px;
  margin-top: 20px;
  gap: 2px;
}
.gradient-reference .tile {
  border-radius: 3px;
}
.moon-grid {
  background: #e1e5f2;
  border-radius: 20px;
  padding: 15px;
  gap: 11px;
}
.moon-grid .tile {
  background: #cdd4e7;
  color: #8c98b5;
  border-radius: 19px;
}
.moon-grid .tile.lit {
  background: #fff3c8;
  color: #c3a361;
  box-shadow: 0 0 16px #fff5c855;
}
.river-grid {
  gap: 4px;
  border-radius: 14px;
  padding: 9px;
  background: #e6f2eb;
  max-width: 460px;
}
.river-grid .tile {
  background: #d3e6db;
  color: #b0cbbd;
  border: 0;
  overflow: hidden;
  border-radius: 7px;
}
.river-grid .tile.flowing {
  color: #66a397;
}
.river-grid .tile svg {
  width: 100%;
  height: 100%;
}
.river-grid .tile.inlet:after,
.river-grid .tile.outlet:after {
  content: "→";
  position: absolute;
  font-size: 15px;
  color: #42756c;
  left: 2px;
  top: 50%;
  transform: translateY(-50%);
  background: #edf8ed;
  border-radius: 5px;
  line-height: 20px;
}
.river-grid .tile.outlet:after {
  left: auto;
  right: 2px;
}
.memory-grid {
  gap: 12px;
}
.memory-grid .tile {
  background: #e5dfd3;
  border-radius: 27px 23px 30px 22px;
  color: #a59d8d;
}
.memory-grid .tile.revealed {
  background: #fbf6e9;
  color: #9e8870;
}
.memory-grid .tile.matched {
  background: #e2e9da;
  color: #839579;
  opacity: 0.8;
}
.palette-button {
  min-width: 39px;
  border: 2px solid white;
  border-radius: 50%;
  font-size: 11px;
}
.slide-grid {
  max-width: 380px;
  gap: 11px;
  padding: 15px;
  border-radius: 19px;
  background: #f1e8d8;
}
.slide-grid .tile {
  background: #fff7e9;
  color: #9c835e;
  font-weight: 500;
  font-size: 32px;
  box-shadow: 0 3px 0 #d6c7ae55;
}
.slide-grid .tile.empty {
  background: #e5dbc8;
  box-shadow: none;
  color: transparent;
}
.nonogram {
  display: grid;
  grid-template-columns: 1.05fr repeat(5, 1fr);
  gap: 5px;
  max-width: 460px;
  margin: auto;
}
.nonogram > .tile {
  border-radius: 6px;
  background: #edf2e8;
  border-color: #dce4d5;
  font-size: 24px;
  color: #a7b69a;
}
.nonogram > .tile.filled {
  background: #7b9670;
  border-color: #7b9670;
}
.row-clue,
.column-clue {
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1.4;
  text-align: center;
  color: #7a8e6e;
  font-size: 16px;
  letter-spacing: 3px;
  font-variant-numeric: tabular-nums;
}
.column-clue {
  min-height: 76px;
  letter-spacing: 0;
}
.row-clue {
  justify-content: flex-end;
  padding-right: 8px;
  font-size: 14px;
}
.dew-grid {
  gap: 6px;
  max-width: 420px;
}
.dew-grid .tile {
  border-radius: 9px;
  font-size: 16px;
  color: #ffffffa8;
}
.dew-grid .tile.source {
  box-shadow: 0 0 0 3px #647d75;
  z-index: 1;
}
.color-choice {
  min-width: 50px;
  min-height: 48px;
  border: 3px solid #fffdf7;
  border-radius: 16px;
  color: white;
  font-size: 22px;
}
.color-choice:disabled {
  outline: 2px solid #8c9685;
  opacity: 1;
}
.line-grid {
  gap: 0;
  max-width: 430px;
  background: #fbf4e4;
  border-radius: 20px;
  padding: 0;
  overflow: hidden;
}
.line-grid .tile {
  background: none;
  position: relative;
  border: 0;
  border-radius: 0;
  font-size: 27px;
  color: #cabc98;
  z-index: 1;
}
.line-grid .tile.visited {
  font-size: 14px;
  color: #8e7846;
}
.line-grid .tile.visited:before {
  content: "";
  position: absolute;
  left: calc(50% - 18px);
  top: calc(50% - 18px);
  width: 36px;
  height: 36px;
  background: #dfd1ae;
  border-radius: 50%;
  z-index: -1;
}
.line-grid .tile.current {
  color: #fff;
}
.line-grid .tile.current:before {
  background: #a98c50;
}
.line-threads {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 0;
}
.balance-scene {
  height: 340px;
  background: #efeee8;
  border-radius: 18px;
  position: relative;
  padding: 0 26px;
  overflow: hidden;
}
.balance-beam {
  position: absolute;
  height: 7px;
  width: 85%;
  background: #aaa89b;
  left: 7.5%;
  top: 185px;
  border-radius: 7px;
  transform: rotate(var(--tilt));
  transition: transform 0.4s;
}
.fulcrum {
  position: absolute;
  left: calc(50% - 23px);
  top: 194px;
  border-left: 23px solid transparent;
  border-right: 23px solid transparent;
  border-bottom: 38px solid #c5c2b5;
}
.balance-slots {
  display: flex;
  justify-content: space-between;
  position: absolute;
  left: 8%;
  width: 84%;
  top: 124px;
  transform: rotate(var(--tilt));
  transform-origin: 50% 64px;
  transition: transform 0.4s;
}
.balance-slot {
  width: 13%;
  padding: 0;
  position: relative;
}
.balance-slot > span {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 50px;
  border-radius: 18px;
  background: #e0ded4;
  color: #c0bdb1;
  font-size: 23px;
}
.balance-slot.occupied > span {
  background: #aaa99b;
  color: #fff9ee;
}
.balance-slot small {
  font-size: 11px;
  color: #979887;
  display: block;
  padding-top: 16px;
}
.balance-slot:nth-child(3) {
  margin-right: 9%;
}
.balance-slot:nth-child(4) {
  margin-left: 9%;
}
.stone-tray {
  position: absolute;
  bottom: 24px;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 19px;
}
.stone {
  height: 45px;
  min-width: 50px;
  background: #b8b6a8;
  border-radius: 22px 18px 20px 17px;
  color: white;
  font-size: 23px;
  transition: transform 0.2s;
}
.stone.chosen {
  outline: 2px solid #8b9680;
  outline-offset: 4px;
  transform: translateY(-3px);
}
.stone.placed {
  background: #c8c7bc;
}
.star-board {
  width: 100%;
  display: block;
  border-radius: 18px;
  background: #e6e6f3;
  touch-action: none;
  max-height: 500px;
}
.star-board line {
  stroke: #a9acc9;
  stroke-width: 3;
  pointer-events: none;
}
.star-board circle {
  fill: #fdfaff;
  stroke: #939abd;
  stroke-width: 4;
  cursor: grab;
}
.star-board circle:active {
  cursor: grabbing;
  fill: #e9dffb;
}
.sudoku-grid {
  gap: 0;
  max-width: 400px;
  padding: 9px;
  background: #e1e8d8;
  border-radius: 17px;
}
.sudoku-grid .tile {
  border-radius: 0;
  border: 1px solid #e3e9dc;
  background: #fffef8;
  color: #799367;
  font-size: 28px;
}
.sudoku-grid .tile.fixed {
  background: #f0f4e9;
  color: #6d7f5e;
  font-weight: 600;
}
.sudoku-grid .tile:nth-child(2n) {
  border-right: 3px solid #b5c6a8;
}
.sudoku-grid .tile:nth-child(4n) {
  border-right: 1px solid #e3e9dc;
}
.sudoku-grid .tile:nth-child(n + 5):nth-child(-n + 8) {
  border-bottom: 3px solid #b5c6a8;
}
.sudoku-grid .tile.chosen {
  box-shadow: inset 0 0 0 3px #96ae82;
}
.sudoku-grid .tile.invalid {
  color: #bd8679;
  background: #f6e8e2;
}
.number-button {
  min-width: 46px;
  font-size: 20px;
}
.rain-grid {
  max-width: 400px;
  gap: 18px;
}
.rain-grid .tile {
  border-radius: 29px;
  background: var(--note-color);
  color: #ffffffc7;
  font-size: 35px;
}
.rain-grid .tile:disabled {
  opacity: 0.85;
}
.rain-grid .tile.sounding {
  background: #fffdf6;
  box-shadow:
    inset 0 0 0 5px var(--note-color),
    0 0 22px #ffffffaa;
  color: var(--game-ink);
  transform: scale(0.96);
}
.luma-controls {
  display: flex;
  width: 100%;
  gap: 10px;
  max-width: 600px;
}
.luma-controls button {
  flex: 1;
  background: #eeedf5;
  border: 1px solid #e1deef;
  border-radius: 13px;
  padding: 9px 3px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  touch-action: manipulation;
}
.luma-controls b {
  font-size: 24px;
  font-weight: 400;
  color: #8b7ca6;
}
.luma-controls span {
  font-size: 11px;
  color: #9589a7;
}
.luma-controls button:active {
  background: #dcd6ed;
}
.direction-button {
  min-width: 44px;
  font-size: 20px;
}
#modal {
  padding: 27px;
  width: min(470px, calc(100% - 28px));
  border: 1px solid var(--line);
  border-radius: 25px;
  background: var(--paper);
  color: var(--ink);
  max-height: 90dvh;
  box-shadow: 0 24px 100px #1c3c3529;
}
#modal::backdrop {
  background: #243b3447;
  backdrop-filter: blur(5px);
}
.maze-grid {
  gap: 0;
  background: #eef1e1;
  max-width: 480px;
  border: 2px solid #93a67d;
  border-radius: 5px;
  overflow: hidden;
}
.maze-grid .tile {
  border-style: solid;
  border-color: #99ab82;
  border-radius: 0;
  color: #708558;
  background: #f5f6e9;
  font-size: clamp(12px, 3vw, 23px);
  min-width: 0;
}
.maze-grid .tile.trail {
  background: #e8eed8;
}
.maze-grid .tile.current {
  color: #5c794a;
}
.maze-grid .tile.hinted {
  box-shadow: none;
  background: #f3e9b6;
}
.line-grid .tile.inactive {
  visibility: hidden;
}
.column-clue {
  white-space: pre-line;
  line-height: 1.2;
  font-size: 13px;
  padding: 6px 0;
}
.star-board {
  touch-action: none;
}
.star-board circle:focus-visible {
  stroke: #fff3c6;
  stroke-width: 5;
  outline: 0;
}
.rain-grid .tile {
  background: var(--note-color);
  color: white;
}
.rain-grid .tile.sounding {
  background: #fff3bf;
  box-shadow: 0 0 0 5px #cbb982 inset;
  transform: scale(0.96);
}
.luma-controls {
  width: 100%;
  margin-bottom: 8px;
}
.balance-scene {
  --tilt: 0deg;
}
.dew-grid .tile {
  color: #ffffffd9;
}
.tile-grid {
  width: 100%;
}
.line-grid .tile:disabled {
  opacity: 1;
}
.nonogram .column-clue {
  min-height: 76px;
}
.game-tools .color-choice {
  color: #fff;
  min-width: 44px;
  min-height: 44px;
}
.game-tools .number-button {
  min-width: 44px;
}
.river-grid .tile {
  color: #9ebcaf;
}
.river-grid .tile.flowing {
  color: #4e9386;
}
@media (max-width: 600px) {
  .tile-grid {
    gap: 7px;
  }
  .moon-grid {
    padding: 12px;
    gap: 8px;
  }
  .moon-grid .tile {
    border-radius: 12px;
  }
  .river-grid {
    gap: 3px;
    padding: 6px;
  }
  .memory-grid .tile {
    font-size: 22px;
  }
  .line-grid,
  .maze-grid {
    gap: 0;
  }
  .dew-grid {
    gap: 4px;
  }
  .dew-grid .tile {
    font-size: 12px;
    border-radius: 6px;
  }
  .nonogram {
    gap: 4px;
  }
  .nonogram .row-clue {
    font-size: 11px;
    letter-spacing: 1px;
    padding-right: 4px;
  }
  .nonogram .column-clue {
    font-size: 12px;
    min-height: 62px;
  }
  .balance-scene {
    height: 300px;
    padding: 0 14px;
  }
  .balance-slots {
    left: 6%;
    width: 88%;
  }
  .balance-slot > span {
    height: 40px;
    font-size: 19px;
  }
  .balance-slot small {
    font-size: 10px;
  }
  .stone-tray {
    bottom: 18px;
  }
  .luma-controls {
    gap: 5px;
  }
  .luma-controls button {
    padding: 9px 4px;
  }
  .luma-controls b {
    font-size: 20px;
  }
  .luma-controls span {
    font-size: 10px;
  }
  .tile-grid.sudoku-grid {
    gap: 0;
  }
  .sudoku-grid .tile {
    font-size: 24px;
  }
  .rain-grid {
    gap: 12px;
  }
  .rain-grid .tile {
    font-size: 34px;
  }
  .line-grid .tile.visited:before {
    width: 28px;
    height: 28px;
    left: calc(50% - 14px);
    top: calc(50% - 14px);
  }
}
