* {box-sizing: border-box;}
body {background-image: conic-gradient(#fbbf24 90deg, transparent 90deg 180deg, #fbbf24 180deg 270deg, transparent 270deg); background-size: 70px 70px; background-color: #ffffff; font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; margin: 0; padding: 0.5rem;}
h1 {border: 3px outset orange; background: white; color: black;}
h1, h2 {margin-top: 0;}
p {font-size: 18px; background: white; border-radius: 4px;}
details {font-size: 18px; background: white; border-radius: 4px;}
summary {padding: 0.5rem 1rem; border-radius: 4px; border: 2px solid orange; background: white; color: black; font-size: 20px; text-align: center;}
button {font: inherit; cursor: pointer;}
#intro {max-width: 900px; margin: 0 auto 1rem; background: #fff; border-radius: 8px; padding: 1rem; box-shadow: 0 2px 4px rgba(0,0,0,0.1); font-size: 18px;}
#intro .highscore {margin: 0.5rem 0; font-weight: bold;}
#startButton, #rankingButton {padding: 0.5rem 1rem; border-radius: 4px; border: 2px solid orange; background: white; color: black; font-size: 20px; text-align: center;}
#gameArea[hidden], #resultDialog[hidden] {display: none;}
#gameArea {max-width: 900px; margin: 0 auto;}
#statusBar {display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.5rem; gap: 0.5rem; flex-wrap: wrap;}
#timer {font-weight: bold;}
#currentHighScore {font-size: 0.9rem;}
/* Board layout */
#board {background: #fff; border-radius: 8px; padding: 0.5rem; box-shadow: 0 2px 4px rgba(0,0,0,0.1);}
.top-row {display: flex; justify-content: space-between; flex-wrap: wrap; gap: 0.5rem; margin-bottom: 0.5rem;}
.pile-group {display: flex; gap: 0.25rem; flex-wrap: wrap; align-items: flex-start;}
.pile-group-title {flex-basis: 100%; font-size: 0.9rem; font-weight: bold; margin-bottom: 0.25rem;}
#tableaus {display: grid; grid-template-columns: repeat(auto-fit, minmax(42px, 1fr)); gap: 0.25rem; margin-top: 0.5rem;}
.tableau-column {border: 1px solid #ccc; min-height: 80px; padding: 0.1rem; border-radius: 4px; background: #fafafa; display: flex; flex-direction: column; gap: 0.1rem;}
.pile-label {position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
/* Cards and slots */
.card-button, .slot-button {border: 1px solid #000; border-radius: 4px; background: #fff; padding: 0.15rem; min-width: 42px; min-height: 32px; font-size: 0.75rem; display: inline-flex; align-items: center; justify-content: center; text-align: center; line-height: 1.2; white-space: nowrap;}
.card-button.red {color: #c00;}
.card-button.black {color: #000;}
.slot-button.empty {background: #eee; color: #666;}
.selected {outline: 3px solid #ff9800; outline-offset: 1px;}
/* Dialog */
#resultDialog {position: fixed; inset: 0; background: rgba(0,0,0,0.4); display: flex; align-items: center; justify-content: center; z-index: 1000;}
#resultDialogContent {background: #fff; max-width: 90vw; width: 420px; padding: 1rem; border-radius: 8px; box-shadow: 0 4px 8px rgba(0,0,0,0.2);}
#resultDialogContent h2 {margin-top: 0; margin-bottom: 0.5rem;}
#resultDialogContent p {margin: 0.3rem 0;}
#highScoreForm {margin-top: 0.5rem;}
#highScoreForm label {display: block; margin-bottom: 0.25rem;}
#highScoreForm input[type="text"] {width: 100%; padding: 0.25rem; margin-bottom: 0.5rem; border: 1px solid #ccc; border-radius: 4px; font: inherit;}
#highScoreForm button {padding: 0.4rem 0.8rem; border-radius: 4px; border: 1px solid #000; background: #4caf50; color: #fff;}
#reloadLink {display: inline-block; margin-top: 0.5rem;}
.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;}
@media (max-width: 480px) {
.card-button, .slot-button {font-size: 0.7rem; min-width: 36px; min-height: 28px;}
.tableau-column {min-height: 72px;}


/* layout.css の div 10% マージンを、ゲーム内では打ち消す */
#intro, #gameArea, #board, #board > div, #resultDialogContent {margin-left: 0; margin-right: 0;}
/* いったん基本の grid 定義だけにしておく */
#tableaus {
  display: grid;
  gap: 0.25rem;
  margin-top: 0.5rem;
}

/* 広めの画面: 8列1段（従来どおり横一列に8束） */
@media (min-width: 640px) {
  #tableaus {
    grid-template-columns: repeat(8, minmax(42px, 1fr));
  }
}

/* 狭めの画面: 4列×2段（必ず上4束／下4束になる） */
@media (max-width: 639px) {
  #tableaus {
    grid-template-columns: repeat(4, minmax(42px, 1fr));
  }
}
