body:has(#screen-friend.active) .wrap { max-width: 720px; padding-inline: max(20px, var(--safe-left)) max(20px, var(--safe-right)); }
#screen-friend .game-head { margin-bottom: 6px; display: grid; grid-template-columns: 1fr auto 1fr; }
#screen-friend .game-head > button { justify-self: start; }
.friend-intro { font-size: 19px; line-height: 1.6; margin: 4px 0 12px; }
.friend-note { font-size: 12px; line-height: 1.8; color: var(--ink-soft); margin: 10px 0; overflow-wrap: anywhere; }
.friend-tabs { position: relative; isolation: isolate; display: grid; grid-template-columns: 1fr 1fr; padding: 4px; border: 1px solid var(--line); border-radius: 10px; background: #e9e7df; }
.friend-tabs::before { content: ""; position: absolute; z-index: -1; left: 4px; top: 4px; bottom: 4px; width: calc((100% - 8px)/2); border-radius: 7px; background: #fcfaf3; box-shadow: 0 1px 6px #39445712; transition: transform .3s cubic-bezier(.2,.75,.25,1); }
.friend-tabs[data-active="receive"]::before { transform: translateX(100%); }
.friend-tabs button { min-height: 44px; border: 0; background: none; font: inherit; font-size: 14px; color: var(--ink-soft); cursor: pointer; border-radius: 7px; }
.friend-tabs button[aria-selected="true"] { color: var(--accent-deep); }
.friend-panel { padding: 16px; margin: 12px 0 0; border: 1px solid var(--line); background: #faf8f1f5; border-radius: 12px; min-width: 0; }
.friend-panel[hidden], .friend-song[hidden] { display: none; }
.friend-panel[role="tabpanel"]:not([hidden]) { animation: ui-panel-in .28s ease both; }
.friend-panel h3 { font-size: 18px; font-weight: 500; line-height: 1.5; }
.friend-panel label { font-size: 11px; color: var(--ink-soft); }
.friend-panel input[type="search"], .friend-panel textarea, .friend-panel select { display: block; width: 100%; min-width: 0; min-height: 44px; font: inherit; font-size: 16px; color: var(--ink); background: #fffdf7; border: 1px solid var(--line); border-radius: 7px; padding: 9px; margin: 4px 0 0; }
.friend-panel textarea { height: 112px; resize: none; overflow-wrap: anywhere; margin: 10px 0 14px; }
.friend-filters, .friend-actions { display: grid; grid-template-columns: minmax(0,1fr) minmax(0,1fr); gap: 10px; }
.friend-filters > *, .friend-actions > * { min-width: 0; }
.friend-actions .btn, #friend-generate, #friend-next { min-height: 46px; padding: 10px; font-size: 13px; letter-spacing: .03em; border-radius: 8px; }
#friend-generate { width: 100%; }
.friend-selection-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.friend-count { font-size: 12px; color: var(--accent-deep); line-height: 1.8; }
.friend-selection-head > div { text-align: right; }
.friend-selection-head small { font-size: 10px; color: var(--ink-soft); }
.friend-length { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.friend-length select { width: 80px; margin: 0; }
.friend-selection { list-style: none; display: grid; grid-auto-flow: column; grid-auto-columns: max(44px,calc((100% - 24px)/5)); justify-content: start; gap: 6px; margin: 0 0 12px; height: 88px; padding-top: 2px; overflow-x: auto; overscroll-behavior-x: contain; scrollbar-width: thin; }
.friend-selection li { min-width: 0; }
.friend-slot { position: relative; width: 100%; height: 76px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 5px; border: 1px dashed #cfd0c6; border-radius: 8px; background: #eeede5; color: var(--ink-soft); cursor: pointer; font: inherit; }
.friend-slot:disabled { cursor: default; }
.friend-slot.filled { border: 1px solid #a2ada5; background: #edf1e7; }
.friend-slot img { width: 32px; height: 32px; object-fit: cover; border-radius: 3px; }
.friend-slot.filled img { animation: ui-picked .25s ease both; }
.friend-slot b { font-size: 17px; font-weight: 400; }
.friend-slot.filled b { position: absolute; left: 3px; top: 3px; font: 9px/14px sans-serif; width: 14px; height: 14px; border-radius: 50%; background: #fbf9ef; }
.friend-slot small { display: block; font-size: 10px; max-width: calc(100% - 8px); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.friend-search-field { position: relative; margin-bottom: 10px; }
.friend-search-field input[type="search"] { padding-right: 48px; margin: 0; }
.friend-search-field input::-webkit-search-cancel-button { display: none; }
#friend-search-clear { position: absolute; right: 0; top: 0; width: 44px; height: 44px; border: 0; background: transparent; font: 20px/1 sans-serif; color: var(--ink-soft); cursor: pointer; }
.friend-filter-count { min-height: 18px; margin: 7px 0 5px; font-size: 10px; color: var(--ink-soft); line-height: 18px; }
.friend-song-list { height: clamp(180px,30svh,260px); overflow-y: auto; overscroll-behavior: contain; scrollbar-gutter: stable; overflow-anchor: none; border-block: 1px solid var(--line); }
.friend-song { position: relative; display: flex; gap: 10px; align-items: center; height: 66px; padding: 9px 6px; border-bottom: 1px solid #e2e3d8; cursor: pointer; border-radius: 5px; transition: background-color .2s ease; }
.friend-song > input { position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.friend-cover { width: 42px; height: 42px; object-fit: cover; border-radius: 4px; flex: 0 0 42px; background: #e9e7df; }
.friend-song-meta { display: grid; gap: 5px; min-width: 0; flex: 1; }
.friend-song-meta > * { white-space: nowrap; text-overflow: ellipsis; overflow: hidden; }
.friend-song b { font-size: 13px; font-weight: 500; color: var(--ink); }
.friend-song small { font-size: 10px; color: var(--ink-soft); }
.friend-checkmark { display: grid; place-items: center; width: 22px; height: 22px; flex: 0 0 22px; border-radius: 50%; border: 1px solid #c8cfc4; font: 17px/1 sans-serif; background: #fbf9f0; transition: background-color .2s, color .2s, scale .2s; }
.friend-checkmark::before { content: "+"; }
.friend-song:has(input:checked) { background: #eaf0e2; }
.friend-song:has(input:checked) .friend-checkmark { background: #668074; border-color: #668074; color: #fff; scale: 1.07; }
.friend-song:has(input:checked) .friend-checkmark::before { content: "✓"; font-size: 13px; }
.friend-song:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: -2px; }
.friend-song:has(input:disabled) { opacity: .55; cursor: not-allowed; }
.friend-song input:disabled { cursor: not-allowed; }
.friend-empty { padding: 40px 12px; text-align: center; font-size: 14px; line-height: 2; color: var(--ink-soft); }
.friend-empty small { font-size: 11px; }
.friend-compose-footer { display: flex; align-items: center; gap: 12px; justify-content: space-between; margin-top: 12px; }
.friend-compose-footer > span { min-width: 0; font-size: 11px; color: var(--ink-soft); line-height: 1.5; }
#friend-next { flex: 0 0 auto; }
.friend-panel .btn:disabled { opacity: .45; cursor: not-allowed; }
.friend-legal { font-size: 10px; line-height: 1.8; color: var(--ink-soft); margin: 12px 0 0; text-align: center; }
.friend-dialog { width: min(440px,calc(var(--dialog-width) - 28px)); max-height: calc(var(--dialog-height) - 4px); overflow-y: auto; overscroll-behavior: contain; }
.friend-dialog[open] { animation: ui-panel-in .28s ease both; }
.friend-dialog::backdrop { background: #23304460; backdrop-filter: blur(4px); }
.friend-dialog header { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
#friend-close { width: 44px; height: 44px; flex: 0 0 44px; border: 0; border-radius: 50%; background: #ebe8de; color: var(--ink-soft); font-size: 24px; cursor: pointer; }
.friend-review-list { list-style: none; max-height: min(275px,40svh); overflow-y: auto; scrollbar-gutter: stable; padding: 0; margin-bottom: 16px; }
.friend-review-list li { display: flex; align-items: center; gap: 10px; min-height: 52px; border-bottom: 1px solid var(--line); padding: 6px 0; font-size: 12px; overflow-wrap: anywhere; }
.friend-review-list img { width: 34px; height: 34px; object-fit: cover; border-radius: 3px; }
.friend-review-list b { font-size: 10px; color: var(--ink-soft); font-weight: 400; }
#friend-review-settings, #friend-output { animation: ui-panel-in .25s ease both; }
#friend-status { min-height: 44px; margin-bottom: 0; }
#friend-import-info { min-height: 86px; }
.friend-dialog[data-stage="share"] #friend-review-settings { display: none; }
.friend-dialog[data-stage="review"] #friend-output { display: none; }
.toy-compact body:has(#screen-friend.active) .wrap { padding-inline: max(16px,var(--safe-left)) max(16px,var(--safe-right)); }
@media (max-width: 760px) { body:has(#screen-friend.active) .wrap { padding-inline: max(16px,var(--safe-left)) max(16px,var(--safe-right)); } }
.toy-small .friend-panel { padding: 12px; }
@media (max-width: 360px) { .friend-panel { padding: 12px; } }
@media (hover: hover) { .friend-song:hover { background: #f0f2e9; } .friend-slot.filled:hover { border-color: var(--accent); } }
@media (prefers-reduced-motion: reduce) { .friend-tabs::before, .friend-panel, .friend-panel * { animation: none !important; transition: none !important; } }
