:root {
  color-scheme: light;
  font-family: "Malgun Gothic", "맑은 고딕", "Apple SD Gothic Neo", sans-serif;
  color: #222a29;
  background: #f6f8f7;
  font-synthesis: none;
  --green: #137854;
  --red: #e53940;
  --yellow: #f2bf19;
  --blue: #2676e4;
  --fullscreen-offset: 0px;
}
@media (min-width: 701px) {
  :root.is-fullscreen { --fullscreen-offset: clamp(16px, 4svh, 48px); }
}
* { box-sizing: border-box; letter-spacing: 0; }
body { margin: 0; min-width: 320px; overflow-x: clip; }
body::before { content: ""; position: fixed; inset: 0; z-index: -1; background-image: linear-gradient(#e8edeb 1px, transparent 1px), linear-gradient(90deg, #e8edeb 1px, transparent 1px); background-size: 40px 40px; opacity: .55; pointer-events: none; }
button, a { -webkit-tap-highlight-color: transparent; }
button { font: inherit; cursor: pointer; touch-action: manipulation; }
button:focus-visible, a:focus-visible { outline: 3px solid #2676e4; outline-offset: 5px; }
button:disabled { cursor: default; }
[hidden] { display: none !important; }
.red { color: var(--red); }
.yellow { color: var(--yellow); }
.green { color: #23a666; }
.blue { color: var(--blue); }
.menu { position: relative; min-height: 100svh; display: flex; flex-direction: column; justify-content: center; align-items: center; padding: 60px 20px 100px; }
.sound-toggle, .fullscreen-toggle { width: 44px; height: 44px; padding: 10px; border: 0; border-radius: 6px; display: inline-grid; place-items: center; background: transparent; flex: 0 0 auto; }
.sound-toggle:hover, .fullscreen-toggle:hover { background: #e5ece8; }
.fullscreen-toggle[aria-pressed="true"] { background: #e5ece8; }
.fullscreen-toggle:disabled { opacity: .5; }
.sound-toggle[aria-pressed="false"] { opacity: .6; }
.menu-controls { position: absolute; top: 18px; right: 28px; display: flex; gap: 8px; }
.dialog-controls { display: flex; justify-content: flex-end; gap: 8px; margin: -36px -40px 8px 0; }
.display-message { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); width: max-content; max-width: calc(100% - 32px); margin: 0; padding: 12px 16px; border-radius: 6px; background: #293e3a; color: white; font-size: 14px; z-index: 10; }
.toolbar-actions { display: flex; align-items: center; justify-content: flex-end; gap: 10px; }
.sample-cards { display: flex; align-items: center; justify-content: center; padding: 20px; margin-bottom: 28px; }
.sample-card { width: 118px; height: 156px; background: white; border: 1px solid #dce3df; border-bottom: 5px solid #dce3df; border-radius: 8px; display: grid; place-items: center; font-family: "Segoe UI Symbol", "Apple Symbols", sans-serif; font-size: 75px; box-shadow: 0 12px 24px #1e3e3210; }
.sample-card:nth-child(1) { transform: rotate(-14deg) translateY(12px); }
.sample-card:nth-child(2) { transform: rotate(-5deg) translateY(-7px); margin-left: 7px; }
.sample-card:nth-child(3) { transform: rotate(6deg) translateY(-7px); margin-left: 7px; }
.sample-card:nth-child(4) { transform: rotate(15deg) translateY(12px); margin-left: 7px; }
h1 { margin: 18px 0 32px; font-size: 44px; line-height: 1.35; font-weight: 900; text-align: center; word-break: keep-all; }
.primary-button { min-height: 58px; padding: 0 38px; border-radius: 8px; background: var(--green); color: white; border: 1px solid var(--green); display: inline-flex; justify-content: center; align-items: center; gap: 12px; font-size: 19px; font-weight: 800; box-shadow: 0 4px 0 #0b5038; transition: background .15s, transform .15s; }
.primary-button:hover { background: #0b6645; transform: translateY(-2px); }
.primary-button:active { transform: translateY(2px); }
[data-icon] { width: 21px; height: 21px; display: inline-flex; flex: 0 0 auto; }
[data-icon] svg { width: 100%; height: 100%; }
.primary-button [data-icon] img { filter: brightness(0) invert(1); }
.menu-details { display: flex; align-items: center; justify-content: center; gap: 15px; color: #62716a; margin-top: 30px; font-size: 14px; }
.menu-details i { width: 3px; height: 3px; background: #a7b3ad; border-radius: 50%; }
.game { padding: calc(14px + var(--fullscreen-offset)) 40px 24px; min-height: 100svh; }
.game-toolbar { max-width: 1440px; margin: 0 auto 14px; min-height: 46px; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 10px; }
#restart { justify-self: start; }
.text-button { min-height: 44px; border: 0; background: transparent; padding: 8px 12px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; border-radius: 6px; color: #394840; font-size: 15px; font-weight: 700; }
.text-button:hover { background: #e5ece8; }
.game-status { display: flex; align-items: center; gap: 16px; font-size: 15px; font-weight: 700; }
#phase { color: var(--green); }
.pair-count { border-left: 1px solid #cdd8d1; padding-left: 16px; color: #69766e; font-weight: 400; font-variant-numeric: tabular-nums; }
.pair-count strong { color: #263a2d; }
.board { width: min(1240px, calc((100svh - 170px - var(--fullscreen-offset)) * 1.53)); margin: 0 auto; display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 12px; }
.card { position: relative; width: 100%; aspect-ratio: 150 / 195; padding: 0; border: 0; border-radius: 8px; background: transparent; perspective: 900px; isolation: isolate; }
.card-inner { position: absolute; inset: 0; transform-style: preserve-3d; transition: transform .27s ease; border-radius: inherit; }
.card.face-up .card-inner { transform: rotateY(180deg); }
.card-face { position: absolute; inset: 0; backface-visibility: hidden; -webkit-backface-visibility: hidden; border-radius: inherit; display: grid; place-items: center; border: 1px solid #344a45; border-bottom-width: 4px; }
.card-back { background: #293e3a; color: #fff; font-size: 38px; font-weight: 700; font-variant-numeric: tabular-nums; }
.card-back::after { content: ""; position: absolute; inset: 7px; border: 1px solid #ffffff1c; border-radius: 4px; }
.card-front { transform: rotateY(180deg); background: #fff; border-color: #d5dfd8; font-family: "Segoe UI Symbol", "Apple Symbols", "Malgun Gothic", sans-serif; font-size: 65px; line-height: 1; }
.card:not(:disabled):hover .card-back { background: #38574e; border-color: #137854; }
.card:not(:disabled):hover { translate: 0 -3px; }
.card.selected .card-front { border-color: #137854; box-shadow: 0 0 0 2px #137854; }
.card.matched { pointer-events: none; z-index: 2; }
.card.matched .card-front { border-color: #46b17e; }
.card.falling { animation: fall .65s cubic-bezier(.42, 0, .85, .45) forwards; }
.card.gone { visibility: hidden; pointer-events: none; }
@keyframes fall { 0% { transform: translateY(0) rotate(0) scale(1); opacity: 1; } 85% { opacity: 1; } 100% { transform: translateY(var(--drop-distance, 120vh)) rotate(var(--drop-angle, 10deg)) scale(.78); opacity: 0; } }
.timer-dock { max-width: 1760px; margin: 22px auto 0; height: 50px; position: relative; z-index: 4; }
.timer-track { height: 100%; border-radius: 6px; background: #e0e5e1; overflow: hidden; position: relative; }
.timer-fill { position: absolute; inset: 0; transform: scaleX(1); transform-origin: left center; background: #35c66f; will-change: transform; }
.timer-text { position: absolute; inset: 0; display: grid; place-items: center; color: #18261f; font-size: 20px; font-weight: 900; font-variant-numeric: tabular-nums; }
.timer-dock.finished { visibility: hidden; }
dialog { border: 1px solid #d6e1d9; border-radius: 8px; background: #fff; padding: 44px 48px 28px; width: min(440px, calc(100% - 32px)); text-align: center; box-shadow: 0 24px 80px #183a2926; }
dialog::backdrop { background: #eef5efcc; backdrop-filter: blur(5px); }
.success-symbols { display: flex; justify-content: center; gap: 12px; font-size: 34px; }
dialog h2 { font-size: 54px; margin: 20px 0 12px; color: #137854; }
dialog p { font-size: 16px; color: #57695d; margin: 0 0 30px; }
dialog .primary-button { width: 100%; }
.dialog-home { margin: 18px auto 0; }
@media (min-width: 701px) and (max-height: 760px) {
  .game { padding-top: calc(8px + var(--fullscreen-offset)); }
  .board { width: min(1100px, calc((100svh - 152px - var(--fullscreen-offset)) * 1.53)); gap: 8px; }
  .card-back { font-size: 28px; }
  .card-front { font-size: 48px; }
  .timer-dock { height: 44px; margin-top: 16px; }
}
@media (max-width: 700px) {
  .menu { padding: 60px 18px 70px; }
  .menu-controls { top: 12px; right: 12px; }
  .sample-cards { width: 100%; max-width: 380px; padding: 12px; margin-bottom: 18px; }
  .sample-card { width: 24%; height: auto; aspect-ratio: 118 / 156; font-size: 50px; }
  .sample-card:nth-child(n) { margin-left: 3px; }
  h1 { font-size: 30px; margin-bottom: 28px; }
  .menu-details { gap: 10px; font-size: 12px; }
  .game { padding: 8px 16px 20px; }
  .game-toolbar { margin-bottom: 14px; grid-template-columns: 1fr auto; gap: 4px 8px; }
  .toolbar-actions { grid-column: 2; grid-row: 1; gap: 4px; }
  .text-button { padding: 8px 4px; font-size: 14px; gap: 5px; white-space: nowrap; }
  .game-status { font-size: 13px; gap: 8px; grid-column: 1 / -1; grid-row: 2; justify-content: center; min-height: 22px; }
  .pair-count { padding-left: 8px; }
  .board { width: min(100%, 460px); height: clamp(400px, calc(100svh - 178px), 880px); grid-template-columns: repeat(4, minmax(0, 1fr)); grid-template-rows: repeat(8, minmax(0, 1fr)); gap: 8px; }
  .card { aspect-ratio: auto; height: 100%; }
  .card-back { font-size: 30px; }
  .card-front { font-size: 40px; }
  .timer-dock { width: 100%; height: 44px; margin: 16px auto 0; }
  .timer-text { font-size: 18px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; }
  .card.falling { animation-name: fade; }
  @keyframes fade { to { opacity: 0; } }
}
