:root {
  color-scheme: light;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
}

body {
  height: 100dvh;
  padding: 10px;
  background: #eef2f4;
  color: #22313a;
  font-family: "Malgun Gothic", "Apple SD Gothic Neo", "Noto Sans KR", system-ui, sans-serif;
  display: flex;
  justify-content: center;
  -webkit-tap-highlight-color: transparent;
}

.game {
  width: 100%;
  max-width: 620px;
  height: 100%;
  max-height: 760px;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* 점수판 */
.hud {
  flex: 0 0 auto;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.hud-item {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 6px;
  padding: 6px 10px;
  background: #ffffff;
  border: 1px solid #d9e2e7;
  border-radius: 10px;
}

.label {
  font-size: 13px;
  color: #62757f;
}

.value {
  font-size: 18px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.hud-target {
  flex: 1 1 auto;
  border-color: #e6c46a;
  background: #fdf1d3;
}

.hud-target .value {
  font-size: 24px;
  color: #b8651a;
}

.btn {
  appearance: none;
  flex: 0 0 auto;
  padding: 9px 14px;
  border: 1px solid #cfdae0;
  border-radius: 10px;
  background: #ffffff;
  color: #22313a;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}

.btn-primary {
  background: #2f7f45;
  border-color: #2a6f3d;
  color: #ffffff;
}

.btn:focus-visible {
  outline: 2px solid #2f7f45;
  outline-offset: 2px;
}

.btn:active {
  transform: translateY(1px);
}

/* 먹은 수 표시 */
.picks {
  flex: 0 0 auto;
  margin: 0;
  font-size: 14px;
  color: #62757f;
  text-align: center;
}

.picks b {
  font-size: 16px;
  color: #22313a;
  font-variant-numeric: tabular-nums;
}

/* 게임 판 */
.stage {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

#board {
  display: block;
  max-width: 100%;
  max-height: 100%;
  background: #ffffff;
  border: 1px solid #cfdae0;
  border-radius: 12px;
  touch-action: none;
}

.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 16px;
  text-align: center;
  background: rgba(255, 255, 255, 0.88);
  border-radius: 12px;
}

.overlay[hidden] {
  display: none;
}

.overlay-text {
  margin: 0;
  font-size: clamp(15px, 4vw, 20px);
  font-weight: 700;
}

/* 방향 버튼 */
.pad {
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: repeat(3, 52px);
  grid-template-rows: repeat(2, 46px);
  gap: 6px;
  justify-content: center;
  user-select: none;
}

.pad-btn {
  appearance: none;
  border: 1px solid #cfdae0;
  border-radius: 10px;
  background: #ffffff;
  color: #2f7f45;
  font-size: 16px;
  cursor: pointer;
  touch-action: none;
}

.pad-btn:active {
  background: #e6f2e9;
}

.pad-btn:focus-visible {
  outline: 2px solid #2f7f45;
  outline-offset: 2px;
}

.pad-btn.up {
  grid-column: 2;
  grid-row: 1;
}

.pad-btn.left {
  grid-column: 1;
  grid-row: 2;
}

.pad-btn.down {
  grid-column: 2;
  grid-row: 2;
}

.pad-btn.right {
  grid-column: 3;
  grid-row: 2;
}

/* 키보드를 쓰는 환경에서는 방향 버튼을 숨깁니다. */
@media (hover: hover) and (pointer: fine) {
  .pad {
    display: none;
  }
}
