/*
 * Gameplay chat, choices and composer
 *
 * Ownership: docs/architecture/css-ownership.md
 * Loaded after RPG Foundation and before History/Gallery CSS.
 */

@media (max-width: 991px) {
    .chat-input-bar {
        padding: 12px 16px;
        gap: 10px;
    }
    
    .chat-input-bar__actions {
        gap: 6px;
    }
    
    .chat-input-action-btn {
        padding: 7px 12px;
        font-size: 0.8rem;
    }
    
    .chat-input-action-btn__label {
        display: none;
    }
    
    .chat-input-bar__input-wrapper {
        gap: 8px;
    }
    
    .chat-input-bar textarea {
        padding: 10px 14px;
        font-size: 0.9rem;
    }
    
    .chat-input-send-btn {
        padding: 10px 16px;
        font-size: 0.9rem;
    }
    
    .chat-input-send-btn__label {
        display: none;
    }
}

.chat-turn-status {
    width: min(100%, 1180px);
    display: inline-flex;
    align-items: center;
    gap: 10px;
    background: transparent;
    border: 0;
    border-top: 1px solid rgba(218, 146, 88, 0.24);
    border-radius: 0;
    padding: 12px 0 0;
    color: var(--color-text-primary);
    box-shadow: none;
    margin: 0 auto 10px;
}

.chat-turn-status[hidden] {
    display: none !important;
}

.chat-turn-status__icon {
    width: 24px;
    height: 24px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    color: #da9258;
    font-size: 0.78rem;
}

.chat-turn-status[data-state="needs-input"] {
    background: transparent;
    border-color: rgba(218, 146, 88, 0.34);
}

.chat-turn-status[data-state="needs-input"] .chat-turn-status__icon {
    background: transparent;
    color: #da9258;
}

.chat-turn-status--thinking {
    align-items: flex-start;
}

.chat-turn-status--thinking .chat-turn-status__icon {
    color: #dfb463;
    text-shadow: 0 0 18px rgba(218, 146, 88, 0.38);
}

.chat-turn-status__group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.chat-turn-status__group[hidden] {
    display: none;
}

.chat-turn-status__body {
    display: flex;
    flex-direction: column;
    gap: 0;
    flex: 1;
}

.chat-turn-status__header {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 8px;
}

.chat-turn-status__body > strong,
.chat-turn-status__header > strong {
    font-size: 0.84rem;
    line-height: 1.4;
}

.master-thinking-scene {
    width: min(100%, 620px);
    margin-top: 8px;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    align-items: center;
    gap: 20px;
    color: var(--color-text-secondary);
}

.master-thinking-scene--compact {
    width: min(100%, 600px);
    margin: 12px 0 0;
}

.master-thinking-scene__table {
    width: 248px;
    height: 196px;
    position: relative;
    display: grid;
    place-items: center;
    flex: 0 0 auto;
}

.master-thinking-scene__table::before {
    content: "";
    position: absolute;
    inset: auto 5px 5px;
    height: 34px;
    border-radius: 50%;
    background:
        radial-gradient(ellipse at center, rgba(218, 146, 88, 0.28), rgba(118, 174, 164, 0.06) 58%, transparent 75%);
    transform: perspective(130px) rotateX(60deg);
    opacity: 0.9;
}

.master-thinking-scene__object {
    width: 190px;
    height: 190px;
    border-radius: 42px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    position: relative;
    color: #fff2cf;
    background:
        radial-gradient(circle at 35% 25%, rgba(255, 246, 220, 0.22), transparent 34%),
        linear-gradient(145deg, rgba(218, 146, 88, 0.2), rgba(73, 107, 229, 0.12)),
        rgba(10, 15, 22, 0.95);
    border: 1px solid rgba(218, 146, 88, 0.35);
    box-shadow:
        inset 0 0 18px rgba(255, 246, 220, 0.07),
        0 10px 22px rgba(0, 0, 0, 0.32),
        0 0 22px rgba(218, 146, 88, 0.1);
    z-index: 2;
    animation: master-thinking-object-breathe 2600ms ease-in-out infinite;
}

.master-thinking-scene__focus {
    position: absolute;
    right: 0;
    bottom: 0;
    width: 44px;
    height: 44px;
    border-radius: 999px;
    display: grid;
    place-items: center;
    color: #fff2cf;
    background:
        radial-gradient(circle at 36% 26%, rgba(255, 246, 220, 0.28), transparent 42%),
        rgba(6, 10, 18, 0.86);
    border: 1px solid rgba(218, 146, 88, 0.35);
    box-shadow: 0 0 18px rgba(218, 146, 88, 0.18);
    z-index: 4;
}

.master-thinking-scene__focus i {
    position: relative;
    z-index: 2;
    font-size: 0.86rem;
}

.master-thinking-scene__mage {
    position: absolute;
    inset: 10px;
    display: block;
    overflow: hidden;
    border-radius: 34px;
    background: rgba(4, 8, 14, 0.94);
    border: 1px solid rgba(255, 246, 220, 0.12);
    box-shadow:
        inset 0 0 28px rgba(0, 0, 0, 0.38),
        0 0 22px rgba(73, 107, 229, 0.14);
    z-index: 3;
    animation: master-thinking-portrait-breathe 5400ms ease-in-out infinite;
}

.master-thinking-scene__mage::after {
    content: "";
    position: absolute;
    inset: 0;
    background:
        radial-gradient(circle at 64% 36%, rgba(109, 158, 255, 0.22), transparent 23%),
        radial-gradient(circle at 28% 18%, rgba(255, 238, 194, 0.2), transparent 22%),
        linear-gradient(180deg, transparent 58%, rgba(5, 8, 13, 0.36));
    box-shadow: inset 0 0 0 1px rgba(255, 246, 220, 0.08);
    pointer-events: none;
}

.master-thinking-scene__mage-portrait {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: cover;
    transform: scale(1.05);
    filter: saturate(1.04) contrast(1.05);
    animation: master-thinking-portrait-drift 6200ms ease-in-out infinite;
}

.master-thinking-scene__pulse {
    position: absolute;
    inset: -7px;
    border-radius: inherit;
    border: 1px solid rgba(218, 146, 88, 0.18);
    opacity: 0;
    animation: master-thinking-pulse 2600ms ease-in-out infinite;
}

.master-thinking-scene__spark {
    width: 4px;
    height: 4px;
    border-radius: 50%;
    position: absolute;
    background: rgba(255, 226, 162, 0.88);
    box-shadow: 0 0 10px rgba(218, 146, 88, 0.56);
    opacity: 0;
    animation: master-thinking-spark 2600ms ease-in-out infinite;
}

.master-thinking-scene__spark--1 {
    left: 14px;
    top: 8px;
    animation-delay: 0ms;
}

.master-thinking-scene__spark--2 {
    right: 18px;
    top: 5px;
    animation-delay: 260ms;
}

.master-thinking-scene__spark--3 {
    left: 27px;
    bottom: 8px;
    animation-delay: 520ms;
}

.master-thinking-scene__spark--4 {
    right: 10px;
    bottom: 11px;
    animation-delay: 780ms;
}

.master-thinking-scene__label {
    max-width: 340px;
    font-size: 0.95rem;
    line-height: 1.5;
    color: rgba(225, 231, 242, 0.82);
}

@keyframes master-thinking-object-breathe {
    0%,
    100% {
        transform: translateY(0) rotate(-2deg);
    }
    50% {
        transform: translateY(-4px) rotate(3deg);
    }
}

@keyframes master-thinking-portrait-breathe {
    0%,
    100% {
        transform: translateY(0) rotate(-1deg);
    }
    50% {
        transform: translateY(-3px) rotate(1deg);
    }
}

@keyframes master-thinking-portrait-drift {
    0%,
    100% {
        transform: scale(1.05) translate3d(0, 0, 0);
    }
    50% {
        transform: scale(1.11) translate3d(-2px, -2px, 0);
    }
}

