 *, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

    :root {
      --sun: #FFD93D;
      --sky: #6BCBF7;
      --coral: #FF6B6B;
      --mint: #6BDFB8;
      --ink: #1a1a2e;
      --cream: #FFFDF4;
    }

    body {
      min-height: 100vh;
      background: var(--sky);
      font-family: 'Nunito', sans-serif;
      display: flex;
      align-items: center;
      justify-content: center;
      overflow: hidden;
      position: relative;
    }

    /* Wavy background blobs */
    body::before {
      content: '';
      position: fixed;
      width: 600px; height: 600px;
      background: radial-gradient(circle, #a8edea55 0%, transparent 70%);
      top: -150px; left: -150px;
      border-radius: 50%;
    }
    body::after {
      content: '';
      position: fixed;
      width: 500px; height: 500px;
      background: radial-gradient(circle, #ffd93d44 0%, transparent 70%);
      bottom: -100px; right: -100px;
      border-radius: 50%;
    }

    .card {
      background: var(--cream);
      border-radius: 32px;
      padding: 48px 40px 40px;
      width: 360px;
      box-shadow: 8px 8px 0px var(--ink), 0 20px 60px rgba(0,0,0,0.15);
      border: 3px solid var(--ink);
      position: relative;
      z-index: 1;
      animation: pop-in 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275) both;
    }

    @keyframes pop-in {
      from { transform: scale(0.7) rotate(-3deg); opacity: 0; }
      to   { transform: scale(1) rotate(0deg); opacity: 1; }
    }

    h1 {
      font-family: 'Boogaloo', cursive;
      font-size: 2.6rem;
      color: var(--ink);
      text-align: center;
      letter-spacing: 1px;
      line-height: 1;
      margin-bottom: 6px;
    }
    h1 span {
      color: var(--coral);
    }

    .subtitle {
      text-align: center;
      font-size: 0.85rem;
      color: #888;
      margin-bottom: 28px;
      letter-spacing: 0.05em;
      text-transform: uppercase;
    }

    /* Coin */
    .coin-wrap {
      perspective: 600px;
      width: 120px; height: 120px;
      margin: 0 auto 28px;
    }
    .coin {
      width: 100%; height: 100%;
      position: relative;
      transform-style: preserve-3d;
      transition: transform 0.7s cubic-bezier(0.4, 0, 0.2, 1);
      border-radius: 50%;
    }
    .coin.flip-heads { animation: flipToHeads 0.7s ease forwards; }
    .coin.flip-tails  { animation: flipToTails  0.7s ease forwards; }

    @keyframes flipToHeads {
      0%   { transform: rotateY(0deg); }
      50%  { transform: rotateY(900deg) scale(1.15); }
      100% { transform: rotateY(1800deg); }
    }
    @keyframes flipToTails {
      0%   { transform: rotateY(0deg); }
      50%  { transform: rotateY(900deg) scale(1.15); }
      100% { transform: rotateY(1800deg) rotateY(180deg); }
    }

    .coin-face {
      position: absolute; inset: 0;
      border-radius: 50%;
      border: 4px solid var(--ink);
      display: flex; align-items: center; justify-content: center;
      font-family: 'Boogaloo', cursive;
      font-size: 2.2rem;
      backface-visibility: hidden;
    }
    .coin-heads {
      background: var(--sun);
      box-shadow: inset 0 -4px 10px rgba(0,0,0,0.12);
    }
    .coin-tails {
      background: var(--mint);
      box-shadow: inset 0 -4px 10px rgba(0,0,0,0.12);
      transform: rotateY(180deg);
    }

    /* Scoreboard */
    .scoreboard {
      display: flex;
      gap: 14px;
      margin-bottom: 28px;
    }
    .score-box {
      flex: 1;
      border-radius: 16px;
      border: 2.5px solid var(--ink);
      padding: 14px 10px;
      text-align: center;
      box-shadow: 4px 4px 0 var(--ink);
    }
    .score-box.wins  { background: #d4f5e2; }
    .score-box.losses{ background: #fde4e4; }
    .score-label {
      font-size: 0.7rem;
      text-transform: uppercase;
      letter-spacing: 0.1em;
      color: #555;
      font-weight: 700;
    }
    .score-num {
      font-family: 'Boogaloo', cursive;
      font-size: 2.8rem;
      line-height: 1;
      color: var(--ink);
    }

    /* Result message */
    .result-msg {
      text-align: center;
      font-weight: 700;
      font-size: 1rem;
      min-height: 26px;
      margin-bottom: 22px;
      color: var(--ink);
      transition: all 0.2s;
    }
    .result-msg.win  { color: #22a85a; }
    .result-msg.loss { color: var(--coral); }

    /* Buttons */
    .btn-row {
      display: flex;
      gap: 12px;
      margin-bottom: 14px;
    }
    .btn {
      flex: 1;
      padding: 14px 10px;
      font-family: 'Boogaloo', cursive;
      font-size: 1.3rem;
      border: 2.5px solid var(--ink);
      border-radius: 14px;
      cursor: pointer;
      box-shadow: 4px 4px 0 var(--ink);
      transition: transform 0.1s, box-shadow 0.1s;
      letter-spacing: 0.05em;
    }
    .btn:active {
      transform: translate(3px, 3px);
      box-shadow: 1px 1px 0 var(--ink);
    }
    .btn-heads { background: var(--sun); }
    .btn-tails { background: var(--mint); }

    .btn-clear {
      width: 100%;
      padding: 10px;
      font-family: 'Nunito', sans-serif;
      font-weight: 700;
      font-size: 0.85rem;
      border: 2px solid #ccc;
      border-radius: 10px;
      background: transparent;
      color: #aaa;
      cursor: pointer;
      letter-spacing: 0.05em;
      text-transform: uppercase;
      transition: all 0.15s;
    }
    .btn-clear:hover { background: #f5e0e0; color: var(--coral); border-color: var(--coral); }

    /* Bounce score on update */
    @keyframes bump {
      0%,100% { transform: scale(1); }
      50%      { transform: scale(1.35); }
    }
    .bump { animation: bump 0.3s ease; }