:root {
  color-scheme: light;
  --paper: #faf8f0;
  --ink: #776e65;
  --muted: #a49a8f;
  --board: #bbada0;
  --slot: #cdc1b4;
  --line: #e8e1d5;
  --accent: #edc22e;
  --radius: 16px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
  font-synthesis: none;
  -webkit-font-smoothing: antialiased;
}

*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; background: var(--paper); color: var(--ink); min-height: 100svh; }
[hidden] { display: none !important; }
button, input { font: inherit; }
button, a, input { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
a { color: inherit; text-decoration: none; }
button, input, a { outline-offset: 5px; }
:focus-visible { outline: 3px solid #bf9228; }
button:disabled { opacity: .45; cursor: not-allowed; transform: none; }
button svg { width: 19px; height: 19px; flex-shrink: 0; }
h1, h2, p { margin: 0; }
::selection { background: #edcc61; color: #514a42; }

.site-header {
  max-width: 1080px;
  min-height: 100px;
  margin: 0 auto;
  padding: 24px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 16px; border-radius: 4px; }
.brand-mark { font-size: 29px; font-weight: 850; letter-spacing: -1.5px; line-height: 1; }
.brand-note { font-size: 9px; font-weight: 700; letter-spacing: 2px; padding-left: 16px; border-left: 1px solid #d8cfc1; }
.header-actions { display: flex; gap: 8px; align-items: center; min-width: 0; }
.button {
  min-height: 46px;
  padding: 12px 22px;
  display: inline-flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
  border: 1px solid transparent;
  border-radius: 9px;
  font-size: 14px;
  font-weight: 650;
  line-height: 1.4;
  text-decoration: none;
  transition: background-color 160ms, color 160ms, border-color 160ms, box-shadow 160ms, transform 160ms;
}
.button:hover:not(:disabled) { transform: translateY(-1px); }
.button:active:not(:disabled) { transform: translateY(0); }
.button-primary { background: #8f7a66; color: #fffaf3; box-shadow: 0 3px 0 #796550; }
.button-primary:hover:not(:disabled) { background: #7c6958; box-shadow: 0 4px 0 #695747; }
.button-secondary { background: #f0ebe1; color: var(--ink); border-color: #e6ddd0; }
.button-secondary:hover:not(:disabled) { background: #e9e1d4; border-color: #d9cbb9; }
.button-quiet { background: transparent; color: var(--ink); padding: 9px 12px; min-height: 40px; font-size: 12px; }
.button-quiet:hover:not(:disabled) { background: #eee8dc; }
.button-link { background: transparent; color: var(--ink); padding: 10px 0; min-height: 36px; }
.button-link:hover:not(:disabled) { color: #4e443a; }
.button-wide { width: 100%; justify-content: space-between; }
.button-small { min-height: 38px; padding: 8px 14px; font-size: 12px; border-radius: 7px; }
.identity-button { max-width: 180px; }
.identity-button span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

main { max-width: 1080px; margin: 0 auto; padding: 0 24px; }
.screen { padding: 68px 0 76px; }
.welcome-screen, .home-screen { display: grid; grid-template-columns: 1fr 1fr; gap: 70px; align-items: center; min-height: 680px; }
.eyebrow { display: inline-flex; gap: 8px; align-items: center; font-size: 10px; font-weight: 700; letter-spacing: 1.6px; line-height: 1.8; text-transform: uppercase; }
.tiny-square { width: 7px; height: 7px; background: var(--accent); border-radius: 2px; flex-shrink: 0; }
.welcome-copy h1, .home-copy h1 { margin: 26px 0 24px; font-size: clamp(40px, 4.4vw, 56px); font-weight: 800; line-height: 1.32; letter-spacing: -2.5px; }
.number-highlight { color: #be922e; font-variant-numeric: lining-nums; }
.lead { font-size: 15px; line-height: 1.95; color: #92867a; }
.welcome-detail { display: flex; align-items: center; gap: 14px; margin-top: 42px; font-size: 11px; color: var(--muted); letter-spacing: 1px; }
.detail-line { width: 32px; height: 1px; background: #cbbfae; }
.name-card {
  padding: 38px;
  border: 1px solid #e8dfd1;
  border-radius: 20px;
  background: #fffdf7;
  box-shadow: 0 16px 48px -24px #8f7a663d, 0 2px 8px #776e6503;
}
.card-kicker, .dialog-kicker { font-size: 9px; letter-spacing: 2px; font-weight: 750; color: var(--muted); }
.name-symbol { display: inline-flex; align-items: center; gap: 13px; margin: 27px 0; color: #b29a7c; font-size: 46px; font-weight: 800; letter-spacing: -2px; }
.name-symbol span { font-size: 24px; font-weight: 400; color: #c9bdaa; }
.name-card h2 { font-size: 25px; font-weight: 750; letter-spacing: -.8px; }
.card-description { margin-top: 12px; font-size: 12px; line-height: 1.9; color: #a09384; }
#name-form { margin-top: 29px; }
#name-form label { display: flex; justify-content: space-between; gap: 8px; font-size: 11px; font-weight: 650; margin-bottom: 10px; }
#name-form label span { color: #b0a496; font-size: 10px; font-weight: 400; }
#nickname { width: 100%; min-height: 50px; border: 1px solid #ded4c5; border-radius: 8px; background: #faf8f0; color: var(--ink); padding: 13px 15px; font-size: 14px; transition: border-color 160ms, box-shadow 160ms; }
#nickname::placeholder { color: #b4a99b; }
#nickname:focus { border-color: #b79b64; box-shadow: 0 0 0 3px #edc22e1a; }
#nickname[aria-invalid="true"] { border-color: #c7775c; }
.form-error { min-height: 25px; font-size: 11px; line-height: 1.6; color: #b5654a; padding: 5px 0; overflow-wrap: anywhere; }
.card-footnote { text-align: center; font-size: 10px; color: #b2a797; margin-top: 21px; }

.home-screen { grid-template-columns: 1fr 440px; gap: 68px; }
.home-copy .eyebrow { letter-spacing: .8px; flex-wrap: wrap; }
#home-player { max-width: 200px; overflow-wrap: anywhere; }
.home-actions { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 30px; align-items: center; }
.home-actions .button-primary { min-width: 170px; justify-content: space-between; }
.home-actions .button-link { padding-left: 4px; padding-right: 4px; }
.home-note { display: flex; align-items: center; gap: 7px; margin-top: 29px; font-size: 10px; letter-spacing: .5px; color: #ac9f8f; }
.note-dot { width: 5px; height: 5px; background: #baa985; border-radius: 50%; flex-shrink: 0; }
.home-preview { width: 100%; }
.preview-heading { display: flex; justify-content: space-between; gap: 10px; margin-bottom: 15px; font-size: 8px; font-weight: 750; letter-spacing: 1.6px; color: #a79b8b; }
.preview-board { display: grid; grid-template-columns: repeat(4, 1fr); grid-template-rows: repeat(4, 1fr); gap: 10px; padding: 12px; background: var(--board); aspect-ratio: 1; border-radius: 14px; box-shadow: 0 16px 38px -24px #776e6573; }
.preview-cell { display: flex; justify-content: center; align-items: center; min-width: 0; background: var(--slot); border-radius: 7px; font-size: 41px; font-weight: 800; letter-spacing: -1.5px; }
.preview-v-2 { background: #eee4da; }
.preview-v-4 { background: #ede0c8; }
.preview-v-8 { background: #f2b179; color: #f9f6f2; }
.preview-v-16 { background: #f59563; color: #f9f6f2; }
.preview-v-32 { background: #f67c5f; color: #f9f6f2; }
.preview-v-64 { background: #f65e3b; color: #f9f6f2; }
.preview-v-128 { background: #edcf72; color: #f9f6f2; font-size: 34px; }
.preview-v-256 { background: #edcc61; color: #f9f6f2; font-size: 34px; }
.preview-v-512 { background: #edc850; color: #f9f6f2; font-size: 34px; }
.preview-caption { display: flex; align-items: center; justify-content: center; gap: 15px; margin-top: 25px; color: #a79b8b; font-size: 10px; letter-spacing: 2px; }
.caption-line { width: 28px; height: 1px; background: #ddd2c2; }

.game-screen { width: 100%; max-width: 520px; margin: 0 auto; padding-top: 29px; padding-bottom: 46px; }
.game-topline, .ranking-topline { display: flex; align-items: center; justify-content: space-between; gap: 18px; }
.back-button { font-size: 11px; gap: 9px; }
.player-chip { display: inline-flex; align-items: center; gap: 7px; min-width: 0; max-width: 55%; padding: 6px 11px; border-radius: 20px; background: #f0ebe1; font-size: 10px; }
#player-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.game-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-top: 21px; }
.game-heading h1 { font-size: 64px; font-weight: 850; letter-spacing: -4px; line-height: 1.05; }
.title-dot { color: #c5a04a; }
.game-heading p { font-size: 11px; margin-top: 9px; color: #a19587; }
.scorecards { display: flex; gap: 9px; }
.score-card { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; min-width: 95px; min-height: 72px; padding: 11px 15px; border-radius: 9px; background: #eae3d7; }
.current-score { background: #bbada0; color: #fffaf3; }
.score-label { font-size: 9px; font-weight: 700; letter-spacing: 1px; white-space: nowrap; }
.score-card strong { font-size: 24px; font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1; }
#gain { position: absolute; top: 24px; right: 13px; font-size: 21px; font-weight: 800; color: #8f7a66; z-index: 8; pointer-events: none; }
#gain.animate, #gain.show, #gain.active { animation: score-gain 700ms ease-out both; }
.game-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 25px; margin-bottom: 16px; }
.moves-counter { font-size: 11px; color: #a29687; white-space: nowrap; }
.moves-counter strong { color: var(--ink); padding: 0 3px; font-variant-numeric: tabular-nums; }
.toolbar-actions { display: flex; gap: 9px; }
.button-small svg { width: 15px; height: 15px; }
#game-board {
  --gap: 12px;
  position: relative;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  grid-template-rows: repeat(4, minmax(0, 1fr));
  width: 100%;
  aspect-ratio: 1;
  gap: 12px;
  padding: 14px;
  border-radius: 14px;
  background: var(--board);
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  overflow: visible;
  isolation: isolate;
}
#game-board:focus-visible { outline-offset: 7px; }
.empty-cell { min-width: 0; min-height: 0; border-radius: 7px; background: var(--slot); }
#tile-layer { --cell-size: calc((100% - 3 * var(--gap)) / 4); position: absolute; inset: 0; z-index: 1; pointer-events: none; overflow: visible; }
.tile {
  position: absolute;
  top: 0;
  left: 0;
  width: var(--cell-size);
  height: var(--cell-size);
  transition: transform 130ms ease-in-out;
  will-change: transform;
  z-index: 1;
}
.tile-face { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; border-radius: 7px; background: var(--tile-color, #3c3a32); color: var(--tile-ink, #f9f6f2); font-size: clamp(30px, 6.5vw, 51px); font-weight: 800; line-height: 1; letter-spacing: -1.5px; font-variant-numeric: tabular-nums; }
.tile-v-2 { --tile-color: #eee4da; --tile-ink: #776e65; }
.tile-v-4 { --tile-color: #ede0c8; --tile-ink: #776e65; }
.tile-v-8 { --tile-color: #f2b179; }
.tile-v-16 { --tile-color: #f59563; }
.tile-v-32 { --tile-color: #f67c5f; }
.tile-v-64 { --tile-color: #f65e3b; }
.tile-v-128 { --tile-color: #edcf72; }
.tile-v-256 { --tile-color: #edcc61; }
.tile-v-512 { --tile-color: #edc850; }
.tile-v-1024 { --tile-color: #edc53f; }
.tile-v-2048 { --tile-color: #edc22e; }
.tile-v-4096 { --tile-color: #3c3a32; }
:is(.tile-v-128, .tile-v-256, .tile-v-512) .tile-face,
.tile-face:is(.tile-v-128, .tile-v-256, .tile-v-512) { font-size: clamp(25px, 5.5vw, 42px); }
:is(.tile-v-1024, .tile-v-2048, .tile-v-4096) .tile-face,
.tile-face:is(.tile-v-1024, .tile-v-2048, .tile-v-4096) { font-size: clamp(19px, 4.4vw, 33px); letter-spacing: -1px; }
.tile-v-2048 .tile-face, .tile-face.tile-v-2048 { box-shadow: 0 0 24px 3px #edc22e4d, inset 0 0 0 1px #ffe89870; }
.tile-face.merge { animation: bounce 280ms ease-out both; }
.tile-face.spawn { animation: spawn 180ms ease-out both; }
.tile:has(.merge) { z-index: 2; }
#fx-layer { position: absolute; inset: 0; z-index: 3; pointer-events: none; overflow: visible; }
.particle { position: absolute; width: 7px; height: 7px; border-radius: 2px; background: #edc22e; pointer-events: none; animation: particle 560ms cubic-bezier(.15,.6,.35,1) forwards; }
.game-overlay { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; padding: 25px; border-radius: 14px; background: #faf8f0dc; backdrop-filter: blur(5px); -webkit-backdrop-filter: blur(5px); z-index: 5; }
.overlay-card { width: 100%; text-align: center; }
.overlay-card .eyebrow { color: #ab9671; font-size: 9px; letter-spacing: 2px; }
.overlay-card h2 { font-size: clamp(29px, 7vw, 42px); margin: 16px 0 13px; font-weight: 800; letter-spacing: -1px; }
.overlay-card p { font-size: 13px; line-height: 1.8; max-width: 330px; margin: 0 auto; overflow-wrap: anywhere; }
.overlay-actions { display: flex; align-items: center; justify-content: center; gap: 12px; margin-top: 26px; flex-wrap: wrap; }
.overlay-actions .button-link { flex-basis: 100%; font-size: 11px; }
.save-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-top: 14px; }
#save-status { font-size: 10px; color: #a29585; line-height: 1.6; overflow-wrap: anywhere; }
#save-button { flex-shrink: 0; font-size: 11px; }
.game-help { margin-top: 26px; border-top: 1px solid var(--line); padding-top: 21px; }
.help-label { font-size: 9px; font-weight: 750; letter-spacing: 2px; color: #a99b88; margin-bottom: 12px; }
.game-help p { font-size: 11px; line-height: 2; color: #a09587; }
.game-help p + p { margin-top: 5px; }
.game-help strong { font-weight: 650; color: #8f8170; }
kbd { display: inline-flex; align-items: center; justify-content: center; min-width: 19px; height: 21px; margin-right: 3px; border: 1px solid #ded4c6; border-bottom-width: 2px; background: #f4efe5; border-radius: 4px; font-size: 11px; font-family: inherit; color: #958371; vertical-align: middle; }

.leaderboard-screen { max-width: 850px; margin: 0 auto; padding-top: 30px; min-height: 670px; }
.ranking-topline .eyebrow { color: #b0a18c; font-size: 8px; letter-spacing: 1.8px; }
.ranking-heading { display: flex; justify-content: space-between; align-items: flex-end; gap: 24px; margin: 32px 0; }
.ranking-heading h1 { font-size: 37px; font-weight: 800; letter-spacing: -1.4px; line-height: 1.45; }
#ranking-subtitle { margin-top: 15px; font-size: 11px; color: #a79a88; line-height: 1.7; }
#refresh-ranking { font-size: 11px; min-height: 39px; padding: 10px 15px; flex-shrink: 0; }
#refresh-ranking svg { width: 15px; height: 15px; }
.ranking-table { border: 1px solid #e7ddce; border-radius: 12px; background: #fffdf7; overflow: hidden; }
.ranking-row { display: grid; grid-template-columns: 65px minmax(0, 1fr) minmax(80px, .65fr) 150px; align-items: center; gap: 15px; padding: 20px 25px; border-bottom: 1px solid #efe7dc; font-size: 13px; min-width: 0; }
#ranking-list .ranking-row:last-child { border-bottom: 0; }
#ranking-list .ranking-row:hover { background: #faf6ec; }
.ranking-head { background: #f0eadf; font-size: 10px; font-weight: 700; color: #a19380; letter-spacing: 1px; padding-top: 15px; padding-bottom: 15px; }
.rank-number { font-variant-numeric: tabular-nums; font-weight: 750; }
#ranking-list .ranking-row:nth-child(-n+3) .rank-number { color: #b18c3c; }
#ranking-list .ranking-row:first-child .rank-number { color: #b58b26; }
.ranking-name { min-width: 0; overflow-wrap: anywhere; font-weight: 650; }
.ranking-score { text-align: right; font-weight: 800; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.ranking-date { text-align: right; font-size: 10px; color: #ab9e8d; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.ranking-message { padding: 47px 25px; text-align: center; }
.empty-ranking-mark { display: block; font-size: 34px; font-weight: 300; color: #d1c3aa; margin-bottom: 16px; }
.ranking-message h2 { font-size: 17px; font-weight: 700; margin-bottom: 11px; }
.ranking-message p { font-size: 11px; color: #a79a89; line-height: 1.8; }
.ranking-error { color: #b5654a; font-size: 12px; line-height: 1.8; }
.my-rank-card { position: relative; margin-top: 20px; padding: 22px 26px; padding-right: 65px; background: #efe8d8; border: 1px solid #e6dcc7; border-radius: 12px; }
.my-rank-card .eyebrow { font-size: 9px; letter-spacing: 1.5px; color: #ac9671; }
#my-rank { font-size: 12px; line-height: 1.8; margin-top: 6px; overflow-wrap: anywhere; }
.my-rank-decoration { position: absolute; top: 26px; right: 25px; font-size: 26px; color: #bda880; }
.ranking-note { text-align: center; font-size: 10px; color: #b0a28f; line-height: 1.8; margin-top: 24px; }

.site-footer { display: flex; align-items: center; justify-content: space-between; gap: 15px; max-width: 1032px; margin: 0 auto; padding: 23px 0 28px; border-top: 1px solid var(--line); font-size: 9px; line-height: 1.8; color: #b3a897; letter-spacing: .4px; }
.site-footer span { font-size: 8px; letter-spacing: .7px; }
.toast { position: fixed; z-index: 30; left: 50%; bottom: max(30px, env(safe-area-inset-bottom)); transform: translateX(-50%); max-width: calc(100vw - 40px); width: max-content; padding: 13px 22px; border-radius: 10px; background: #776e65; color: #fffaf3; box-shadow: 0 8px 25px #51453726; font-size: 12px; line-height: 1.7; text-align: center; pointer-events: none; overflow-wrap: anywhere; }
.toast { opacity: 0; visibility: hidden; transition: opacity 160ms, visibility 160ms; }
.toast.visible { opacity: 1; visibility: visible; }
.toast:empty { display: none; }
.tile-super .tile-face { font-size: clamp(16px, 3.4vw, 28px); letter-spacing: -1px; }
.ranking-row.is-me { background: #f6efda; }
@media (max-width: 650px) { .welcome-copy .lead, .welcome-detail { display: none; } .welcome-screen { gap: 24px; } }
#confirm-dialog { width: min(420px, calc(100vw - 40px)); padding: 30px; border: 1px solid #e4d8c6; border-radius: 16px; background: #fffdf7; color: var(--ink); box-shadow: 0 22px 90px #51453724; }
#confirm-dialog:not([open]) { display: none; }
#confirm-dialog::backdrop { background: #54483d55; backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); }
#confirm-title { font-size: 24px; font-weight: 750; margin-top: 18px; }
#confirm-text { font-size: 12px; line-height: 1.9; margin-top: 13px; color: #a29585; overflow-wrap: anywhere; }
.dialog-actions { display: flex; gap: 11px; justify-content: flex-end; margin-top: 27px; }
.dialog-actions .button { min-height: 41px; font-size: 12px; }

@keyframes bounce { 0% { transform: scale(1); } 38% { transform: scale(1.16); } 68% { transform: scale(.97); } 100% { transform: scale(1); } }
@keyframes spawn { 0% { opacity: 0; transform: scale(.55); } 100% { opacity: 1; transform: scale(1); } }
@keyframes particle { 0% { opacity: 1; transform: translate(0, 0) scale(1) rotate(0deg); } 100% { opacity: 0; transform: translate(var(--dx, 0px), var(--dy, -60px)) scale(.25) rotate(150deg); } }
@keyframes score-gain { 0% { opacity: 1; transform: translateY(0); } 100% { opacity: 0; transform: translateY(-42px); } }

@media (min-width: 1200px) {
  .welcome-screen, .home-screen { min-height: 710px; }
}
@media (max-width: 900px) {
  .welcome-screen, .home-screen { gap: 34px; grid-template-columns: 1fr 1fr; }
  .name-card { padding: 28px; }
  .welcome-copy h1, .home-copy h1 { font-size: 43px; }
  .preview-cell { font-size: 34px; }
  :is(.preview-v-128, .preview-v-256, .preview-v-512) { font-size: 27px; }
  .preview-heading { font-size: 7px; letter-spacing: 1px; }
  .site-footer { margin-left: 24px; margin-right: 24px; }
}
@media (max-width: 650px) {
  .site-header { min-height: 77px; padding: 19px 20px; gap: 12px; }
  .brand-mark { font-size: 26px; }
  .brand-note { display: none; }
  .header-actions { gap: 1px; }
  .button-quiet { font-size: 11px; padding: 8px 9px; min-height: 36px; gap: 6px; }
  .button-quiet svg { width: 17px; height: 17px; }
  .identity-button { max-width: 145px; }
  main { padding: 0 20px; }
  .screen { padding-top: 35px; padding-bottom: 42px; }
  .welcome-screen, .home-screen { display: grid; grid-template-columns: minmax(0, 1fr); gap: 35px; min-height: auto; max-width: 440px; margin: 0 auto; }
  .welcome-copy h1, .home-copy h1 { font-size: 43px; line-height: 1.25; letter-spacing: -1.8px; margin-top: 20px; margin-bottom: 17px; }
  .welcome-copy h1 br:nth-of-type(2), .home-copy h1 br:nth-of-type(2) { display: none; }
  .eyebrow { font-size: 9px; letter-spacing: 1px; }
  .lead { font-size: 13px; line-height: 1.8; }
  .welcome-detail { margin-top: 20px; font-size: 10px; }
  .name-card { padding: 27px; border-radius: 15px; }
  .name-symbol { font-size: 36px; margin: 17px 0; }
  .name-card h2 { font-size: 23px; }
  .card-description { font-size: 11px; }
  #name-form { margin-top: 23px; }
  #nickname { font-size: 16px; }
  .home-actions { margin-top: 23px; gap: 11px; }
  .home-note { margin-top: 23px; font-size: 9px; }
  .home-preview { max-width: 400px; margin: 2px auto 0; }
  .preview-cell { font-size: clamp(26px, 8vw, 39px); }
  :is(.preview-v-128, .preview-v-256, .preview-v-512) { font-size: clamp(23px, 6.5vw, 31px); }
  .preview-caption { margin-top: 19px; }
  .game-screen { padding-top: 17px; }
  .game-heading { margin-top: 15px; gap: 10px; }
  .game-heading h1 { font-size: 56px; letter-spacing: -3px; }
  .game-heading p { font-size: 10px; }
  .scorecards { gap: 7px; }
  .score-card { min-width: 78px; min-height: 66px; padding: 10px 12px; }
  .score-card strong { font-size: 21px; }
  .score-label { font-size: 8px; letter-spacing: .7px; }
  .game-toolbar { margin-top: 22px; margin-bottom: 14px; }
  .game-help { margin-top: 18px; padding-top: 18px; }
  .game-help p { font-size: 10px; }
  .leaderboard-screen { min-height: 580px; padding-top: 17px; }
  .ranking-topline .eyebrow { font-size: 7px; letter-spacing: 1px; }
  .ranking-heading { align-items: flex-start; flex-direction: column; gap: 18px; margin: 27px 0 23px; }
  .ranking-heading h1 { font-size: 30px; }
  #ranking-subtitle { font-size: 10px; margin-top: 10px; }
  .ranking-row { grid-template-columns: 39px minmax(0, 1fr) minmax(65px, .6fr); gap: 6px 11px; padding: 17px 16px; font-size: 12px; }
  .ranking-date { grid-column: 2 / 4; text-align: left; font-size: 9px; }
  .ranking-head { padding: 13px 16px; font-size: 9px; }
  .ranking-head .ranking-date { display: none; }
  .my-rank-card { padding: 18px 20px; padding-right: 53px; }
  .my-rank-decoration { top: 23px; right: 20px; }
  #my-rank { font-size: 11px; }
  .ranking-message { padding: 35px 19px; }
  .ranking-message h2 { font-size: 16px; }
  .site-footer { margin: 0 20px; flex-direction: column; gap: 4px; padding: 20px 0 24px; text-align: center; }
  #confirm-dialog { padding: 25px; }
}
@media (max-width: 370px) {
  .welcome-copy h1, .home-copy h1 { font-size: 36px; }
  .name-card { padding: 23px; }
  .game-heading h1 { font-size: 45px; }
  .score-card { min-width: 67px; padding: 10px 8px; }
  .score-card strong { font-size: 19px; }
  .button-small { padding: 8px 10px; font-size: 11px; }
  .toolbar-actions { gap: 6px; }
  .moves-counter { font-size: 10px; }
  .overlay-actions { gap: 9px; margin-top: 18px; }
  .overlay-actions .button { padding: 10px 13px; font-size: 12px; }
  .overlay-card p { font-size: 11px; }
  .game-overlay { padding: 17px; }
  .ranking-heading h1 { font-size: 27px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; }
  .button, .tile, #nickname { transition: none !important; }
  .tile-face.merge, .tile-face.spawn { animation: none !important; }
  .particle { display: none; animation: none; }
  #gain.animate, #gain.show, #gain.active { animation: none; opacity: 0; }
  .button:hover:not(:disabled), .button:active:not(:disabled) { transform: none; }
}
@supports (padding: max(0px)) {
  body { padding-left: env(safe-area-inset-left); padding-right: env(safe-area-inset-right); }
  .site-header { padding-top: max(19px, env(safe-area-inset-top)); }
  .site-footer { padding-bottom: max(24px, env(safe-area-inset-bottom)); }
}