@keyframes master-thinking-pulse {
    0% {
        opacity: 0;
        transform: scale(0.9);
    }
    45% {
        opacity: 0.72;
    }
    100% {
        opacity: 0;
        transform: scale(1.18);
    }
}

@keyframes master-thinking-spark {
    0%,
    100% {
        opacity: 0;
        transform: translateY(4px) scale(0.72);
    }
    42% {
        opacity: 1;
        transform: translateY(-5px) scale(1);
    }
}

.chat-turn-status__progress,
.chat-turn-status__timeline,
.chat-turn-status__group,
.chat-turn-status__causality {
    display: none !important;
}

.chat-turn-status__progress {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 4px;
}

.chat-turn-status__progress-bar {
    flex: 1;
    height: 6px;
    background: rgba(73, 107, 229, 0.2);
    border-radius: 999px;
    overflow: hidden;
    position: relative;
}

.chat-turn-status__progress-bar::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, rgba(56, 224, 168, 0.9), rgba(73, 107, 229, 0.9));
    border-radius: 999px;
    transition: width 0.3s ease;
}

.chat-turn-status__progress-bar.has-progress::after {
    width: var(--progress-width, 0%) !important;
}

.chat-turn-status[data-state="needs-input"] .chat-turn-status__progress-bar::after {
    background: linear-gradient(90deg, rgba(255, 198, 88, 0.9), rgba(255, 198, 88, 0.7));
}

.chat-turn-status__progress-text {
    font-size: 0.75rem;
    color: var(--color-text-muted);
    white-space: nowrap;
    min-width: 80px;
    text-align: right;
}

.chat-turn-status__timeline {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 10px 12px;
    border-radius: 12px;
    border: 1px solid rgba(120, 132, 220, 0.24);
    background: rgba(12, 16, 34, 0.54);
}

.chat-turn-status__timeline-steps {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 6px;
}

.chat-turn-status__timeline-step {
    text-align: center;
    font-size: 0.7rem;
    color: var(--color-text-muted);
    border: 1px solid rgba(120, 132, 220, 0.24);
    border-radius: 999px;
    padding: 4px 8px;
    background: rgba(10, 12, 24, 0.72);
}

.chat-turn-status__timeline-step.is-done {
    color: var(--color-success);
    border-color: rgba(56, 224, 168, 0.45);
    background: rgba(56, 224, 168, 0.14);
}

.chat-turn-status__timeline-step.is-active {
    color: var(--color-text-primary);
    border-color: rgba(73, 107, 229, 0.58);
    background: rgba(73, 107, 229, 0.2);
}

.chat-turn-status__timeline-step.is-failed {
    color: var(--color-danger);
    border-color: rgba(255, 81, 98, 0.56);
    background: rgba(255, 81, 98, 0.16);
}

.chat-turn-status__timeline-meta {
    color: var(--color-text-muted);
    font-size: 0.72rem;
}

.chat-turn-status__group-label {
    font-size: 0.78rem;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--color-text-muted);
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.chat-turn-status__list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.chat-turn-status__causality {
    display: flex;
    flex-direction: column;
    gap: 8px;
    border: 1px solid rgba(120, 132, 220, 0.24);
    border-radius: 12px;
    background: rgba(12, 16, 34, 0.54);
    padding: 10px 12px;
}

.chat-turn-status__causality[hidden] {
    display: none;
}

.chat-turn-status__causality-summary {
    margin: 0;
    font-size: 0.82rem;
    line-height: 1.45;
    color: var(--color-text-secondary);
}

.chat-turn-status__causality-list {
    margin: 0;
    padding-left: 18px;
    display: grid;
    gap: 4px;
    color: var(--color-text-muted);
    font-size: 0.76rem;
}

