* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; overflow: hidden; }
body {
  font-family: 'Mali', 'Itim', system-ui, sans-serif;
  background: linear-gradient(180deg, #cfe9ff 0%, #ffd8e8 55%, #fff0c2 100%);
  color: #5a3a55;
  user-select: none;
  -webkit-user-select: none;
  position: relative;
  overscroll-behavior: none;
  touch-action: manipulation;
}

/* พื้นหลังเมฆลอย ๆ */
.bg-decor { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 0; }
.cloud {
  position: absolute; width: 110px; height: 60px; background: rgba(255,255,255,0.85);
  border-radius: 60px; filter: blur(0.4px);
  box-shadow: 0 6px 14px rgba(180, 200, 230, 0.3);
}
.cloud::before, .cloud::after{
  content:''; position:absolute; background:inherit; border-radius:50%;
}
.cloud::before { width:55px; height:55px; top:-22px; left:18px; }
.cloud::after { width:38px; height:38px; top:-14px; right:20px; }
.c1 { top:8%; left:-30px; animation: drift 22s linear infinite; }
.c2 { top:18%; right:-40px; animation: drift2 28s linear infinite; transform: scale(.7); }
.c3 { top:55%; left:-50px; animation: drift 30s linear infinite; transform: scale(.85); opacity:.7;}
@keyframes drift { from{ transform: translateX(-20px) } to { transform: translateX(110vw) } }
@keyframes drift2 { from{ transform: translateX(20px) scale(.7) } to { transform: translateX(-110vw) scale(.7) } }

.sparkle {
  position: absolute; width: 14px; height: 14px;
  background: radial-gradient(circle, #fff 0%, #ffd1e2 60%, transparent 70%);
  border-radius: 50%;
  animation: twinkle 2.6s ease-in-out infinite;
}
.star {
  position:absolute; width:18px; height:18px;
  background: gold;
  clip-path: polygon(50% 0%, 61% 35%, 98% 35%, 68% 57%, 79% 91%, 50% 70%, 21% 91%, 32% 57%, 2% 35%, 39% 35%);
  animation: floaty 4s ease-in-out infinite;
  filter: drop-shadow(0 2px 4px rgba(255,200,0,.4));
}
.heart {
  position:absolute; width:16px; height:16px; transform: rotate(-45deg);
  background: #ff8fb1; animation: floaty 5s ease-in-out infinite;
}
.heart::before, .heart::after { content:''; position:absolute; width:16px; height:16px; background:inherit; border-radius:50%;}
.heart::before { top:-8px; left:0; }
.heart::after { top:0; left:8px; }
@keyframes twinkle { 0%,100%{transform:scale(.6); opacity:.5} 50%{transform:scale(1.2); opacity:1} }
@keyframes floaty { 0%,100%{transform: translateY(0) rotate(0)} 50%{transform: translateY(-10px) rotate(8deg)} }

/* App container */
.app {
  position: relative; z-index: 1;
  height: 100dvh; max-width: 480px; margin: 0 auto;
  display: flex; flex-direction: column;
  padding: 14px 16px 18px; gap: 10px;
}

/* Header */
.header {
  display: flex; align-items: center; justify-content: space-between;
  background: rgba(255,255,255,.65); backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-radius: 22px; padding: 10px 14px;
  box-shadow: 0 6px 20px rgba(255, 170, 200, .25), inset 0 0 0 2px rgba(255,255,255,.7);
}
.title {
  font-weight: 700; font-size: 18px; color:#ff5e8a;
  letter-spacing: .5px; display:flex; align-items:center; gap:6px;
}
.title .ribbon{
  background: linear-gradient(135deg, #ff7aa8, #ff9ec7);
  color:#fff; padding: 4px 12px; border-radius: 999px;
  font-size: 13px; font-weight:700;
  box-shadow: 0 4px 10px rgba(255,120,160,.4);
}
.score-pill {
  display:flex; align-items:center; gap:8px;
  background: linear-gradient(135deg, #fff, #ffe6f0);
  padding: 6px 10px; border-radius: 999px;
  border: 2px solid #ffc1d6;
  font-weight: 700; font-size: 13px;
}
.score-pill .me{ color:#ff5e8a; }
.score-pill .cpu{ color:#5aa9ff; }
.score-pill .dot{ color:#bbb; }

/* VS bar */
.vs-row {
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 8px;
  background: rgba(255,255,255,.55); border-radius: 20px; padding: 10px;
  box-shadow: 0 6px 18px rgba(180,200,255,.25);
}
.player-card {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 6px 4px; border-radius: 16px; position: relative;
}
.player-card.me { background: linear-gradient(180deg, #ffd9e8, #fff); }
.player-card.cpu { background: linear-gradient(180deg, #d6ebff, #fff); }
.avatar {
  width: 78px; height: 78px; border-radius: 50%;
  background:#fff; display:flex; align-items:center; justify-content:center;
  box-shadow: 0 6px 14px rgba(0,0,0,.08), inset 0 0 0 3px #fff;
  position: relative;
  transition: transform .25s ease;
}
.me .avatar { border: 3px solid #ffb1cb; }
.cpu .avatar { border: 3px solid #a8d3ff; }
.avatar svg { width: 64px; height: 64px; }
.name-tag {
  font-weight: 700; font-size: 13px; color: #fff;
  padding: 3px 12px; border-radius: 999px;
  box-shadow: 0 3px 8px rgba(0,0,0,.12);
}
.me .name-tag { background: linear-gradient(135deg,#ff7aa8,#ff5e8a); }
.cpu .name-tag { background: linear-gradient(135deg,#7ab8ff,#5aa9ff); }

.vs-badge {
  width: 56px; height: 56px; border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, #fff3a3, #ffce3a 70%, #ffae00);
  display:flex; align-items:center; justify-content:center;
  color:#ff5e2d; font-weight:800; font-size: 20px;
  box-shadow: 0 6px 14px rgba(255,170,0,.45), inset 0 -4px 0 rgba(0,0,0,.08);
  border: 3px solid #fff;
  animation: pulse 1.6s ease-in-out infinite;
  text-shadow: 0 2px 0 rgba(255,255,255,.6);
}
@keyframes pulse { 0%,100%{ transform: scale(1) } 50%{ transform: scale(1.08) } }

/* Hand display zone */
.arena {
  flex: 1;
  display: grid; grid-template-columns: 1fr 1fr; gap: 10px;
  align-items: center;
  background: linear-gradient(180deg, rgba(255,255,255,.7), rgba(255,255,255,.45));
  border-radius: 24px; padding: 14px;
  box-shadow: 0 8px 24px rgba(255,180,210,.2), inset 0 0 0 2px rgba(255,255,255,.8);
  position: relative; overflow: hidden;
  min-height: 0;
}
.arena::before, .arena::after{
  content:''; position:absolute; width: 80px; height: 80px; border-radius:50%;
  filter: blur(20px); opacity:.6;
}
.arena::before{ background:#ffc6dc; top:-20px; left:-20px;}
.arena::after{ background:#bcdcff; bottom:-20px; right:-20px;}

.hand-box {
  aspect-ratio: 1 / 1.05;
  background: #fff;
  border-radius: 20px;
  display:flex; align-items:center; justify-content:center;
  box-shadow: 0 6px 14px rgba(0,0,0,.06), inset 0 0 0 3px rgba(255,255,255,.9);
  position: relative; z-index: 1;
  border: 3px dashed transparent;
  transition: transform .25s ease, border-color .25s ease;
}
.hand-box.me { background: linear-gradient(180deg, #fff, #ffe6f0); border-color: #ffc1d6; }
.hand-box.cpu { background: linear-gradient(180deg, #fff, #e6f1ff); border-color: #b8daff; }
.hand-box .label {
  position:absolute; top:8px; left:50%; transform: translateX(-50%);
  font-size: 11px; font-weight:700; padding: 2px 10px; border-radius: 999px;
  color:#fff;
}
.hand-box.me .label { background:#ff7aa8; }
.hand-box.cpu .label { background:#5aa9ff; }
.hand-emoji {
  font-size: 60px; line-height: 1;
  filter: drop-shadow(0 4px 6px rgba(0,0,0,.15));
  transition: transform .25s ease;
}

/* Result banner */
.result-banner {
  text-align: center; font-weight: 700; font-size: 16px;
  padding: 8px 14px; border-radius: 16px;
  background: rgba(255,255,255,.8);
  color:#5a3a55;
  box-shadow: 0 4px 12px rgba(0,0,0,.06);
  min-height: 38px;
  display:flex; align-items:center; justify-content:center; gap:6px;
  transition: all .3s ease;
}
.result-banner.win { background: linear-gradient(135deg,#fff0a8,#ffd86b); color:#a85a00; }
.result-banner.lose { background: linear-gradient(135deg,#e0e0e0,#cfcfcf); color:#555; }
.result-banner.draw { background: linear-gradient(135deg,#e6e0ff,#cfc5ff); color:#5b3aa8; }

/* Choices */
.choices-title {
  text-align:center; font-weight:700; font-size: 14px; color:#ff5e8a;
  background: rgba(255,255,255,.7); align-self:center;
  padding: 4px 14px; border-radius: 999px;
  box-shadow: 0 3px 8px rgba(255,180,200,.25);
  margin-top: -4px;
}
.choices {
  display:grid; grid-template-columns: repeat(3, 1fr); gap: 10px;
}
.choice-btn {
  border: none; cursor: pointer; outline: none;
  background: linear-gradient(180deg,#fff,#fff8fb);
  border-radius: 22px; padding: 12px 6px 10px;
  display:flex; flex-direction:column; align-items:center; gap:4px;
  box-shadow: 0 6px 0 rgba(0,0,0,.05), 0 6px 18px rgba(255,180,200,.3);
  transition: transform .12s ease, box-shadow .12s ease, filter .12s ease;
  font-family: inherit;
}
.choice-btn .ico {
  width: 56px; height: 56px; border-radius: 50%;
  display:flex; align-items:center; justify-content:center;
  font-size: 30px;
  box-shadow: inset 0 -4px 0 rgba(0,0,0,.06);
}
.choice-btn[data-key="rock"] .ico { background: linear-gradient(160deg,#ffd1de,#ff9ec0); }
.choice-btn[data-key="paper"] .ico { background: linear-gradient(160deg,#fff1b0,#ffd96b); }
.choice-btn[data-key="scissors"] .ico { background: linear-gradient(160deg,#cfe7ff,#8ec5ff); }
.choice-btn .name { font-weight:700; font-size: 13px; }
.choice-btn[data-key="rock"] .name { color:#ff5e8a; }
.choice-btn[data-key="paper"] .name { color:#cf8b00; }
.choice-btn[data-key="scissors"] .name { color:#3d8bff; }
.choice-btn:active { transform: translateY(2px); box-shadow: 0 2px 0 rgba(0,0,0,.05), 0 4px 10px rgba(255,180,200,.3); }
.choice-btn:disabled { filter: grayscale(.4) opacity(.6); cursor: not-allowed; }
.choice-btn.picked { transform: scale(1.04); box-shadow: 0 6px 0 #ffb1cb, 0 6px 22px rgba(255,140,180,.5); }

/* Bottom row */
.bottom-row {
  display:flex; gap: 8px; align-items:center; justify-content:space-between;
}
.reset-btn, .rules-btn {
  flex:1;
  border:none; cursor:pointer; padding: 10px;
  background: rgba(255,255,255,.75);
  color:#7a5670; font-weight:700; font-size: 13px;
  border-radius: 14px;
  box-shadow: 0 3px 0 rgba(0,0,0,.05);
  font-family: inherit;
}
.reset-btn:active, .rules-btn:active { transform: translateY(1px); }

/* Animations */
.shake { animation: shake .5s ease; }
@keyframes shake {
  0%,100% { transform: translateY(0) rotate(0); }
  20% { transform: translateY(-12px) rotate(-6deg); }
  40% { transform: translateY(-2px) rotate(6deg); }
  60% { transform: translateY(-12px) rotate(-4deg); }
  80% { transform: translateY(-2px) rotate(4deg); }
}
.pop { animation: pop .35s ease; }
@keyframes pop {
  0% { transform: scale(.6); opacity: 0; }
  60% { transform: scale(1.15); opacity: 1; }
  100% { transform: scale(1); }
}
.wiggle { animation: wiggle .6s ease; }
@keyframes wiggle {
  0%,100% { transform: rotate(0); }
  25% { transform: rotate(-8deg); }
  75% { transform: rotate(8deg); }
}

/* Confetti */
.confetti {
  position: fixed; top: -10px; width: 10px; height: 14px;
  pointer-events: none; z-index: 9;
  border-radius: 2px;
}

/* Modal */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(90,58,85,.45);
  backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
  display:none; align-items:center; justify-content:center; z-index: 10;
  padding: 20px;
}
.modal-overlay.show { display:flex; }
.modal {
  background: linear-gradient(180deg,#fff,#fff5fa);
  border-radius: 24px; padding: 22px 18px 18px;
  width: 100%; max-width: 360px;
  box-shadow: 0 20px 50px rgba(255,120,160,.4), inset 0 0 0 3px #fff;
  text-align: center;
  animation: pop .4s ease;
}
.modal h2 { color:#ff5e8a; font-size: 20px; margin-bottom: 10px; }
.modal .rule-row {
  display:flex; align-items:center; justify-content:center; gap:8px;
  background: #fff; border-radius: 12px; padding: 8px;
  margin: 6px 0;
  box-shadow: 0 2px 6px rgba(0,0,0,.05);
  font-weight: 700; font-size: 14px;
}
.modal .rule-row .gt { color: #ff7aa8; font-weight: 800; }
.modal .close-btn {
  margin-top: 12px; width: 100%; padding: 12px;
  border:none; cursor:pointer; font-family: inherit;
  background: linear-gradient(135deg,#ff7aa8,#ff5e8a);
  color:#fff; font-weight: 700; font-size: 15px;
  border-radius: 14px;
  box-shadow: 0 4px 12px rgba(255,120,160,.4);
}

/* Small phones tweaks */
@media (max-height: 700px){
  .avatar { width: 64px; height: 64px; }
  .avatar svg { width: 52px; height: 52px; }
  .vs-badge { width: 46px; height: 46px; font-size: 16px; }
  .hand-emoji { font-size: 50px; }
  .choice-btn .ico { width: 48px; height: 48px; font-size: 26px; }
  .stage-cell { padding: 4px 0; }
  .stage-cell .num { font-size: 11px; }
  .stage-cell .rwd { font-size: 10px; }
}

/* Stage bar */
.stage-bar {
  display: grid; grid-template-columns: repeat(6, 1fr); gap: 4px;
  background: rgba(255,255,255,.55); border-radius: 16px; padding: 6px;
  box-shadow: 0 4px 14px rgba(180,200,255,.2);
}
.stage-cell {
  display:flex; flex-direction:column; align-items:center;
  padding: 6px 0;
  background: #fff; border-radius: 10px;
  box-shadow: inset 0 0 0 2px rgba(255,193,214,.4);
  font-weight: 700;
  transition: all .25s ease;
}
.stage-cell .num {
  font-size: 12px; color:#a07088;
  background: #ffe6f0; padding: 1px 8px; border-radius: 999px;
  margin-bottom: 2px;
}
.stage-cell .rwd {
  font-size: 12px; color:#ff5e8a;
}
.stage-cell.passed {
  background: linear-gradient(180deg,#fff0a8,#ffd86b);
  box-shadow: inset 0 0 0 2px #ffae00;
}
.stage-cell.passed .num { background: #fff; color:#a85a00; }
.stage-cell.passed .rwd { color:#a85a00; }
.stage-cell.current {
  background: linear-gradient(180deg,#ffd9e8,#ff9ec0);
  box-shadow: inset 0 0 0 2px #ff5e8a, 0 4px 12px rgba(255,140,180,.4);
  transform: scale(1.04);
}
.stage-cell.current .num { background:#fff; color:#ff5e8a; }
.stage-cell.current .rwd { color:#fff; text-shadow: 0 1px 0 rgba(0,0,0,.15); }

/* Decide row (Stop / Continue) */
.decide-row {
  display:grid; grid-template-columns: 1fr 1fr; gap: 10px;
}
.decide-row.hidden { display: none; }
.decide-btn {
  border:none; cursor:pointer; padding: 12px 10px;
  font-family: inherit; font-weight: 800; font-size: 15px;
  border-radius: 18px;
  box-shadow: 0 6px 0 rgba(0,0,0,.06), 0 6px 18px rgba(255,180,200,.3);
  color:#fff;
  transition: transform .12s ease, box-shadow .12s ease;
}
.decide-btn:active { transform: translateY(2px); box-shadow: 0 2px 0 rgba(0,0,0,.06), 0 4px 12px rgba(255,180,200,.3); }
.decide-btn.stop { background: linear-gradient(135deg,#ffb88a,#ff7e5e); }
.decide-btn.continue { background: linear-gradient(135deg,#7ed6c1,#3bb8e0); }
.decide-btn:disabled { filter: grayscale(.4) opacity(.6); cursor: not-allowed; }

/* Big icon for modals */
.big-icon { font-size: 56px; line-height: 1; margin-bottom: 6px; }
.modal p { color:#7a5670; line-height: 1.5; margin: 6px 0 4px; font-size: 14px; }
.modal .rule-note { color:#7a5670; font-size: 12px; margin-top: 8px; line-height: 1.5; }

/* Win/Lose tint on result modal */
.result-modal-content.win { background: linear-gradient(180deg,#fffdf3,#fff5da); }
.result-modal-content.lose { background: linear-gradient(180deg,#fafafa,#eaeaea); }
.result-modal-content.win h2 { color: #d68b00; }
.result-modal-content.lose h2 { color: #555; }

.hidden { display: none !important; }

