/* Existing habitat colors remain the game's navigation. */
:root { --fc-surface: #292e27; --fc-inset: #20251f; --fc-soft-line: #ffffff12; --fc-warning: #e5c58a; }
[hidden] { display: none !important; }
button.secondary-button { color: var(--fc-text); background: #343b32; border: 1px solid var(--fc-line); font-size: 14px; margin: 0; }
#game-map { grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: stretch; }
.region { min-width: 0; padding: 12px 8px; box-sizing: border-box; }
.region .player-marker { display: block; min-width: 0; width: 100%; height: auto; max-height: none; white-space: normal; overflow: visible; text-overflow: clip; word-break: normal; overflow-wrap: anywhere; line-height: 1.65; font-weight: 500; margin: 4px 0; }
.region .player-marker .hunger { display: inline-flex; flex-wrap: wrap; font-size: 11px; max-width: 100%; }
.region .peeked-role, .region .suspected-role { white-space: normal; overflow-wrap: anywhere; }
.floating-rules-btn, .floating-whisper-btn { left: auto !important; top: 4px !important; cursor: pointer; touch-action: manipulation; }
#lobby-chat, #waiting-room-chat, #game-chat { background: var(--fc-surface); padding: 16px; }
.chat-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
#lobby-chat .chat-heading h3, #waiting-room-chat .chat-heading h3, #game-chat .chat-heading h3 { margin: 0; }
.chat-context { color: var(--fc-muted); font-size: 12px; margin: 0 0 12px; }
#lobby-chat-messages, #waiting-room-chat-messages, #game-chat-messages { height: clamp(180px, 30svh, 320px); padding: 8px 12px; background: var(--fc-inset); overflow-y: auto; overscroll-behavior: contain; }
.message { padding: 10px 0; margin: 0; border-bottom: 1px solid var(--fc-soft-line); background: transparent; }
.message .message-sender { display: block; font-size: 12px; font-weight: 600; color: var(--fc-muted); margin-bottom: 3px; overflow-wrap: anywhere; }
.message .message-body { display: block; color: var(--fc-text); white-space: pre-wrap; overflow-wrap: anywhere; }
.message.own .message-sender { color: var(--fc-green); }
.message.system { color: var(--fc-muted); font-size: 12px; border: 0; padding: 7px 0; }
.message.error { color: var(--fc-warning); }
.chat-compose input { background: var(--fc-inset); color: var(--fc-text); border: 1px solid var(--fc-line); font-size: 16px; }
.chat-compose button { font-size: 14px; padding: 10px 16px; }
.chat-footnote { color: var(--fc-muted); font-size: 11px; text-align: right; margin: 6px 0 0; }
#rules-popup, .friends-dialog { position: fixed; inset: 0; transform: none; width: 100%; height: 100%; max-width: none; max-height: none; box-sizing: border-box; padding: 20px; border: 0; border-radius: 0; background: #000b; display: flex; align-items: center; justify-content: center; overflow: hidden; z-index: 10001; }
.dialog-shell { width: min(100%, 640px); max-height: calc(100dvh - 40px); display: flex; flex-direction: column; min-height: 0; border: 1px solid var(--fc-line); border-radius: 12px; background: var(--fc-surface); overflow: hidden; }
.dialog-header { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 20px; border-bottom: 1px solid var(--fc-line); flex-shrink: 0; }
.dialog-header h2 { text-align: left; font-size: 20px; border: 0; padding: 0; margin: 0; }
.dialog-header p { font-size: 12px; color: var(--fc-muted); margin: 4px 0 0; }
#rules-popup #close-rules-popup { position: static; margin: 0; flex-shrink: 0; }
#rules-popup-content, .friends-body { padding: 20px; min-height: 0; overflow-y: auto; overscroll-behavior: contain; }
.rule-intro { margin: 0 0 16px; font-size: 14px; color: var(--fc-muted); }
.game-rules-container { padding: 0; font-family: inherit; color: var(--fc-text); }
.rule-section { margin: 0; padding: 0; border: 0; border-bottom: 1px solid var(--fc-line); background: none; border-radius: 0; }
.rule-section > summary { cursor: pointer; padding: 16px 0; font-size: 16px; font-weight: 600; color: var(--fc-text); }
.rule-section > summary:focus-visible { outline: 2px solid var(--fc-green); outline-offset: 2px; }
.rule-content { padding: 0 0 16px; font-size: 14px; color: var(--fc-muted); line-height: 1.7; }
.rule-content p { margin: 8px 0; }
.rule-content strong { color: var(--fc-text); }
.rule-steps { padding-left: 22px; margin: 0; }
.rule-steps li { padding: 6px 0 6px 4px; }
.rule-content li { font-size: 14px; line-height: 1.7; margin: 0; }
.rule-steps strong { display: block; }
.rule-animal-list { display: grid; gap: 0; margin: 0; }
.rule-animal-list > div { display: grid; grid-template-columns: 85px 1fr; gap: 12px; padding: 12px 0; border-top: 1px solid var(--fc-soft-line); }
.rule-animal-list dt { color: var(--fc-text); font-weight: 600; }
.rule-animal-list small { display: block; font-size: 11px; font-weight: 400; color: var(--fc-muted); }
.rule-animal-list dd { margin: 0; }
.rule-link { display: inline-block; margin-top: 20px; color: var(--fc-green); }
.whisper-popup-content { width: min(640px, calc(100% - 24px)); height: min(600px, calc(100dvh - 32px)); max-height: calc(100dvh - 32px); box-shadow: none; border-color: var(--fc-line); background: var(--fc-surface); }
.whisper-header { background: transparent; padding: 16px; gap: 12px; flex-shrink: 0; }
.whisper-header h3 { color: var(--fc-text); font-size: 18px; }
.whisper-body { height: auto; flex: 1; min-height: 0; overflow: hidden; }
#whisper-chat-list, #whisper-messages { min-height: 0; overflow-y: auto; overscroll-behavior: contain; }
#whisper-chat-area { flex: 1; min-height: 0; }
.whisper-chat-header { flex-shrink: 0; padding: 12px; gap: 12px; background: var(--fc-surface); }
#current-chat-target { min-width: 0; overflow-wrap: anywhere; color: var(--fc-text); }
.whisper-chat-item { margin: 0; border: 0; border-bottom: 1px solid var(--fc-soft-line); padding: 14px 16px; background: transparent; box-shadow: none; border-radius: 0; }
.whisper-player-name, .whisper-last-message, .whisper-message { white-space: normal; overflow: visible; overflow-wrap: anywhere; text-overflow: clip; }
.whisper-chat-item { width: 100%; box-sizing: border-box; text-align: left; }
.whisper-chat-item .chat-info { min-width: 0; }
.whisper-chat-item .player-name, .whisper-chat-item .last-message { white-space: normal; overflow: visible; overflow-wrap: anywhere; text-overflow: clip; }
#whisper-messages { background: var(--fc-inset); padding: 12px; }
.whisper-message, .whisper-message:hover { max-width: 85%; padding: 12px; border-radius: 8px; box-sizing: border-box; box-shadow: none; transform: none; animation: none; }
.whisper-message.my-message { background: #3a5032; border-color: #627558; }
.whisper-message.other-message { background: #30382d; border-color: var(--fc-line); }
.whisper-message::before, .whisper-message::after { display: none; }
.whisper-chat-header .back-button { color: var(--fc-muted); }
.whisper-input-area { display: flex; flex-shrink: 0; gap: 8px; padding: 12px; background: var(--fc-surface); }
#whisper-input { flex: 1; min-width: 0; margin: 0; font-size: 16px; }
#whisper-send { margin: 0; font-size: 14px; }
#whisper-send, #whisper-send:hover { background: #426339; color: var(--fc-text); }
#whisper-input:focus { border-color: var(--fc-green); box-shadow: none; outline: 2px solid var(--fc-green); outline-offset: 2px; }
.floating-whisper-btn, .floating-whisper-btn:hover { background: #343d2f; border: 1px solid #819773; box-shadow: none; }
.lobby-header { gap: 8px; flex-wrap: wrap; }
.lobby-header h2 { flex: 1; }
.room-invite-actions, .friend-add-form { display: flex; gap: 8px; margin: 12px 0; }
.room-invite-actions button { flex: 1; }
.room-link-box, .invite-preview { padding: 16px; border: 1px solid var(--fc-line); border-radius: 8px; margin: 16px 0; background: var(--fc-inset); }
.room-link-box label, .room-link-box small { display: block; font-size: 13px; color: var(--fc-muted); }
#room-link-input { width: 100%; box-sizing: border-box; padding: 10px; margin-top: 8px; font-size: 13px; border: 1px solid var(--fc-line); background: var(--fc-surface); color: var(--fc-text); }
#room-link-status, .friends-status { font-size: 13px; color: var(--fc-warning); margin: 8px 0; min-height: 20px; overflow-wrap: anywhere; }
.friends-section { margin-top: 24px; }
.friends-section h3 { text-align: left; font-size: 14px; margin: 0 0 8px; color: var(--fc-muted); }
.friend-add-form input { min-width: 0; margin: 0; flex: 1; font-size: 16px; }
.friend-add-form button { margin: 0; flex-shrink: 0; font-size: 14px; }
.friends-list { list-style: none; margin: 0; padding: 0; }
.friend-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 12px 0; border-bottom: 1px solid var(--fc-soft-line); }
.friend-row .friend-label { flex: 1 1 110px; min-width: 0; overflow-wrap: anywhere; }
.friend-row .friend-label small { display: block; color: var(--fc-muted); font-size: 12px; }
.friend-row .friend-label small.online { color: var(--fc-green); }
.friend-row button { min-height: 40px; padding: 8px 10px; font-size: 13px; margin: 0; }
.friends-empty { color: var(--fc-muted); font-size: 13px; padding: 8px 0; }
.friends-note { font-size: 12px; color: var(--fc-muted); }
body.dialog-open { overflow: hidden; }
@media(max-width:600px) {
    #rules-popup, .friends-dialog { padding: 12px; }
    .dialog-shell { max-height: calc(100dvh - 24px); }
    .dialog-header, #rules-popup-content, .friends-body { padding: 16px; }
    #lobby-chat, #waiting-room-chat, #game-chat { padding: 12px; }
    .chat-heading { gap: 8px; }
}