.turn-status-chip {
    background: rgba(73, 107, 229, 0.18);
    border: 1px solid rgba(73, 107, 229, 0.32);
    border-radius: 999px;
    padding: 4px 8px 4px 4px;
    font-size: 0.75rem;
    color: var(--color-text-secondary);
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.turn-status-chip__avatar {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: rgba(73, 107, 229, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.65rem;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.9);
    flex-shrink: 0;
}

.turn-status-chip--submitted {
    background: rgba(56, 224, 168, 0.16);
    border-color: rgba(56, 224, 168, 0.32);
    color: var(--color-success);
}

.turn-status-chip--submitted .turn-status-chip__avatar {
    background: rgba(56, 224, 168, 0.4);
}

.turn-status-chip--pending {
    background: rgba(255, 81, 98, 0.14);
    border-color: rgba(255, 81, 98, 0.28);
    color: var(--color-danger);
}

.turn-status-chip--pending .turn-status-chip__avatar {
    background: rgba(255, 81, 98, 0.3);
}

.chat-input-section {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding-bottom: 24px;
}

.chat-party-toggle {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.chat-party-toggle i {
    color: var(--color-accent);
}

.chat-party-toggle--floating {
    order: 1;
}

.chat-container {
    width: 100%;
    background: rgba(18, 20, 38, 0.92);
    border-radius: 28px;
    border: 1px solid rgba(120, 132, 220, 0.18);
    box-shadow: var(--shadow-card);
    display: flex;
    flex-direction: column;
    overflow: visible;
    position: relative;
}

.chat-gameplay-layout {
    display: grid;
    grid-template-columns: 72px minmax(0, 1fr);
    gap: 16px;
    align-items: start;
}

.chat-window {
    flex: 1;
    padding: 28px;
    overflow-y: auto;
    background: radial-gradient(circle at top, rgba(73,107,229,0.08), transparent 60%), rgba(12,14,29,0.92);
    -webkit-overflow-scrolling: touch; /* Melhora scroll no iOS */
}

.chat-message {
    max-width: 70%;
    padding: 16px 18px;
    border-radius: 18px;
    margin-bottom: 18px;
    line-height: 1.6;
    box-shadow: 0 12px 30px rgba(0,0,0,0.28);
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.chat-message-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 4px;
}

.chat-message-author-wrapper {
    display: flex;
    align-items: center;
    gap: 8px;
}

.chat-message-author-meta {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.chat-message-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.95);
    flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.chat-message-avatar--ai {
    background: linear-gradient(135deg, rgba(73, 107, 229, 0.9), rgba(52, 83, 200, 0.9));
    color: rgba(255, 255, 255, 0.95);
}

.chat-message-avatar--ai i {
    font-size: 0.9rem;
}

.chat-message-author {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--color-text-primary);
    opacity: 0.9;
}

.chat-message-character {
    font-size: 0.72rem;
    color: var(--color-text-muted);
    line-height: 1.2;
}

.chat-message-timestamp {
    font-size: 0.75rem;
    color: var(--color-text-muted);
    opacity: 0.7;
    white-space: nowrap;
}

.chat-message .message-content {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
}

.chat-message .message-content h3.message-heading {
    font-family: 'Montserrat', sans-serif;
    font-size: 1.05rem;
    margin: 0;
    color: var(--color-text-primary);
}

.chat-message .message-content p {
    margin: 0;
    line-height: 1.6;
    color: var(--color-text-secondary);
}

.chat-message .message-content ul.message-list,
.chat-message .message-content ol.message-list {
    margin: 0;
    padding-left: 1.4rem;
    display: grid;
    gap: 6px;
    color: var(--color-text-secondary);
}

.chat-message .message-content ol.message-list {
    list-style: decimal;
}

.chat-message .message-content ul.message-list {
    list-style: disc;
}

.chat-message.user {
    margin-left: auto;
    background: linear-gradient(135deg, rgba(73,107,229,0.85), rgba(52,83,200,0.85));
}

.chat-message.user .chat-message-author {
    color: rgba(255, 255, 255, 0.95);
}

.chat-message.user .chat-message-character {
    color: rgba(255, 255, 255, 0.78);
}

.chat-message.user .chat-message-timestamp {
    color: rgba(255, 255, 255, 0.75);
}

.chat-message.ai {
    margin-right: auto;
    background: rgba(20, 23, 44, 0.92);
    border: 1px solid rgba(73,107,229,0.22);
}

.chat-turn-stage {
    width: min(100%, 1180px);
    margin: 0 auto 32px;
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 18px;
    align-items: start;
}

.chat-turn-stage > .chat-message {
    margin-bottom: 0;
}

.chat-turn-stage > .chat-message.user {
    width: min(100%, 680px);
    max-width: 100%;
    justify-self: end;
    background: rgba(21, 40, 42, 0.72);
    border: 1px solid rgba(99, 170, 160, 0.2);
    border-radius: 6px;
    box-shadow: none;
}

.chat-turn-stage > .chat-message.ai:not(.chat-message-image) {
    width: min(100%, 76ch);
    max-width: 100%;
    justify-self: center;
    padding: 8px 0 12px 20px;
    border: 0;
    border-left: 2px solid rgba(218, 146, 88, 0.7);
    border-radius: 0;
    background: transparent;
    box-shadow: none;
}

.chat-turn-stage > .chat-message.ai:not(.chat-message-image) .message-content {
    font-family: Georgia, 'Times New Roman', serif;
    font-size: 1.22rem;
    line-height: 1.65;
}

.chat-turn-stage > .chat-message.ai:not(.chat-message-image) .message-content p {
    color: #edf2ec;
}

.chat-turn-stage > .chat-message-image {
    width: 100%;
    max-width: 100%;
    padding: 0;
    border: 1px solid rgba(99, 170, 160, 0.22);
    border-radius: 6px;
    background: rgba(14, 27, 30, 0.78);
    box-shadow: none;
}

.chat-turn-stage > .chat-message-image .chat-message-header {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.chat-turn-stage > .chat-message-image .message-content {
    gap: 0;
}

.chat-turn-stage > .chat-message-image .message-content p {
    padding: 10px 12px 12px;
    color: #9eb0ad;
    font-size: 0.82rem;
    line-height: 1.45;
}

@media (min-width: 1280px) {
    .chat-turn-stage--with-media {
        grid-template-columns: minmax(300px, 0.82fr) minmax(540px, 1.28fr);
        column-gap: 32px;
    }

    .chat-turn-stage--with-media > .chat-message.user {
        grid-column: 1 / -1;
    }

    .chat-turn-stage--with-media > .chat-message-image {
        grid-column: 1;
    }

    .chat-turn-stage--with-media > .chat-message.ai:not(.chat-message-image) {
        grid-column: 2;
        justify-self: stretch;
    }
}

.chat-message.ai.chat-message--opening {
    border-color: rgba(56, 224, 168, 0.46);
    background:
      radial-gradient(circle at top right, rgba(56, 224, 168, 0.16), transparent 56%),
      rgba(20, 23, 44, 0.94);
    box-shadow: 0 18px 42px rgba(15, 24, 45, 0.52);
}

.chat-message.ai.chat-message--scene-current {
    max-width: 100%;
}

.chat-message.ai.chat-message--scene-current .message-heading {
    font-size: 1.12rem;
}

.chat-message.ai.chat-message--scene-current .message-content p {
    color: rgba(236, 241, 255, 0.92);
}

.chat-window:not(.is-history-expanded) .chat-message.chat-message--scene-history {
    display: none;
}

.chat-message.chat-message--scene-history {
    max-width: 74%;
    opacity: 0.74;
}

.chat-history-toggle {
    align-self: flex-start;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin: 0 0 14px;
    padding: 7px 11px;
    border-radius: 999px;
    border: 1px solid rgba(120, 132, 220, 0.18);
    background: rgba(10, 13, 28, 0.68);
    color: rgba(232, 244, 255, 0.82);
    font-size: 0.78rem;
    font-weight: 700;
    cursor: pointer;
}

.chat-history-toggle:hover,
.chat-history-toggle[aria-expanded="true"] {
    border-color: rgba(56, 224, 168, 0.28);
    color: rgba(236, 241, 255, 0.94);
}

.chat-message--player-action .message-content {
    gap: 0;
}

.player-action-card {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 14px 16px;
    border-radius: 16px;
    background: rgba(10, 12, 26, 0.14);
    border: 1px solid rgba(255, 255, 255, 0.18);
}

.chat-message.user .player-action-card {
    background: rgba(7, 10, 24, 0.16);
    border-color: rgba(255, 255, 255, 0.22);
}

.player-action-card__eyebrow {
    font-size: 0.72rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.78);
}

.chat-message.ai .player-action-card__eyebrow {
    color: var(--color-text-muted);
}

.player-action-card__title {
    font-size: 1rem;
    font-weight: 700;
    line-height: 1.45;
    color: rgba(255, 255, 255, 0.96);
}

.chat-message.ai .player-action-card__title {
    color: var(--color-text-primary);
}

.player-action-card__meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.player-action-card__pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.14);
    border: 1px solid rgba(255, 255, 255, 0.16);
    font-size: 0.72rem;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.9);
}

.player-action-card__pill--dice {
    background: rgba(56, 224, 168, 0.18);
    border-color: rgba(56, 224, 168, 0.28);
    color: rgba(220, 255, 243, 0.96);
}

.chat-message.ai .player-action-card__pill {
    background: rgba(73, 107, 229, 0.12);
    border-color: rgba(73, 107, 229, 0.18);
    color: var(--color-text-secondary);
}

.chat-message.ai .player-action-card__pill--dice {
    background: rgba(56, 224, 168, 0.12);
    border-color: rgba(56, 224, 168, 0.2);
    color: rgba(198, 255, 234, 0.94);
}

.player-action-card__details {
    margin: 0;
    color: rgba(255, 255, 255, 0.86);
    line-height: 1.55;
}

.chat-message.ai .player-action-card__details {
    color: var(--color-text-secondary);
}

.chat-message.ai .chat-message-author {
    color: var(--color-accent);
}

.chat-progress-bar {
    position: absolute;
    top: 0;
    left: 0;
    height: 3px;
    width: 0;
    background: linear-gradient(90deg, rgba(73,107,229,0.8), rgba(56,224,168,0.7));
    opacity: 0;
    transition: width var(--transition-fast), opacity var(--transition-fast), background var(--transition-fast);
    z-index: 2;
}

.chat-progress-bar.is-active {
    opacity: 1;
}

.chat-progress-bar.has-error {
    background: linear-gradient(90deg, rgba(255,81,98,0.85), rgba(255,140,120,0.75));
}

.choice-strip {
    display: grid;
    gap: 14px;
    margin: 32px auto 0;
    padding-top: 24px;
    width: min(100%, 1180px);
    border-top: 1px solid rgba(218, 146, 88, 0.26);
}

.choice-strip--thinking {
    gap: 10px;
}

.choice-strip--thinking .master-thinking-scene {
    margin-top: 0;
}

.choice-strip--pending-turn {
    min-height: clamp(260px, 38vh, 500px);
    margin-top: 28px;
    padding: clamp(22px, 4vw, 42px);
    border-top: 0;
    border-radius: 18px;
    place-items: center;
    align-content: center;
    text-align: center;
    background:
        radial-gradient(circle at 50% 22%, rgba(255, 239, 199, 0.12), transparent 32%),
        linear-gradient(180deg, rgba(218, 146, 88, 0.09), rgba(73, 107, 229, 0.05)),
        rgba(7, 12, 18, 0.68);
    border: 1px solid rgba(218, 146, 88, 0.2);
    box-shadow:
        inset 0 1px 0 rgba(255, 246, 220, 0.05),
        0 24px 60px rgba(0, 0, 0, 0.24);
}

.choice-strip--pending-turn .choice-strip-title {
    max-width: 620px;
    margin: 0 auto;
    color: var(--color-text-primary);
    font-family: var(--font-heading);
    font-size: clamp(1.25rem, 2.2vw, 2rem);
    line-height: 1.08;
}

