/* 100plays — 장난감·클레이 스타일
   통통한 입체 블록(아래쪽 두께 + 위쪽 광택), 하늘색 바탕, 원색 블록
   주황 = 나(진영 'r'), 보라 = 상대(AI·2P, 진영 'l') */
@import url('/fonts/jua.css');
@font-face { font-family: 'Lilita One'; src: url('/fonts/lilita.woff2') format('woff2'); font-display: swap; }
@font-face { font-family: 'Nunito'; font-weight: 600; src: url('/fonts/nunito-600.woff2') format('woff2'); font-display: swap; }
@font-face { font-family: 'Nunito'; font-weight: 800; src: url('/fonts/nunito-800.woff2') format('woff2'); font-display: swap; }

:root {
  --sky: #d3eaff;
  --sky-2: #b9dcfb;
  --sky-3: #9ccbf3;
  --ink: #23205a;
  --ink-soft: #5d5a8f;
  --white: #ffffff;
  --white-edge: #a9cdee;
  --orange: #ff7a1a; --orange-d: #d65a00; --orange-l: #ffb070;
  --purple: #7a4dff; --purple-d: #5330cf; --purple-l: #b49bff;
  --mint: #2cd4a4; --mint-d: #12a37b;
  --yellow: #ffd23f; --yellow-d: #dba600;
  --pink: #ff5fa2; --pink-d: #d63a7e;
  --blue: #3da5ff; --blue-d: #1b7cd3;
  --lime: #9be03b; --lime-d: #6fb216;
  --display: 'Lilita One', 'Jua', 'Nunito', system-ui, sans-serif;
  --body: 'Nunito', 'Jua', system-ui, -apple-system, sans-serif;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --gloss: inset 0 3px 0 rgba(255, 255, 255, .45);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; height: 100%; overflow: hidden; overscroll-behavior: none;
  background: var(--sky); color: var(--ink);
  font-family: var(--body); font-weight: 600;
  word-break: keep-all;   /* 한국어 단어 중간 줄바꿈 방지 */
  touch-action: manipulation; -webkit-user-select: none; user-select: none;
}
button { font: inherit; color: inherit; cursor: pointer; border: 0; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid var(--ink); outline-offset: 3px; }

