:root {
  color-scheme: light;
  font-family: ui-rounded, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  color: #29214e;
  background: #f7f5ff;
  font-synthesis: none;
  --purple: #6845d8;
  --muted: #625879;
  --line: #e7dff7;
}

*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; background: radial-gradient(ellipse at 87% 0%, #eee6ff, transparent 50%), #f7f5ff; }
button { font: inherit; color: inherit; cursor: pointer; -webkit-tap-highlight-color: transparent; }
button:focus-visible { outline: 3px solid #6845d8; outline-offset: 3px; }
button:disabled { cursor: default; opacity: .55; }
[hidden] { display: none !important; }

.top, main { width: min(1220px, 100% - 72px); margin-inline: auto; }
.top { display: flex; align-items: center; justify-content: space-between; padding-block: 24px; border-bottom: 1px solid #e5dcf6; }
.brand { display: flex; align-items: center; gap: 12px; font-size: 21px; font-weight: 850; }
.logo { width: 45px; height: 45px; border-radius: 14px; background: #6e49e4; box-shadow: 0 3px #4e31b4; display: grid; grid-template-columns: repeat(2, 10px); grid-template-rows: repeat(2, 10px); place-content: center; gap: 3px; transform: rotate(-7deg); }
.logo i { border-radius: 2px; background: #fff4aa; }
.logo i:nth-child(2) { background: #ff9a7e; clip-path: polygon(50% 0, 100% 100%, 0 100%); }
.logo i:nth-child(3) { background: #b5f2d2; border-radius: 50%; }
.logo i:nth-child(4) { background: #e3d5ff; }
.quiet { display: inline-flex; align-items: center; gap: 8px; padding: 8px 15px; min-height: 44px; border: 1px solid var(--line); background: white; border-radius: 14px; font-size: 15px; font-weight: 750; }
.quiet span:first-child { color: var(--purple); font-size: 22px; line-height: 1; }

main { padding-block: 29px 35px; }
.intro { display: flex; align-items: end; justify-content: space-between; gap: 16px; margin-bottom: 23px; }
h1, h2, p { margin: 0; }
h1 { font-size: clamp(34px, 4.6vw, 58px); line-height: 1.12; font-weight: 900; letter-spacing: -.06em; }
h1 span { color: #8054ea; }
.intro p { color: var(--muted); font-size: 16px; margin-top: 11px; }
.modes { display: flex; justify-content: center; gap: 5px; border: 1px solid var(--line); border-radius: 18px; background: #ede6fa; padding: 5px; flex: none; }
.modes button { border: 0; border-radius: 12px; background: transparent; min-height: 45px; padding: 7px 16px; font-size: 16px; font-weight: 800; white-space: nowrap; }
.modes [aria-pressed="true"] { background: var(--purple); color: #fff; box-shadow: 0 2px #4d2eac; }

.playroom { display: grid; grid-template-columns: 222px minmax(0, 1fr); align-items: start; gap: 18px; }
.tray, .game { background: white; border: 1px solid var(--line); border-radius: 26px; box-shadow: 0 7px 24px #412b7710; }
.tray { padding: 20px 15px 16px; }
h2 { font-size: 18px; font-weight: 850; }
.tray h2, .tray > p { padding-inline: 4px; }
.tray > p { font-size: 14px; color: var(--muted); margin-top: 6px; }
.shapes { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; margin-top: 16px; }
.shapes button { --card: #eafaf1; border: 1px solid transparent; border-radius: 15px; min-height: 99px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 9px; background: var(--card); font-size: 14px; font-weight: 800; touch-action: none; user-select: none; }
.shapes button[data-shape="triangle"] { --card: #f1eafd; }
.shapes button[data-shape="rectangle"] { --card: #fff0ea; }
.shapes button[data-shape="circle"] { --card: #fff8df; }
.shapes button:hover { border-color: #a990e4; }
.tray .tray-tip { display: flex; align-items: center; gap: 7px; background: #f6f2fd; border-radius: 12px; padding: 9px 8px; margin-top: 13px; }
.tray-tip span:first-child { color: #6942cc; font-size: 21px; line-height: 1; }

.game { padding: 13px; }
.game-head, .game-foot { min-height: 44px; display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 0 5px; }
.game-head { margin-bottom: 9px; }
.game-title { display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.dot { width: 9px; height: 9px; background: #8054ea; border-radius: 50%; box-shadow: 0 0 0 4px #eee4fd; }
#count { font-weight: 750; font-size: 14px; color: #5735ae; background: #f0e9ff; padding: 5px 10px; border-radius: 16px; white-space: nowrap; }
.models { display: flex; gap: 4px; }
.models button { border: 1px solid transparent; background: #f7f4fd; border-radius: 10px; padding: 5px 8px; min-height: 38px; font-size: 14px; font-weight: 750; white-space: nowrap; }
.models [aria-pressed="true"] { border-color: #b49af4; background: #eee5ff; }

.board { position: relative; isolation: isolate; aspect-ratio: 800 / 500; border: 2px solid #e5daf9; border-radius: 19px; overflow: hidden; touch-action: none; background: radial-gradient(circle, #b4a4d5 1px, transparent 1.5px) 0 0 / 20px 20px, #f6f1ff; }
.board-art { position: absolute; inset: 0; color: #a582ef; pointer-events: none; }
.board-art span { position: absolute; font-size: clamp(14px, 2.7vw, 34px); }
.board-art span:nth-child(1) { left: 10%; top: 14%; }
.board-art span:nth-child(2) { right: 12%; top: 19%; color: #c5a4ff; }
.board-art span:nth-child(3) { right: 10%; bottom: 15%; }
.board-art span:nth-child(4) { left: 13%; bottom: 12%; color: #c5a4ff; }
.shape { --fill: #66dcb1; --edge: #238e76; --shine: #a3f0d3; --face: inset(0 round 10%); position: relative; display: block; flex: none; }
.shape::before, .shape::after { content: ""; position: absolute; pointer-events: none; clip-path: var(--face); }
.shape::before { inset: 0; background: var(--edge); }
.shape::after { inset: 6% 6% 10%; background: linear-gradient(145deg, var(--shine), var(--fill) 66%); }
.triangle { --fill: #a781f2; --edge: #6945c9; --shine: #d5baff; --face: polygon(50% 0, 100% 100%, 0 100%); }
.triangle::after { inset: 13% 9% 8%; }
.rectangle { --fill: #ff9d83; --edge: #c45447; --shine: #ffc3ab; --face: inset(0 round 6% / 12%); }
.rectangle::after { inset-inline: 3%; }
.circle { --fill: #ffd570; --edge: #b77a25; --shine: #fff0a2; --face: circle(50%); }
.tile-icon { width: 34px; height: 34px; }
.tile-icon.triangle { height: 30px; }
.tile-icon.rectangle { width: 56px; height: 28px; }
.piece, .guide { position: absolute; padding: 0; border: 0; background: transparent; margin: 0; translate: -50% -50%; }
.piece { touch-action: none; cursor: grab; filter: drop-shadow(0 3px 1px #39265a27); }
.piece:active { cursor: grabbing; }
.piece.selected { filter: drop-shadow(0 0 2px #4b219f) drop-shadow(0 0 5px #a06aff); }
.piece:focus-visible { outline-offset: 3px; }
.guide::before { background: var(--edge); opacity: .47; }
.guide::after { background: var(--shine); opacity: .74; }
.celebration { position: absolute; z-index: 3; top: 7%; left: 50%; translate: -50%; padding: 8px 18px; border: 2px solid #e8b55a; border-radius: 20px; background: #fff4c6; color: #6c421c; font-size: clamp(17px, 2.5vw, 24px); font-weight: 850; white-space: nowrap; pointer-events: none; }
.game-foot { margin-top: 9px; }
.game-foot p { color: var(--muted); font-size: 14px; }
.actions { display: flex; gap: 5px; }
.actions button { min-height: 42px; border: 1px solid var(--line); border-radius: 11px; background: #f8f4ff; padding: 4px 9px; font-weight: 750; font-size: 14px; white-space: nowrap; }
.actions button span { color: var(--purple); font-size: 17px; }
.actions button:hover:not(:disabled), .quiet:hover { background: #eee5ff; }

@media (min-width: 851px) {
  .top, main { max-width: max(850px, calc(266px + (100svh - 364px) * 1.6)); }
}
@media (min-width: 851px) and (max-height: 820px) {
  .top { padding-block: 14px; }
  main { padding-top: 19px; }
  .intro { margin-bottom: 16px; }
  h1 { font-size: clamp(34px, 4.6vw, 48px); }
}
@media (max-width: 850px) {
  .top, main { width: calc(100% - 36px); }
  .playroom { grid-template-columns: 172px minmax(0, 1fr); gap: 12px; }
  .tray { padding-inline: 11px; }
  .game-foot { flex-wrap: wrap; }
}
@media (max-width: 650px) {
  .top, main { width: calc(100% - 20px); }
  .top { padding: 10px 3px; }
  .brand { font-size: 18px; }
  .logo { width: 36px; height: 36px; }
  main { padding-block: 16px 14px; }
  .intro { align-items: start; flex-direction: column; gap: 11px; margin: 0 2px 12px; }
  .intro p { font-size: 14px; margin-top: 5px; }
  .modes { align-self: stretch; }
  .modes button { flex: 1; min-height: 41px; }
  .playroom { grid-template-columns: 1fr; gap: 9px; }
  .tray, .game { border-radius: 18px; }
  .tray { display: grid; grid-template-columns: auto 1fr; align-items: center; gap: 5px; padding: 7px; }
  .tray > p { text-align: right; margin: 0; }
  .tray .tray-tip { display: none; }
  .shapes { grid-column: 1 / -1; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 5px; margin: 0; }
  .shapes button { min-height: 63px; gap: 4px; border-radius: 10px; }
  .tile-icon { width: 23px; height: 23px; }
  .tile-icon.triangle { height: 20px; }
  .tile-icon.rectangle { width: 34px; height: 17px; }
  .game { padding: 6px; }
  .game-head, .game-foot { padding-inline: 3px; }
  .game-head { flex-wrap: wrap; }
  .models { order: 3; flex-basis: 100%; }
  .models button { flex: 1; }
  .board { border-radius: 14px; background-size: 15px 15px; }
  .game-foot { justify-content: center; }
  .game-foot p { width: 100%; text-align: center; }
  .actions { width: 100%; justify-content: center; }
  .actions button { flex: 1; padding-inline: 5px; }
}