.choice-strip--pending-turn .master-thinking-scene {
    justify-self: center;
    text-align: left;
}

.choice-strip--thinking .master-thinking-scene__label,
.choice-strip--pending-turn .master-thinking-scene__label {
    display: none;
}

.choice-strip--pending-turn .current-scene-panel,
.choice-strip--pending-turn .choice-outcome-panel,
.choice-strip--pending-turn .choice-strip-subtitle,
.choice-strip--pending-turn .choice-strip-buttons,
.choice-strip--pending-turn .node-choice-dice-host:not(.node-choice-dice-host--floating-result) {
    display: none;
}

.choice-strip--thinking .choice-strip-status,
.choice-strip--pending-turn .choice-strip-status {
    display: none !important;
}

.choice-strip--dice-pending {
    min-height: 0;
    margin-top: 0;
    padding: 0;
    border: 0;
    background: transparent;
    box-shadow: none;
}

.choice-strip--dice-pending .choice-strip-title,
.choice-strip--dice-pending .master-thinking-scene,
.choice-strip--dice-pending .choice-strip-status {
    display: none;
}

.chat-dice-spotlight-active .chat-turn-status--thinking {
    display: none;
}

.choice-strip.is-expired .btn-choice {
    opacity: 0.55;
    cursor: not-allowed;
}

.choice-strip.is-processing .btn-choice.is-selected {
    box-shadow: 0 18px 36px rgba(73, 107, 229, 0.18);
}

.choice-strip.is-error .btn-choice {
    border-color: rgba(255, 81, 98, 0.4);
}

.choice-strip--player-specific {
    border-left: 3px solid rgba(73, 107, 229, 0.4);
    padding-left: 12px;
}

.choice-strip--player-specific .btn-choice {
    position: relative;
}

.choice-outcome-panel {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 14px 16px;
    border-radius: 16px;
    background: rgba(18, 20, 38, 0.78);
    border: 1px solid rgba(120, 132, 220, 0.18);
}

.choice-outcome-panel__title {
    font-size: 0.82rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: rgba(198, 206, 255, 0.88);
}

.choice-outcome-panel__list {
    display: grid;
    gap: 8px;
}

.choice-outcome-panel__item {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 10px 12px;
    border-radius: 12px;
    background: rgba(73, 107, 229, 0.08);
    border: 1px solid rgba(73, 107, 229, 0.18);
}

.choice-outcome-panel__name {
    font-size: 0.86rem;
    color: var(--color-text-primary);
}

.choice-outcome-panel__summary {
    font-size: 0.83rem;
    line-height: 1.45;
    color: var(--color-text-secondary);
}

.current-scene-panel {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 13px 15px;
    border-radius: 12px;
    background: rgba(8, 12, 25, 0.82);
    border: 1px solid rgba(56, 224, 168, 0.22);
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.16);
}

.current-scene-panel__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.current-scene-panel__title {
    color: rgba(232, 244, 255, 0.94);
    font-size: 0.9rem;
    font-weight: 800;
}

.current-scene-panel__list {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px 12px;
}

.current-scene-panel__item {
    min-width: 0;
    display: flex;
    align-items: flex-start;
    gap: 8px;
}

.current-scene-panel__item i {
    margin-top: 3px;
    color: rgba(56, 224, 168, 0.86);
    font-size: 0.8rem;
}

.current-scene-panel__item p {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin: 0;
    color: var(--color-text-secondary);
    font-size: 0.78rem;
    line-height: 1.35;
}

.current-scene-panel__item strong {
    color: rgba(232, 244, 255, 0.92);
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0;
}

.btn-choice {
    min-height: 92px;
    padding: 16px;
    border-radius: 6px;
    background: rgba(14, 27, 30, 0.78);
    border: 1px solid rgba(99, 170, 160, 0.24);
    color: var(--color-text-primary);
    text-align: left;
    display: flex;
    flex-direction: column;
    gap: 6px;
    transition: transform var(--transition-fast), background var(--transition-fast), border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.btn-choice:hover:not(:disabled) {
    transform: translateY(-2px);
    background: rgba(21, 40, 42, 0.92);
    border-color: rgba(99, 170, 160, 0.58);
    box-shadow: 0 12px 24px rgba(7, 16, 18, 0.24);
}

.btn-choice:disabled {
    cursor: not-allowed;
}

.btn-choice.is-selected {
    background: rgba(51, 81, 77, 0.96);
    color: #edf2ec;
    border-color: rgba(218, 146, 88, 0.72);
    box-shadow: 0 0 0 2px rgba(218, 146, 88, 0.16);
}

.btn-choice.is-awaiting-dice {
    position: relative;
    background: linear-gradient(135deg, rgba(73,107,229,0.75), rgba(93,126,255,0.65));
    border-color: rgba(93, 126, 255, 0.6);
    box-shadow: 0 0 0 2px rgba(93, 126, 255, 0.3), 0 16px 32px rgba(93, 126, 255, 0.25);
    animation: pulse-awaiting 2s ease-in-out infinite;
}

.btn-choice.is-awaiting-dice::after {
    content: '🎲';
    position: absolute;
    top: 8px;
    right: 12px;
    font-size: 16px;
    opacity: 0.9;
}

@keyframes pulse-awaiting {
    0%, 100% {
        box-shadow: 0 0 0 2px rgba(93, 126, 255, 0.3), 0 16px 32px rgba(93, 126, 255, 0.25);
    }
    50% {
        box-shadow: 0 0 0 3px rgba(93, 126, 255, 0.5), 0 20px 40px rgba(93, 126, 255, 0.35);
    }
}

.btn-choice.is-locked {
    border-color: rgba(120, 132, 220, 0.18);
}

.btn-choice--other-player {
    opacity: 0.5;
    background: rgba(18, 20, 38, 0.6);
    border-color: rgba(120, 132, 220, 0.15);
    cursor: not-allowed;
}

.btn-choice--other-player:hover {
    transform: none;
    background: rgba(18, 20, 38, 0.6);
    border-color: rgba(120, 132, 220, 0.15);
    box-shadow: none;
}

.btn-choice--for-you {
    border-color: rgba(99, 170, 160, 0.3);
    background: rgba(14, 27, 30, 0.78);
}

.btn-choice--for-you:hover:not(:disabled) {
    border-color: rgba(99, 170, 160, 0.58);
    background: rgba(21, 40, 42, 0.92);
}

.choice-badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 999px;
    background: rgba(212, 109, 114, 0.16);
    color: #f0a4a8;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-top: 4px;
}

.choice-badge--assignee {
    background: rgba(73, 107, 229, 0.16);
    color: rgba(198, 206, 255, 0.92);
}

.choice-strip.is-expired .btn-choice.is-selected {
    opacity: 1;
}

.choice-label {
    font-weight: 600;
    font-size: 15px;
}

.choice-description {
    font-size: 13px;
    color: var(--color-text-secondary);
    line-height: 1.4;
}

.choice-strip-status {
    display: none;
    align-items: center;
    gap: 10px;
    margin-top: 12px;
    font-size: 13px;
    color: var(--color-text-secondary);
}

.choice-strip-status.is-visible {
    display: flex;
}

.choice-status-spinner {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: 2px solid rgba(73, 107, 229, 0.2);
    border-top-color: rgba(73, 107, 229, 0.85);
    animation: dm-spin 0.8s linear infinite;
}

.choice-strip-status[data-status-type="expired"] .choice-status-spinner,
.choice-strip-status[data-status-type="error"] .choice-status-spinner,
.choice-strip-status[data-status-type="info"] .choice-status-spinner {
    display: none;
}

.choice-strip-status[data-status-type="info"] {
    color: rgba(255, 198, 88, 0.9);
    background: rgba(255, 198, 88, 0.1);
    border: 1px solid rgba(255, 198, 88, 0.3);
    border-radius: 8px;
    padding: 8px 12px;
    margin-top: 12px;
}