/* ---------- 입체 블록 ---------- */
.blk {
  --c: var(--white); --e: var(--white-edge); --lift: 5px;
  background: var(--c);
  border-radius: 18px;
  box-shadow: 0 var(--lift) 0 var(--e), var(--gloss);
  transition: transform .09s ease, box-shadow .09s ease;
}
button.blk:active { transform: translateY(calc(var(--lift) - 1px)); box-shadow: 0 1px 0 var(--e), var(--gloss); }
.blk.orange { --c: var(--orange); --e: var(--orange-d); color: #fff; }
.blk.purple { --c: var(--purple); --e: var(--purple-d); color: #fff; }

.icon-btn { width: 54px; height: 54px; display: grid; place-items: center; border-radius: 17px; flex-shrink: 0; }
.icon-btn svg { width: 24px; height: 24px; fill: none; stroke: var(--ink); stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; }
.icon-btn svg .solid { fill: var(--ink); stroke: none; }

.wide-btn { width: 100%; padding: 15px; font-family: var(--display); font-size: 19px; border-radius: 18px; }

/* ---------- 홈 ---------- */
#home {
  height: 100dvh; display: flex; flex-direction: column;
  max-width: 1040px; margin: 0 auto;
  padding: calc(var(--safe-t) + 16px) 18px 0;
}
.top { display: flex; align-items: flex-start; justify-content: space-between; }

/* 로고: 1·0·0 장난감 블록 + plays */
.logo { display: flex; align-items: flex-end; gap: 4px; text-decoration: none; color: var(--ink); padding-top: 6px; }
.logo .cube {
  width: 40px; height: 44px; display: grid; place-items: center;
  font-family: 'Lilita One', sans-serif; font-size: 30px; color: #fff; line-height: 1;
  border-radius: 11px; padding-top: 2px;
}
.logo .cube:nth-child(1) { --c: var(--orange); --e: var(--orange-d); transform: rotate(-7deg); }
.logo .cube:nth-child(2) { --c: var(--purple); --e: var(--purple-d); transform: translateY(-5px) rotate(5deg); }
.logo .cube:nth-child(3) { --c: var(--mint); --e: var(--mint-d); transform: rotate(-3deg); }
.logo .word { font-family: 'Lilita One', sans-serif; font-size: 34px; margin-left: 6px; line-height: .9; padding-bottom: 4px; }
.logo:hover .cube:nth-child(1) { animation: hop .5s ease; }
.logo:hover .cube:nth-child(2) { animation: hop .5s .08s ease; }
.logo:hover .cube:nth-child(3) { animation: hop .5s .16s ease; }
@keyframes hop { 40% { translate: 0 -8px; } }

.lang { height: 42px; padding: 0 14px; border-radius: 14px; font-weight: 800; font-size: 14px; --lift: 4px; }

.hero { display: flex; align-items: flex-end; justify-content: space-between; gap: 14px; margin: 24px 0 18px; }
.hero h1 { margin: 0; font-family: var(--display); font-weight: 400; font-size: clamp(30px, 8.6vw, 54px); line-height: 1.04; }
.hero p { margin: 8px 0 0; color: var(--ink-soft); font-size: 15px; }
.dice-btn {
  flex-shrink: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  width: 92px; height: 92px; border-radius: 24px; --lift: 6px; margin-bottom: 6px;
  font-family: var(--display); font-size: 14px; line-height: 1.05; text-align: center;
}
.dice-btn .die { font-size: 34px; line-height: 1; transition: transform .4s ease; }
.dice-btn:active .die { transform: rotate(180deg); }

.search { display: flex; align-items: center; gap: 10px; height: 50px; padding: 0 16px; border-radius: 16px; --lift: 4px; flex-shrink: 0; }
.search svg { width: 20px; height: 20px; fill: none; stroke: var(--ink-soft); stroke-width: 2.6; stroke-linecap: round; }
.search input {
  flex: 1; min-width: 0; border: 0; outline: none; background: transparent;
  font: inherit; font-weight: 700; font-size: 16px; color: var(--ink);
  -webkit-user-select: text; user-select: text;
}
.search input::placeholder { color: #8f9bc0; }

.chips { display: flex; gap: 8px; overflow-x: auto; flex-shrink: 0; margin: 0 -18px; padding: 14px 18px 18px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chips button { flex-shrink: 0; padding: 9px 15px; border-radius: 999px; --lift: 4px; font-weight: 800; font-size: 14px; }
.chips button.on { --c: var(--chip); --e: var(--chip-e); color: #fff; }

.list {
  flex: 1; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch;
  margin: 0 -18px; padding: 2px 18px calc(var(--safe-b) + 28px);
}
.section-title { font-family: var(--display); font-weight: 400; font-size: 21px; margin: 4px 2px 12px; display: flex; align-items: baseline; gap: 8px; }
.section-title .n { font-family: var(--body); font-weight: 800; font-size: 14px; color: var(--ink-soft); }
.grid { display: grid; gap: 16px 12px; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); margin-bottom: 28px; }

.game { text-align: left; padding: 14px 14px 13px; border-radius: 22px; display: flex; flex-direction: column; gap: 10px; min-height: 132px; --lift: 6px; }
.game .ico {
  width: 52px; height: 52px; border-radius: 16px; display: grid; place-items: center; font-size: 28px;
  background: var(--tint); box-shadow: inset 0 -4px 0 rgba(0,0,0,.12), inset 0 3px 0 rgba(255,255,255,.45);
}
.game:hover .ico, .game:active .ico { animation: boing .45s ease; }
@keyframes boing { 30% { transform: scale(1.12, .9); } 60% { transform: scale(.95, 1.06) translateY(-4px); } }
.game .name { font-weight: 800; font-size: 15.5px; line-height: 1.2; }
.game .meta { margin-top: auto; font-size: 12.5px; font-weight: 800; color: var(--tint-d); }
.game.soon { --c: rgba(255,255,255,.5); --e: rgba(150,190,230,.45); }
.game.soon .ico { filter: saturate(.2); opacity: .65; }
.game.soon .name, .game.soon .meta { color: var(--ink-soft); }
.empty { text-align: center; padding: 40px 0; color: var(--ink-soft); }

/* 카테고리 색 */
[data-cat="board"] { --tint: var(--orange-l); --tint-d: var(--orange-d); --chip: var(--orange); --chip-e: var(--orange-d); }
[data-cat="card"] { --tint: var(--purple-l); --tint-d: var(--purple-d); --chip: var(--purple); --chip-e: var(--purple-d); }
[data-cat="party"] { --tint: #ffb3d3; --tint-d: var(--pink-d); --chip: var(--pink); --chip-e: var(--pink-d); }
[data-cat="word"] { --tint: #9cf0d6; --tint-d: var(--mint-d); --chip: var(--mint); --chip-e: var(--mint-d); }
[data-cat="puzzle"] { --tint: #ffe68a; --tint-d: #a07a00; --chip: var(--yellow-d); --chip-e: #a37c00; }
[data-cat="arcade"] { --tint: #a6d6ff; --tint-d: var(--blue-d); --chip: var(--blue); --chip-e: var(--blue-d); }
[data-cat="sports"] { --tint: #cdf28f; --tint-d: #5b9410; --chip: var(--lime-d); --chip-e: #528a0c; }
[data-cat="all"] { --chip: var(--ink); --chip-e: #110f38; }

/* ---------- 플레이 화면 ---------- */
#player {
  position: fixed; inset: 0; height: 100dvh; width: 100vw; z-index: 10; overflow: hidden; touch-action: none;
  background: radial-gradient(120% 80% at 50% 0%, #e6f3ff 0%, var(--sky) 55%, #c4e2fd 100%);
  display: flex; flex-direction: column;
  padding: calc(var(--safe-t) + 12px) 14px calc(var(--safe-b) + 14px);
}
.bar { display: flex; gap: 9px; max-width: 560px; width: 100%; margin: 0 auto 16px; flex-shrink: 0; }
.score {
  flex: 1; min-width: 0; height: 54px; border-radius: 17px; --lift: 5px;
  display: flex; align-items: center; justify-content: space-between; gap: 6px; padding: 0 14px; color: #fff;
  transition: transform .15s ease, filter .15s ease;
}
.score .lbl { font-weight: 800; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.score b { font-family: 'Lilita One', sans-serif; font-weight: 400; font-size: 30px; line-height: 1; display: inline-block; }
.score.l { --c: var(--purple); --e: var(--purple-d); }
.score.r { --c: var(--orange); --e: var(--orange-d); }
.bar.turns .score:not(.turn) { filter: saturate(.55) brightness(1.08); }
.bar.turns .score.turn { transform: translateY(-3px); }
.score b.bump { animation: bump .4s ease; }
@keyframes bump { 40% { transform: scale(1.5); } }

#soundBtn .off { display: none; }
#soundBtn.muted .on { display: none; }
#soundBtn.muted .off { display: block; }

.stage { flex: 1; min-height: 0; position: relative; display: grid; place-items: center; }
.stage canvas { display: block; touch-action: none; }

/* 시트 */
.sheet {
  position: absolute; inset: 0; z-index: 20; display: grid; place-items: center; padding: 20px;
  background: rgba(190, 220, 250, .55); -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
}
.sheet-card {
  width: 100%; max-width: 360px; padding: 22px 18px 20px; border-radius: 28px; --lift: 8px;
  display: flex; flex-direction: column; gap: 12px;
  animation: plop .32s cubic-bezier(.3, 1.6, .5, 1);
}
@keyframes plop { from { transform: scale(.85) translateY(10px); opacity: 0; } }
.sheet-card .head { display: flex; align-items: center; gap: 14px; margin-bottom: 2px; }
.sheet-card .head .ico {
  width: 58px; height: 58px; border-radius: 18px; display: grid; place-items: center; font-size: 30px; flex-shrink: 0;
  background: var(--tint, var(--sky-2)); box-shadow: inset 0 -4px 0 rgba(0,0,0,.12), inset 0 3px 0 rgba(255,255,255,.45);
}
.sheet-card h2 { margin: 0; font-family: var(--display); font-weight: 400; font-size: 27px; line-height: 1.05; }
.sheet-card h2.win { color: var(--orange-d); }
.sheet-card h2.lose { color: var(--purple-d); }
.sheet-card .sub { margin: 4px 0 0; color: var(--ink-soft); font-size: 14px; }
.sheet-card .label { font-weight: 800; font-size: 13px; color: var(--ink-soft); margin: 4px 4px -4px; }

.seg { display: flex; gap: 6px; padding: 5px; border-radius: 18px; background: var(--sky-2); box-shadow: inset 0 3px 0 rgba(0,0,0,.06); }
.seg button {
  flex: 1; padding: 10px 4px; border-radius: 13px; background: transparent; font-weight: 800; font-size: 14px; color: var(--ink-soft);
  line-height: 1.15; transition: background .12s ease, transform .12s ease;
}
.seg button.on { background: var(--white); color: var(--ink); box-shadow: 0 3px 0 var(--white-edge); transform: translateY(-2px); }
.seg button:disabled { opacity: .45; }
.seg button small { display: block; font-size: 10.5px; font-weight: 700; opacity: .8; }

.result-score { display: flex; justify-content: center; align-items: center; gap: 14px; font-family: 'Lilita One', sans-serif; font-size: 46px; line-height: 1; margin: 4px 0 8px; }
.result-score .l { color: var(--purple); }
.result-score .r { color: var(--orange); }
.result-score .sep { color: var(--sky-3); font-size: 30px; }

.toast {
  position: fixed; left: 50%; bottom: calc(var(--safe-b) + 26px); transform: translateX(-50%); z-index: 50;
  padding: 12px 18px; border-radius: 16px; white-space: nowrap; font-weight: 800; font-size: 14px;
  --c: var(--ink); --e: #110f38; color: #fff; animation: plop .3s cubic-bezier(.3, 1.6, .5, 1);
}

/* ---------- 보드게임 공통 ---------- */
.board-wrap { display: flex; flex-direction: column; align-items: center; justify-content: center; width: 100%; height: 100%; }
.status-line { position: absolute; left: 0; right: 0; bottom: 0; text-align: center; font-weight: 800; font-size: 15px; color: var(--ink-soft); pointer-events: none; }
.board-wrap .status-line { position: static; margin-top: 18px; min-height: 22px; }

/* 장난감 말·돌 (위 광택 + 아래 두께) */
.disc.r, .stone.r { background: var(--purple); box-shadow: inset 0 -5px 0 var(--purple-d), inset 0 4px 0 rgba(255,255,255,.35); }
.disc.b, .stone.b { background: var(--orange); box-shadow: inset 0 -5px 0 var(--orange-d), inset 0 4px 0 rgba(255,255,255,.4); }

/* 틱택토 */
.ttt { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; padding-bottom: 6px; }
.ttt button { border-radius: 22px; padding: 0; display: grid; place-items: center; --lift: 7px; }
.ttt button.win { --c: #fff3c4; --e: var(--yellow-d); }
.ttt svg { width: 60%; height: 60%; overflow: visible; }
.ttt .mx { stroke: var(--orange); stroke-width: 16; stroke-linecap: round; fill: none; stroke-dasharray: 80; stroke-dashoffset: 80; animation: draw .2s ease forwards; }
.ttt .mx.two { animation-delay: .12s; }
.ttt .mo { stroke: var(--purple); stroke-width: 15; fill: none; stroke-dasharray: 170; stroke-dashoffset: 170; animation: draw .3s ease forwards; }
@keyframes draw { to { stroke-dashoffset: 0; } }

/* 사목 */
.c4 {
  display: grid; gap: 7px; padding: 11px; border-radius: 26px; position: relative;
  background: var(--blue); box-shadow: 0 8px 0 var(--blue-d), inset 0 4px 0 rgba(255,255,255,.35);
}
.c4 .cell { border-radius: 50%; background: #e8f4ff; box-shadow: inset 0 5px 0 rgba(20,60,120,.22); position: relative; cursor: pointer; }
.c4 .disc { position: absolute; inset: 6%; border-radius: 50%; animation: drop var(--dur, .35s) cubic-bezier(.5, 0, .75, 0) forwards; }
@keyframes drop { from { transform: translateY(var(--from, -400%)); } to { transform: translateY(0); } }
.c4 .cell.win .disc { animation: winpop .5s ease infinite alternate; }
@keyframes winpop { to { transform: scale(1.12); } }

/* 리버시 */
.rv {
  display: grid; grid-template-columns: repeat(8, 1fr); gap: 4px; padding: 10px; border-radius: 24px;
  background: var(--mint-d); box-shadow: 0 8px 0 #0b7c5c, inset 0 4px 0 rgba(255,255,255,.25);
}
.rv button { border-radius: 9px; padding: 0; background: var(--mint); box-shadow: inset 0 3px 0 rgba(255,255,255,.3); display: grid; place-items: center; position: relative; }
.rv .stone { width: 80%; height: 80%; border-radius: 50%; }
.rv .stone.flip { animation: flip .32s ease; }
@keyframes flip { 50% { transform: scaleX(0) translateY(-4px); } }
.rv .hint { width: 28%; height: 28%; border-radius: 50%; background: rgba(255,255,255,.75); animation: breathe 1.2s ease-in-out infinite alternate; }
@keyframes breathe { to { transform: scale(.7); opacity: .55; } }
.rv button.last::after { content: ''; position: absolute; width: 18%; height: 18%; border-radius: 50%; background: #fff; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
@media (min-width: 720px) {
  .grid { grid-template-columns: repeat(auto-fill, minmax(176px, 1fr)); gap: 20px 16px; }
  .logo .cube { width: 46px; height: 50px; font-size: 34px; }
  .logo .word { font-size: 40px; }
}
