html {
  font-size: 14px;
}

@media (min-width: 768px) {
  html {
    font-size: 16px;
  }
}

.btn:focus, .btn:active:focus, .btn-link.nav-link:focus, .form-control:focus, .form-check-input:focus {
  box-shadow: 0 0 0 0.1rem white, 0 0 0 0.25rem #258cfb;
}

html {
  position: relative;
  min-height: 100%;
}

body {
  margin-bottom: 60px;
}

.form-floating > .form-control-plaintext::placeholder, .form-floating > .form-control::placeholder {
  color: var(--bs-secondary-color);
  text-align: end;
}

.form-floating > .form-control-plaintext:focus::placeholder, .form-floating > .form-control:focus::placeholder {
  text-align: start;
}

.app-title { font-weight: 700; margin: 1rem 0 1.5rem; }

.people-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.25rem;
}

.person-card {
    background: #fff;
    border-radius: 16px;
    padding: 1.25rem;
    box-shadow: 0 4px 18px rgba(60, 40, 20, 0.12);
}

.person-head { display: flex; align-items: center; gap: 0.9rem; margin-bottom: 1rem; }

.avatar { width: 52px; height: 52px; border-radius: 50%; object-fit: cover; }

.avatar-initial {
    display: flex; align-items: center; justify-content: center;
    background: #6f4e37; color: #fff; font-weight: 700; font-size: 1.4rem;
}

.person-name { font-size: 1.25rem; font-weight: 600; }

.coffees { display: flex; flex-wrap: wrap; gap: 0.35rem; margin: 0; }

.coffee-btn {
    font-size: 1.7rem;
    line-height: 1;
    padding: 0.2rem 0.3rem;
    background: none;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: transform 0.1s, background 0.1s;
}

