
#game2048 * { box-sizing: border-box; }
#game2048 {
  margin: 0;
  background: #101722;
  color: #edf2fa;
  font-family: system-ui, -apple-system, "Segoe UI", "Yu Gothic", sans-serif;
  line-height: 1.5;
}
#game2048 .game-content { width: min(470px, calc(100% - 24px)); margin: 24px auto; }
#game2048 header { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
#game2048 h1 { font-size: 42px; line-height: 1; margin: 0; color: #f2ce62; }
#game2048 .scores { display: flex; gap: 8px; }
#game2048 .score {
  position: relative;
  background: #202c3d;
  border-radius: 10px;
  padding: 8px 12px;
  text-align: center;
  min-width: 76px;
  font-variant-numeric: tabular-nums;
}
#game2048 .score span { display: block; font-size: 12px; color: #bdcada; }
#game2048 .score strong { font-size: 20px; overflow-wrap: anywhere; }
#game2048 #gain {
  position: absolute;
  right: 0;
  top: 100%;
  color: #f2ce62;
  font-weight: 800;
  white-space: nowrap;
  z-index: 3;
  font-size: 16px;
}
#game2048 button {
  font: inherit;
  font-weight: 700;
  min-height: 44px;
  border: 1px solid #52647c;
  border-radius: 9px;
  background: #293a50;
  color: #f5f8ff;
  padding: 8px 16px;
  cursor: pointer;
}
#game2048 button:hover { background: #374c66; }
#game2048 button:disabled { opacity: .45; cursor: default; }
#game2048 :focus-visible { outline: 3px solid #f2ce62; outline-offset: 4px; }
#game2048 .toolbar { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; margin: 16px 0 10px; }
#game2048 .board {
  position: relative;
  container-type: inline-size;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 9px;
  background: #202c3d;
  padding: 9px;
  border-radius: 14px;
  touch-action: none;
  user-select: none;
}
#game2048 .cell {
  aspect-ratio: 1;
  min-width: 0;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  background: #2c394c;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}
#game2048 .cell[data-value="2"] { background: #dae2eb; color: #263348; }
#game2048 .cell[data-value="4"] { background: #ebdfbd; color: #3a321f; }
#game2048 .cell[data-value="8"] { background: #edaa60; color: #281b0d; }
#game2048 .cell[data-value="16"] { background: #ef8750; color: #28170e; }
#game2048 .cell[data-value="32"] { background: #e56b59; color: #26110e; }
#game2048 .cell[data-value="64"] { background: #db4d48; color: #fff; }
#game2048 .cell.high { background: #e8c04c; color: #28200b; }
#game2048 .cell[data-value="128"] { background: #f2db8b; color: #302711; }
#game2048 .cell[data-value="256"] { background: #eac55d; color: #302609; }
#game2048 .cell[data-value="512"] { background: #d5aa35; color: #241b06; }
#game2048 .cell[data-value="1024"] { background: #b98419; color: #fff; }
#game2048 .cell[data-value="2048"] { background: #805408; color: #fff; }
#game2048 .ghost { position: absolute; margin: 0; z-index: 2; pointer-events: none; }
#game2048 .board-wrap { position: relative; }
#game2048 .visual-notice {
  height: 1.5em;
  margin: 6px 0;
  font-size: 14px;
  line-height: 1.5;
}
#game2048 .overlay {
  position: absolute;
  inset: 0;
  z-index: 4;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  border-radius: 14px;
  background: #101722df;
}
#game2048 .overlay[hidden] { display: none; }
#game2048 .overlay-panel { text-align: center; max-width: 100%; }
#game2048 #message { display: block; font-size: 24px; font-weight: 800; margin-bottom: 18px; }
#game2048 .overlay-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
#game2048 button.primary { background: #f2ce62; border-color: #f2ce62; color: #29200a; }
#game2048 button.primary:hover { background: #ffe08a; }
#game2048 .sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}
#game2048 .controls {
  display: grid;
  grid-template-columns: repeat(3, 58px);
  gap: 7px;
  justify-content: center;
  margin: 12px 0;
}
#game2048 .controls button { padding: 7px; font-size: 22px; }
#game2048 .up { grid-column: 2; }
#game2048 .left { grid-column: 1; }
#game2048 .help { color: #bdcada; font-size: 14px; margin: 16px 0; }
#game2048 .save-note { font-size: 13px; color: #e5cb82; min-height: 1.5em; }
#game2048 dialog {
  max-width: min(390px, calc(100% - 32px));
  background: #202c3d;
  color: #edf2fa;
  border: 1px solid #52647c;
  border-radius: 14px;
  padding: 22px;
}
#game2048 dialog::backdrop { background: #000a; }
#game2048 dialog h2 { margin-top: 0; font-size: 20px; }
#game2048 .dialog-actions { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; }
@media (max-width: 360px) {
  #game2048 .game-content { margin-top: 0; }
  #game2048 .score { padding: 6px 8px; min-width: 66px; }
  #game2048 h1 { font-size: 36px; }
  #game2048 .board { gap: 6px; padding: 7px; }
}
    