.node-next-options .choice-strip-title {
    width: 100%;
    font-size: 1.04rem;
}

.node-next-options .choice-strip-subtitle {
    max-width: 720px;
}

.choice-status-text {
    display: inline-block;
}

.chat-message.is-typing-indicator {
    border: 1px dashed rgba(73, 107, 229, 0.28);
    background: rgba(20, 23, 44, 0.6);
}

.dice-inline-placeholder {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 2px 8px;
    margin: 4px 0;
    border-radius: 999px;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    background: rgba(73, 107, 229, 0.12);
    border: 1px solid rgba(73, 107, 229, 0.2);
}

.dice-inline-placeholder--linked {
    font-weight: 600;
}

.node-choice-dice-host {
    flex: 1 1 100%;
    margin-top: 2px;
}

.node-choice-dice-host--floating-result {
    width: min(100%, 980px);
    margin: 8px auto 18px;
}

.node-choice-dice-host--spotlight .dice-roll-result-card {
    min-height: clamp(190px, 30vh, 320px);
    padding: clamp(22px, 4vw, 42px);
    border-radius: 18px;
    grid-template-columns: minmax(170px, 0.82fr) minmax(0, 1fr) auto;
    gap: clamp(18px, 3vw, 34px);
    background:
        radial-gradient(circle at 24% 28%, rgba(255, 246, 220, 0.18), transparent 30%),
        radial-gradient(circle at 76% 16%, rgba(118, 174, 164, 0.12), transparent 30%),
        linear-gradient(135deg, rgba(218, 146, 88, 0.2), rgba(73, 107, 229, 0.1)),
        rgba(7, 12, 18, 0.96);
    box-shadow:
        inset 0 1px 0 rgba(255, 246, 220, 0.06),
        0 28px 70px rgba(0, 0, 0, 0.34),
        0 0 56px rgba(218, 146, 88, 0.1);
}

.node-choice-dice-host--spotlight .dice-roll-result-card__stage {
    width: clamp(150px, 18vw, 230px);
    height: clamp(122px, 18vh, 190px);
}

.node-choice-dice-host--spotlight .dice-roll-result-card__table {
    inset: auto 2px 15px;
    height: clamp(38px, 7vh, 62px);
    transform: perspective(160px) rotateX(58deg);
}

.node-choice-dice-host--spotlight .dice-roll-result-card__die {
    width: clamp(82px, 9vw, 124px);
    height: clamp(82px, 9vw, 124px);
    border-radius: 26px 24px 30px;
}

.node-choice-dice-host--spotlight .dice-roll-result-card__die-value {
    font-size: clamp(28px, 4vw, 46px);
}

.node-choice-dice-host--spotlight .dice-roll-result-card__trail {
    width: clamp(132px, 18vw, 210px);
    height: clamp(34px, 5vh, 58px);
    filter: blur(6px);
}

.node-choice-dice-host--spotlight .dice-roll-result-card__shadow {
    bottom: clamp(17px, 3vh, 27px);
    width: clamp(70px, 9vw, 112px);
    height: clamp(18px, 2.8vh, 30px);
}

.node-choice-dice-host--spotlight .dice-roll-result-card__eyebrow {
    font-size: 12px;
}

.node-choice-dice-host--spotlight .dice-roll-result-card__title {
    font-size: clamp(1.5rem, 2.4vw, 2.35rem);
}

.node-choice-dice-host--spotlight .dice-roll-result-card__detail {
    max-width: 520px;
    font-size: clamp(0.92rem, 1.25vw, 1.08rem);
}

.node-choice-dice-host--spotlight .dice-roll-result-card__footnote {
    font-size: 0.88rem;
}

.dice-roll-result-card {
    margin-top: 14px;
    min-height: 96px;
    padding: 14px 16px;
    border-radius: 10px;
    border: 1px solid rgba(218, 146, 88, 0.34);
    background:
        radial-gradient(circle at 16% 24%, rgba(255, 239, 199, 0.13), transparent 28%),
        linear-gradient(135deg, rgba(218, 146, 88, 0.16), rgba(73, 107, 229, 0.07)),
        rgba(8, 14, 18, 0.92);
    box-shadow: 0 18px 38px rgba(0, 0, 0, 0.26);
    display: grid;
    grid-template-columns: 118px minmax(0, 1fr) auto;
    align-items: center;
    gap: 14px;
    animation: dice-result-settle 420ms cubic-bezier(0.2, 0.8, 0.2, 1);
    overflow: hidden;
    position: relative;
}

.node-choice-dice-host > .dice-roll-result-card {
    width: min(100%, 840px);
}

.dice-roll-result-card::before {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    background:
        radial-gradient(circle at 18% 26%, rgba(255, 246, 220, 0.12), transparent 24%),
        linear-gradient(90deg, transparent, rgba(255, 246, 220, 0.08), transparent);
    opacity: 0;
    transform: translateX(-42%);
}

.dice-roll-result-card--rolling::before {
    animation: dice-table-light-sweep 1100ms ease-in-out infinite;
}

.dice-roll-result-card--rolling {
    border-color: rgba(223, 180, 99, 0.52);
    background:
        radial-gradient(circle at 14% 32%, rgba(255, 239, 199, 0.22), transparent 31%),
        linear-gradient(135deg, rgba(218, 146, 88, 0.24), rgba(73, 107, 229, 0.12)),
        rgba(8, 14, 18, 0.96);
    box-shadow:
        0 18px 42px rgba(0, 0, 0, 0.34),
        0 0 0 1px rgba(255, 246, 220, 0.05),
        0 0 34px rgba(218, 146, 88, 0.12);
}

.dice-roll-result-card[data-outcome-tone="danger"] {
    border-color: rgba(229, 102, 102, 0.5);
    background:
        linear-gradient(135deg, rgba(229, 102, 102, 0.16), rgba(73, 107, 229, 0.07)),
        rgba(13, 16, 28, 0.88);
}

.dice-roll-result-card[data-outcome-tone="warning"] {
    border-color: rgba(236, 187, 92, 0.52);
}

.dice-roll-result-card[data-outcome-tone="success"] {
    border-color: rgba(112, 211, 154, 0.5);
    background:
        linear-gradient(135deg, rgba(112, 211, 154, 0.14), rgba(223, 180, 99, 0.08)),
        rgba(13, 16, 28, 0.88);
}

.dice-roll-result-card__stage {
    width: 112px;
    height: 72px;
    display: grid;
    place-items: center;
    position: relative;
    isolation: isolate;
}

.dice-roll-result-card__table {
    position: absolute;
    inset: auto 4px 8px;
    height: 25px;
    border-radius: 50%;
    background:
        radial-gradient(ellipse at center, rgba(218, 146, 88, 0.22), rgba(118, 174, 164, 0.05) 52%, transparent 72%);
    transform: perspective(90px) rotateX(58deg);
    opacity: 0.88;
}

.dice-roll-result-card__die {
    width: 52px;
    height: 52px;
    border-radius: 16px 14px 18px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #fff6dc;
    background:
        linear-gradient(145deg, rgba(255, 237, 196, 0.2), rgba(218, 146, 88, 0.15) 36%, rgba(73, 107, 229, 0.17)),
        rgba(9, 14, 22, 0.95);
    border: 1px solid rgba(218, 146, 88, 0.42);
    box-shadow:
        inset 0 0 20px rgba(255, 255, 255, 0.08),
        0 12px 24px rgba(0, 0, 0, 0.28);
    position: relative;
    overflow: hidden;
    z-index: 3;
    clip-path: polygon(50% 0%, 90% 16%, 100% 55%, 73% 100%, 27% 100%, 0% 55%, 10% 16%);
}