.coffee-btn:hover { background: #f0e3d6; transform: scale(1.15); }

body { background: #f6efe8; }

.add-form {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
    margin-bottom: 1.5rem;
    max-width: 520px;
}

.add-form .form-control { border-radius: 10px; flex: 1 1 160px; }
.add-form .coffee-count { flex: 0 0 90px; }

.add-btn { background: #6f4e37; color: #fff; border-radius: 10px; font-weight: 600; }
.add-btn:hover { background: #5a3e2b; color: #fff; }

.add-form .avatar-file { flex: 1 1 100%; }

.coffee-icon {
    display: block;
    width: 30px;
    height: 30px;
    background-color: #6f4e37;
    -webkit-mask: url(/img/coffee.svg) center / contain no-repeat;
    mask: url(/img/coffee.svg) center / contain no-repeat;
    transition: background-color 0.15s;
}

.coffee-btn:hover .coffee-icon { background-color: #3e2a1c; }

/* ===== Modern look ===== */
body {
    background: linear-gradient(160deg, #f9f3ec 0%, #efe0d0 100%) fixed;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    color: #3e2a1c;
}

.navbar {
    background: rgba(255, 255, 255, 0.65) !important;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: none !important;
    box-shadow: 0 2px 14px rgba(60, 40, 20, 0.08) !important;
}

.navbar-brand { font-weight: 700; color: #4a3426 !important; }

.app-title {
    font-weight: 800;
    letter-spacing: -0.5px;
    color: #3e2a1c;
}

.person-card {
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.7);
    border-radius: 22px;
    padding: 1.4rem;
    box-shadow: 0 10px 30px rgba(80, 50, 25, 0.12);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.person-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 16px 38px rgba(80, 50, 25, 0.18);
}

.avatar {
    width: 56px;
    height: 56px;
    box-shadow: 0 0 0 3px #fff, 0 4px 12px rgba(80, 50, 25, 0.25);
}

.avatar-initial { background: linear-gradient(135deg, #b88a63, #6f4e37); }

.person-name { font-weight: 700; color: #3e2a1c; }

.coffee-btn:hover { background: rgba(111, 78, 55, 0.12); }

/* ===== One-row add form ===== */
.add-form {
    max-width: none;
    flex-wrap: nowrap;
    align-items: center;
}

.add-form .form-control { flex: 1 1 0; min-width: 0; }
.add-form .coffee-count { flex: 0 0 90px; }
.add-form .avatar-file { flex: 1.4 1 0; }
.add-btn { flex: 0 0 auto; white-space: nowrap; padding: 0.5rem 1.3rem; }

@media (max-width: 768px) {
    .add-form { flex-wrap: wrap; }
    .add-form .form-control { flex: 1 1 160px; }
    .add-form .coffee-count { flex: 0 0 90px; }
    .add-form .avatar-file { flex: 1 1 100%; }
}

/* ===== Compact avatar button ===== */
.avatar-pick {
    flex: 0 0 auto;
    max-width: 170px;
    margin: 0;
    padding: 0.5rem 1rem;
    border-radius: 10px;
    border: 1px dashed #b88a63;
    background: rgba(255, 255, 255, 0.6);
    color: #6f4e37;
    font-weight: 600;
    white-space: nowrap;
    cursor: pointer;
    transition: background 0.15s;
}

.avatar-pick:hover { background: #fff; }

.avatar-pick span {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
}

.add-form .reason-input { flex: 2 1 0; }

/* ===== History ===== */
.history { margin-top: 1rem; border-top: 1px solid rgba(111, 78, 55, 0.15); padding-top: 0.7rem; }

.history summary {
    cursor: pointer;
    font-weight: 600;
    color: #6f4e37;
    font-size: 0.95rem;
}

.history-list {
    list-style: none;
    margin: 0.6rem 0 0;
    padding: 0;
    max-height: 190px;
    overflow-y: auto;
    font-size: 0.88rem;
}

.history-list li {
    display: grid;
    grid-template-columns: 112px 36px 1fr;
    gap: 0.5rem;
    padding: 0.3rem 0;
    border-bottom: 1px dashed rgba(111, 78, 55, 0.15);
}

.h-date { color: #8a7566; }
.h-change { font-weight: 700; }
.h-added .h-change { color: #b5532c; }
.h-spent .h-change { color: #3d8b5a; }
.h-reason { overflow-wrap: anywhere; }

/* ===== History slide panel ===== */
.history-btn {
    margin-left: auto;
    padding: 0.3rem 0.85rem;
    border: 1px solid rgba(111, 78, 55, 0.3);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.7);
    color: #6f4e37;
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s;
}

.history-btn:hover { background: #fff; }

.drawer-overlay {
    position: fixed;
    inset: 0;
    background: rgba(40, 25, 15, 0.35);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s;
    z-index: 1040;
}

.drawer-overlay.open { opacity: 1; pointer-events: auto; }

.history-drawer {
    position: fixed;
    top: 0;
    right: 0;
    height: 100%;
    width: min(380px, 92vw);
    background: rgba(255, 255, 255, 0.94);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    box-shadow: -10px 0 30px rgba(60, 40, 20, 0.22);
    transform: translateX(100%);
    transition: transform 0.3s ease;
    z-index: 1050;
    display: flex;
    flex-direction: column;
}

.history-drawer.open { transform: translateX(0); }

.drawer-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.1rem 1.3rem;
    border-bottom: 1px solid rgba(111, 78, 55, 0.15);
}

.drawer-head h2 { margin: 0; font-size: 1.2rem; font-weight: 700; color: #3e2a1c; }

.drawer-close {
    border: none;
    background: none;
    font-size: 1.8rem;
    line-height: 1;
    color: #6f4e37;
    cursor: pointer;
}

.drawer-body { flex: 1; overflow-y: auto; padding: 0.5rem 1.3rem 1.5rem; }

.drawer-body .history-list { max-height: none; overflow: visible; font-size: 0.92rem; }

/* ===== Card layout: count top right, History bottom right ===== */
.person-card { display: flex; flex-direction: column; }

.debt-count {
    margin-left: auto;
    min-width: 2.4rem;
    height: 2.4rem;
    padding: 0 0.7rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    background: linear-gradient(135deg, #b88a63, #6f4e37);
    color: #fff;
    font-weight: 800;
    font-size: 1.1rem;
    box-shadow: 0 4px 10px rgba(80, 50, 25, 0.25);
}

.card-foot {
    margin-top: auto;
    padding-top: 0.9rem;
    display: flex;
    justify-content: flex-end;
}

/* ===== Title and Add button icons ===== */
.app-title { display: flex; align-items: center; gap: 0.6rem; }

.title-icon {
    display: inline-block;
    width: 42px;
    height: 42px;
    background-color: #6f4e37;
    -webkit-mask: url(/img/coffee.svg) center / contain no-repeat;
    mask: url(/img/coffee.svg) center / contain no-repeat;
}

.add-btn { display: inline-flex; align-items: center; gap: 0.45rem; }

.btn-icon {
    display: inline-block;
    width: 20px;
    height: 20px;
    background-color: currentColor;
    -webkit-mask: url(/img/coffee.svg) center / contain no-repeat;
    mask: url(/img/coffee.svg) center / contain no-repeat;
}

/* ===== Different icons for title and Add button ===== */
.title-icon {
    -webkit-mask: url(/img/coffee-takeaway.svg) center / contain no-repeat;
    mask: url(/img/coffee-takeaway.svg) center / contain no-repeat;
}

.btn-icon {
    width: 22px;
    height: 22px;
    -webkit-mask: url(/img/coffee-plus.svg) center / contain no-repeat;
    mask: url(/img/coffee-plus.svg) center / contain no-repeat;
}

/* ===== Delete all data ===== */
.danger-zone { margin-top: 3rem; text-align: center; }

.delete-all-btn {
    background: none;
    border: 1px solid rgba(160, 50, 40, 0.35);
    color: #a03228;
    border-radius: 10px;
    padding: 0.45rem 1.1rem;
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}

.delete-all-btn:hover { background: #a03228; color: #fff; }

.delete-dialog {
    border: none;
    border-radius: 20px;
    padding: 1.6rem;
    width: min(380px, 92vw);
    box-shadow: 0 20px 50px rgba(40, 25, 15, 0.35);
    color: #3e2a1c;
}

.delete-dialog::backdrop { background: rgba(40, 25, 15, 0.45); }
.delete-dialog h3 { font-weight: 700; margin: 0 0 0.5rem; }
.delete-dialog p { font-size: 0.92rem; color: #6b5547; }
.delete-dialog .form-control { border-radius: 10px; letter-spacing: 0.3rem; text-align: center; }

.dialog-actions { display: flex; gap: 0.6rem; justify-content: flex-end; margin-top: 1rem; }
.cancel-btn { background: #efe3d6; color: #6f4e37; border-radius: 10px; font-weight: 600; }
.confirm-delete-btn { background: #a03228; color: #fff; border-radius: 10px; font-weight: 600; }
.confirm-delete-btn:hover { background: #82271f; color: #fff; }

.notice { padding: 0.7rem 1rem; border-radius: 12px; margin-bottom: 1rem; font-weight: 600; }
.notice-ok { background: #e3f1e7; color: #2f6b45; }
.notice-error { background: #f8e1de; color: #a03228; }

/* ===== Users panel and dropdown ===== */
.page-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin: 1rem 0 1.5rem;
}

.page-head .app-title { margin: 0; }

.users-btn {
    padding: 0.45rem 1.1rem;
    border: 1px solid rgba(111, 78, 55, 0.3);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.7);
    color: #6f4e37;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s;
}

.users-btn:hover { background: #fff; }

.add-form .user-select { flex: 1.3 1 0; min-width: 0; border-radius: 10px; }

.user-add-form {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    padding: 1rem 0;
    border-bottom: 1px solid rgba(111, 78, 55, 0.15);
}

.user-add-form .form-control { border-radius: 10px; }
.user-add-form .avatar-pick { max-width: none; text-align: center; }

.user-list { list-style: none; margin: 0; padding: 0; }

.user-list li {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    padding: 0.7rem 0;
    border-bottom: 1px dashed rgba(111, 78, 55, 0.15);
}

.user-list form { margin: 0; }
.user-name { flex: 1; font-weight: 600; overflow-wrap: anywhere; }

.avatar-sm { width: 42px; height: 42px; font-size: 1.1rem; box-shadow: 0 0 0 2px #fff, 0 3px 8px rgba(80, 50, 25, 0.2); }

.avatar-pick.small { padding: 0.3rem 0.8rem; font-size: 0.82rem; }

/* ===== Earned by: star badge ===== */
.star-icon {
    display: inline-block;
    width: 17px;
    height: 17px;
    background-color: currentColor;
    -webkit-mask: url(/img/star.svg) center / contain no-repeat;
    mask: url(/img/star.svg) center / contain no-repeat;
}

.earned-count {
    margin-left: auto;
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    height: 2.4rem;
    padding: 0 0.75rem;
    border-radius: 999px;
    background: #fff4d6;
    color: #b7791f;
    font-weight: 800;
    font-size: 1rem;
    box-shadow: 0 2px 8px rgba(183, 121, 31, 0.2);
}

.earned-zero { opacity: 0.45; }

.person-head .debt-count { margin-left: 0; flex-shrink: 0; }
.person-name { min-width: 0; overflow-wrap: anywhere; }

.h-earned { display: block; color: #8a7566; font-size: 0.82rem; }

.add-form .earned-select { flex: 1.1 1 0; }

/* ===== Reset debts button ===== */
.danger-zone { display: flex; gap: 0.8rem; justify-content: center; flex-wrap: wrap; }

.reset-btn {
    background: none;
    border: 1px solid rgba(111, 78, 55, 0.4);
    color: #6f4e37;
    border-radius: 10px;
    padding: 0.45rem 1.1rem;
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}

.reset-btn:hover { background: #6f4e37; color: #fff; }

.confirm-reset-btn { background: #6f4e37; color: #fff; border-radius: 10px; font-weight: 600; }
.confirm-reset-btn:hover { background: #5a3e2b; color: #fff; }

/* ===== Clickable star ===== */
button.earned-count {
    border: none;
    cursor: pointer;
    font-family: inherit;
    transition: transform 0.15s, box-shadow 0.15s;
}

button.earned-count:hover {
    transform: scale(1.06);
    box-shadow: 0 4px 12px rgba(183, 121, 31, 0.35);
}

/* ===== Language switch ===== */
.head-actions { display: flex; align-items: center; gap: 0.7rem; }

.lang-switch {
    display: inline-flex;
    border: 1px solid rgba(111, 78, 55, 0.3);
    border-radius: 999px;
    overflow: hidden;
    background: rgba(255, 255, 255, 0.7);
}

.lang-opt {
    padding: 0.4rem 0.85rem;
    font-weight: 700;
    font-size: 0.85rem;
    color: #6f4e37;
    text-decoration: none;
}

.lang-opt:hover:not(.active) { background: #fff; }
.lang-opt.active { background: #6f4e37; color: #fff; }

/* ===== All-history panel ===== */
.h-reason strong { display: block; color: #3e2a1c; }

/* ===== Leaderboard ===== */
.leaderboard { margin-top: 2.5rem; }

.leader-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 800;
    font-size: 1.4rem;
    color: #3e2a1c;
    margin-bottom: 1rem;
}

.leader-title .star-icon { width: 24px; height: 24px; color: #d99a1e; }

.leader-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 0.9rem;
}

.leader-card {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    padding: 0.9rem 1.1rem;
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.7);
    box-shadow: 0 6px 20px rgba(80, 50, 25, 0.1);
}

.leader-rank {
    width: 2rem;
    height: 2rem;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: #efe3d6;
    color: #6f4e37;
    font-weight: 800;
}

.rank-1 { box-shadow: 0 8px 26px rgba(217, 154, 30, 0.28); }
.rank-1 .leader-rank { background: linear-gradient(135deg, #f6d365, #d99a1e); color: #fff; }
.rank-2 .leader-rank { background: linear-gradient(135deg, #d7dde2, #9aa5ae); color: #fff; }
.rank-3 .leader-rank { background: linear-gradient(135deg, #e0b48a, #b0703a); color: #fff; }

.leader-info { flex: 1; min-width: 0; }
.leader-name { font-weight: 700; color: #3e2a1c; overflow-wrap: anywhere; }
.leader-msg { font-size: 0.85rem; color: #8a7566; }

.leader-stars {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    font-weight: 800;
    font-size: 1.15rem;
    color: #b7791f;
}

.leader-stars .star-icon { width: 20px; height: 20px; }
.rank-0 .leader-stars { opacity: 0.45; }

/* ===== Wallpaper ===== */
body { background: #f9f3ec; }

body::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: -1;
    background: #f9f3ec url(/img/wallpaper.png) center / cover no-repeat;
    pointer-events: none;
}

/* ===== Make-it animation ===== */
.coffee-btn { position: relative; }

.coffee-btn.drinking { pointer-events: none; z-index: 2; }

.coffee-btn.drinking .coffee-icon {
    background-color: #b5532c;
    animation: cupDrink 0.65s ease-in forwards;
}

@keyframes cupDrink {
    0%   { transform: translateY(0) rotate(0) scale(1); opacity: 1; }
    30%  { transform: translateY(-10px) rotate(-12deg) scale(1.25); opacity: 1; }
    65%  { transform: translateY(-16px) rotate(-38deg) scale(1.2); opacity: 1; }
    100% { transform: translateY(-30px) rotate(-50deg) scale(0.2); opacity: 0; }
}

.coffee-btn.drinking::after {
    content: "";
    position: absolute;
    left: 50%;
    top: 2px;
    width: 8px;
    height: 8px;
    margin-left: -4px;
    border-radius: 50%;
    background: rgba(111, 78, 55, 0.35);
    animation: steamUp 0.65s ease-out forwards;
}

@keyframes steamUp {
    0%   { transform: translateY(0) scale(0.6); opacity: 0.9; }
    100% { transform: translateY(-34px) scale(2.2); opacity: 0; }
}

.debt-count.bump { animation: badgeBump 0.45s ease; }

@keyframes badgeBump {
    0%   { transform: scale(1); }
    40%  { transform: scale(1.35); }
    100% { transform: scale(1); }
}

/* ===== Mobile (portrait) ===== */
@media (max-width: 600px) {
    .page-head {
        flex-direction: column;
        align-items: stretch;
        gap: 0.9rem;
    }

    .head-actions { width: 100%; gap: 0.5rem; }

    .lang-switch { flex: 0 0 auto; }
    .lang-opt { padding: 0.7rem 1rem; font-size: 0.95rem; }

    .users-btn {
        flex: 1 1 0;
        min-width: 0;
        padding: 0.7rem 0.5rem;
        font-size: 0.95rem;
        text-align: center;
    }

    .add-form { flex-direction: column; align-items: stretch; gap: 0.7rem; }

    .add-form .form-control,
    .add-form .form-select,
    .add-form .user-select,
    .add-form .earned-select,
    .add-form .reason-input,
    .add-form .coffee-count {
        flex: 0 0 auto;
        width: 100%;
        min-height: 50px;
        padding: 0.75rem 1rem;
        font-size: 1rem;
    }

    .add-form .add-btn {
        width: 100%;
        justify-content: center;
        padding: 0.8rem 1rem;
        font-size: 1.05rem;
    }
}

/* ===== Roll the dice ===== */
.dice-zone { text-align: center; margin-top: 2rem; }

.dice-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.7rem;
    padding: 0.8rem 1.6rem;
    border: none;
    border-radius: 999px;
    background: linear-gradient(135deg, #b88a63, #6f4e37);
    color: #fff;
    font-weight: 700;
    font-size: 1.05rem;
    box-shadow: 0 8px 22px rgba(80, 50, 25, 0.3);
    cursor: pointer;
    transition: transform 0.15s, box-shadow 0.15s;
}

.dice-btn:hover { transform: translateY(-2px); box-shadow: 0 12px 26px rgba(80, 50, 25, 0.35); }
.dice-btn:active { transform: translateY(0); }
.dice-btn.rolling { pointer-events: none; }

.dice-icon {
    display: block;
    width: 26px;
    height: 26px;
    background-color: currentColor;
    -webkit-mask: url(/img/dice.svg) center / contain no-repeat;
    mask: url(/img/dice.svg) center / contain no-repeat;
}

.dice-btn.rolling .dice-icon { animation: diceRoll 1.1s ease-in-out; }

@keyframes diceRoll {
    0%   { transform: translateY(0) rotate(0); }
    20%  { transform: translateY(-14px) rotate(160deg) scale(1.15); }
    45%  { transform: translateY(0) rotate(330deg); }
    60%  { transform: translateY(-8px) rotate(480deg); }
    80%  { transform: translateY(0) rotate(640deg); }
    100% { transform: translateY(0) rotate(720deg); }
}

.dice-dialog {
    border: none;
    border-radius: 24px;
    padding: 0;
    width: min(380px, 92vw);
    overflow: visible;
    box-shadow: 0 24px 60px rgba(40, 25, 15, 0.4);
    color: #3e2a1c;
}

.dice-dialog::backdrop { background: rgba(40, 25, 15, 0.5); }

.dice-stage {
    position: relative;
    padding: 1.6rem 1.4rem 1.3rem;
    text-align: center;
    background: linear-gradient(180deg, #ffffff, #f9f1e6);
    border-radius: 24px;
}

.dice-title { font-weight: 800; font-size: 1.2rem; margin: 0 0 1rem; }

.dice-avatar-wrap { position: relative; width: 120px; height: 120px; margin: 0 auto 0.8rem; }

.dice-avatar {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #b88a63, #6f4e37);
    color: #fff;
    font-size: 3rem;
    font-weight: 800;
    box-shadow: 0 0 0 4px #fff, 0 8px 22px rgba(80, 50, 25, 0.3);
}

.dice-avatar img { width: 100%; height: 100%; object-fit: cover; }

.dice-avatar.win {
    animation: winPop 0.7s cubic-bezier(0.2, 1.4, 0.4, 1);
    box-shadow: 0 0 0 4px #fff, 0 0 0 8px #f0b429, 0 10px 30px rgba(240, 180, 41, 0.5);
}

@keyframes winPop {
    0%   { transform: scale(0.5); }
    60%  { transform: scale(1.18); }
    100% { transform: scale(1); }
}

.dice-name { font-weight: 800; font-size: 1.5rem; min-height: 2rem; overflow-wrap: anywhere; }
.dice-name.win { color: #b5532c; }

.dice-msg {
    color: #8a7566;
    font-weight: 600;
    min-height: 1.4rem;
    margin-bottom: 0.6rem;
    opacity: 0;
    transition: opacity 0.4s;
}

.dice-msg.show { opacity: 1; }

.dice-actions { justify-content: center; margin-top: 1rem; }

/* stars */
.dice-stars { position: absolute; inset: 0; pointer-events: none; }

.dice-stars span {
    position: absolute;
    left: 50%;
    top: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    background-color: #f0b429;
    -webkit-mask: url(/img/star.svg) center / contain no-repeat;
    mask: url(/img/star.svg) center / contain no-repeat;
    opacity: 0;
    animation: starBurst 1.3s ease-out forwards;
}

@keyframes starBurst {
    0%   { transform: translate(0, 0) scale(0) rotate(0); opacity: 1; }
    60%  { opacity: 1; }
    100% { transform: translate(var(--dx), var(--dy)) scale(1.1) rotate(200deg); opacity: 0; }
}

/* coffee being made */
.dice-cup { display: block; width: 120px; height: 110px; margin: 0 auto; }

.cup-fill { transform: translateY(0); }
.dice-dialog.reveal .cup-fill { animation: cupFill 1.4s ease-out 0.3s forwards; }

@keyframes cupFill { to { transform: translateY(-50px); } }

.pour { stroke-dasharray: 30; stroke-dashoffset: 30; }
.dice-dialog.reveal .pour { animation: pourFlow 1.2s ease-in-out 0.2s forwards; }

@keyframes pourFlow {
    0%   { stroke-dashoffset: 30; }
    30%  { stroke-dashoffset: 0; }
    80%  { stroke-dashoffset: 0; }
    100% { stroke-dashoffset: -30; }
}

.steam { opacity: 0; }
.dice-dialog.reveal .steam { animation: steamRise 1.8s ease-in-out 1.4s infinite; }
.dice-dialog.reveal .steam.s2 { animation-delay: 1.8s; }
.dice-dialog.reveal .steam.s3 { animation-delay: 2.2s; }

@keyframes steamRise {
    0%   { transform: translateY(6px); opacity: 0; }
    40%  { opacity: 0.85; }
    100% { transform: translateY(-8px); opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
    .dice-btn .dice-icon,
    .dice-avatar.win,
    .dice-stars span,
    .pour,
    .steam { animation: none !important; }

    .dice-dialog.reveal .cup-fill { animation: none; transform: translateY(-50px); }
}

/* ===== Settings ===== */
.settings-btn {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.45rem 0.8rem;
}

.gear-icon {
    display: block;
    width: 20px;
    height: 20px;
    background-color: currentColor;
    -webkit-mask: url(/img/gear.svg) center / contain no-repeat;
    mask: url(/img/gear.svg) center / contain no-repeat;
    transition: transform 0.35s;
}

.settings-btn:hover .gear-icon { transform: rotate(60deg); }

@media (max-width: 600px) {
    .settings-btn { padding: 0.7rem 1rem; }
}

.settings-list { text-align: left; margin-top: 0.8rem; }

.setting-row { display: flex; flex-direction: column; gap: 0.4rem; margin: 0 0 0.8rem; }
.setting-label { font-weight: 600; font-size: 0.92rem; color: #6b5547; }

.settings-dialog .setting-input { letter-spacing: normal; text-align: left; }

.settings-msg { min-height: 1.2rem; margin-top: 0.5rem; font-weight: 600; font-size: 0.9rem; }
.settings-msg[hidden] { display: none; }
.settings-err { color: #a03228; }
.settings-ok { color: #2f6b45; }

/* ===== Danger buttons inside settings ===== */
.settings-danger {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid rgba(111, 78, 55, 0.15);
}

.settings-danger button { width: 100%; padding: 0.6rem 1rem; }