.game2048-page{max-width:1120px;margin:20px auto;padding:0 16px;color:#263332;font-family:system-ui,"Yu Gothic",sans-serif}.game2048-page h1{font-size:28px}.game2048-page .game-notes{max-width:740px;margin:24px auto;line-height:1.8}
#game2048{position:relative;margin:auto;border-radius:16px;overflow:hidden;max-width:100%;background:#101722;color:#edf2fa;line-height:1.5}
#game2048 .game-content{width:470px;height:720px;margin:0;padding:18px;transform-origin:top left;position:relative}
#game2048 .board{height:434px;aspect-ratio:1;box-sizing:border-box} #game2048 .toolbar{margin:10px 0} #game2048 .controls{margin:6px 0} #game2048 .visual-notice{margin:2px 0} #game2048 .save-note{margin:2px 0;font-size:12px} #game2048 .game-content>header{height:62px}
#game2048 .menu-overlay{position:absolute;inset:0;z-index:8;background:#101722ed;display:flex;align-items:center;justify-content:center;padding:24px}
#game2048 .menu-overlay[hidden],#game2048 [hidden]{display:none!important} #game2048 .menu-panel{width:100%;max-height:100%;overflow:auto;text-align:center} #game2048 .menu-panel h2{color:#f2ce62;font-size:30px;margin:0 0 18px} #game2048 .menu-panel p{text-align:left} #game2048 .menu-panel button{margin:5px} #game2048 .menu-actions{display:flex;flex-direction:column;max-width:280px;margin:auto} #game2048 #ranking-slot{max-height:90px;overflow:auto}
#game2048 .sound-row{display:flex;align-items:center;justify-content:center;gap:12px;margin:16px 0} #game2048 input[type=range]{width:190px} #game2048 .controls{grid-template-columns:repeat(4,64px)} #game2048 .up,#game2048 .left{grid-column:auto} #game2048 .overlay-panel{max-height:100%;overflow:auto} #game2048 .board-wrap .overlay{padding:12px}

#game2048 #confirm-new{z-index:10} #game2048 #help-menu,#game2048 #settings-menu{z-index:9}

#game2048 .board-title{font-size:42px;line-height:1;margin:0;color:#f2ce62;font-weight:700} #game2048 #ranking-slot{margin-top:12px;max-height:160px}

/* Fixed 4:3 frame. UI controls retain their CSS pixel size. */
#game2048{width: min(800px,100%);aspect-ratio:4/3;max-width:100%;margin:0 auto;container-type:size}
#game2048 .game-content{position:relative;width:100%;height:100%;margin:0;padding:0;transform:none!important}
#game2048 .board-wrap{position:absolute;left:10px;top:10px;width:var(--board-size);height:var(--board-size)}
#game2048 .board{width:100%;height:100%;padding:7px;gap:6px;border-radius:12px}
#game2048 .game-content>header{position:absolute;left:calc(var(--board-size) + 20px);right:10px;top:10px;height:52px;display:block}
#game2048 .board-title{display:none}
#game2048 .scores{width:100%;gap:5px}
#game2048 .score{padding:3px;min-width:0;flex:1;border-radius:7px}
#game2048 .score span{font-size:14px;line-height:1.4}
#game2048 .score strong{font-size:18px;line-height:1.4}
#game2048 .toolbar{position:absolute;left:10px;right:10px;bottom:10px;height:44px;margin:0;display:flex;flex-wrap:nowrap;gap:6px}
#game2048 .toolbar button{flex:1;min-width:0;min-height:44px;padding:4px;font-size:14px}
#game2048 .controls{position:absolute;left:calc(var(--board-size) + 20px);right:10px;top:70px;display:grid;grid-template-columns:repeat(2,44px);grid-auto-rows:44px;gap:6px;margin:0}
#game2048 .controls button{height:44px;min-height:44px;padding:0;font-size:24px}
#game2048 .save-note{position:absolute;left:calc(var(--board-size) + 20px);right:10px;top:172px;bottom:64px;overflow:auto;margin:0;font-size:14px;line-height:1.35}
#game2048 .visual-notice{position:absolute;left:15px;top:15px;max-width:calc(var(--board-size) - 10px);height:auto;background:#101722e8;border-radius:5px;margin:0;z-index:3;font-size:14px;pointer-events:none}
#game2048 .visual-notice:empty{display:none}
#game2048 .menu-overlay{padding:12px}
#game2048 .menu-panel{max-width:560px;max-height:100%;font-size:14px;line-height:1.4}
#game2048 .menu-panel h2{font-size:24px;line-height:1.3;margin:0 0 10px}
#game2048 .menu-panel p{margin:8px 0}
#game2048 .menu-panel button{font-size:14px;min-height:44px;margin:0;padding:6px 10px}
#game2048 .menu-actions{display:grid;grid-template-columns:1fr 1fr;gap:8px;max-width:340px}
#game2048 .sound-row{margin:8px 0;gap:8px;min-height:44px}
#game2048 input[type=range]{width:160px;min-height:44px}
#game2048 input[type=checkbox]{width:22px;height:22px}
#game2048 .overlay-panel{width:100%;max-height:100%;overflow:auto;font-size:14px}
#game2048 #message{font-size:24px;margin-bottom:10px}
#game2048 .overlay-actions{gap:6px}
#game2048 .overlay-actions button{font-size:14px;min-height:44px;padding:6px 10px}
#game2048 #ranking-slot{max-height:120px;margin-top:10px}

/* Results use the full game frame so phone controls stay together. */
#game2048 .board-wrap #status{inset:auto;left:-10px;top:-10px;width:100cqw;height:100cqh;border-radius:16px}
#game2048 #status .overlay-panel{max-width:560px;margin:auto}
#game2048 #ranking-slot{max-height:none;overflow:visible}
#game2048 #ranking-slot p,#game2048 #ranking-slot button{font-size:14px}
#game2048[data-busy="true"]::after{content:'開始を準備しています…';position:absolute;inset:0;z-index:12;display:grid;place-items:center;background:#101722f2;color:#edf2fa;font-size:16px;font-weight:700;pointer-events:auto}

/* Description panels follow oshifuda; related links follow colormix. */
.game2048-page{box-sizing:border-box;width:min(1120px,calc(100% - 48px));max-width:none;margin:0 auto 64px;padding:0;color:#2e3131;font-size:16px;line-height:1.8}
.game2048-page .game-intro{padding:32px 0}
.game2048-page .game-intro h1{margin:0 0 16px;font-size:clamp(28px,4vw,42px);line-height:1.3}
.game2048-page .game-intro p{margin:0;color:#6e7473}
.game2048-page .game-toolbar{padding-right:110px;margin-bottom:12px;min-height:44px;display:flex;align-items:center}
.game2048-page .game-toolbar p{margin:0;color:#6e7473;font-size:14px;line-height:1.6}
.game2048-page .game-toolbar strong{color:#347a68;margin-right:8px}
.game2048-page .game-fullscreen-open,.game2048-page .game-fullscreen-close{min-height:44px}
.game2048-page .description-section{padding:64px 0 12px}
.game2048-page .description-section h2,.game2048-page .info-section h2{margin:0 0 22px;font-size:32px;line-height:1.3}
.game2048-page .description-panel{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:30px;padding:28px 30px;border:1px solid #e4e9df;border-left:5px solid #62ad98;border-radius:8px;background:#fff}
.game2048-page .description-block+.description-block{padding-left:30px;border-left:1px solid #e4e9df}
.game2048-page .description-block h3{margin:0 0 12px;font-size:20px;line-height:1.4}
.game2048-page .guide-list{display:grid;gap:0;margin:0}
.game2048-page .guide-list>div{display:grid;grid-template-columns:115px minmax(0,1fr);gap:12px;padding:9px 0;border-bottom:1px solid #edf0eb}
.game2048-page .guide-list>div:last-child{border:0}
.game2048-page .guide-list dt{color:#347a68;font-weight:800}
.game2048-page .guide-list dd{margin:0;color:#545d5b}
.game2048-page .info-section{padding:32px 0}
.game2048-page .info-section p{margin:0}
.game2048-page .info-section a{color:#347a68;text-underline-offset:3px}
.game2048-page .game-notes{max-width:none}
.game2048-page .game-shell.is-game-fullscreen .game-toolbar{display:none}
@media(max-width:760px){
.game2048-page{width:calc(100% - 32px)}
.game2048-page .game-intro{padding:24px 0}
.game2048-page .description-section{padding-top:48px}
.game2048-page .description-section h2,.game2048-page .info-section h2{font-size:27px}
.game2048-page .description-panel{grid-template-columns:1fr;padding:22px 20px;gap:24px}
.game2048-page .description-block+.description-block{padding:24px 0 0;border-left:0;border-top:1px solid #e4e9df}
.game2048-page .guide-list>div{grid-template-columns:1fr;gap:2px;padding:10px 0}
}

.game2048-site{margin:0;background:#fffefd;color:#2e3131;font-family:system-ui,-apple-system,"Segoe UI","Yu Gothic",Meiryo,sans-serif}
.game2048-page .game-toolbar{position:absolute;top:10px;left:0;right:110px;padding:0;margin:0;height:44px}

.game2048-page .game-shell{box-sizing:border-box}

/* Directional cross, separated from the lower-left game actions. */
#game2048 .controls{left:auto;right:10px;top:auto;bottom:10px;width:144px;height:144px;grid-template-columns:repeat(3,44px);grid-template-rows:repeat(3,44px);gap:6px}
#game2048 .controls [data-direction="up"]{grid-column:2;grid-row:1}
#game2048 .controls [data-direction="left"]{grid-column:1;grid-row:2}
#game2048 .controls [data-direction="right"]{grid-column:3;grid-row:2}
#game2048 .controls [data-direction="down"]{grid-column:2;grid-row:3}
#game2048 .toolbar{right:auto;width:var(--board-size)}
#game2048 .toolbar button{padding:4px 0;flex:1 1 0;font-size:14px}
#game2048 .game-content>header{left:auto;right:10px;width:144px;height:44px}
#game2048 .score span,#game2048 .score strong{line-height:1.1}
#game2048 .save-note{left:calc(var(--board-size) + 20px);right:10px;top:60px;bottom:160px;line-height:1.3}
@media(max-width:360px){
.game2048-page .game-shell{width:calc(100% + 32px);margin-left:-16px}
.game2048-page .game-shell.is-game-fullscreen{padding-left:0!important;padding-right:0!important}
}

/* Actual frame width includes the effect of a desktop scrollbar. */
@container (max-width:319px){
#game2048 #new-game{display:none}
#game2048 .save-note{left:10px;right:auto;width:var(--board-size);top:calc(var(--board-size) + 14px);bottom:64px}
}