.dice-roll-result-card__die::before,
.dice-roll-result-card__die::after {
    content: "";
    position: absolute;
    inset: 8px;
    border: 1px solid rgba(255, 246, 220, 0.11);
    clip-path: polygon(50% 0%, 90% 16%, 100% 55%, 73% 100%, 27% 100%, 0% 55%, 10% 16%);
}

.dice-roll-result-card__die::after {
    inset: 15px;
    opacity: 0.72;
}

.dice-roll-result-card__die i {
    position: relative;
    z-index: 2;
    transform-origin: center;
    animation: dice-icon-pop 520ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

.dice-roll-result-card__die-value {
    position: absolute;
    z-index: 4;
    color: #fff7dd;
    font-family: var(--font-heading);
    font-size: 18px;
    line-height: 1;
    text-shadow: 0 1px 8px rgba(0, 0, 0, 0.45);
}

.dice-roll-result-card--resolved .dice-roll-result-card__die i {
    opacity: 0.16;
}

.dice-roll-result-card--rolling .dice-roll-result-card__die {
    animation: dice-stage-roll 1180ms cubic-bezier(0.28, 0.05, 0.18, 1) infinite;
    border-color: rgba(255, 246, 220, 0.24);
    box-shadow:
        inset 0 0 22px rgba(255, 255, 255, 0.1),
        0 14px 28px rgba(0, 0, 0, 0.36),
        0 0 24px rgba(218, 146, 88, 0.18);
}

.dice-roll-result-card--rolling .dice-roll-result-card__die i {
    animation: dice-rolling-tumble 590ms cubic-bezier(0.34, 0.01, 0.2, 1) infinite;
}

.dice-roll-result-card__trail {
    position: absolute;
    width: 96px;
    height: 28px;
    border-radius: 999px;
    background: linear-gradient(90deg, transparent, rgba(218, 146, 88, 0.42), rgba(118, 174, 164, 0.22), transparent);
    filter: blur(4px);
    opacity: 0;
    transform: translateX(-64px) translateY(10px) rotate(-15deg);
    z-index: 2;
}

.dice-roll-result-card--rolling .dice-roll-result-card__trail {
    animation: dice-trail-sweep 1180ms ease-in-out infinite;
}

.dice-roll-result-card__shadow {
    position: absolute;
    bottom: 12px;
    width: 48px;
    height: 13px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.46);
    filter: blur(4px);
    z-index: 1;
}

.dice-roll-result-card--rolling .dice-roll-result-card__shadow {
    animation: dice-shadow-pulse 1180ms cubic-bezier(0.28, 0.05, 0.18, 1) infinite;
}

.dice-roll-result-card__body {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.dice-roll-result-card__eyebrow,
.dice-roll-result-card__footnote {
    color: var(--color-text-secondary);
    font-size: 11px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.dice-roll-result-card__title {
    color: var(--color-text-primary);
    font-family: var(--font-heading);
    font-size: 22px;
    line-height: 1.05;
}

.dice-roll-result-card__detail {
    color: var(--color-text-primary);
    font-size: 13px;
    line-height: 1.35;
}

.dice-roll-result-card__footnote {
    letter-spacing: 0;
    text-transform: none;
}

.dice-roll-result-card__breakdown {
    justify-self: end;
    max-width: 120px;
    border-radius: 999px;
    padding: 6px 10px;
    color: var(--color-text-secondary);
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.09);
    font-size: 12px;
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

@keyframes dice-result-settle {
    from {
        opacity: 0;
        transform: translateY(8px) scale(0.98);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes dice-icon-pop {
    0% {
        transform: rotate(-18deg) scale(0.86);
    }
    70% {
        transform: rotate(7deg) scale(1.08);
    }
    100% {
        transform: rotate(0) scale(1);
    }
}

@keyframes dice-rolling-tumble {
    0% {
        transform: translateX(-4px) rotate(-32deg) scale(0.92);
        opacity: 0.78;
    }
    28% {
        transform: translateX(5px) rotate(116deg) scale(1.14);
        opacity: 1;
    }
    56% {
        transform: translateX(-2px) rotate(236deg) scale(0.98);
    }
    78% {
        transform: translateX(3px) rotate(326deg) scale(1.08);
    }
    100% {
        transform: translateX(-4px) rotate(448deg) scale(0.92);
        opacity: 0.82;
    }
}

@keyframes dice-stage-roll {
    0% {
        transform: translate(-34px, 4px) rotate(-36deg) scale(0.9);
    }
    18% {
        transform: translate(-14px, -10px) rotate(58deg) scale(1.08);
    }
    38% {
        transform: translate(10px, 3px) rotate(163deg) scale(0.96);
    }
    58% {
        transform: translate(28px, -8px) rotate(256deg) scale(1.1);
    }
    78% {
        transform: translate(12px, 4px) rotate(352deg) scale(0.98);
    }
    100% {
        transform: translate(-34px, 4px) rotate(504deg) scale(0.9);
    }
}

@keyframes dice-trail-sweep {
    0% {
        opacity: 0;
        transform: translateX(-62px) translateY(10px) rotate(-15deg);
    }
    35% {
        opacity: 0.9;
    }
    100% {
        opacity: 0;
        transform: translateX(46px) translateY(10px) rotate(-15deg);
    }
}

@keyframes dice-shadow-pulse {
    0% {
        opacity: 0.48;
        transform: translateX(-28px) scale(0.74);
    }
    18% {
        opacity: 0.28;
        transform: translateX(-12px) scale(0.56);
    }
    38% {
        opacity: 0.5;
        transform: translateX(8px) scale(0.82);
    }
    58% {
        opacity: 0.26;
        transform: translateX(24px) scale(0.58);
    }
    78% {
        opacity: 0.5;
        transform: translateX(12px) scale(0.82);
    }
    100% {
        opacity: 0.48;
        transform: translateX(-28px) scale(0.74);
    }
}

@keyframes dice-table-light-sweep {
    0% {
        opacity: 0;
        transform: translateX(-42%);
    }
    50% {
        opacity: 1;
    }
    100% {
        opacity: 0;
        transform: translateX(42%);
    }
}

.message-image-action {
    display: none;
    margin-top: 14px;
}

.message-image-action.is-visible {
    display: flex;
}

.btn-generate-image {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    border-radius: 14px;
    border: 1px solid rgba(73, 107, 229, 0.35);
    background: rgba(73, 107, 229, 0.12);
    color: var(--color-text-primary);
    font-size: 13px;
    padding: 10px 16px;
    transition: background var(--transition-fast), border-color var(--transition-fast), transform var(--transition-fast);
}

.btn-generate-image span {
    font-weight: 600;
    letter-spacing: 0.02em;
}

.btn-generate-image:hover:not(.is-disabled):not(:disabled) {
    transform: translateY(-1px);
    background: rgba(73, 107, 229, 0.2);
    border-color: rgba(73, 107, 229, 0.55);
}

.btn-generate-image:disabled,
.btn-generate-image.is-disabled {
    cursor: not-allowed;
    opacity: 0.6;
}

.btn-generate-image.is-loading::after {
    content: '';
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.35);
    border-top-color: rgba(255, 255, 255, 0.95);
    animation: dm-spin 0.9s linear infinite;
}

.typing-text {
    font-size: 13px;
    color: var(--color-text-secondary);
    margin-bottom: 6px;
}

.typing-dots {
    display: flex;
    gap: 6px;
}

.typing-dots span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: rgba(73, 107, 229, 0.9);
    animation: typingDot 0.9s ease-in-out infinite;
}

.typing-dots span:nth-child(2) {
    animation-delay: 0.18s;
}

.typing-dots span:nth-child(3) {
    animation-delay: 0.36s;
}

.global-progress-overlay {
    position: fixed;
    inset: 0;
    background: rgba(6, 6, 14, 0.78);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition-medium);
    z-index: 999;
}

.global-progress-overlay.is-visible {
    opacity: 1;
    pointer-events: auto;
}

.global-progress-card {
    background: rgba(18, 20, 38, 0.95);
    border: 1px solid rgba(73, 107, 229, 0.25);
    padding: 32px 48px;
    border-radius: 24px;
    box-shadow: 0 30px 60px rgba(12, 14, 29, 0.45);
    text-align: center;
    max-width: 420px;
    width: 90%;
}

.global-progress-spinner {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    border: 6px solid rgba(73, 107, 229, 0.2);
    border-top-color: rgba(73, 107, 229, 0.95);
    margin: 0 auto 18px;
    animation: dm-spin 0.9s linear infinite;
}

.global-progress-message {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: var(--color-text-primary);
}

@keyframes dm-spin {
    to {
        transform: rotate(360deg);
    }
}

@keyframes typingDot {
    0%, 80%, 100% {
        transform: translateY(0);
        opacity: 0.2;
    }
    40% {
        transform: translateY(-4px);
        opacity: 1;
    }
}

.chat-message.chat-message-image {
    padding: 12px;
    max-width: min(620px, 80%);
    background: rgba(20, 23, 44, 0.92);
    border: 1px solid rgba(73,107,229,0.22);
    overflow: hidden;
}

.chat-introduction-card {
    background: linear-gradient(135deg, rgba(73, 107, 229, 0.15) 0%, rgba(73, 107, 229, 0.08) 100%);
    border: 1px solid rgba(73, 107, 229, 0.3);
    border-radius: var(--radius-md);
    padding: var(--spacing-lg);
    margin: var(--spacing-md) 0;
    animation: slideInUp 0.4s ease-out;
}

.chat-introduction-card.is-completed {
    opacity: 0;
    transform: translateY(-10px);
    transition: opacity 0.5s ease, transform 0.5s ease;
}

.chat-introduction-content {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-md);
}

