/* Kingdom letters (9 Nov 2026): every message to the player is a royal letter, after the user's sheet.
   - .letter on .ask-card (Confirm Action) and .rp-box (Royal Reward): parchment in a gold frame, a ribbon title
     with a crown on top, red and parchment buttons. Opens by unfolding (the ribbon unfurls, the crown drops in),
     closes by folding away (.closing).
   - .note.letter: a sealed scroll (a wax seal holds the icon) that unrolls in and rolls up when it goes.
   - .toast.letter: a gold plaque with a crest, for short messages during a match.
   Everything is drawn in CSS so it stays sharp on every phone. */

:root {
  --lp-ink: #4a2a0e;
  --lp-ink-soft: #6b4520;
  --lp-gold-frame: linear-gradient(135deg, #fff1b8 0%, #e2ad3c 22%, #8a5a12 45%, #f8dc84 62%, #b07818 82%, #ffe7a0 100%);
  --lp-paper: radial-gradient(ellipse at 50% 35%, #fdf3da 0%, #f3e0b6 52%, #dcbb80 100%);
  --lp-grain: repeating-linear-gradient(112deg, rgba(120, 72, 18, .035) 0 1px, transparent 1px 5px), repeating-linear-gradient(22deg, rgba(255, 255, 255, .08) 0 1px, transparent 1px 7px);
  --lp-red: linear-gradient(180deg, #e2454c 0%, #b21d27 48%, #7c0c14 100%);
  --lp-purple: linear-gradient(180deg, #8a3cb0 0%, #5a1d84 52%, #3a0e5a 100%);
  --lp-crown: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 70'%3E%3Cdefs%3E%3ClinearGradient id='g' x1='0' y1='0' x2='0' y2='1'%3E%3Cstop offset='0' stop-color='%23fff4c2'/%3E%3Cstop offset='.45' stop-color='%23f2c142'/%3E%3Cstop offset='1' stop-color='%23a8680e'/%3E%3C/linearGradient%3E%3C/defs%3E%3Cpath d='M8 58 L4 18 L28 36 L50 6 L72 36 L96 18 L92 58 Z' fill='url(%23g)' stroke='%236b3d06' stroke-width='3' stroke-linejoin='round'/%3E%3Crect x='8' y='54' width='84' height='12' rx='3' fill='url(%23g)' stroke='%236b3d06' stroke-width='3'/%3E%3Ccircle cx='50' cy='38' r='7' fill='%23d9283a' stroke='%236b0a14' stroke-width='2'/%3E%3Ccircle cx='27' cy='45' r='4.5' fill='%233a6fe0' stroke='%23122a6b' stroke-width='1.5'/%3E%3Ccircle cx='73' cy='45' r='4.5' fill='%233a6fe0' stroke='%23122a6b' stroke-width='1.5'/%3E%3Ccircle cx='4' cy='17' r='4' fill='%23ffe7a0' stroke='%236b3d06' stroke-width='2'/%3E%3Ccircle cx='50' cy='6' r='4.5' fill='%23ffe7a0' stroke='%236b3d06' stroke-width='2'/%3E%3Ccircle cx='96' cy='17' r='4' fill='%23ffe7a0' stroke='%236b3d06' stroke-width='2'/%3E%3C/svg%3E");
}

/* ---------- the letter: Confirm Action, Royal Reward ---------- */
.ask-card.letter, .reward-pop .rp-box.letter {
  position: relative; width: 540px; max-width: calc(100vw - 40px); box-sizing: border-box;
  padding: 58px 40px 30px; border-radius: 22px; text-align: center; color: var(--lp-ink);
  border: 7px solid transparent;
  background: var(--lp-grain) padding-box, var(--lp-paper) padding-box, var(--lp-gold-frame) border-box;
  box-shadow: 0 0 0 2px #5a3608, inset 0 0 46px rgba(124, 74, 14, .38), 0 24px 60px rgba(0, 0, 0, .65);
  transform-origin: 50% 0; animation: letterOpen .55s cubic-bezier(.2, 1.25, .35, 1) both;
}
.ask-card.letter.wide { width: 660px; }
.ask-card.letter::after, .reward-pop .rp-box.letter::after { /* the gold jewel under the letter */
  content: ''; position: absolute; left: 50%; bottom: -15px; width: 24px; height: 24px; transform: translateX(-50%) rotate(45deg);
  background: var(--lp-gold-frame); box-shadow: 0 0 0 2px #5a3608, 0 4px 8px rgba(0, 0, 0, .4); border-radius: 4px;
}
.letter .l-crown { position: absolute; left: 50%; top: -76px; width: 86px; height: 60px; transform: translateX(-50%); background: var(--lp-crown) center / contain no-repeat; filter: drop-shadow(0 4px 6px rgba(0, 0, 0, .5)); animation: crownDrop .6s .25s cubic-bezier(.2, 1.5, .4, 1) both; z-index: 2; }
.letter .l-ribbon { position: absolute; left: 50%; top: -30px; transform: translateX(-50%); min-width: 300px; max-width: 92%; padding: 10px 46px 12px; box-sizing: border-box;
  background: var(--lp-red); color: #ffeab0; font: 900 26px/1.1 'Cinzel', serif; letter-spacing: .04em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  text-shadow: 0 2px 0 #4a0508, 0 0 10px rgba(255, 210, 120, .35);
  clip-path: polygon(0 0, 100% 0, 94% 50%, 100% 100%, 0 100%, 6% 50%);
  box-shadow: inset 0 0 0 3px rgba(255, 220, 140, .85); animation: ribbonUnfurl .5s .15s cubic-bezier(.2, 1.2, .4, 1) both; }
.letter.l-purple .l-ribbon { background: var(--lp-purple); text-shadow: 0 2px 0 #24063a, 0 0 10px rgba(255, 210, 120, .35); }
.letter .ask-ico { font-size: 44px; line-height: 1; margin: 4px 0 6px; filter: drop-shadow(0 3px 3px rgba(80, 40, 0, .35)); }
.letter h3 { margin: 4px 0 8px; font: 900 26px/1.2 'Cinzel', serif; color: #5a2d0c; background: none; -webkit-text-fill-color: currentColor; text-shadow: none; }
.letter p, .letter .rp-items { margin: 0 0 6px; font: 600 19px/1.45 Georgia, 'Times New Roman', serif; color: var(--lp-ink); text-shadow: 0 1px 0 rgba(255, 255, 255, .5); }
.letter p b, .letter p strong { color: #7a1810; }
.letter .l-rule { display: block; height: 14px; margin: 14px auto 18px; width: 70%; background:
  radial-gradient(circle, #b07818 0 4px, transparent 5px) center / 14px 14px no-repeat,
  linear-gradient(90deg, transparent, #b07818 20%, #b07818 80%, transparent) center / 100% 2px no-repeat; }
.letter .ask-actions { display: flex; justify-content: center; gap: 18px; }
/* buttons: Yes / OK is royal red, Cancel is parchment */
.letter .big-btn { min-width: 160px; border-radius: 14px; font: 900 22px/1 'Cinzel', serif; letter-spacing: .04em; padding: 13px 22px; color: #fff1c4;
  background: var(--lp-red); border: 3px solid #f2c75a; box-shadow: 0 0 0 2px #5a1a08, 0 5px 0 #4a0a0e, 0 10px 18px rgba(0, 0, 0, .35); text-shadow: 0 2px 0 #4a0508; }
.letter .big-btn[data-a="0"], .letter .big-btn.blue { color: #5a3410; text-shadow: 0 1px 0 rgba(255, 255, 255, .6); background: linear-gradient(180deg, #fff6dc 0%, #ecd6a0 60%, #d4b26c 100%); box-shadow: 0 0 0 2px #7a5212, 0 5px 0 #8a6420, 0 10px 18px rgba(0, 0, 0, .3); }
.letter .big-btn:active { transform: translateY(3px); box-shadow: 0 0 0 2px #5a1a08, 0 2px 0 #4a0a0e; }
.letter .big-btn.green { background: linear-gradient(180deg, #4fc06a 0%, #1f8a3e 55%, #0f5a26 100%); }
.letter .del-confirm, .letter input, .letter select { background: #fffaf0; color: var(--lp-ink); border: 2px solid #c79a4a; }
.letter .type-pick { color: var(--lp-ink); }
/* closing: the letter folds up and away */
.ask-card.letter.closing, .reward-pop .rp-box.letter.closing { animation: letterClose .28s ease-in both; }
.ask.closing, .reward-pop.closing { animation: shadeOut .28s ease-in both; }

/* Royal Reward */
.reward-pop .rp-box.letter { width: 560px; padding-top: 64px; }
.reward-pop .rp-box.letter .rp-items { font-size: 22px; margin: 6px 0 16px; }
.reward-pop .rp-box.letter .rp-shine { position: absolute; inset: 0; border-radius: 16px; pointer-events: none; overflow: hidden; }
.reward-pop .rp-box.letter .rp-shine::before { content: ''; position: absolute; left: 50%; top: 42%; width: 480px; height: 480px; transform: translate(-50%, -50%);
  background: repeating-conic-gradient(from 0deg, rgba(255, 214, 102, .28) 0deg 10deg, transparent 10deg 24deg); border-radius: 50%; animation: rpSpin 14s linear infinite;
  -webkit-mask: radial-gradient(circle, #000 20%, transparent 65%); mask: radial-gradient(circle, #000 20%, transparent 65%); }

/* ---------- the sealed scroll: notifications ---------- */
.note.letter { width: 420px; padding: 12px 40px 14px 82px; border-radius: 12px; overflow: visible; color: var(--lp-ink); align-items: center; min-height: 74px; box-sizing: border-box;
  border: 3px solid transparent;
  background: var(--lp-grain) padding-box, var(--lp-paper) padding-box, var(--lp-gold-frame) border-box;
  box-shadow: 0 0 0 1.5px #6b4210, inset 0 0 26px rgba(124, 74, 14, .32), 0 14px 30px rgba(0, 0, 0, .55);
  backdrop-filter: none; -webkit-backdrop-filter: none;
  animation: scrollOpen .5s cubic-bezier(.2, 1, .3, 1) both; }
.note.letter::before, .note.letter::after { /* the rolled ends of the scroll */
  content: ''; position: absolute; top: -6px; bottom: -6px; width: 16px; border-radius: 9px;
  background: linear-gradient(90deg, #8a5a1c 0%, #e8c98a 35%, #fff2d0 50%, #d6ad66 70%, #7a4c12 100%);
  box-shadow: 0 3px 6px rgba(0, 0, 0, .4); left: -10px; right: auto; width: 16px; }
.note.letter::after { left: auto; right: -10px; }
.note.letter .n-glow { display: none; }
.note.letter .n-ico { position: absolute; left: 10px; top: 50%; width: 60px; height: 60px; margin-top: -30px; border-radius: 48% 52% 46% 54% / 52% 47% 53% 48%;
  background: radial-gradient(circle at 35% 30%, #f06a6e 0%, #c0222c 42%, #7c0c14 100%);
  box-shadow: 0 0 0 3px rgba(124, 12, 20, .55), inset 0 -4px 8px rgba(0, 0, 0, .35), inset 0 3px 6px rgba(255, 200, 200, .35), 0 4px 8px rgba(0, 0, 0, .45);
  animation: sealStamp .45s .25s cubic-bezier(.2, 1.6, .4, 1) both; }
.note.letter .n-ico::before { content: ''; position: absolute; inset: 7px; border-radius: 50%; border: 2px dashed rgba(255, 200, 190, .45); }
.note.letter .n-ico i { position: relative; font-size: 24px; }
.note.letter .n-body { color: var(--lp-ink); }
.note.letter .n-body > b:first-child { display: block; color: #5a2d0c; font: 900 18px/1.2 'Cinzel', serif; letter-spacing: .02em; margin-bottom: 2px; }
.note.letter .n-kind { background: none; color: #8a5a1c; padding: 0; font: 900 12px 'Cinzel', serif; letter-spacing: .14em; box-shadow: none; }
.note.letter .n-text { color: var(--lp-ink); font: 600 15.5px/1.4 Georgia, 'Times New Roman', serif; }
.note.letter .n-text b { color: #7a1810; }
.note.letter .n-x { right: 8px; background: rgba(90, 50, 10, .12); color: #5a3410; }
.note.letter .n-x:hover { background: rgba(90, 50, 10, .24); }
.note.letter .n-timer { left: 14px; right: 14px; bottom: 4px; height: 2px; border-radius: 2px; background: linear-gradient(90deg, #b07818, #f2c75a); box-shadow: none; }
.note.letter .n-btn { border-radius: 10px; font: 900 14px 'Cinzel', serif; color: #fff1c4; background: var(--lp-red); border: 2px solid #f2c75a; box-shadow: 0 3px 0 #4a0a0e; }
.note.letter .n-btn + .n-btn, .note.letter .n-btn.ghost { color: #5a3410; background: linear-gradient(180deg, #fff6dc, #e2c690); border-color: #b07818; box-shadow: 0 3px 0 #8a6420; }
/* kinds: the seal changes colour (error: dark ruby; reward: gold; invite: green; social: rose; warning: amber) */
.note.letter.nt-err .n-ico { background: radial-gradient(circle at 35% 30%, #d84a50 0%, #8e1018 45%, #4a0508 100%); }
.note.letter.nt-err { animation: scrollOpen .5s cubic-bezier(.2, 1, .3, 1) both, noteShake .45s .5s ease-in-out; }
.note.letter.nt-reward .n-ico, .note.letter.nt-success .n-ico { background: radial-gradient(circle at 35% 30%, #fff6c4 0%, #f2c142 42%, #a8680e 100%); box-shadow: 0 0 0 3px rgba(168, 104, 14, .6), inset 0 -4px 8px rgba(0, 0, 0, .25), 0 0 16px rgba(255, 214, 90, .7); }
.note.letter.nt-reward, .note.letter.nt-success { box-shadow: 0 0 0 1.5px #6b4210, inset 0 0 26px rgba(124, 74, 14, .3), 0 0 22px rgba(255, 214, 90, .55), 0 14px 30px rgba(0, 0, 0, .55); }
.note.letter.nt-invite .n-ico { background: radial-gradient(circle at 35% 30%, #8ff09f 0%, #2a9a46 45%, #0f5a26 100%); }
.note.letter.nt-social .n-ico { background: radial-gradient(circle at 35% 30%, #ffb0d4 0%, #d0457f 45%, #7a1748 100%); }
.note.letter.nt-warn .n-ico { background: radial-gradient(circle at 35% 30%, #ffe0a0 0%, #e09224 45%, #8a4a06 100%); }
.note.letter.out { animation: scrollClose .38s ease-in forwards; }

/* ---------- the gold plaque: short messages during a match ---------- */
.toast.letter { gap: 12px; padding: 8px 26px 8px 10px; border-radius: 14px; color: var(--lp-ink); font: 700 18px/1.25 'Cinzel', serif;
  border: 3px solid transparent;
  background: var(--lp-grain) padding-box, var(--lp-paper) padding-box, var(--lp-gold-frame) border-box;
  box-shadow: 0 0 0 1.5px #6b4210, 0 0 18px rgba(255, 214, 90, .45), 0 10px 22px rgba(0, 0, 0, .5);
  animation: plaqueIn .45s cubic-bezier(.2, 1.4, .4, 1) both; }
.toast.letter .t-ico { width: 40px; height: 46px; border-radius: 0; font-size: 20px;
  clip-path: polygon(50% 100%, 0 72%, 0 0, 100% 0, 100% 72%); background: var(--lp-red); box-shadow: none; filter: drop-shadow(0 2px 2px rgba(0, 0, 0, .4)); }
.toast.letter.nt-reward .t-ico, .toast.letter.nt-success .t-ico { background: linear-gradient(180deg, #fff6c4, #f2c142 50%, #a8680e); }
.toast.letter.nt-err .t-ico { background: linear-gradient(180deg, #d84a50, #8e1018 55%, #4a0508); }
.toast.letter.nt-invite .t-ico { background: linear-gradient(180deg, #8ff09f, #2a9a46 55%, #0f5a26); }
.toast.letter span { color: var(--lp-ink); }

/* ---------- animations ---------- */
@keyframes letterOpen {
  0% { opacity: 0; transform: perspective(1000px) rotateX(-82deg) scaleY(.35); }
  55% { opacity: 1; transform: perspective(1000px) rotateX(10deg) scaleY(1.03); }
  80% { transform: perspective(1000px) rotateX(-3deg); }
  100% { opacity: 1; transform: none; }
}
@keyframes letterClose { to { opacity: 0; transform: perspective(1000px) rotateX(78deg) scaleY(.3) translateY(-30px); } }
@keyframes ribbonUnfurl { 0% { clip-path: polygon(48% 0, 52% 0, 52% 50%, 52% 100%, 48% 100%, 48% 50%); opacity: .4; } 100% { clip-path: polygon(0 0, 100% 0, 94% 50%, 100% 100%, 0 100%, 6% 50%); opacity: 1; } }
@keyframes crownDrop { 0% { opacity: 0; transform: translate(-50%, -40px) scale(.6) rotate(-12deg); } 100% { opacity: 1; transform: translate(-50%, 0) scale(1) rotate(0); } }
@keyframes sealStamp { 0% { opacity: 0; transform: scale(2.1) rotate(-28deg); } 70% { opacity: 1; transform: scale(.9) rotate(4deg); } 100% { opacity: 1; transform: scale(1) rotate(0); } }
@keyframes scrollOpen { 0% { clip-path: inset(-12px 100% -12px -14px round 12px); opacity: .6; } 100% { clip-path: inset(-12px -14px -12px -14px round 12px); opacity: 1; } }
@keyframes scrollClose { 0% { clip-path: inset(-12px -14px -12px -14px round 12px); opacity: 1; } 100% { clip-path: inset(-12px -14px -12px 100% round 12px); opacity: 0; } }
@keyframes plaqueIn { 0% { opacity: 0; transform: translate(-50%, -26px) scale(.8); } 100% { opacity: 1; transform: translate(-50%, 0) scale(1); } }
@keyframes shadeOut { to { background: transparent; } }
@keyframes rpSpin { to { transform: translate(-50%, -50%) rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  .ask-card.letter, .reward-pop .rp-box.letter, .letter .l-crown, .letter .l-ribbon, .note.letter, .note.letter .n-ico, .toast.letter, .reward-pop .rp-box.letter .rp-shine::before { animation: none !important; }
  .ask-card.letter.closing, .reward-pop .rp-box.letter.closing { opacity: 0; }
}
