:root {
  --bg: #1f2a44;
  --bg-2: #2f3f66;
  --panel: #2b3858;
  --tile: #f7f7fb;
  --text: #ffffff;
  --muted: #c9d3ea;
  --focus: #ffd54f;
  --btn: #ffd54f;
  --btn-hi: #ffe98a;
  --btn-text: #1f2a44;
  --c-circle: #e53935;
  --c-circle-hi: #ff8a80;
  --c-square: #1e88e5;
  --c-square-hi: #7cc4ff;
  --c-triangle: #43a047;
  --c-triangle-hi: #9be59c;
  --c-diamond: #fb8c00;
  --c-diamond-hi: #ffcc80;
  --c-star: #8e24aa;
  --c-star-hi: #d59be8;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans KR", sans-serif;
  -webkit-text-size-adjust: 100%;
}

body {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  min-height: 100vh;
  padding: 16px;
  /* 은은한 배경 그라디언트 */
  background: radial-gradient(circle at 50% 0%, var(--bg-2) 0%, var(--bg) 70%);
}

::selection { background: var(--focus); color: var(--btn-text); }

.game {
  width: 100%;
  max-width: 460px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.title {
  margin: 8px 0 0;
  font-size: 1.7rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  text-align: center;
}

/* 점수: 휴대폰에서도 멀리서 읽히도록 크게, 배경과 대비를 높게 */
.score-box {
  margin: 0;
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 10px;
}

.score-label {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--muted);
}

.score {
  font-size: 2.6rem;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.35);
  min-width: 2ch;
  text-align: left;
}

/* 판: 둥근 패널, 화면 너비에 맞춰 줄어들고 최대 너비만 제한 */
.board {
  width: 100%;
  max-width: 440px;
  aspect-ratio: 1 / 1;
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  grid-template-rows: repeat(6, 1fr);
  gap: 5px;
  padding: 8px;
  background: linear-gradient(180deg, #34456d, var(--panel));
  border-radius: 18px;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.12);
  user-select: none;
  -webkit-user-select: none;
}

.tile {
  appearance: none;
  border: 0;
  padding: 0;
  margin: 0;
  border-radius: 12px;
  background: linear-gradient(180deg, #ffffff 0%, #e6e9f4 100%);
  box-shadow: inset 0 -4px 0 rgba(0, 0, 0, 0.12), 0 2px 4px rgba(0, 0, 0, 0.3);
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 120ms ease-out, box-shadow 120ms ease-out;
}

.tile:hover {
  transform: translateY(-1px);
  box-shadow: inset 0 -4px 0 rgba(0, 0, 0, 0.12), 0 4px 8px rgba(0, 0, 0, 0.3);
}

.tile:active {
  transform: translateY(1px) scale(0.97);
  box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.12), 0 1px 2px rgba(0, 0, 0, 0.3);
}

.tile:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

/* 눌러서 고른 블록 표시 (game.js의 handleTileClick이 selected 칸에 붙인다) */
.tile.selected {
  outline: 3px solid #ffffff;
  outline-offset: 0;
  box-shadow: 0 0 0 3px var(--focus), 0 4px 10px rgba(0, 0, 0, 0.35);
}

.tile[data-shape="circle"]   { --c: var(--c-circle);   --hi: var(--c-circle-hi); }
.tile[data-shape="square"]   { --c: var(--c-square);   --hi: var(--c-square-hi); }
.tile[data-shape="triangle"] { --c: var(--c-triangle); --hi: var(--c-triangle-hi); }
.tile[data-shape="diamond"]  { --c: var(--c-diamond);  --hi: var(--c-diamond-hi); }
.tile[data-shape="star"]     { --c: var(--c-star);     --hi: var(--c-star-hi); }

/* 도형은 CSS로만 그린다: 그라디언트 + 왼쪽 위 빛 반사로 광택 표현 */
.shape {
  display: block;
  width: 62%;
  height: 62%;
  background:
    radial-gradient(circle at 32% 26%, rgba(255, 255, 255, 0.85) 0 10%, rgba(255, 255, 255, 0) 22%),
    linear-gradient(160deg, var(--hi) 0%, var(--c) 60%, var(--c) 100%);
  pointer-events: none;
}

.shape.circle   { border-radius: 50%; }
.shape.square   { border-radius: 14%; }
.shape.triangle { clip-path: polygon(50% 0, 100% 100%, 0 100%); }
.shape.diamond  { clip-path: polygon(50% 0, 100% 50%, 50% 100%, 0 50%); }
.shape.star {
  clip-path: polygon(50% 0%, 61% 35%, 98% 35%, 68% 57%, 79% 91%,
                     50% 70%, 21% 91%, 32% 57%, 2% 35%, 39% 35%);
}

/* 다시 시작 버튼: 손가락으로 누르기 쉬운 큰 크기, hover·active·focus-visible 제공 */
.restart {
  appearance: none;
  min-width: 180px;
  min-height: 52px;
  padding: 12px 28px;
  border: 0;
  border-radius: 999px;
  background: linear-gradient(180deg, var(--btn-hi) 0%, var(--btn) 100%);
  color: var(--btn-text);
  font: inherit;
  font-size: 1.25rem;
  font-weight: 800;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  box-shadow: 0 4px 0 #c9a227, 0 8px 16px rgba(0, 0, 0, 0.35);
  transition: transform 120ms ease-out, box-shadow 120ms ease-out, filter 120ms ease-out;
}

.restart:hover {
  filter: brightness(1.06);
  transform: translateY(-1px);
}

.restart:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 #c9a227, 0 3px 6px rgba(0, 0, 0, 0.35);
}

.restart:focus-visible {
  outline: 3px solid #ffffff;
  outline-offset: 3px;
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