.chat-introduction-title {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--color-text-primary);
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
}

.chat-introduction-title i {
    color: var(--color-accent);
}

.chat-introduction-text {
    margin: 0;
    color: var(--color-text-secondary);
    line-height: 1.6;
}

.chat-introduction-hint {
    margin: 0;
    padding: var(--spacing-sm);
    background: rgba(73, 107, 229, 0.1);
    border-left: 3px solid var(--color-accent);
    border-radius: var(--radius-sm);
    color: var(--color-text-secondary);
    font-size: 0.9rem;
    line-height: 1.5;
}

.chat-introduction-hint strong {
    color: var(--color-text-primary);
}

.chat-introduction-btn {
    align-self: flex-start;
    margin-top: var(--spacing-sm);
}

@keyframes slideInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.chat-message-image .generated-image {
    display: block;
    width: 100%;
    height: auto;
    max-height: min(55vh, 520px);
    border-radius: 14px;
    object-fit: contain;
    background: rgba(6, 7, 16, 0.85);
    box-shadow: 0 18px 36px rgba(0, 0, 0, 0.35);
}

.chat-input-bar {
    width: min(100%, 1180px);
    margin: 0 auto;
    padding: 18px 20px 20px;
    border-top: 1px solid rgba(99, 170, 160, 0.18);
    background: rgba(7, 16, 19, 0.94);
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.chat-input-bar__actions {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}

.chat-input-action-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border-radius: 10px;
    border: 1px solid rgba(120, 132, 220, 0.26);
    background: rgba(18, 20, 38, 0.82);
    color: var(--color-text-primary);
    font-size: 0.85rem;
    cursor: pointer;
    transition: all var(--transition-fast);
    white-space: nowrap;
}

.chat-input-action-btn:hover {
    background: rgba(32, 36, 66, 0.92);
    border-color: rgba(73, 107, 229, 0.45);
    transform: translateY(-1px);
}

.chat-input-action-btn--accent {
    border-color: rgba(73, 107, 229, 0.45);
    background: rgba(73, 107, 229, 0.12);
}

.chat-input-action-btn--accent:hover {
    background: rgba(73, 107, 229, 0.22);
    border-color: rgba(73, 107, 229, 0.6);
}

.chat-input-action-btn__label {
    font-weight: 500;
}

.chat-input-bar__input-wrapper {
    display: flex;
    gap: 10px;
    align-items: flex-end;
    width: 100%;
}

.chat-composer-label {
    color: #9eb0ad;
    font-size: 0.78rem;
    font-weight: 700;
}

.chat-input-bar textarea {
    flex: 1;
    min-height: 48px;
    max-height: 160px;
    resize: none;
    border-radius: 6px;
    background: rgba(14, 27, 30, 0.92);
    border: 1px solid rgba(99, 170, 160, 0.26);
    color: #edf2ec;
    padding: 12px 14px;
    font: inherit;
    font-size: 1rem;
    line-height: 1.45;
    min-width: 0;
    -webkit-appearance: none; /* Remove estilos padrão iOS */
    appearance: none;
}

.chat-input-bar textarea:focus {
    border-color: rgba(218, 146, 88, 0.72);
    box-shadow: 0 0 0 3px rgba(218, 146, 88, 0.14);
    outline: none;
}

.chat-input-send-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 20px;
    border-radius: 6px;
    background: #da9258;
    border: 1px solid #da9258;
    color: #071013;
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    transition: all var(--transition-fast);
    white-space: nowrap;
    flex-shrink: 0;
}

.chat-input-send-btn:hover:not(.is-disabled) {
    background: #efaa70;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(73, 107, 229, 0.4);
}

.chat-input-send-btn.is-disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.chat-input-send-btn__label {
    font-weight: 600;
}

.chat-message-actions {
    margin-top: 8px;
}

.choice-strip-title {
    font-size: 0.92rem;
    font-weight: 700;
    color: var(--color-text-primary);
    margin: 0 0 8px 0;
}

.choice-strip-subtitle {
    width: 100%;
    font-size: 0.85rem;
    color: var(--color-text-secondary);
    margin: -2px 0 8px 0;
    line-height: 1.45;
}

.node-next-options .choice-strip-buttons {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
}

