:root { color-scheme: light; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Hiragino Kaku Gothic ProN", "Noto Sans JP", sans-serif; color: #373c37; background: #f7f5ef; }
* { box-sizing: border-box; }
body { margin: 0; min-width: 280px; }
button { font: inherit; cursor: pointer; -webkit-tap-highlight-color: transparent; }
button:focus-visible, .board:focus-visible { outline: 3px solid #247267; outline-offset: 5px; }
button { transition: background .15s, transform .15s; }
button:active { transform: translateY(2px); }
.game { width: min(100% - 40px, 460px); margin: 56px auto 28px; }
.header { display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.eyebrow { margin: 0 0 4px; font-size: 12px; font-weight: 750; letter-spacing: .16em; color: #697568; }
h1 { margin: 0; font-size: clamp(62px, 18vw, 88px); font-weight: 850; letter-spacing: -.075em; line-height: 1.08; }
h1 span { color: #db9c2f; }
.score-box { position: relative; min-width: 106px; padding: 14px 20px; text-align: center; background: #e9ede4; border: 1px solid #dce2d7; border-radius: 14px; }
.score-box > span:first-child { display: block; font-size: 12px; font-weight: 700; color: #5d6b5c; }
.score-box strong { display: block; font-size: 29px; line-height: 1.25; font-variant-numeric: tabular-nums; }
#score-gain { position: absolute; right: 12px; top: 40%; font-weight: 800; color: #267365; pointer-events: none; }
.gain { animation: gain .65s ease-out forwards; }
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 23px 0 19px; }
.toolbar p { margin: 0; font-size: 14px; }
.button { border: 0; border-radius: 9px; padding: 12px 17px; background: #3b5447; color: #fff; font-weight: 650; font-size: 14px; }
.button:hover { background: #293e32; }
.restart { white-space: nowrap; }
.restart span { font-size: 18px; margin-right: 3px; }
.board-wrap { position: relative; border-radius: 19px; }
.board { display: grid; grid-template-columns: repeat(4, 1fr); gap: 11px; padding: 13px; border-radius: 19px; background: #a9b3a3; box-shadow: 0 10px 28px #3e4c3510, inset 0 1px 0 #ffffff50; aspect-ratio: 1; touch-action: none; user-select: none; -webkit-user-select: none; }
.tile { display: flex; align-items: center; justify-content: center; border-radius: 10px; background: #c2cbbb; color: #454d3e; font-size: clamp(26px, 8vw, 43px); font-weight: 800; font-variant-numeric: tabular-nums; letter-spacing: -.035em; min-width: 0; }
.tile[data-value="2"] { background: #f1f0e6; }
.tile[data-value="4"] { background: #e6e9cc; }
.tile[data-value="8"] { background: #eed399; color: #624923; }
.tile[data-value="16"] { background: #eab775; color: #593d21; }
.tile[data-value="32"] { background: #dc915f; color: #fff; }
.tile[data-value="64"] { background: #c66b49; color: #fff; }
.tile[data-value="128"] { background: #94a365; color: #fff; }
.tile[data-value="256"] { background: #748f56; color: #fff; }
.tile[data-value="512"] { background: #507a54; color: #fff; }
.tile[data-value="1024"] { background: #38654d; color: #fff; }
.tile[data-value="2048"] { background: #e6b238; color: #403514; box-shadow: 0 0 22px #f4d27580; }
.tile.large { font-size: clamp(21px, 6.5vw, 33px); }
.tile.extra-large { font-size: clamp(17px, 5.5vw, 27px); background: #344d40; color: white; }
.board { position: relative; grid-template-rows: repeat(4, 1fr); }
.cell { position: relative; min-width: 0; min-height: 0; border-radius: 10px; background: #c2cbbb; }
.cell .tile { position: absolute; inset: 0; z-index: 1; }
.controls { display: flex; justify-content: center; gap: 9px; margin: 22px 0 26px; }
.controls button { width: 46px; height: 42px; background: #eeeee6; border: 1px solid #d9ddd2; border-radius: 8px; color: #4b5b48; font-size: 22px; }
.controls button:hover { background: #e1e6d9; }
.instructions { border-top: 1px solid #dcded5; padding-top: 21px; }
.instructions h2 { font-size: 14px; margin: 0 0 10px; }
.instructions p { font-size: 14px; line-height: 1.9; margin: 0; color: #626a60; }
.key-hint { font-weight: 750; white-space: nowrap; }
.example { display: flex; align-items: center; justify-content: center; gap: 13px; margin: 18px 0 12px; }
.example span { width: 37px; height: 37px; display: grid; place-items: center; border-radius: 7px; background: #eae8dc; font-size: 20px; font-weight: 750; }
.example .four { background: #e1e6c9; }
.example b { font-size: 14px; font-weight: 500; color: #7b8275; }
.instructions .subtle { text-align: center; font-size: 13px; }
footer { margin-top: 25px; text-align: center; color: #7c8377; font-size: 12px; }
.game-mode { text-align: center; color: #586750; font-size: 13px; margin: 12px 0 0; }
.account-panel, .ranking { margin-bottom: 26px; padding: 20px; border: 1px solid #dce2d7; border-radius: 14px; background: #f0f1e9; }
.account-heading, .ranking-heading { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.account-heading span { font-size: 14px; }
.account-panel p, .ranking p { font-size: 14px; line-height: 1.7; color: #626a60; }
.google-button { background: white; color: #303b33; border: 1px solid #b9c4b4; }
.google-button:hover { background: #e4e9de; }
.text-button { border: 0; background: transparent; color: #365f49; text-decoration: underline; font-size: 14px; padding: 8px; }
#profile-form label { display: block; font-size: 14px; margin: 12px 0 8px; }
.name-input { display: flex; gap: 8px; }
.name-input input { min-width: 0; width: 100%; padding: 10px; border: 1px solid #b9c4b4; border-radius: 8px; font: inherit; background: white; }
#ranked-start { margin-top: 14px; }
.ranking { background: transparent; }
.ranking h2 { font-size: 17px; margin: 0; }
.ranking table { width: 100%; border-collapse: collapse; font-size: 14px; }
.ranking th, .ranking td { text-align: left; padding: 10px 5px; border-bottom: 1px solid #dce2d7; overflow-wrap: anywhere; }
.ranking td:nth-child(2) { max-width: 210px; }
.ranking th:last-child, .ranking td:last-child { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
button:disabled { cursor: wait; opacity: .55; }
.result #save-status { font-size: 13px; margin: 12px 0 0; }
.overlay { overflow-y: auto; }
.overlay { position: absolute; inset: 0; border-radius: inherit; background: #f7f5eff0; backdrop-filter: blur(5px); display: grid; place-items: center; padding: 20px; z-index: 2; }
[hidden] { display: none !important; }
.result { text-align: center; }
.result h2 { font-size: clamp(27px, 7vw, 38px); letter-spacing: -.04em; margin: 10px 0; }
.result > p:not(.eyebrow) { font-size: 14px; line-height: 1.8; margin-bottom: 25px; }
.result button { margin: 4px; }
.share-score { display: block; width: fit-content; margin: 12px auto 0; text-decoration: none; background: #222; }
.share-score:focus-visible { outline: 3px solid #247267; outline-offset: 4px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
@keyframes gain { from { opacity: 1; transform: translateY(0); } to { opacity: 0; transform: translateY(-35px); } }
@media (max-width: 480px) { .game { margin-top: 28px; width: min(100% - 28px, 460px); } .board { gap: 8px; padding: 10px; border-radius: 15px; } .tile { border-radius: 8px; } .toolbar { margin-top: 20px; } .toolbar p { font-size: 13px; } .button { padding: 11px 12px; } }
@media (max-width: 340px) { .toolbar { align-items: flex-start; flex-direction: column; } .score-box { min-width: 88px; padding: 12px; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } #score-gain { display: none; } }
#nickname-dialog { width: min(440px, calc(100vw - 40px)); box-sizing: border-box; padding: 24px; border: 1px solid #dce2d7; border-radius: 16px; background: #f0f1e9; color: #303b32; }
#nickname-dialog::backdrop { background: rgb(20 30 20 / 65%); }
#nickname-dialog p { font-size: 14px; line-height: 1.7; }
#nickname-dialog label { display: block; margin: 16px 0 8px; }
#nickname-dialog input { width: 100%; box-sizing: border-box; padding: 12px; font: inherit; border: 1px solid #a9b6a7; border-radius: 8px; }
#nickname-logout { margin-top: 20px; }

.header { flex-wrap: wrap; }
#header-account { flex-basis: 100%; display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 13px; }
#login-status { min-width: 0; overflow-wrap: anywhere; }
#open-profile { flex-shrink: 0; }
#profile-dialog { width: min(440px, calc(100vw - 40px)); padding: 24px; border: 1px solid #dce2d7; border-radius: 16px; background: #f0f1e9; color: #303b32; }
#profile-dialog::backdrop { background: rgb(20 30 20 / 65%); }
#profile-dialog p { font-size: 14px; line-height: 1.7; overflow-wrap: anywhere; }