@media (min-width: 720px) and (max-width: 1279px) {
    .node-next-options .choice-strip-buttons {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 991px) {
    .chat-gameplay-layout {
        grid-template-columns: minmax(0, 1fr);
    }

    .chat-container {
        width: 100%;
    }

    .current-scene-panel__list {
        grid-template-columns: 1fr;
    }
    
    .chat-window {
        padding: 20px 16px;
    }

    .chat-turn-status {
        width: calc(100% - 24px);
        margin: 0 12px 14px;
        padding: 14px 16px;
    }

    .chat-message {
        max-width: 88%;
    }
    
    .chat-container {
        min-height: auto;
    }
}

@media (max-width: 575px) {
    .chat-container {
        border-radius: 16px;
    }
    
    .chat-window {
        padding: 16px 12px;
    }

    .chat-message {
        max-width: 92%;
        padding: 12px 14px;
        margin-bottom: 14px;
        border-radius: 16px;
    }
    
    .chat-message-header {
        flex-wrap: wrap;
        gap: 6px;
        margin-bottom: 6px;
    }
    
    .chat-message-author-wrapper {
        gap: 6px;
    }
    
    .chat-message-avatar {
        width: 26px;
        height: 26px;
        font-size: 0.65rem;
    }
    
    .chat-message-author {
        font-size: 0.8rem;
    }
    
    .chat-message-timestamp {
        font-size: 0.7rem;
    }
    
    .chat-message .message-content {
        font-size: 0.95rem;
        line-height: 1.5;
    }

    .chat-message.chat-message-image {
        max-width: 100%;
        padding: 10px;
    }

    .chat-turn-stage {
        width: 100%;
        margin-bottom: 24px;
        gap: 14px;
    }

    .chat-turn-stage > .chat-message.ai:not(.chat-message-image) {
        padding: 4px 0 10px 14px;
    }

    .chat-turn-stage > .chat-message.ai:not(.chat-message-image) .message-content {
        font-size: 1.08rem;
        line-height: 1.58;
    }

    .chat-turn-stage > .chat-message-image {
        padding: 0;
    }

    .chat-message-image .generated-image {
        max-height: min(50vh, 400px);
        border-radius: 12px;
    }

    .chat-turn-status {
        width: calc(100% - 24px);
        margin: 0 12px 12px;
        padding: 12px 14px;
        border-radius: 14px;
    }
    
    .chat-turn-status__icon {
        width: 32px;
        height: 32px;
        font-size: 0.9rem;
    }
    
    .chat-turn-status__body > strong,
    .chat-turn-status__header > strong {
        font-size: 0.85rem;
    }

    .master-thinking-scene {
        grid-template-columns: minmax(0, 1fr);
        justify-items: center;
        width: min(100%, 390px);
        gap: 10px;
        text-align: center;
    }

    .master-thinking-scene--compact {
        width: min(100%, 370px);
    }

    .master-thinking-scene__table {
        width: 210px;
        height: 168px;
    }

    .master-thinking-scene__object {
        width: 160px;
        height: 160px;
        border-radius: 38px;
    }

    .master-thinking-scene__mage {
        inset: 9px;
        border-radius: 31px;
    }

    .master-thinking-scene__label {
        max-width: 300px;
        font-size: 0.9rem;
    }
    
    .chat-turn-status__progress {
        flex-direction: column;
        align-items: stretch;
        gap: 6px;
        margin-top: 6px;
    }
    
    .chat-turn-status__progress-bar {
        height: 5px;
    }
    
    .chat-turn-status__progress-text {
        text-align: left;
        min-width: auto;
        font-size: 0.7rem;
    }
    
    .chat-turn-status__group-label {
        font-size: 0.7rem;
    }

    .chat-turn-status__timeline {
        padding: 8px 10px;
        gap: 6px;
    }

    .chat-turn-status__timeline-steps {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .chat-turn-status__timeline-step {
        font-size: 0.68rem;
        padding: 4px 6px;
    }

    .chat-turn-status__timeline-meta {
        font-size: 0.68rem;
    }

    .chat-turn-status__causality {
        padding: 8px 10px;
        gap: 6px;
    }

    .chat-turn-status__causality-summary {
        font-size: 0.78rem;
    }

    .chat-turn-status__causality-list {
        font-size: 0.72rem;
        padding-left: 16px;
    }
    
    .turn-status-chip {
        padding: 3px 6px 3px 3px;
        font-size: 0.7rem;
    }
    
    .turn-status-chip__avatar {
        width: 18px;
        height: 18px;
        font-size: 0.6rem;
    }
    
    .chat-input-section {
        padding-bottom: 16px;
    }
    
    .chat-input-bar {
        padding: 12px 14px;
        gap: 10px;
        position: sticky;
        bottom: 0;
        background: rgba(12,14,29,0.98);
        border-top: 1px solid rgba(120, 132, 220, 0.2);
        backdrop-filter: blur(10px);
        z-index: 10;
    }
    
    /* Safe area para barra de input em dispositivos com notch */
    @supports (padding: max(0px)) {
        .chat-input-bar {
            padding-bottom: max(12px, env(safe-area-inset-bottom));
            padding-left: max(14px, env(safe-area-inset-left));
            padding-right: max(14px, env(safe-area-inset-right));
        }
    }
    
    .chat-input-bar__actions {
        gap: 6px;
        flex-wrap: wrap;
    }
    
    .chat-input-action-btn {
        padding: 8px 10px;
        font-size: 0.85rem;
        min-width: 44px;
        min-height: 44px;
        justify-content: center;
    }
    
    .chat-input-action-btn i {
        font-size: 1rem;
    }
    
    .chat-input-bar__input-wrapper {
        gap: 8px;
    }
    
    .chat-input-bar textarea {
        padding: 12px 14px;
        font-size: 16px; /* Evita zoom automático no iOS (16px é o mínimo) */
        border-radius: 6px;
        -webkit-appearance: none;
        appearance: none;
    }
    
    .chat-input-send-btn {
        padding: 12px 16px;
        font-size: 1rem;
        min-width: 50px;
        min-height: 44px;
        border-radius: 6px;
    }
    
    .chat-input-send-btn i {
        font-size: 1.1rem;
    }
    
    .choice-strip {
        gap: 8px;
        margin-top: 12px;
        width: 100%;
    }

    .choice-strip--pending-turn {
        min-height: min(48vh, 430px);
        margin-top: 18px;
        padding: 22px 16px;
        border-radius: 16px;
    }

    .choice-strip--pending-turn .choice-strip-title {
        font-size: 1.18rem;
    }

    .choice-strip--pending-turn .master-thinking-scene {
        text-align: center;
    }

    .node-next-options .choice-strip-buttons {
        grid-template-columns: minmax(0, 1fr);
    }
    
    .btn-choice {
        flex: 1 1 100%;
        min-height: 56px;
        padding: 12px 16px;
        border-radius: 6px;
        font-size: 0.9rem;
    }
    
    .choice-label {
        font-size: 0.9rem;
    }
    
    .choice-description {
        font-size: 0.85rem;
    }
    
    .choice-badge {
        font-size: 0.65rem;
        padding: 2px 6px;
        margin-top: 4px;
    }

    .dice-roll-result-card {
        grid-template-columns: auto minmax(0, 1fr);
        align-items: start;
        padding: 11px 12px;
        gap: 10px;
        min-height: 88px;
    }

    .node-choice-dice-host--floating-result {
        width: 100%;
        margin: 8px auto 16px;
    }

    .node-choice-dice-host--spotlight .dice-roll-result-card {
        min-height: min(42vh, 360px);
        padding: 22px 16px;
        grid-template-columns: minmax(0, 1fr);
        justify-items: center;
        text-align: center;
        gap: 12px;
    }

    .dice-roll-result-card__stage {
        width: 80px;
        height: 58px;
    }

    .node-choice-dice-host--spotlight .dice-roll-result-card__stage {
        width: min(58vw, 190px);
        height: min(32vh, 160px);
    }

    .dice-roll-result-card__die {
        width: 42px;
        height: 42px;
        border-radius: 13px;
    }

    .node-choice-dice-host--spotlight .dice-roll-result-card__die {
        width: min(28vw, 104px);
        height: min(28vw, 104px);
        border-radius: 24px;
    }

    .dice-roll-result-card__title {
        font-size: 20px;
    }

    .node-choice-dice-host--spotlight .dice-roll-result-card__title {
        font-size: clamp(1.35rem, 8vw, 2rem);
    }

    .dice-roll-result-card__breakdown {
        grid-column: 2;
        justify-self: start;
        max-width: 100%;
    }

    .node-choice-dice-host--spotlight .dice-roll-result-card__breakdown {
        grid-column: auto;
        justify-self: center;
    }
}

@media (max-width: 560px) {
    .current-scene-panel {
        padding: 12px;
    }

    .choice-strip {
        margin-top: 10px;
        gap: 8px;
    }

    .node-next-options .choice-strip-title,
    .node-next-options .choice-strip-subtitle {
        margin-bottom: 0;
    }
}

@media (prefers-reduced-motion: reduce) {
    .btn-choice:hover:not(:disabled) {
        transform: none;
    }

    .dice-roll-result-card,
    .dice-roll-result-card__die i,
    .dice-roll-result-card--rolling .dice-roll-result-card__die i,
    .dice-roll-result-card--rolling .dice-roll-result-card__die,
    .dice-roll-result-card--rolling .dice-roll-result-card__trail,
    .dice-roll-result-card--rolling .dice-roll-result-card__shadow,
    .dice-roll-result-card--rolling::before,
    .dice-roll-result-card--rolling::before,
    .master-thinking-scene__object,
    .master-thinking-scene__mage,
    .master-thinking-scene__mage-portrait,
    .master-thinking-scene__pulse,
    .master-thinking-scene__spark {
        animation: none;
    }
}
