@font-face {
    font-family: 'Junge';
    src: url('/junge.ttf') format('truetype');
}
@font-face {
    font-family: 'Noto';
    src: url('/noto.ttf') format('truetype');
}

* {
    font-family: 'Junge', serif;
}

body {
    transition: background-color 0.3s ease, color 0.3s ease;
    user-select: none;
}

body {
    background-color: #ffffff;
    color: #000000;
}

body.dark-mode {
    background-color: #272424;
    color: #ffffff;
}

html.dark-mode {
    background-color: #272424;
    color: #ffffff;
}

html.dark-mode body {
    background-color: #272424;
    color: #ffffff;
}

.theme-toggle {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 10px 15px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    background-color: #f0f0f0;
    color: #000000;
    font-family: 'Junge', serif;
}

body.dark-mode .theme-toggle {
    background-color: #272424;
    color: #ffffff;
}

.leftdiv {
    position: fixed;
    top: 0;
    left: max(0px, calc(50% - 600px));
    height: 100vh;
    width: 275px;
    display: flex;
    flex-direction: column;
    justify-content: safe center;
    align-items: flex-start;
    gap: 15px;
    padding: 20px;
    overflow-y: auto;
    scrollbar-width: none;          /* Firefox */
    -ms-overflow-style: none;       /* IE / old Edge */
}

.leftdiv::-webkit-scrollbar {       /* Chrome / Safari */
    display: none;
}

body.dark-mode .leftdiv {
    background-color: transparent;
}

.leftdiv a {
    color: inherit;
    text-decoration: none;
    padding: 8px;
    border-radius: 5px;
    position: relative;
    transition: color 0.2s ease;
}

.leftdiv a::after,
.dropbutton-arrow::after {
    content: '';
    position: absolute;
    left: -3px;
    right: 16px;
    bottom: 4px;
    height: 1px;
    background-color: currentColor;
    transform: scaleX(0);
    transform-origin: left;
    transition: transform 0.25s ease;
    pointer-events: none;
}

.leftdiv a:hover::after,
.leftdiv a:focus-visible::after,
.dropbutton-arrow:hover::after,
.dropbutton-arrow:focus-visible::after {
    transform: scaleX(0.9);
}

.dropbutton {
    display: flex;
    flex-direction: column;
    width: 100%;
}

.dropbutton-row {
    display: flex;
    align-items: center;
    width: 100%;
}

.dropbutton-link {
    display: block;
    flex: 1;
}

.dropbutton-arrow {
    background: none;
    border: none;
    cursor: pointer;
    color: inherit;
    font-size: 0.75em;
    padding: 4px;
    border-radius: 5px;
    position: relative;
    transition: transform 0.25s ease, color 0.2s ease;
    transform: rotate(0deg);
}

.dropbutton-arrow:hover {
    background-color: transparent;
}

.dropbutton.expanded .dropbutton-arrow {
    transform: rotate(90deg);
}

.subitems {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    max-height: 0;
    transition: max-height 0.25s ease;
}

.dropbutton.expanded .subitems {
    max-height: 500px;
    margin-left: -3px;
}

.subitems a {
    font-size: 0.9em;
    opacity: 0.85;
}

.content {
    margin-left: max(0px, calc(50% - 600px + 275px));
    width: min(100%, 600px);
    max-width: 600px;
    min-height: 100vh;
    border-left: 1px solid rgba(0, 0, 0, 0.1);
    border-right: 1px solid rgba(0, 0, 0, 0.1);
}

body.dark-mode .content {
    border-left-color: rgba(255, 255, 255, 0.1);
    border-right-color: rgba(255, 255, 255, 0.1);
}

.tweet-composer {
    display: flex;
    gap: 12px;
    padding: 16px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
    top: 0;
    background-color: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(10px);
    z-index: 10;
}

body.dark-mode .tweet-composer {
    background-color: rgba(39, 36, 36, 0.8);
    border-bottom-color: rgba(255, 255, 255, 0.1);
}

.avatar-small {
    width: 48px;
    height: 48px;
    border-radius: 100% !important;
    object-fit: cover;
    flex-shrink: 0;
}

.composer-input-container {
    display: flex;
    flex-direction: column;
    flex: 1;
    gap: 4px;
}

.composer-name {
    background-color: transparent;
    color: inherit;
    border: none;
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
    font-family: 'Junge', serif;
    font-size: 1em;
    font-weight: bold;
    outline: none;
    padding: 4px 0;
    margin-top: 8px;
}

body.dark-mode .composer-name {
    border-bottom-color: rgba(255, 255, 255, 0.1);
}

.composer-name::placeholder,
.composer-input::placeholder {
    color: rgba(0, 0, 0, 0.5);
}

body.dark-mode .composer-name::placeholder,
body.dark-mode .composer-input::placeholder {
    color: rgba(255, 255, 255, 0.5);
}

.composer-input {
    width: 100%;
    background-color: transparent;
    color: inherit;
    border: none;
    font-size: 1.25em;
    font-family: 'Junge', serif;
    resize: none;
    outline: none;
    min-height: 48px;
    line-height: 1.5;
}

.composer-attachments {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.composer-attachments:empty {
    display: none;
}

.attachment {
    position: relative;
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 12px;
    overflow: hidden;
}

body.dark-mode .attachment {
    border-color: rgba(255, 255, 255, 0.1);
}

.attachment img {
    display: block;
    max-width: 100%;
    max-height: 360px;
    object-fit: cover;
}

.attachment audio {
    display: block;
    width: 100%;
}

.attachment-audio {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    border: none;
}

body.dark-mode .attachment-audio {
    border: none;
}

.attachment-audio audio {
    flex: 1;
    min-width: 0;
}

.attachment-audio .attachment-remove {
    position: static;
    flex-shrink: 0;
}

.attachment iframe {
    display: block;
    width: 100%;
    height: 420px;
    border: none;
}

.attachment-remove {
    position: absolute;
    top: 6px;
    right: 6px;
    background-color: rgba(0, 0, 0, 0.6);
    color: white;
    border: none;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    cursor: pointer;
    font-family: 'Junge', serif;
    font-size: 0.9em;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.composer-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.composer-actions {
    display: flex;
    gap: 4px;
}

.composer-action {
    background: none;
    border: none;
    cursor: pointer;
    color: inherit;
    padding: 6px;
    border-radius: 50%;
    width: 36px;
    height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s ease;
}

.composer-action svg {
    display: block;
}

.composer-action:hover {
    background-color: rgba(0, 0, 0, 0.06);
}

body.dark-mode .composer-action:hover {
    background-color: rgba(255, 255, 255, 0.08);
}

.composer-action.active {
    background-color: rgba(0, 0, 0, 0.1);
}

body.dark-mode .composer-action.active {
    background-color: rgba(255, 255, 255, 0.14);
}

.compose-button {
    background-color: #272424;
    color: white;
    border: none;
    border-radius: 20px;
    padding: 10px 24px;
    font-weight: bold;
    font-size: 0.875em;
    cursor: pointer;
    font-family: 'Junge', serif;
    transition: background-color 0.2s ease;
}

.compose-button:hover {
    background-color: #272424;
}

.compose-button:active {
    background-color: #272424;
}

.feed {
    display: flex;
    flex-direction: column;
}

.feed-item {
    display: flex;
    gap: 10px;
    padding: 10px 14px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
    font-size: 0.875em;
}

body.dark-mode .feed-item {
    border-bottom-color: rgba(255, 255, 255, 0.1);
}

.feed-item-body {
    display: flex;
    flex-direction: column;
    flex: 1;
    gap: 4px;
    min-width: 0;
}

.feed-item-name {
    font-weight: bold;
    display: flex;
    align-items: center;
    gap: 6px;
    padding-top: 5px;
}

.feed-item-handle,
.feed-comment-handle {
    font-size: 0.8em;
    opacity: 0.55;
    margin-top: -2px;
    margin-bottom: 7px;
    word-break: break-all;
}

.feed-item-flag {
    font-family: 'Segoe UI Emoji', 'Apple Color Emoji', 'Noto Color Emoji', sans-serif;
    font-weight: normal;
    font-size: 1em;
    line-height: 1;
}

.composer-name-row {
    display: flex;
    align-items: center;
    gap: 8px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
    margin: -16px -16px 8px;
    padding: 8px 0;
}

body.is-logged-in .composer-name,
body.is-logged-in .composer-name-row {
    display: none !important;
}

body.dark-mode .composer-name-row {
    border-bottom-color: rgba(255, 255, 255, 0.1);
}

.composer-name-row .composer-name {
    flex: 1;
    border-bottom: none;
    margin-top: 0;
}

.composer-flag {
    font-family: 'Segoe UI Emoji', 'Apple Color Emoji', 'Noto Color Emoji', sans-serif;
    font-size: 1em;
    padding-right: 15px;
    line-height: 1;
}

.feed-item-text {
    white-space: pre-wrap;
    word-wrap: break-word;
}

.feed-item img,
.feed-item audio,
.feed-item iframe {
    max-width: 100%;
}

.feed-item iframe {
    width: calc(100% + 60px);
    max-width: none;
    height: 420px;
    border: none;
    border-radius: 12px;
    margin-left: -60px;
}

.feed-item img {
    border-radius: 12px;
    max-height: 360px;
}

.feed-item-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 4px;
    margin-top: 4px;
    max-width: 425px;
}

.feed-action {
    background: none;
    border: none;
    cursor: pointer;
    color: inherit;
    opacity: 0.65;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 1px;
    border-radius: 999px;
    font-family: 'Junge', serif;
    font-size: 0.85em;
    transition: background-color 0.2s ease, color 0.2s ease, opacity 0.2s ease;
}

.feed-action[hidden] {
    display: none;
}

.feed-action:hover {
    opacity: 1;
}

body.dark-mode .feed-action:hover {
    background-color: rgba(255, 255, 255, 0.08);
}

.feed-action-upvotes:hover {
    color: #2ecc71;
}

.feed-action-bookmarks:hover {
    color: #f1c40f;
}

.feed-action-comments:hover {
    color: #3498db;
}

.feed-action svg {
    display: block;
}

.feed-action .action-glyph {
    display: inline-block;
    font-size: 18px;
    line-height: 1;
    font-family: "Yu Mincho", "Hiragino Mincho ProN", "Noto Serif JP", serif;
}

.feed-action-count {
    line-height: 1;
}

.feed-action-bookmarks .feed-action-count {
    opacity: 0;
    transition: opacity 0.2s ease;
}

.feed-action-bookmarks:hover .feed-action-count,
.feed-action-bookmarks:focus-visible .feed-action-count {
    opacity: 1;
}

.feed-item-image {
    max-width: 100%;
    max-height: 420px;
    border-radius: 8px;
    display: block;
    margin-top: 6px;
}

.feed-item-comments[hidden] {
    display: none;
}

.feed-item-comments {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid rgba(0, 0, 0, 0.08);
}

body.dark-mode .feed-item-comments {
    border-top-color: rgba(255, 255, 255, 0.08);
}

.feed-item-comments-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.feed-comment {
    display: flex;
    gap: 10px;
    margin-top: 4px;
    padding-bottom: 4px;
    padding-top: 10px;
    background-color: transparent;
    border-radius: 0;
    border-top: 1px solid rgba(0, 0, 0, 0.08);
    font-size: 0.875em;
}

body.dark-mode .feed-comment {
    background-color: transparent;
    border-top-color: rgba(255, 255, 255, 0.08);
}

.feed-comment-body {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.feed-comment-name {
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 6px;
    padding-top: 5px;
}

.feed-comment-text {
    white-space: pre-wrap;
    word-wrap: break-word;
}

.feed-comment-form {
    margin-top: 10px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.feed-comment-form input,
.feed-comment-form textarea {
    font-family: inherit;
    font-size: 0.9em;
    padding: 6px 8px;
    border: 1px solid rgba(0, 0, 0, 0.15);
    border-radius: 6px;
    background: transparent;
    color: inherit;
    resize: vertical;
}

.feed-comment-form textarea {
    min-height: 60px;
}

body.dark-mode .feed-comment-form input,
body.dark-mode .feed-comment-form textarea {
    border-color: rgba(255, 255, 255, 0.18);
}

.feed-comment-form .compose-button {
    align-self: flex-end;
}

.feed-item-comments-loading {
    font-size: 0.85em;
    opacity: 0.7;
}

.feed-item-clickable {
    cursor: pointer;
    transition: background-color 0.15s ease;
}

.feed-item-clickable:hover {
    background-color: rgba(0, 0, 0, 0.025);
}

body.dark-mode .feed-item-clickable:hover {
    background-color: rgba(255, 255, 255, 0.03);
}

.feed-action.active {
    opacity: 1;
}

.feed-action-upvotes.active { color: #2ecc71; }
.feed-action-bookmarks.active { color: #f1c40f; }
.feed-action-bookmarks.active .feed-action-count { opacity: 1; }

body .mod-only { display: none; }
body.is-mod .mod-only { display: inline-flex; }

body .admin-only { display: none; }
body.is-admin .admin-only { display: inline-flex; }

.feed-action-delete:hover { color: #e74c3c; }
.feed-action-ban:hover { color: #c0392b; }

.ban-dialog {
    width: min(380px, 100%);
    padding: 32px 28px 24px;
    text-align: center;
    gap: 0;
}

.ban-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background-color: rgba(192, 57, 43, 0.12);
    color: #c0392b;
    margin: 0 auto 16px;
}

.ban-title {
    margin: 0 0 6px;
    font-size: 1.4em;
    font-weight: 600;
    color: #c0392b;
}

.ban-subtitle {
    margin: 0 0 18px;
    opacity: 0.7;
    font-size: 0.92em;
}

.ban-reason-block {
    background-color: rgba(0, 0, 0, 0.04);
    border-radius: 12px;
    padding: 12px 14px;
    margin-bottom: 20px;
    text-align: left;
}

body.dark-mode .ban-reason-block {
    background-color: rgba(255, 255, 255, 0.05);
}

.ban-reason-label {
    font-size: 0.75em;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    opacity: 0.6;
    margin-bottom: 4px;
}

.ban-reason {
    margin: 0;
    font-size: 0.95em;
    white-space: pre-wrap;
    word-wrap: break-word;
}

.ban-ok {
    width: 100%;
    background-color: #272424;
    color: #ffffff;
    border: none;
    border-radius: 999px;
    padding: 12px 20px;
    font-family: inherit;
    font-size: 0.95em;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.15s ease;
}

.ban-ok:hover { opacity: 0.9; }

body.dark-mode .ban-ok {
    background-color: #ffffff;
    color: #272424;
}

.comment-ban {
    background: none;
    border: none;
    color: inherit;
    cursor: pointer;
    padding: 2px 4px;
    opacity: 0.6;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.comment-ban:hover { opacity: 1; color: #c0392b; }
.comment-ban svg { width: 14px; height: 14px; }

.feed-action-pin:hover { color: #f39c12; }
.feed-action-pin.active { color: #f39c12; }

.feed-item-pinned {
    background-color: rgba(243, 156, 18, 0.05);
    border-left: 3px solid #f39c12;
    position: relative;
}

body.dark-mode .feed-item-pinned {
    background-color: rgba(243, 156, 18, 0.08);
}

.feed-item-pin-label {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.75em;
    color: #f39c12;
    opacity: 0.9;
    margin-left: auto;
    padding-right: 24px;
}

.feed-item-pin-label svg {
    width: 12px;
    height: 12px;
}

.feed-item-pin-hide {
    position: absolute;
    top: 6px;
    right: 6px;
    background: none;
    border: none;
    color: inherit;
    cursor: pointer;
    opacity: 0.45;
    padding: 4px;
    border-radius: 4px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.feed-item-pin-hide:hover { opacity: 1; background: rgba(0, 0, 0, 0.06); }
body.dark-mode .feed-item-pin-hide:hover { background: rgba(255, 255, 255, 0.08); }

.feed-item-pin-collapsed {
    display: none !important;
}

.role-badge {
    display: inline-flex;
    align-items: center;
    margin-left: 4px;
    color: #8b8b8b;
    line-height: 0;
    vertical-align: middle;
}

.role-badge svg {
    display: block;
    width: 16px;
    height: 16px;
}

body.dark-mode .role-badge {
    color: #b5b5b5;
}

.comment-delete {
    margin-left: auto;
    background: none;
    border: none;
    color: inherit;
    opacity: 0.5;
    cursor: pointer;
    font-size: 1em;
    line-height: 1;
    padding: 0 4px;
}

.comment-delete:hover { opacity: 1; color: #e74c3c; }

.feed-comment-reply-info {
    font-size: 0.85em;
    opacity: 0.65;
    margin-top: -4px;
}

.feed-comment-reply-info .mention-link {
    opacity: 1;
}

.feed-comment-actions {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-top: 8px;
    margin-left: -8px;
    padding-bottom: 12px;
}

.feed-action.feed-comment-action {
    padding: 3px 8px;
    font-size: 0.8em;
}

.feed-action .feed-action-label {
    line-height: 1;
}

.mention {
    color: #3498db;
    opacity: 0.9;
}

.mention-link {
    color: #3498db;
    text-decoration: none;
    cursor: pointer;
}

.mention-link:hover {
    text-decoration: underline;
}

body.dark-mode .mention,
body.dark-mode .mention-link {
    color: #5dade2;
}

.comment-highlight {
    animation: commentHighlight 1.6s ease;
}

@keyframes commentHighlight {
    0% { background-color: rgba(52, 152, 219, 0.18); }
    100% { background-color: transparent; }
}

.composer-reply-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    align-self: flex-start;
    padding: 3px 8px;
    border-radius: 999px;
    background-color: rgba(52, 152, 219, 0.12);
    color: #3498db;
    font-size: 0.85em;
}

.composer-reply-chip[hidden] { display: none; }

body.dark-mode .composer-reply-chip {
    background-color: rgba(93, 173, 226, 0.18);
    color: #5dade2;
}

.composer-reply-chip-clear {
    background: none;
    border: none;
    color: inherit;
    cursor: pointer;
    font-size: 1em;
    line-height: 1;
    padding: 0 2px;
    opacity: 0.7;
}

.composer-reply-chip-clear:hover { opacity: 1; }

.sidebar-shortcuts {
    /* Negative margin cancels most of the .leftdiv gap (15px) so the
       buttons sit close under the avatar/name instead of far below. */
    margin-top: -6px;
    padding: 0 8px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.sidebar-shortcut {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    box-sizing: border-box;
    flex: 0 0 36px;
    border-radius: 50%;
    color: inherit;
    text-decoration: none;
    transition: background-color 0.15s ease;
}

.sidebar-shortcut:hover {
    background-color: rgba(0, 0, 0, 0.06);
}

body.dark-mode .sidebar-shortcut:hover {
    background-color: rgba(255, 255, 255, 0.08);
}

.sidebar-shortcut-avatar {
    padding: 0;
    overflow: hidden;
    display: none;
}

.sidebar-shortcut-lang {
    background: none;
    border: 1px solid rgba(0, 0, 0, 0.15);
    font-family: inherit;
    font-size: 0.75em;
    font-weight: 600;
    letter-spacing: 0.05em;
    cursor: pointer;
    padding: 0;
}

body.dark-mode .sidebar-shortcut-lang {
    border-color: rgba(255, 255, 255, 0.18);
}

.sidebar-shortcut-lang:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.sidebar-shortcut-logout {
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    color: #e74c3c;
}

.sidebar-shortcut-logout:hover {
    background-color: rgba(231, 76, 60, 0.12);
}

body.dark-mode .sidebar-shortcut-logout {
    color: #f87171;
}

body.dark-mode .sidebar-shortcut-logout:hover {
    background-color: rgba(248, 113, 113, 0.16);
}

.sidebar-avatar {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
    display: block;
}

.sidebar-shortcut-badge {
    position: absolute;
    top: 0;
    right: 0;
    background-color: #e74c3c;
    color: #fff;
    border-radius: 999px;
    padding: 0 5px;
    font-size: 0.7em;
    line-height: 1.4;
    min-width: 16px;
    text-align: center;
}

.board-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 16px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
}

body.dark-mode .board-header {
    border-bottom-color: rgba(255, 255, 255, 0.1);
}

.board-title {
    margin: 0;
    font-size: 1.2em;
    font-weight: bold;
}

.board-show-pinned {
    display: none;
    background: none;
    border: none;
    color: inherit;
    cursor: pointer;
    opacity: 0.55;
    padding: 6px;
    border-radius: 6px;
    align-items: center;
    justify-content: center;
}
.board-show-pinned.is-active { display: inline-flex; }
.board-show-pinned:hover { opacity: 1; background: rgba(0, 0, 0, 0.06); }
body.dark-mode .board-show-pinned:hover { background: rgba(255, 255, 255, 0.08); }
.board-show-pinned svg { width: 20px; height: 20px; }

.page-header {
    display: flex;
    align-items: center;
    padding: 16px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
}

body.dark-mode .page-header {
    border-bottom-color: rgba(255, 255, 255, 0.1);
}

.page-title {
    margin: 0;
    font-size: 1.2em;
    font-weight: bold;
}

.page-list {
    display: flex;
    flex-direction: column;
}

.page-loading,
.page-empty {
    padding: 24px;
    text-align: center;
    opacity: 0.6;
    font-size: 0.95em;
}

.notification-item {
    display: block;
    padding: 12px 14px;
    color: inherit;
    text-decoration: none;
    transition: background-color 0.15s ease;
    border: 1px solid transparent;
}

.notification-item:hover {
    background-color: rgba(0, 0, 0, 0.04);
}

body.dark-mode .notification-item:hover {
    background-color: rgba(255, 255, 255, 0.05);
}

.notification-item.unread {
    border-color: rgba(52, 152, 219, 0.25);
    background-color: rgba(52, 152, 219, 0.06);
}

body.dark-mode .notification-item.unread {
    border-color: rgba(93, 173, 226, 0.3);
    background-color: rgba(93, 173, 226, 0.08);
}

.notification-text {
    font-size: 0.95em;
}

.notification-preview {
    margin-top: 2px;
    font-size: 0.85em;
    opacity: 0.7;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.profile-header {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 20px 16px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
}

body.dark-mode .profile-header {
    border-bottom-color: rgba(255, 255, 255, 0.1);
}

.profile-avatar-wrap {
    position: relative;
    display: inline-block;
    width: 72px;
    height: 72px;
    flex-shrink: 0;
}

.profile-avatar-wrap.editable {
    cursor: pointer;
}

.profile-avatar {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    object-fit: cover;
    display: block;
}

.profile-avatar-edit {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ffffff;
    background-color: rgba(0, 0, 0, 0.4);
    opacity: 0;
    transition: opacity 0.15s ease;
    pointer-events: none;
}

.profile-avatar-edit[hidden] { display: none; }

.profile-avatar-wrap.editable:hover .profile-avatar-edit {
    opacity: 1;
}

.profile-stats {
    display: flex;
    gap: 14px;
    margin-top: 6px;
    font-size: 0.9em;
    opacity: 0.8;
}

.profile-stat strong {
    font-weight: 600;
}

.profile-meta {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.profile-description {
    margin: 6px 0 0;
    font-size: 0.92em;
    opacity: 0.8;
    white-space: pre-wrap;
    word-wrap: break-word;
}

.profile-matches { padding: 0; }
.profile-matches[hidden] { display: none; }
.profile-posts[hidden] { display: none; }
.profile-section-title { margin: 0 0 10px; font-size: 1.1em; font-weight: 600; }
/* Profile matches grid - no extra outer padding (the feed area already
 * provides it). Cards stack flush like the lobby/wiki listings. */
.profile-matches-list { padding: 0; }
/* Inside a profile match card, the players row must not wrap mid-name -
 * truncate with ellipsis instead so the card height stays predictable. */
.profile-match-card .play-recent-players {
    flex-wrap: nowrap;
    min-width: 0;
    overflow: hidden;
}
.profile-match-card .play-recent-name {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1 1 auto;
}
.profile-match-card .play-recent-vs { flex-shrink: 0; }
.profile-match-card .play-recent-avatar { flex-shrink: 0; }
.profile-match-card .play-recent-meta { flex-shrink: 0; }

/* Twitter-style profile tabs: full-width row of equal buttons with an
 * underline on the active one. Sits flush below the profile header. */
.profile-tabs {
    display: flex;
    align-items: stretch;
    border-bottom: 1px solid rgba(0, 0, 0, 0.10);
    margin: 0;
    padding: 0;
}
body.dark-mode .profile-tabs { border-bottom-color: rgba(255, 255, 255, 0.10); }
.profile-tab {
    flex: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 14px 12px;
    border: none;
    background: transparent;
    color: inherit;
    font: inherit;
    font-size: 0.95rem;
    cursor: pointer;
    opacity: 0.6;
    border-bottom: 2px solid transparent;
    transition: background-color 0.12s ease, opacity 0.12s ease, border-color 0.12s ease;
    text-decoration: none;
}
.profile-tab:hover { background: rgba(0, 0, 0, 0.04); opacity: 0.9; }
body.dark-mode .profile-tab:hover { background: rgba(255, 255, 255, 0.05); }
.profile-tab-active {
    opacity: 1;
    font-weight: 700;
    border-bottom-color: currentColor;
}
.profile-tab-label { white-space: nowrap; }
.profile-tab-count {
    font-size: 0.78rem;
    opacity: 0.55;
    font-weight: 500;
    font-variant-numeric: tabular-nums;
}
.profile-tab-active .profile-tab-count { opacity: 0.75; }
/* Result chip on profile match cards: same pill as .play-public-chip but
 * coloured per outcome (win / loss / active / draw). */
.profile-match-result-chip {
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.profile-match-result-win {
    background: rgba(26, 127, 58, 0.15);
    color: #1a7f3a;
}
.profile-match-result-loss {
    background: rgba(185, 28, 28, 0.13);
    color: #b91c1c;
}
.profile-match-result-active {
    background: rgba(194, 65, 12, 0.13);
    color: #c2410c;
}
.profile-match-result-draw {
    background: rgba(0, 0, 0, 0.10);
    color: rgba(0, 0, 0, 0.65);
}
.profile-match-result-unrated {
    background: transparent;
    color: rgba(0, 0, 0, 0.4);
    border: 1px dashed rgba(0, 0, 0, 0.25);
}
body.dark-mode .profile-match-result-unrated {
    color: rgba(255, 255, 255, 0.45);
    border-color: rgba(255, 255, 255, 0.30);
}
body.dark-mode .profile-match-result-win {
    background: rgba(74, 222, 128, 0.15);
    color: #4ade80;
}
body.dark-mode .profile-match-result-loss {
    background: rgba(248, 113, 113, 0.15);
    color: #f87171;
}
body.dark-mode .profile-match-result-active {
    background: rgba(251, 146, 60, 0.15);
    color: #fb923c;
}
body.dark-mode .profile-match-result-draw {
    background: rgba(255, 255, 255, 0.10);
    color: rgba(255, 255, 255, 0.65);
}

.profile-name {
    margin: 0;
    font-size: 1.4em;
    font-weight: bold;
}

.profile-handle {
    font-size: 0.9em;
    opacity: 0.6;
}

.feed-item-edit-btn {
    margin-left: auto;
    background: none;
    border: none;
    color: inherit;
    opacity: 0.5;
    cursor: pointer;
    padding: 2px 6px;
    border-radius: 4px;
    transition: opacity 0.15s ease, background-color 0.15s ease;
}

.feed-item-edit-btn:hover {
    opacity: 1;
    background-color: rgba(0, 0, 0, 0.06);
}

body.dark-mode .feed-item-edit-btn:hover {
    background-color: rgba(255, 255, 255, 0.08);
}

.feed-item-edit-textarea {
    width: 100%;
    min-height: 80px;
    background: transparent;
    color: inherit;
    border: 1px solid rgba(0, 0, 0, 0.15);
    border-radius: 8px;
    padding: 8px 10px;
    font-family: inherit;
    font-size: 1em;
    resize: vertical;
    outline: none;
}

body.dark-mode .feed-item-edit-textarea {
    border-color: rgba(255, 255, 255, 0.18);
}

.feed-item-edit-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

.sidebar-auth {
    margin-top: 16px;
    padding: 0 16px;
    font-size: 0.9em;
    opacity: 0.85;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
}

.sidebar-auth-user {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
    max-width: 100%;
}

.sidebar-auth-avatar-link {
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    overflow: hidden;
    margin-left: -11px;
    border: 2px solid transparent;
    transition: border-color 0.15s ease;
}

.sidebar-auth-avatar-link:hover {
    border-color: #000;
    border: 2px solid #000;
    border-radius: 100%;
}

body.dark-mode .sidebar-auth-avatar-link:hover {
    border-color: #f5f5f5;
}

/* The .leftdiv a::after hover underline must not show under the
   avatar or username link in the auth block. */
.sidebar-auth-avatar-link::after,
.sidebar-auth-name::after {
    display: none;
}

.sidebar-auth-avatar {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    border-radius: 50%;
}

.sidebar-auth-name {
    font-weight: 600;
    color: inherit;
    text-decoration: none;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-left: -13px;
    white-space: nowrap;
}

.sidebar-auth-name:hover {
    text-decoration: underline;
}

.sidebar-auth-login {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: none;
    border: none;
    color: inherit;
    cursor: pointer;
    font: inherit;
    font-size: 1em;
    padding: 0;
    opacity: 0.75;
    transition: opacity 0.15s ease;
}

.sidebar-auth-login:hover {
    opacity: 1;
}

.auth-dialog {
    width: min(400px, 100%);
    padding: 28px 28px 24px;
    gap: 0;
}

.auth-close {
    position: absolute;
    top: 14px;
    right: 14px;
    background: none;
    border: none;
    color: inherit;
    opacity: 0.55;
    cursor: pointer;
    padding: 6px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.15s ease, background-color 0.15s ease;
}

.auth-close:hover {
    opacity: 1;
    background-color: rgba(0, 0, 0, 0.06);
}

body.dark-mode .auth-close:hover {
    background-color: rgba(255, 255, 255, 0.08);
}

.auth-hero {
    text-align: center;
    margin-bottom: 18px;
}

.auth-title {
    margin: 0 0 4px;
    font-size: 1.5em;
    font-weight: 600;
}

.auth-subtitle {
    margin: 0;
    opacity: 0.6;
    font-size: 0.92em;
}

.auth-tabs {
    position: relative;
    display: flex;
    background-color: rgba(0, 0, 0, 0.05);
    border-radius: 999px;
    padding: 4px;
    margin-bottom: 18px;
}

body.dark-mode .auth-tabs {
    background-color: rgba(255, 255, 255, 0.06);
}

.auth-tab {
    flex: 1;
    position: relative;
    z-index: 1;
    background: transparent;
    border: none;
    color: inherit;
    padding: 8px 12px;
    border-radius: 999px;
    cursor: pointer;
    font-family: inherit;
    font-size: 0.9em;
    opacity: 0.6;
    transition: opacity 0.2s ease;
}

.auth-tab.active {
    opacity: 1;
    font-weight: 600;
}

.auth-tab-indicator {
    position: absolute;
    top: 4px;
    bottom: 4px;
    left: 4px;
    width: calc(50% - 4px);
    background-color: #ffffff;
    border-radius: 999px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    transition: transform 0.25s ease;
    z-index: 0;
}

body.dark-mode .auth-tab-indicator {
    background-color: #3a3636;
}

.auth-modal[data-mode="register"] .auth-tab-indicator {
    transform: translateX(100%);
}

.auth-body {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.auth-avatar-uploader {
    position: relative;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border: 1px dashed rgba(0, 0, 0, 0.2);
    border-radius: 12px;
    cursor: pointer;
    transition: border-color 0.15s ease, background-color 0.15s ease;
}

.auth-avatar-uploader[hidden],
.auth-field[hidden] { display: none; }

.auth-avatar-uploader:hover {
    border-color: rgba(0, 0, 0, 0.4);
    background-color: rgba(0, 0, 0, 0.02);
}

body.dark-mode .auth-avatar-uploader {
    border-color: rgba(255, 255, 255, 0.2);
}

body.dark-mode .auth-avatar-uploader:hover {
    border-color: rgba(255, 255, 255, 0.4);
    background-color: rgba(255, 255, 255, 0.03);
}

.auth-avatar-preview {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background-color: rgba(0, 0, 0, 0.05);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    flex-shrink: 0;
    opacity: 0.7;
}

body.dark-mode .auth-avatar-preview {
    background-color: rgba(255, 255, 255, 0.06);
}

.auth-avatar-preview.has-image {
    opacity: 1;
}

.auth-avatar-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.auth-avatar-text {
    flex: 1;
    font-size: 0.92em;
    opacity: 0.75;
}

.auth-avatar-clear {
    background: none;
    border: none;
    color: inherit;
    opacity: 0.5;
    cursor: pointer;
    font-size: 1.2em;
    line-height: 1;
    padding: 4px 8px;
    border-radius: 50%;
    transition: opacity 0.15s ease, background-color 0.15s ease;
}

.auth-avatar-clear:hover {
    opacity: 1;
    background-color: rgba(0, 0, 0, 0.06);
}

body.dark-mode .auth-avatar-clear:hover {
    background-color: rgba(255, 255, 255, 0.08);
}

.auth-field {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.auth-label {
    font-size: 0.8em;
    opacity: 0.7;
    padding-left: 2px;
}

.auth-input {
    font-family: inherit;
    font-size: 0.95em;
    padding: 10px 12px;
    border: 1px solid rgba(0, 0, 0, 0.15);
    border-radius: 10px;
    background: transparent;
    color: inherit;
    outline: none;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.auth-input:focus {
    border-color: rgba(0, 0, 0, 0.5);
    box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.05);
}

body.dark-mode .auth-input {
    border-color: rgba(255, 255, 255, 0.18);
}

body.dark-mode .auth-input:focus {
    border-color: rgba(255, 255, 255, 0.5);
    box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.06);
}

.auth-error {
    margin: 0;
    color: #e74c3c;
    font-size: 0.88em;
    text-align: center;
}

.auth-submit {
    margin-top: 4px;
    background-color: #272424;
    color: #ffffff;
    border: none;
    border-radius: 999px;
    padding: 12px 20px;
    font-family: inherit;
    font-size: 0.95em;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.1s ease, opacity 0.15s ease;
}

.auth-submit:hover:not(:disabled) {
    opacity: 0.9;
}

.auth-submit:active:not(:disabled) {
    transform: translateY(1px);
}

.auth-submit:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

body.dark-mode .auth-submit {
    background-color: #ffffff;
    color: #272424;
}

.thread-header {
    padding: 8px 16px 0;
    margin-bottom: 4px;
}

.thread-back {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    color: inherit;
    text-decoration: none;
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    font: inherit;
    transition: background-color 0.15s ease;
}

.thread-back svg {
    display: block;
}

.thread-back:hover {
    background-color: rgba(0, 0, 0, 0.06);
}

body.dark-mode .thread-back:hover {
    background-color: rgba(255, 255, 255, 0.08);
}

.thread-post .feed-item {
    cursor: default;
}

.thread-comments-section {
    margin-top: 4px;
}

.thread-comments-list {
    display: flex;
    flex-direction: column;
    padding: 0 16px;
}

.thread-comments-empty {
    font-size: 0.9em;
    opacity: 0.6;
    padding: 16px 0;
    text-align: center;
}

.thread-comment-form {
    padding: 0 16px;
    border-top: 1px solid rgba(0, 0, 0, 0.08);
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
}

body.dark-mode .thread-comment-form {
    border-top-color: rgba(255, 255, 255, 0.08);
    border-bottom-color: rgba(255, 255, 255, 0.08);
}

.thread-comment-form .comment-composer {
    padding: 12px 0;
}

.thread-comments-list .feed-comment:first-child {
    border-top: none;
}

.thread-loading,
.thread-error {
    padding: 12px;
    opacity: 0.7;
    font-size: 0.95em;
}

.modal-feed-item {
    cursor: default;
    padding: 0;
    background: transparent !important;
}

.modal-feed-item:hover {
    background: transparent;
}

.comment-modal .modal-body {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding-top: 4px;
}

.comment-modal-post {
    padding-bottom: 4px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
}

body.dark-mode .comment-modal-post {
    border-bottom-color: rgba(255, 255, 255, 0.08);
}

.comment-composer {
    margin: 0;
    padding: 8px 0 0;
    background: transparent !important;
    backdrop-filter: none;
    border-bottom: none;
}

.modal[hidden] {
    display: none;
}

.modal {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal-backdrop {
    position: absolute;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.5);
}

.modal-dialog {
    position: relative;
    background-color: #ffffff;
    color: #000000;
    width: min(560px, 100%);
    max-height: calc(100vh - 40px);
    border-radius: 16px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

body.dark-mode .modal-dialog {
    background-color: #272424;
    color: #ffffff;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
}

body.dark-mode .modal-header {
    border-bottom-color: rgba(255, 255, 255, 0.1);
}

.modal-title {
    margin: 0;
    font-size: 1.1em;
}

.modal-close {
    background: none;
    border: none;
    cursor: pointer;
    color: inherit;
    padding: 6px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s ease;
}

.modal-close:hover {
    background-color: rgba(0, 0, 0, 0.06);
}

body.dark-mode .modal-close:hover {
    background-color: rgba(255, 255, 255, 0.08);
}

.modal-body {
    padding: 16px 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    overflow-y: auto;
}

.modal-lishogi-input {
    background-color: transparent;
    color: inherit;
    border: 1px solid rgba(0, 0, 0, 0.15);
    border-radius: 8px;
    font-family: 'Junge', serif;
    font-size: 0.95em;
    outline: none;
    padding: 10px 12px;
}

body.dark-mode .modal-lishogi-input {
    border-color: rgba(255, 255, 255, 0.15);
}

.modal-preview {
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 12px;
    min-height: 360px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

body.dark-mode .modal-preview {
    border-color: rgba(255, 255, 255, 0.1);
}

.modal-preview iframe {
    display: block;
    width: 100%;
    height: 420px;
    border: none;
}

.modal-preview-hint {
    margin: 0;
    padding: 24px;
    text-align: center;
    opacity: 0.65;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding: 12px 20px 16px;
    border-top: 1px solid rgba(0, 0, 0, 0.1);
}

body.dark-mode .modal-footer {
    border-top-color: rgba(255, 255, 255, 0.1);
}

.modal-cancel {
    background: none;
    border: 1px solid rgba(0, 0, 0, 0.15);
    color: inherit;
    border-radius: 20px;
    padding: 10px 20px;
    cursor: pointer;
    font-family: 'Junge', serif;
    font-size: 1em;
}

body.dark-mode .modal-cancel {
    border-color: rgba(255, 255, 255, 0.2);
}

.modal-confirm:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

@media (max-width: 900px) {
    .leftdiv {
        position: fixed;
        top: auto;
        bottom: 0;
        left: 0;
        right: 0;
        width: 100%;
        height: auto;
        flex-direction: row;
        justify-content: space-around;
        align-items: center;
        padding: 10px 10px calc(10px + env(safe-area-inset-bottom, 0px));
        gap: 6px;
        background-color: rgba(255, 255, 255, 0.95);
        backdrop-filter: blur(10px);
        border-top: 1px solid rgba(0, 0, 0, 0.1);
        z-index: 50;
        /* Bottom bar: must NOT inherit the desktop scroll container,
           otherwise backdrop-filter makes it clip the fixed submenu. */
        overflow: visible;
    }

    body.dark-mode .leftdiv {
        background-color: rgba(31, 29, 29, 0.95);
        border-top-color: rgba(255, 255, 255, 0.1);
    }

    .leftdiv > img,
    .leftdiv .sidebar-header {
        display: none;
    }

    .leftdiv .dropbutton {
        width: auto;
        flex: 0 0 auto;
        min-width: 0;
        position: relative;
    }

    .leftdiv .dropbutton-row {
        display: flex;
        align-items: center;
        justify-content: center;
        width: auto;
    }

    .leftdiv .dropbutton-arrow {
        display: none;
    }

    .leftdiv .dropbutton-link {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        padding: 0;
        width: 44px;
        height: 44px;
        border-radius: 50%;
        font-size: 0;
        flex: 0 0 auto;
        transition: background-color 0.15s ease;
    }

    .leftdiv .dropbutton-link::after {
        display: none;
    }

    .leftdiv .dropbutton-link:hover,
    .leftdiv .dropbutton-link:active,
    .leftdiv .dropbutton.expanded .dropbutton-link {
        background-color: rgba(0, 0, 0, 0.08);
    }

    body.dark-mode .leftdiv .dropbutton-link:hover,
    body.dark-mode .leftdiv .dropbutton-link:active,
    body.dark-mode .leftdiv .dropbutton.expanded .dropbutton-link {
        background-color: rgba(255, 255, 255, 0.1);
    }

    .leftdiv .dropbutton-link::before {
        content: "";
        display: block;
        width: 24px;
        height: 24px;
        background-color: currentColor;
        -webkit-mask-size: 24px 24px;
        mask-size: 24px 24px;
        -webkit-mask-repeat: no-repeat;
        mask-repeat: no-repeat;
        -webkit-mask-position: center;
        mask-position: center;
    }

    .leftdiv .dropbutton[data-key="boards"] .dropbutton-link::before {
        -webkit-mask-image: url("data:image/svg+xml;charset=UTF-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='black' d='M21 11.5a8.38 8.38 0 0 1-.9 3.8 8.5 8.5 0 0 1-7.6 4.7 8.38 8.38 0 0 1-3.8-.9L3 21l1.9-5.7a8.38 8.38 0 0 1-.9-3.8 8.5 8.5 0 0 1 4.7-7.6 8.38 8.38 0 0 1 3.8-.9h.5a8.48 8.48 0 0 1 8 8v.5z'/%3E%3C/svg%3E");
        mask-image: url("data:image/svg+xml;charset=UTF-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='black' d='M21 11.5a8.38 8.38 0 0 1-.9 3.8 8.5 8.5 0 0 1-7.6 4.7 8.38 8.38 0 0 1-3.8-.9L3 21l1.9-5.7a8.38 8.38 0 0 1-.9-3.8 8.5 8.5 0 0 1 4.7-7.6 8.38 8.38 0 0 1 3.8-.9h.5a8.48 8.48 0 0 1 8 8v.5z'/%3E%3C/svg%3E");
    }

    .leftdiv .dropbutton[data-key="studies"] .dropbutton-link::before {
        -webkit-mask-image: url("/images/study-pieces.svg");
        mask-image: url("/images/study-pieces.svg");
    }

    .leftdiv .dropbutton[data-key="play"] .dropbutton-link::before {
        -webkit-mask-image: url("data:image/svg+xml;charset=UTF-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='black' d='M8 5v14l11-7z'/%3E%3C/svg%3E");
        mask-image: url("data:image/svg+xml;charset=UTF-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='black' d='M8 5v14l11-7z'/%3E%3C/svg%3E");
    }

    .leftdiv .dropbutton[data-key="preferences"] .dropbutton-link::before {
        -webkit-mask-image: url("data:image/svg+xml;charset=UTF-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='black' fill-rule='evenodd' d='M19.14 12.94a7.07 7.07 0 0 0 0-1.88l2.03-1.58a.5.5 0 0 0 .12-.64l-1.92-3.32a.5.5 0 0 0-.61-.22l-2.39.96a7 7 0 0 0-1.62-.94l-.36-2.54a.5.5 0 0 0-.5-.42h-3.84a.5.5 0 0 0-.5.42l-.36 2.54a7 7 0 0 0-1.62.94l-2.39-.96a.5.5 0 0 0-.61.22L2.6 8.84a.5.5 0 0 0 .12.64l2.03 1.58a7.07 7.07 0 0 0 0 1.88L2.72 14.5a.5.5 0 0 0-.12.64l1.92 3.32a.5.5 0 0 0 .61.22l2.39-.96a7 7 0 0 0 1.62.94l.36 2.54a.5.5 0 0 0 .5.42h3.84a.5.5 0 0 0 .5-.42l.36-2.54a7 7 0 0 0 1.62-.94l2.39.96a.5.5 0 0 0 .61-.22l1.92-3.32a.5.5 0 0 0-.12-.64zM12 15.5A3.5 3.5 0 1 1 12 8.5a3.5 3.5 0 0 1 0 7z'/%3E%3C/svg%3E");
        mask-image: url("data:image/svg+xml;charset=UTF-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='black' fill-rule='evenodd' d='M19.14 12.94a7.07 7.07 0 0 0 0-1.88l2.03-1.58a.5.5 0 0 0 .12-.64l-1.92-3.32a.5.5 0 0 0-.61-.22l-2.39.96a7 7 0 0 0-1.62-.94l-.36-2.54a.5.5 0 0 0-.5-.42h-3.84a.5.5 0 0 0-.5.42l-.36 2.54a7 7 0 0 0-1.62.94l-2.39-.96a.5.5 0 0 0-.61.22L2.6 8.84a.5.5 0 0 0 .12.64l2.03 1.58a7.07 7.07 0 0 0 0 1.88L2.72 14.5a.5.5 0 0 0-.12.64l1.92 3.32a.5.5 0 0 0 .61.22l2.39-.96a7 7 0 0 0 1.62.94l.36 2.54a.5.5 0 0 0 .5.42h3.84a.5.5 0 0 0 .5-.42l.36-2.54a7 7 0 0 0 1.62-.94l2.39.96a.5.5 0 0 0 .61-.22l1.92-3.32a.5.5 0 0 0-.12-.64zM12 15.5A3.5 3.5 0 1 1 12 8.5a3.5 3.5 0 0 1 0 7z'/%3E%3C/svg%3E");
    }

    .leftdiv .dropbutton[data-key="support"] .dropbutton-link::before {
        -webkit-mask-image: url("data:image/svg+xml;charset=UTF-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='black' d='M16 11c1.66 0 3-1.34 3-3s-1.34-3-3-3-3 1.34-3 3 1.34 3 3 3zm-8 0c1.66 0 3-1.34 3-3S9.66 5 8 5 5 6.34 5 8s1.34 3 3 3zm0 2c-2.33 0-7 1.17-7 3.5V19h14v-2.5c0-2.33-4.67-3.5-7-3.5zm8 0c-.29 0-.62.02-.97.05 1.16.84 1.97 1.97 1.97 3.45V19h6v-2.5c0-2.33-4.67-3.5-7-3.5z'/%3E%3C/svg%3E");
        mask-image: url("data:image/svg+xml;charset=UTF-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='black' d='M16 11c1.66 0 3-1.34 3-3s-1.34-3-3-3-3 1.34-3 3 1.34 3 3 3zm-8 0c1.66 0 3-1.34 3-3S9.66 5 8 5 5 6.34 5 8s1.34 3 3 3zm0 2c-2.33 0-7 1.17-7 3.5V19h14v-2.5c0-2.33-4.67-3.5-7-3.5zm8 0c-.29 0-.62.02-.97.05 1.16.84 1.97 1.97 1.97 3.45V19h6v-2.5c0-2.33-4.67-3.5-7-3.5z'/%3E%3C/svg%3E");
    }

    .leftdiv .dropbutton[data-key="donate"] .dropbutton-link::before {
        -webkit-mask-image: url("data:image/svg+xml;charset=UTF-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='black' d='M12 21.35l-1.45-1.32C5.4 15.36 2 12.28 2 8.5 2 5.42 4.42 3 7.5 3c1.74 0 3.41.81 4.5 2.09C13.09 3.81 14.76 3 16.5 3 19.58 3 22 5.42 22 8.5c0 3.78-3.4 6.86-8.55 11.54L12 21.35z'/%3E%3C/svg%3E");
        mask-image: url("data:image/svg+xml;charset=UTF-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='black' d='M12 21.35l-1.45-1.32C5.4 15.36 2 12.28 2 8.5 2 5.42 4.42 3 7.5 3c1.74 0 3.41.81 4.5 2.09C13.09 3.81 14.76 3 16.5 3 19.58 3 22 5.42 22 8.5c0 3.78-3.4 6.86-8.55 11.54L12 21.35z'/%3E%3C/svg%3E");
    }

    .leftdiv .subitems {
        display: none;
        position: fixed;
        bottom: calc(74px + env(safe-area-inset-bottom, 0px));
        left: 12px;
        right: 12px;
        flex-direction: column;
        gap: 2px;
        padding: 8px;
        min-width: 0;
        max-width: none;
        max-height: none;
        overflow: visible;
        background-color: rgba(255, 255, 255, 0.98);
        color: #000;
        border: 1px solid rgba(0, 0, 0, 0.1);
        border-radius: 14px;
        box-shadow: 0 12px 32px rgba(0, 0, 0, 0.18);
        z-index: 60;
        animation: dropbuttonPopIn 0.15s ease;
    }

    body.dark-mode .leftdiv .subitems {
        background-color: rgba(46, 43, 43, 0.98);
        color: #fff;
        border-color: rgba(255, 255, 255, 0.12);
        box-shadow: 0 12px 32px rgba(0, 0, 0, 0.5);
    }

    .leftdiv .dropbutton.expanded .subitems {
        display: flex;
    }

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

    .leftdiv .subitems a {
        display: flex;
        align-items: center;
        gap: 12px;
        padding: 10px 14px;
        width: 100%;
        font-size: 0.95em;
        opacity: 1;
        border-radius: 8px;
        white-space: nowrap;
        text-align: left;
        transition: background-color 0.15s ease;
    }

    .leftdiv .subitems a::after {
        display: none;
    }

    .leftdiv .subitems a:hover,
    .leftdiv .subitems a:active {
        background-color: rgba(0, 0, 0, 0.06);
    }

    body.dark-mode .leftdiv .subitems a:hover,
    body.dark-mode .leftdiv .subitems a:active {
        background-color: rgba(255, 255, 255, 0.08);
    }

    .leftdiv .subitems a::before {
        content: "";
        flex: 0 0 auto;
        display: block;
        width: 22px;
        height: 22px;
        background-color: currentColor;
        -webkit-mask-size: 22px 22px;
        mask-size: 22px 22px;
        -webkit-mask-repeat: no-repeat;
        mask-repeat: no-repeat;
        -webkit-mask-position: center;
        mask-position: center;
    }

    .leftdiv .subitems a[href="/b/shogi"]::before {
        -webkit-mask-image: url("/images/board-shogi.svg");
        mask-image: url("/images/board-shogi.svg");
    }

    .leftdiv .subitems a[href="/b/anime"]::before {
        -webkit-mask-image: url("/images/board-anime.svg");
        mask-image: url("/images/board-anime.svg");
    }

    .leftdiv .subitems a[href="/b/tech"]::before {
        -webkit-mask-image: url("/images/board-tech.svg");
        mask-image: url("/images/board-tech.svg");
    }

    .leftdiv .subitems a[href="/b/venting"]::before {
        -webkit-mask-image: url("/images/board-venting.svg");
        mask-image: url("/images/board-venting.svg");
    }

    .leftdiv .subitems a[href="/b/life"]::before {
        -webkit-mask-image: url("/images/board-life.svg");
        mask-image: url("/images/board-life.svg");
    }

    .leftdiv .subitems a[href="/pieces"]::before {
        -webkit-mask-image: url("/images/study-pieces.svg");
        mask-image: url("/images/study-pieces.svg");
    }

    .leftdiv .subitems a[href="/castles"]::before {
        -webkit-mask-image: url("/images/study-castles.svg");
        mask-image: url("/images/study-castles.svg");
    }

    .leftdiv .subitems a[href="/openings"]::before {
        -webkit-mask-image: url("/images/study-openings.svg");
        mask-image: url("/images/study-openings.svg");
    }

    .sidebar-auth {
        display: none;
    }

    .sidebar-shortcuts {
        margin-top: 0;
        padding: 0;
        gap: 6px;
        flex: 0 0 auto;
    }

    .sidebar-shortcut {
        width: 44px;
        height: 44px;
    }

    /* .sidebar-auth is hidden on mobile, so the avatar shortcut is the
       only profile/login entry point here - bring it back. */
    .sidebar-shortcut-avatar {
        display: inline-flex;
    }

    .sidebar-shortcut svg {
        width: 22px;
        height: 22px;
    }

    .sidebar-shortcut-bookmarks {
        display: none !important;
    }

    .sidebar-shortcut-lang,
    .sidebar-shortcut-logout {
        display: none !important;
    }

    .content {
        margin-left: 0;
        width: 100%;
        max-width: 100%;
        min-height: calc(100vh - 72px);
        border-left: none;
        border-right: none;
        padding-bottom: calc(88px + env(safe-area-inset-bottom, 0px));
    }

    .feed-item iframe {
        width: 100%;
        margin-left: 0;
    }

    .attachment iframe,
    .modal-preview iframe {
        height: 320px;
    }

    .theme-toggle {
        top: auto;
        bottom: calc(88px + env(safe-area-inset-bottom, 0px));
    }

    .modal {
        padding: 12px;
    }

    .modal-dialog {
        max-height: calc(100vh - 80px);
    }
}

.piece-link,
.wiki-link {
    color: #2c2c2c;
    text-decoration: none;
    border-bottom: 1px dotted currentColor;
    cursor: pointer;
    transition: color 0.15s ease, border-bottom-color 0.15s ease;
}

.piece-link:hover,
.piece-link:focus,
.wiki-link:hover,
.wiki-link:focus {
    color: #000;
    border-bottom-style: dashed;
    outline: none;
}

body.dark-mode .piece-link,
body.dark-mode .wiki-link {
    color: #c8c8c8;
}

body.dark-mode .piece-link:hover,
body.dark-mode .piece-link:focus,
body.dark-mode .wiki-link:hover,
body.dark-mode .wiki-link:focus {
    color: #fff;
}

.piece-tooltip {
    position: absolute;
    z-index: 10000;
    max-width: 320px;
    min-width: 180px;
    padding: 10px 12px;
    background: #1f1d1d;
    color: #f4f4f4;
    border-radius: 8px;
    box-shadow: 0 4px 18px rgba(0, 0, 0, 0.25);
    font-size: 0.88em;
    line-height: 1.45;
    pointer-events: auto;
}

body.dark-mode .piece-tooltip {
    background: #f5f3f3;
    color: #1f1d1d;
    box-shadow: 0 4px 18px rgba(0, 0, 0, 0.45);
}

.piece-tooltip[hidden] {
    display: none;
}

.piece-tooltip-head {
    display: flex;
    flex-direction: column;
    margin-bottom: 6px;
}

.piece-tooltip-kanji {
    font-size: 1.1em;
    opacity: 0.85;
}

.piece-tooltip-title {
    font-weight: bold;
}

.piece-tooltip-move {
    margin-bottom: 4px;
}

.piece-tooltip-move-label {
    font-weight: bold;
    opacity: 0.85;
}

.piece-tooltip-desc {
    opacity: 0.95;
}

.piece-name-chip {
    display: inline-block;
}

.wiki-picker-menu {
    position: absolute;
    z-index: 10001;
    min-width: 260px;
    max-width: 320px;
    max-height: 280px;
    overflow-y: auto;
    background: #fff;
    color: #1f1d1d;
    border: 1px solid #d8d8d8;
    border-radius: 10px;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.18);
    padding: 4px;
    font-size: 0.92em;
}

.wiki-picker-menu[hidden] {
    display: none;
}

body.dark-mode .wiki-picker-menu {
    background: #1f1d1d;
    color: #f4f4f4;
    border-color: #3a3a3a;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.5);
}

.wiki-picker-empty {
    padding: 10px 12px;
    opacity: 0.6;
    font-style: italic;
}

.wiki-picker-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: 7px;
    cursor: pointer;
    transition: background-color 0.1s ease;
}

.wiki-picker-item:hover,
.wiki-picker-item.active {
    background: #f0f0f0;
}

body.dark-mode .wiki-picker-item:hover,
body.dark-mode .wiki-picker-item.active {
    background: #2e2c2c;
}

.wiki-picker-badge {
    flex: 0 0 auto;
    width: 28px;
    height: 28px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #ece9e3;
    color: #2c2c2c;
    border-radius: 6px;
    font-weight: bold;
    font-size: 0.95em;
    line-height: 1;
}

body.dark-mode .wiki-picker-badge {
    background: #36302a;
    color: #f0e8da;
}

.wiki-picker-badge-castles {
    background: #d8e4d6;
    color: #2c4429;
}

body.dark-mode .wiki-picker-badge-castles {
    background: #2f3f2c;
    color: #c2dabf;
}

.wiki-picker-badge-openings {
    background: #e0dcef;
    color: #382c5e;
}

body.dark-mode .wiki-picker-badge-openings {
    background: #322c4a;
    color: #c8c0e0;
}

.wiki-picker-main {
    display: flex;
    flex-direction: column;
    min-width: 0;
    flex: 1 1 auto;
}

.wiki-picker-title {
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.wiki-picker-slug {
    font-size: 0.78em;
    opacity: 0.6;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.wiki-article {
    padding: 24px 28px;
    max-width: 880px;
    margin: 0 auto;
    position: relative;
}

.wiki-toolbar-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 24px;
}

.wiki-back {
    color: inherit;
    text-decoration: none;
    opacity: 0.7;
    font-size: 0.92em;
}

.wiki-back:hover { opacity: 1; }

.wiki-kanji {
    text-align: center;
    font-size: 5em;
    line-height: 1.1;
    margin: 8px 0 4px 0;
    letter-spacing: 0.04em;
}

.wiki-title {
    text-align: center;
    margin: 0 0 14px 0;
    font-size: 2em;
    font-weight: bold;
    line-height: 1.2;
}

.wiki-movement {
    text-align: center;
    margin: 0 auto 24px auto;
    max-width: 640px;
    line-height: 1.55;
    opacity: 0.85;
}

.wiki-movement-label {
    font-weight: bold;
    opacity: 0.7;
    margin-right: 4px;
}

.wiki-divider {
    border: none;
    border-top: 1px solid rgba(0, 0, 0, 0.12);
    margin: 0 0 24px 0;
}

body.dark-mode .wiki-divider {
    border-top-color: rgba(255, 255, 255, 0.15);
}

.wiki-toolbar-actions {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.wiki-icon-btn {
    background: transparent;
    border: 1px solid rgba(0, 0, 0, 0.2);
    color: inherit;
    cursor: pointer;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.15s ease, border-color 0.15s ease;
}

.wiki-icon-btn svg {
    display: block;
}

body.dark-mode .wiki-icon-btn {
    border-color: rgba(255, 255, 255, 0.22);
}

.wiki-icon-btn:hover {
    background-color: rgba(0, 0, 0, 0.05);
    border-color: currentColor;
}

body.dark-mode .wiki-icon-btn:hover {
    background-color: rgba(255, 255, 255, 0.06);
}

.wiki-body-rendered {
    line-height: 1.65;
    font-size: 1em;
}

.wiki-body-rendered h1,
.wiki-body-rendered h2,
.wiki-body-rendered h3,
.wiki-body-rendered h4 {
    margin-top: 1.4em;
    margin-bottom: 0.5em;
    line-height: 1.25;
}

.wiki-body-rendered h2 {
    font-size: 1.45em;
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
    padding-bottom: 4px;
}

body.dark-mode .wiki-body-rendered h2 {
    border-bottom-color: rgba(255, 255, 255, 0.1);
}

.wiki-body-rendered h3 { font-size: 1.2em; }

.wiki-body-rendered p { margin: 0 0 1em 0; }

.wiki-body-rendered ul,
.wiki-body-rendered ol {
    margin: 0 0 1em 1.4em;
    padding: 0;
}

.wiki-body-rendered blockquote {
    margin: 1em 0;
    padding: 8px 14px;
    border-left: 3px solid rgba(0, 0, 0, 0.2);
    opacity: 0.85;
    font-style: italic;
}

body.dark-mode .wiki-body-rendered blockquote {
    border-left-color: rgba(255, 255, 255, 0.25);
}

.wiki-body-rendered .wiki-cite {
    font-size: 0.78em;
    line-height: 0;
    vertical-align: super;
    margin-left: 1px;
}

.wiki-body-rendered .wiki-cite a {
    color: #1a4ea8;
    text-decoration: none;
    padding: 0 1px;
}

.wiki-body-rendered .wiki-cite a:hover {
    text-decoration: underline;
}

body.dark-mode .wiki-body-rendered .wiki-cite a {
    color: #7aaaff;
}

.wiki-body-rendered .wiki-cite a:target,
.wiki-body-rendered .wiki-references li:target {
    background: rgba(255, 230, 120, 0.45);
    border-radius: 3px;
}

body.dark-mode .wiki-body-rendered .wiki-cite a:target,
body.dark-mode .wiki-body-rendered .wiki-references li:target {
    background: rgba(120, 100, 0, 0.55);
}

.wiki-body-rendered .wiki-references {
    margin-top: 2em;
    padding-top: 0.6em;
    border-top: 1px solid rgba(0, 0, 0, 0.1);
    font-size: 0.92em;
}

body.dark-mode .wiki-body-rendered .wiki-references {
    border-top-color: rgba(255, 255, 255, 0.12);
}

.wiki-body-rendered .wiki-references h2 {
    font-size: 1.1em;
    margin: 0 0 0.5em 0;
    border-bottom: none;
    padding-bottom: 0;
}

.wiki-body-rendered .wiki-references ol {
    margin: 0 0 0 1.6em;
    padding: 0;
}

.wiki-body-rendered .wiki-references li {
    margin: 0.25em 0;
    padding: 1px 4px;
}

.wiki-body-rendered .wiki-ref-back {
    color: inherit;
    text-decoration: none;
    opacity: 0.7;
    margin-right: 4px;
}

.wiki-body-rendered .wiki-ref-back:hover {
    text-decoration: underline;
    opacity: 1;
}

.wiki-body-rendered .wiki-ref-backs {
    font-size: 0.85em;
}

.wiki-body-rendered .wiki-ref-backs .wiki-ref-back {
    margin-right: 3px;
}

.wiki-body-rendered code {
    font-family: monospace;
    background: rgba(0, 0, 0, 0.06);
    padding: 1px 5px;
    border-radius: 3px;
    font-size: 0.92em;
}

body.dark-mode .wiki-body-rendered code {
    background: rgba(255, 255, 255, 0.08);
}

.wiki-body-rendered hr {
    border: none;
    border-top: 1px solid rgba(0, 0, 0, 0.12);
    margin: 1.5em 0;
}

body.dark-mode .wiki-body-rendered hr {
    border-top-color: rgba(255, 255, 255, 0.15);
}

.wiki-image {
    max-width: 100%;
    border-radius: 6px;
    vertical-align: middle;
}

.wiki-figure {
    margin: 1.2em 0;
    text-align: center;
}

.wiki-figure img {
    max-width: 100%;
    border-radius: 8px;
}

.wiki-figure figcaption {
    font-size: 0.88em;
    opacity: 0.7;
    margin-top: 6px;
}

.wiki-lishogi {
    margin: 1.2em 0;
}

.wiki-lishogi iframe {
    width: 100%;
    height: 480px;
    border: 0;
    border-radius: 8px;
    background: #000;
}

.wiki-empty {
    opacity: 0.55;
    font-style: italic;
}

.wiki-footer {
    margin-top: 28px;
    padding-top: 12px;
    border-top: 1px solid rgba(0, 0, 0, 0.1);
    font-size: 0.85em;
    opacity: 0.7;
    clear: both;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.wiki-footer > span[hidden] {
    display: none;
}

body.dark-mode .wiki-footer {
    border-top-color: rgba(255, 255, 255, 0.12);
}

/* Editor */

.wiki-editor {
    margin-top: 12px;
    border: 1px solid rgba(0, 0, 0, 0.15);
    border-radius: 10px;
    overflow: hidden;
    background: rgba(0, 0, 0, 0.015);
}

body.dark-mode .wiki-editor {
    border-color: rgba(255, 255, 255, 0.15);
    background: rgba(255, 255, 255, 0.025);
}

.wiki-editor-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    padding: 8px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
    background: rgba(0, 0, 0, 0.025);
}

body.dark-mode .wiki-editor-toolbar {
    border-bottom-color: rgba(255, 255, 255, 0.1);
    background: rgba(255, 255, 255, 0.03);
}

.wiki-tool-btn {
    background: transparent;
    border: 1px solid transparent;
    border-radius: 5px;
    padding: 5px 10px;
    cursor: pointer;
    color: inherit;
    font-family: inherit;
    font-size: 0.95em;
    line-height: 1;
    min-width: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.wiki-tool-btn:hover {
    background: rgba(0, 0, 0, 0.06);
    border-color: rgba(0, 0, 0, 0.15);
}

body.dark-mode .wiki-tool-btn:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.18);
}

.wiki-editor-textarea {
    width: 100%;
    border: 0;
    padding: 14px;
    resize: vertical;
    background: transparent;
    color: inherit;
    font-family: monospace;
    font-size: 0.95em;
    line-height: 1.5;
    outline: none;
    min-height: 420px;
}

.wiki-editor-title {
    width: 100%;
    border: 0;
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
    padding: 12px 14px;
    background: transparent;
    color: inherit;
    font-family: 'Junge', serif;
    font-size: 1.2em;
    font-weight: bold;
    outline: none;
}

body.dark-mode .wiki-editor-title {
    border-bottom-color: rgba(255, 255, 255, 0.1);
}

.wiki-editor-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    padding: 10px 12px;
    border-top: 1px solid rgba(0, 0, 0, 0.08);
}

body.dark-mode .wiki-editor-actions {
    border-top-color: rgba(255, 255, 255, 0.1);
}

.wiki-editor-status {
    margin-right: auto;
    font-size: 0.88em;
    opacity: 0.75;
}

@media (max-width: 720px) {
    .wiki-infobox {
        float: none;
        width: auto;
        margin: 0 0 18px 0;
    }
}

.pages-header {
    justify-content: space-between;
    gap: 12px;
}

.pages-empty {
    grid-column: 1 / -1;
    text-align: center;
    padding: 40px 20px;
    opacity: 0.6;
    font-size: 0.95em;
}

.page-form-field {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.page-form-label {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-weight: bold;
    font-size: 0.95em;
}

.page-form-hint {
    font-size: 0.82em;
    opacity: 0.65;
    line-height: 1.4;
}

.pieces-index {
    display: column;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
}

.pieces-index-card {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 14px 16px;
    border: 1px solid rgba(0, 0, 0, 0.12);
    text-decoration: none;
    color: inherit;
    transition: border-color 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
    background: transparent;
}

body.dark-mode .pieces-index-card {
    border-color: rgba(255, 255, 255, 0.15);
}

.pieces-index-card:hover {
    border-color: rgba(0, 0, 0, 0.4);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06);
}

body.dark-mode .pieces-index-card:hover {
    border-color: rgba(255, 255, 255, 0.5);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.pieces-index-kanji {
    font-size: 1.8em;
    line-height: 1;
    opacity: 0.9;
}

.pieces-index-label {
    font-weight: bold;
    font-size: 1em;
}

.pieces-index-kanji.promoted {
    color: #cc0000;
}

body.dark-mode .pieces-index-kanji.promoted,
body.dark-mode .wiki-kanji.promoted,
body.dark-mode .piece-tooltip-kanji.promoted {
    color: #ff5252;
}

.wiki-kanji.promoted,
.piece-tooltip-kanji.promoted {
    color: #cc0000;
}

.pieces-index-move {
    font-size: 0.85em;
    opacity: 0.7;
    line-height: 1.4;
}

.support-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.support-card {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 16px;
    border: 1px solid rgba(0, 0, 0, 0.12);
    text-decoration: none;
    color: inherit;
    background: transparent;
    transition: border-color 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
}

body.dark-mode .support-card {
    border-color: rgba(255, 255, 255, 0.15);
}

a.support-card:hover {
    border-color: rgba(0, 0, 0, 0.4);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06);
}

body.dark-mode a.support-card:hover {
    border-color: rgba(255, 255, 255, 0.5);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.support-card-icon {
    width: 56px;
    height: 56px;
    object-fit: contain;
    flex: 0 0 auto;
    border-radius: 6px;
}

.support-card-info {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.support-card-name {
    font-weight: bold;
    font-size: 1em;
}

.support-card-desc {
    font-size: 0.85em;
    opacity: 0.7;
    line-height: 1.4;
}

.support-card-link {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    color: inherit;
    opacity: 0.65;
    transition: opacity 0.15s ease, background-color 0.15s ease;
}

.support-card-link:hover {
    opacity: 1;
    background-color: rgba(0, 0, 0, 0.06);
}

body.dark-mode .support-card-link:hover {
    background-color: rgba(255, 255, 255, 0.08);
}

.settings-page {
    padding: 24px 28px 60px;
    max-width: 880px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 28px;
}

.settings-page-title {
    text-align: center;
    margin: 0;
    font-size: 2em;
    font-weight: bold;
    line-height: 1.2;
}

.settings-page-title::after {
    content: '';
    display: block;
    border-top: 1px solid rgba(0, 0, 0, 0.12);
    margin: 18px 0 0;
}

body.dark-mode .settings-page-title::after {
    border-top-color: rgba(255, 255, 255, 0.15);
}

.settings-section {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 0;
    border: none;
    border-radius: 0;
}

body.dark-mode .settings-section {
    border: none;
}

.settings-section + .settings-section {
    padding-top: 24px;
    border-top: 1px solid rgba(0, 0, 0, 0.08);
}

body.dark-mode .settings-section + .settings-section {
    border-top-color: rgba(255, 255, 255, 0.1);
}

.settings-section-title {
    margin: 0;
    font-size: 1.25em;
    font-weight: bold;
    letter-spacing: 0.01em;
}

.settings-section-hint {
    margin: 0;
    font-size: 0.92em;
    opacity: 0.75;
    line-height: 1.55;
    max-width: 640px;
}

.settings-section-status {
    margin: 4px 0 0;
    font-size: 0.85em;
    color: #b91c1c;
    line-height: 1.4;
}
.settings-section-status:empty { display: none; }
body.dark-mode .settings-section-status { color: #f87171; }

.settings-toggle {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    user-select: none;
    margin-top: 4px;
}

.settings-toggle input[type="checkbox"] {
    appearance: none;
    -webkit-appearance: none;
    width: 38px;
    height: 22px;
    border-radius: 999px;
    background-color: rgba(0, 0, 0, 0.15);
    position: relative;
    cursor: pointer;
    transition: background-color 0.2s ease;
    margin: 0;
}

.settings-toggle input[type="checkbox"]::after {
    content: "";
    position: absolute;
    top: 2px;
    left: 2px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background-color: #fff;
    transition: transform 0.2s ease;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.settings-toggle input[type="checkbox"]:checked {
    background-color: #2ecc71;
}

.settings-toggle input[type="checkbox"]:checked::after {
    transform: translateX(16px);
}

body.dark-mode .settings-toggle input[type="checkbox"] {
    background-color: rgba(255, 255, 255, 0.18);
}

body.dark-mode .settings-toggle input[type="checkbox"]:checked {
    background-color: #2ecc71;
}

.translation-modal .modal-dialog {
    max-width: 540px;
    width: 92%;
    display: flex;
    flex-direction: column;
    gap: 14px;
    padding: 22px 24px;
}

.translation-modal-title {
    margin: 0;
    font-size: 1.15em;
    font-weight: bold;
}

.translation-modal-field {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.translation-modal-field label {
    font-size: 0.82em;
    opacity: 0.75;
}

.translation-modal-field input,
.translation-modal-field select,
.translation-modal-field textarea {
    background-color: transparent;
    color: inherit;
    border: 1px solid rgba(0, 0, 0, 0.15);
    border-radius: 8px;
    padding: 8px 10px;
    font: inherit;
    outline: none;
    transition: border-color 0.15s ease;
}

.translation-modal-field textarea {
    min-height: 140px;
    resize: vertical;
    line-height: 1.45;
}

body.dark-mode .translation-modal-field input,
body.dark-mode .translation-modal-field select,
body.dark-mode .translation-modal-field textarea {
    border-color: rgba(255, 255, 255, 0.18);
}

.translation-modal-field input:focus,
.translation-modal-field select:focus,
.translation-modal-field textarea:focus {
    border-color: rgba(0, 0, 0, 0.4);
}

body.dark-mode .translation-modal-field input:focus,
body.dark-mode .translation-modal-field select:focus,
body.dark-mode .translation-modal-field textarea:focus {
    border-color: rgba(255, 255, 255, 0.5);
}

.translation-modal-status {
    font-size: 0.85em;
    opacity: 0.7;
    min-height: 1.2em;
}

.translation-modal-actions {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 10px;
}

.translation-modal-actions .translation-modal-delete {
    margin-right: auto;
    background: none;
    border: none;
    color: #e74c3c;
    cursor: pointer;
    font: inherit;
    padding: 6px 8px;
    border-radius: 6px;
}

.translation-modal-actions .translation-modal-delete:hover {
    background-color: rgba(231, 76, 60, 0.12);
}

.feed-action-translate {
    color: inherit;
}

.feed-item-translated-tag,
.wiki-translated-tag {
    display: inline-block;
    margin-left: 6px;
    padding: 1px 6px;
    border-radius: 999px;
    font-size: 0.7em;
    font-weight: normal;
    background-color: rgba(0, 0, 0, 0.08);
    opacity: 0.8;
    vertical-align: middle;
}

body.dark-mode .feed-item-translated-tag,
body.dark-mode .wiki-translated-tag {
    background-color: rgba(255, 255, 255, 0.12);
}

.sidebar-header {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
}

body.dark-mode .sidebar-header > img {
    filter: invert(1) hue-rotate(180deg);
}

.sidebar-theme-toggle {
    background: transparent;
    border: 1px solid rgba(0, 0, 0, 0.15);
    color: inherit;
    cursor: pointer;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    transition: background-color 0.15s ease, border-color 0.15s ease;
}

body.dark-mode .sidebar-theme-toggle {
    border-color: rgba(255, 255, 255, 0.2);
}

.sidebar-theme-toggle:hover {
    background-color: rgba(0, 0, 0, 0.05);
}

body.dark-mode .sidebar-theme-toggle:hover {
    background-color: rgba(255, 255, 255, 0.06);
}

.sidebar-theme-toggle svg {
    display: block;
}

/* --- Wiki editor role gating --- */
body .wiki-editor-only { display: none; }
body.is-wiki-editor .wiki-editor-only { display: inline-flex; }
body .wiki-submitter-only { display: none; }
body.is-logged-in:not(.is-wiki-editor) .wiki-submitter-only { display: inline-flex; }

.wiki-castle-modal {
    position: fixed; inset: 0;
    display: flex; align-items: center; justify-content: center;
    z-index: 50;
}
.wiki-castle-modal[hidden] { display: none; }
.wiki-castle-modal-backdrop {
    position: absolute; inset: 0;
    background: rgba(0,0,0,0.45);
    cursor: pointer;
}
.wiki-castle-modal-card {
    position: relative;
    background: #fff; color: #1d1f23;
    padding: 22px 24px 18px;
    border-radius: 12px;
    box-shadow: 0 12px 40px rgba(0,0,0,0.25);
    max-width: 460px;
    width: calc(100% - 40px);
    max-height: calc(100vh - 60px);
    overflow-y: auto;
}
body.dark-mode .wiki-castle-modal-card {
    background: #2c2e34; color: #f5f5f5;
}
.wiki-castle-modal-close {
    position: absolute;
    top: 6px; right: 10px;
    background: transparent; border: none;
    font-size: 1.5rem;
    color: inherit;
    cursor: pointer;
    opacity: 0.55;
    line-height: 1; padding: 4px 8px;
}
.wiki-castle-modal-close:hover { opacity: 1; }
.wiki-castle-editor-title { margin: 0 0 6px; font-size: 1.25em; font-weight: bold; }
.wiki-castle-editor-hint { margin: 0 0 16px; font-size: 0.92em; opacity: 0.75; line-height: 1.55; max-width: 640px; }
.wiki-castle-editor-board {
    display: grid;
    grid-template-columns: repeat(9, 1fr);
    grid-template-rows: repeat(9, 1fr);
    width: min(360px, 100%);
    aspect-ratio: 1 / 1;
    border: 1.5px solid #000;
    margin: 0 auto 14px;
    background: #fff;
}
body.dark-mode .wiki-castle-editor-board { border-color: #f5f5f5; background: #1f1d1d; }
.wiki-castle-editor-cell {
    border: 0.5px solid rgba(0, 0, 0, 0.5);
    display: flex; align-items: center; justify-content: center;
    cursor: pointer;
    user-select: none;
    transition: background-color 0.1s ease;
}
body.dark-mode .wiki-castle-editor-cell { border-color: rgba(245, 245, 245, 0.4); }
.wiki-castle-editor-cell:hover { background: rgba(46, 204, 113, 0.12); }
.wiki-castle-editor-piece {
    font-family: 'Noto', 'Junge', serif;
    font-size: clamp(0.8rem, 3vw, 1.4rem);
    font-weight: 700;
    line-height: 1;
}
.wiki-castle-editor-piece-promoted { color: #b91c1c; }
body.dark-mode .wiki-castle-editor-piece-promoted { color: #f87171; }
.wiki-castle-editor-palette {
    display: flex; flex-wrap: wrap; gap: 6px;
    margin-bottom: 14px;
    justify-content: center;
}
.wiki-castle-editor-palette-btn {
    width: 36px; height: 36px;
    padding: 0;
    border: 1px solid rgba(0, 0, 0, 0.3);
    background: #fff;
    color: #000;
    border-radius: 50%;
    cursor: pointer;
    font-family: 'Noto', 'Junge', serif;
    font-size: 1.05rem;
    font-weight: 700;
    line-height: 1;
    display: inline-flex; align-items: center; justify-content: center;
    transition: border-color 0.12s ease, background-color 0.12s ease;
}
.wiki-castle-editor-palette-btn:hover { border-color: #000; }
.wiki-castle-editor-palette-btn-active { border-color: #000; background: rgba(0, 0, 0, 0.06); }
body.dark-mode .wiki-castle-editor-palette-btn {
    background: #1f1d1d; color: #f5f5f5; border-color: rgba(255, 255, 255, 0.3);
}
body.dark-mode .wiki-castle-editor-palette-btn:hover { border-color: #f5f5f5; }
body.dark-mode .wiki-castle-editor-palette-btn-active { border-color: #f5f5f5; background: rgba(255, 255, 255, 0.08); }
.wiki-castle-editor-palette-eraser { font-size: 1.3rem; opacity: 0.7; }
.wiki-castle-editor-actions { display: flex; gap: 8px; align-items: center; justify-content: center; }
.wiki-castle-editor-btn {
    padding: 8px 16px;
    border: 1px solid rgba(0, 0, 0, 0.3);
    background: transparent;
    color: inherit;
    border-radius: 6px;
    cursor: pointer;
    font: inherit;
}
.wiki-castle-editor-btn:hover { border-color: #000; }
body.dark-mode .wiki-castle-editor-btn { border-color: rgba(255, 255, 255, 0.3); }
body.dark-mode .wiki-castle-editor-btn:hover { border-color: #f5f5f5; }
.wiki-castle-editor-btn-primary { background: #000; color: #fff; border-color: #000; }
.wiki-castle-editor-btn-primary:hover { background: rgba(0, 0, 0, 0.85); }
body.dark-mode .wiki-castle-editor-btn-primary { background: #f5f5f5; color: #000; border-color: #f5f5f5; }
body.dark-mode .wiki-castle-editor-btn-primary:hover { background: rgba(245, 245, 245, 0.85); }
.wiki-castle-editor-status { margin: 10px 0 0; font-size: 0.92em; opacity: 0.8; }
.wiki-castle-editor-status-error { color: #b91c1c; opacity: 1; }
body.dark-mode .wiki-castle-editor-status-error { color: #f87171; }
body .logged-in-only { display: none; }
body.is-logged-in .logged-in-only { display: inline-flex; }

/* --- Wiki draft (new page) --- */
body[data-page-draft] .wiki-article {
    padding: 24px 8px;
    max-width: 980px;
}
.wiki-draft.wiki-editor {
    border: 0;
    background: transparent;
    border-radius: 0;
    margin-top: 28px;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 18px;
    overflow: visible;
}
.wiki-draft .page-form-field { gap: 4px; }
.wiki-draft .page-form-label {
    font-weight: bold;
    font-size: 0.95em;
    font-family: 'Junge', serif;
    flex-direction: row;
    align-items: center;
    gap: 8px;
}
.wiki-draft .page-form-icon {
    flex-shrink: 0;
    opacity: 0.75;
}
.wiki-draft .modal-lishogi-input {
    width: 100%;
    box-sizing: border-box;
    padding: 14px 0;
    border: 0;
    border-bottom: 1px solid rgba(0, 0, 0, 0.15);
    border-radius: 0;
    background: transparent;
    color: inherit;
    font-family: 'Junge', serif;
    font-size: 1em;
    outline: none;
}
body.dark-mode .wiki-draft .modal-lishogi-input {
    border-bottom-color: rgba(255, 255, 255, 0.18);
}
.wiki-draft .modal-lishogi-input:focus {
    border-bottom-color: rgba(0, 0, 0, 0.4);
}
body.dark-mode .wiki-draft .modal-lishogi-input:focus {
    border-bottom-color: rgba(255, 255, 255, 0.5);
}
.wiki-draft .inline-md-editor {
    border-radius: 4px;
    margin-top: 0;
}
.wiki-draft .wiki-editor-textarea { min-height: 320px; }
.wiki-draft .wiki-editor-tags {
    border-top: 0;
    padding: 0;
    flex-wrap: wrap;
    align-items: center;
}
.wiki-draft .wiki-editor-actions {
    border-top: 0;
    padding: 0;
    margin-top: 4px;
}
.wiki-draft-login-prompt {
    margin-top: 16px;
    padding: 16px;
    border: 1px dashed rgba(0, 0, 0, 0.2);
    border-radius: 4px;
    text-align: center;
}
body.dark-mode .wiki-draft-login-prompt { border-color: rgba(255, 255, 255, 0.22); }

/* --- Wiki review queue --- */
.review-card-link {
    text-decoration: none;
}
.review-card-target {
    font-size: 0.82em;
    opacity: 0.6;
    font-family: monospace;
}
.review-card-resolution {
    font-size: 0.82em;
    opacity: 0.75;
    margin-top: 2px;
}
.review-card-resolution-approved { color: #1f8a4d; }
.review-card-resolution-rejected { color: #b53324; }
body.dark-mode .review-card-resolution-approved { color: #6ee7a4; }
body.dark-mode .review-card-resolution-rejected { color: #ff8a7e; }

.review-detail-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
    margin: 8px 0 16px;
    font-size: 0.9em;
    opacity: 0.85;
}
.review-detail-target {
    font-family: monospace;
    color: inherit;
}
.review-detail-submitter { margin-left: auto; opacity: 0.8; }
.review-detail-resolution {
    margin: 10px 0;
    font-size: 0.95em;
    padding: 8px 12px;
    border-radius: 6px;
}
.review-detail-resolution-approved {
    background-color: rgba(46, 204, 113, 0.12);
    color: #1f8a4d;
}
.review-detail-resolution-rejected {
    background-color: rgba(231, 76, 60, 0.12);
    color: #b53324;
}
body.dark-mode .review-detail-resolution-approved { color: #6ee7a4; }
body.dark-mode .review-detail-resolution-rejected { color: #ff8a7e; }
.review-detail-note {
    font-style: italic;
    opacity: 0.85;
    margin: -6px 0 14px;
    font-size: 0.9em;
}
.review-detail-current {
    margin-top: 36px;
    padding-top: 24px;
    border-top: 1px dashed rgba(0, 0, 0, 0.18);
}
body.dark-mode .review-detail-current { border-top-color: rgba(255, 255, 255, 0.22); }
.review-detail-current-title {
    font-size: 1.1em;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    opacity: 0.7;
    margin: 0 0 12px;
}
.review-detail-current-page-title { opacity: 0.85; }

.review-action-approve {
    color: #1f8a4d;
    border-color: #2ecc71;
}
.review-action-approve:hover {
    background-color: rgba(46, 204, 113, 0.18);
}
.review-action-reject {
    color: #b53324;
    border-color: #e74c3c;
}
.review-action-reject:hover {
    background-color: rgba(231, 76, 60, 0.18);
}
body.dark-mode .review-action-approve { color: #6ee7a4; }
body.dark-mode .review-action-reject { color: #ff8a7e; }

/* --- Wiki upvote button --- */
.wiki-upvote-btn {
    width: auto !important;
    padding: 0 12px !important;
    gap: 4px;
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    height: 36px;
    border-radius: 18px !important;
    transition: color 0.15s ease, border-color 0.15s ease, background-color 0.15s ease;
}

.wiki-upvote-btn:hover { color: #2ecc71; border-color: #2ecc71; }
.wiki-upvote-btn.active { color: #2ecc71; border-color: #2ecc71; }
.wiki-upvote-glyph {
    font-family: "Yu Mincho", "Hiragino Mincho ProN", "Noto Serif JP", serif;
    font-size: 16px;
    line-height: 1;
}
.wiki-upvote-count { font-size: 0.85em; line-height: 1; }

/* --- Wiki tag chips --- */
.wiki-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    justify-content: center;
    margin: 6px 0 14px;
}
.wiki-tags[hidden] { display: none; }

.wiki-tags .wiki-tag-chip {
    font-size: 0.92em;
    gap: 4px;
}

.wiki-tag-chip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 26px;
    height: 26px;
    border-radius: 999px;
    font-family: "Yu Mincho", "Hiragino Mincho ProN", "Noto Serif JP", serif;
    font-size: 0.85em;
    font-weight: normal;
    line-height: 1;
    color: inherit;
    border: 1px solid transparent;
    user-select: none;
}

.wiki-tag-beginner { color: #1f8a4d; }
.wiki-tag-advanced {  color: #b53324; }
.wiki-tag-variant  {  color: #7d3da3; }
.wiki-tag-yagura   {  color: #2c6fb5; }
.wiki-tag-mino     {  color: #c0883f; }
.wiki-tag-ibisha   {  color: #0f8a8a; }
.wiki-tag-furibisha {  color: #c0398a; }
body.dark-mode .wiki-tag-beginner { color: #6ee7a4; }
body.dark-mode .wiki-tag-advanced { color: #ff8a7e; }
body.dark-mode .wiki-tag-variant  { color: #d6a6ee; }
body.dark-mode .wiki-tag-yagura   { color: #8cb8ec; }
body.dark-mode .wiki-tag-mino     { color: #f0c98a; }
body.dark-mode .wiki-tag-ibisha    { color: #5fd0d0; }
body.dark-mode .wiki-tag-furibisha { color: #ef9fd0; }

.wiki-tag-toggle {
    cursor: pointer;
    background-color: transparent;
    border: 1px solid rgba(0, 0, 0, 0.2);
    color: inherit;
    font: inherit;
    opacity: 0.65;
    transition: opacity 0.15s ease, border-color 0.15s ease, background-color 0.15s ease;
}
body.dark-mode .wiki-tag-toggle { border-color: rgba(255, 255, 255, 0.22); }
.wiki-tag-toggle:hover { opacity: 1; }
.wiki-tag-toggle.active { opacity: 1; }
.wiki-tag-toggle.wiki-tag-beginner.active { background-color: rgba(46, 204, 113, 0.22); border-color: #2ecc71; }
.wiki-tag-toggle.wiki-tag-advanced.active { background-color: rgba(231, 76, 60, 0.22); border-color: #e74c3c; }
.wiki-tag-toggle.wiki-tag-variant.active  { background-color: rgba(155, 89, 182, 0.22); border-color: #9b59b6; }
.wiki-tag-toggle.wiki-tag-yagura.active   { background-color: rgba(52, 152, 219, 0.22); border-color: #3498db; }
.wiki-tag-toggle.wiki-tag-mino.active     { background-color: rgba(230, 169, 80, 0.22); border-color: #e6a950; }
.wiki-tag-toggle.wiki-tag-ibisha.active    { background-color: rgba(15, 138, 138, 0.22); border-color: #14b8a6; }
.wiki-tag-toggle.wiki-tag-furibisha.active { background-color: rgba(192, 57, 138, 0.22); border-color: #d6549e; }

.wiki-editor-tags {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    border-top: 1px solid rgba(0, 0, 0, 0.08);
}
body.dark-mode .wiki-editor-tags { border-top-color: rgba(255, 255, 255, 0.1); }
.wiki-editor-tags-label {
    font-size: 0.85em;
    opacity: 0.7;
    margin-right: 4px;
}

.wiki-editor-description {
    width: 100%;
    border: 0;
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
    padding: 8px 14px;
    background: transparent;
    color: inherit;
    font: inherit;
    font-size: 0.95em;
    line-height: 1.4;
    resize: vertical;
    outline: none;
    min-height: 48px;
    opacity: 0.9;
}
body.dark-mode .wiki-editor-description { border-bottom-color: rgba(255, 255, 255, 0.1); }

/* --- Translation menu (per-page lang viewer) --- */
.wiki-toolbar-actions { position: relative; }
.wiki-lang-menu {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    z-index: 60;
    min-width: 200px;
    background-color: #ffffff;
    color: #000;
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 10px;
    box-shadow: 0 8px 22px rgba(0, 0, 0, 0.15);
    padding: 4px;
    display: flex;
    flex-direction: column;
}
body.dark-mode .wiki-lang-menu {
    background-color: #2e2b2b;
    color: #fff;
    border-color: rgba(255, 255, 255, 0.12);
}
.wiki-lang-menu-item {
    background: transparent;
    border: none;
    color: inherit;
    text-align: left;
    padding: 8px 10px;
    border-radius: 6px;
    font: inherit;
    cursor: pointer;
}
.wiki-lang-menu-item:hover { background-color: rgba(0, 0, 0, 0.06); }
body.dark-mode .wiki-lang-menu-item:hover { background-color: rgba(255, 255, 255, 0.08); }
.wiki-lang-menu-item.active { font-weight: 600; background-color: rgba(0, 0, 0, 0.04); }
body.dark-mode .wiki-lang-menu-item.active { background-color: rgba(255, 255, 255, 0.06); }
.wiki-lang-menu-empty {
    padding: 8px 10px;
    font-size: 0.85em;
    opacity: 0.65;
}
.wiki-lang-menu-sep {
    height: 1px;
    background-color: rgba(0, 0, 0, 0.08);
    margin: 4px 2px;
}
body.dark-mode .wiki-lang-menu-sep { background-color: rgba(255, 255, 255, 0.1); }

/* --- Pieces / pages popular section --- */
.pieces-section-title {
    margin: 18px 16px 8px;
    font-size: 0.95em;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    opacity: 0.6;
}
.pieces-index-popular {
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}
body.dark-mode .pieces-index-popular { border-bottom-color: rgba(255, 255, 255, 0.08); }

.pieces-index-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 2px;
}
.pieces-index-label {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
    width: 100%;
}
.pieces-index-name {
    font-weight: bold;
    flex: 1 1 auto;
    min-width: 0;
}
.pieces-index-chips {
    margin-left: auto;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
}
.pieces-index-bottom {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    width: 100%;
}
.pieces-index-bottom .pieces-index-move {
    flex: 1 1 auto;
    min-width: 0;
}
.pieces-index-upvotes {
    margin-left: auto;
    flex-shrink: 0;
    font-size: 0.85em;
    opacity: 0.7;
    font-family: "Yu Mincho", "Hiragino Mincho ProN", "Noto Serif JP", serif;
    white-space: nowrap;
}
.pieces-index-creator {
    width: 100%;
    margin-top: 6px;
    font-size: 0.8em;
    opacity: 0.6;
    font-style: italic;
}

/* --- Wiki listing filter bar --- */
.wiki-filter {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
}
body.dark-mode .wiki-filter { border-bottom-color: rgba(255, 255, 255, 0.08); }

.wiki-filter-search {
    flex: 1 1 200px;
    min-width: 0;
    background-color: transparent;
    color: inherit;
    border: 1px solid rgba(0, 0, 0, 0.15);
    border-radius: 999px;
    padding: 8px 14px;
    font: inherit;
    font-size: 0.95em;
    outline: none;
    transition: border-color 0.15s ease;
}
body.dark-mode .wiki-filter-search { border-color: rgba(255, 255, 255, 0.18); }
.wiki-filter-search:focus { border-color: rgba(0, 0, 0, 0.4); }
body.dark-mode .wiki-filter-search:focus { border-color: rgba(255, 255, 255, 0.5); }

.wiki-filter-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.wiki-filter-select {
    flex: 0 0 auto;
    background-color: transparent;
    color: inherit;
    border: 1px solid rgba(0, 0, 0, 0.15);
    border-radius: 999px;
    padding: 8px 32px 8px 14px;
    font: inherit;
    font-size: 0.95em;
    cursor: pointer;
    outline: none;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23666' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    background-size: 14px;
    transition: border-color 0.15s ease;
}
body.dark-mode .wiki-filter-select {
    border-color: rgba(255, 255, 255, 0.18);
    background-image: url("data:image/svg+xml;charset=UTF-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23bbb' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
}
.wiki-filter-select:focus { border-color: rgba(0, 0, 0, 0.4); }
body.dark-mode .wiki-filter-select:focus { border-color: rgba(255, 255, 255, 0.5); }
.wiki-filter-select option { background-color: #ffffff; color: #000; }
body.dark-mode .wiki-filter-select option { background-color: #2e2b2b; color: #fff; }

.pages-create-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    padding: 0;
    background: transparent;
    border: 1px solid rgba(0, 0, 0, 0.2);
    color: inherit;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.15s ease, border-color 0.15s ease;
}
body.dark-mode .pages-create-btn { border-color: rgba(255, 255, 255, 0.22); }
.pages-create-btn:hover {
    background-color: rgba(0, 0, 0, 0.05);
    border-color: currentColor;
}
body.dark-mode .pages-create-btn:hover { background-color: rgba(255, 255, 255, 0.06); }
.pages-create-btn svg { display: block; }

.feed-loading-more {
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: rgba(0, 0, 0, 0.4);
}
body.dark-mode .feed-loading-more { color: rgba(255, 255, 255, 0.4); }
.feed-loading-more.is-loading::after {
    content: '';
    width: 18px;
    height: 18px;
    border: 2px solid currentColor;
    border-top-color: transparent;
    border-radius: 50%;
    animation: kletka-spin 0.8s linear infinite;
}
@keyframes kletka-spin { to { transform: rotate(360deg); } }

.wiki-title-kanji {
    font-size: 0.85em;
    font-weight: 500;
    color: rgba(0, 0, 0, 0.6);
    margin-left: 4px;
}
body.dark-mode .wiki-title-kanji { color: rgba(255, 255, 255, 0.6); }
.wiki-aliases { display: none; }

/* Toasts */
.toast-container {
    position: fixed;
    left: 50%;
    bottom: 24px;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column-reverse;
    gap: 8px;
    z-index: 9999;
    pointer-events: none;
    width: max-content;
    max-width: calc(100vw - 32px);
}
.toast {
    pointer-events: auto;
    background: rgba(28, 30, 36, 0.96);
    color: #f5f5f5;
    padding: 10px 16px;
    border-radius: 10px;
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.28);
    font-size: 0.92rem;
    line-height: 1.35;
    max-width: 360px;
    cursor: pointer;
    opacity: 0;
    transform: translateY(8px);
    transition: opacity 0.18s ease, transform 0.18s ease;
}
body.dark-mode .toast {
    background: rgba(245, 245, 245, 0.95);
    color: #1d1f23;
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.5);
}
.toast.toast-in { opacity: 1; transform: translateY(0); }
.toast.toast-out { opacity: 0; transform: translateY(-4px); }
.toast-title {
    font-weight: 600;
    margin-bottom: 4px;
    font-size: 0.95rem;
}
.toast-body { font-size: 0.9rem; }
.toast-success { background: #166534; color: #fff; }
.toast-error { background: #991b1b; color: #fff; }
body.dark-mode .toast-success { background: #22c55e; color: #052e16; }
body.dark-mode .toast-error { background: #f87171; color: #4c0519; }

/* ---- Play (Shogi matches) ---- */
.page-title-tag { font-weight: 400; opacity: 0.55; font-size: 0.7em; margin-left: 6px; }
.pages-header-actions { display: inline-flex; align-items: center; gap: 6px; }
.play-lead {
    margin: 12px 16px 14px;
    opacity: 0.7;
    font-size: 0.92rem;
    line-height: 1.45;
    max-width: 640px;
}

.play-modal-dialog { width: min(420px, 100%); }
.play-modal-dialog .modal-body { gap: 14px; }
.play-modal-title {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}
.play-modal-title-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.06);
    color: inherit;
    flex-shrink: 0;
}
body.dark-mode .play-modal-title-icon { background: rgba(255, 255, 255, 0.08); }
.play-modal-hint {
    margin: 0;
    font-size: 0.9rem;
    opacity: 0.75;
    line-height: 1.4;
    display: flex;
    align-items: flex-start;
    gap: 8px;
}
.play-modal-hint-icon { flex-shrink: 0; margin-top: 2px; }
.play-modal-search {
    position: relative;
    display: flex;
    align-items: center;
}
.play-modal-search-icon {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    pointer-events: none;
    opacity: 0.55;
}
.play-modal-search > .play-modal-input.wiki-filter-search { padding-left: 32px; }
.play-modal-input.wiki-filter-search {
    width: 100%;
    box-sizing: border-box;
    padding: 6px 12px;
    font-size: 0.88rem;
    border-radius: 6px;
    flex: none;
}

.play-icon-btn {
    display: inline-flex; align-items: center; justify-content: center;
    width: 36px; height: 36px;
    padding: 0;
    border: none;
    background: transparent;
    color: inherit;
    border-radius: 50%;
    cursor: pointer;
    opacity: 0.7;
    text-decoration: none;
    flex-shrink: 0;
    transition: opacity 0.12s ease, background-color 0.12s ease;
}
.play-icon-btn:hover { background: rgba(0,0,0,0.07); opacity: 1; }
body.dark-mode .play-icon-btn:hover { background: rgba(255,255,255,0.08); }
.play-icon-btn[hidden] { display: none; }
.play-icon-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.play-icon-btn-busy svg { animation: play-icon-spin 1.2s linear infinite; }
@keyframes play-icon-spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }

.play-share {
    display: flex; align-items: center; gap: 4px;
    padding: 6px 8px 6px 12px;
    border: 1px solid rgba(0, 0, 0, 0.12);
    border-radius: 6px;
}
body.dark-mode .play-share { border-color: rgba(255, 255, 255, 0.15); }
.play-share[hidden] { display: none; }
.play-share-icon { flex-shrink: 0; opacity: 0.55; }
.play-share-input {
    flex: 1; min-width: 0;
    padding: 6px 4px;
    border: none;
    background: transparent;
    color: inherit;
    font-size: 0.92rem;
    outline: none;
}

.play-invite-form { position: relative; }
.play-invite-form > .wiki-filter-search { width: 100%; box-sizing: border-box; }
.play-invite-results {
    list-style: none; margin: 8px 0 0; padding: 0;
    max-height: 280px; overflow-y: auto;
    border: 1px solid rgba(0, 0, 0, 0.12);
}
body.dark-mode .play-invite-results { border-color: rgba(255, 255, 255, 0.15); }
.play-invite-results[hidden] { display: none; }
.play-invite-result {
    display: flex; align-items: center; gap: 10px;
    padding: 8px 12px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}
body.dark-mode .play-invite-result { border-bottom-color: rgba(255, 255, 255, 0.08); }
.play-invite-result:last-child { border-bottom: none; }
.play-invite-avatar { width: 28px; height: 28px; border-radius: 50%; flex-shrink: 0; }
.play-invite-name { flex: 1; font-size: 0.95rem; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.play-invite-btn {
    width: 32px; height: 32px;
    border: none; background: transparent; color: inherit;
    border-radius: 50%; cursor: pointer; opacity: 0.65;
    display: inline-flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}
.play-invite-btn:hover { opacity: 1; background: rgba(0,0,0,0.06); }
body.dark-mode .play-invite-btn:hover { background: rgba(255,255,255,0.08); }
.play-invite-empty { padding: 10px 12px; opacity: 0.6; font-size: 0.92rem; }

.play-recent-card { gap: 10px; }
.play-recent-players {
    display: flex; align-items: center; gap: 8px;
    flex-wrap: wrap;
    width: 100%;
}
.play-recent-avatar { width: 24px; height: 24px; border-radius: 50%; flex-shrink: 0; }
.play-recent-name {
    font-weight: 600; font-size: 0.95rem;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    min-width: 0;
}
.play-recent-vs { font-size: 0.85rem; opacity: 0.5; }
.play-recent-meta { display: flex; align-items: center; gap: 8px; }
.play-recent-chip {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    opacity: 0.7;
}
.play-recent-chip-active { color: #166534; opacity: 1; }
body.dark-mode .play-recent-chip-active { color: #4ade80; }
.play-recent-chip-finished { opacity: 0.55; }
.play-recent-chip-waiting { opacity: 0.55; font-style: italic; text-transform: none; letter-spacing: 0; }

/* Match room */
.content-play {
    padding-bottom: 30px;
    display: flex;
    flex-direction: column;
}
.content-play .play-history-section { margin-top: auto; }
.play-room-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.play-room-actions { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.play-spectators {
    display: inline-flex; align-items: center; gap: 4px;
    font-size: 0.85rem;
    opacity: 0.7;
}
.play-spectators[hidden] { display: none; }
.play-status { font-size: 0.95rem; opacity: 0.85; }

.play-room {
    display: grid;
    grid-template-rows: auto 1fr auto;
    gap: 10px;
    align-items: center;
    justify-items: center;
    margin-top: 12px;
}
.play-side { width: 100%; max-width: 540px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.play-player {
    display: flex; align-items: center; gap: 10px;
    padding: 0;
    background: transparent;
    border: none;
    border-radius: 0;
    position: relative;
}
.play-speech-bubble {
    position: absolute;
    left: 0;
    background: #fff;
    color: #000;
    border: 1px solid #000;
    border-radius: 14px;
    padding: 6px 12px;
    font-family: 'Noto', 'Junge', serif;
    font-size: 0.95rem;
    line-height: 1.2;
    max-width: 260px;
    word-break: break-word;
    z-index: 5;
    pointer-events: none;
    opacity: 0;
    transform: translateY(4px);
    transition: opacity 0.25s ease, transform 0.25s ease;
}
.play-speech-bubble.play-speech-show {
    opacity: 1;
    transform: translateY(0);
}
.play-side-top .play-speech-bubble { top: calc(100% + 10px); }
.play-side-bottom .play-speech-bubble { bottom: calc(100% + 10px); }
.play-speech-bubble::after {
    content: '';
    position: absolute;
    width: 10px;
    height: 10px;
    background: #fff;
    transform: rotate(45deg);
    left: 16px;
}
.play-side-top .play-speech-bubble::after {
    top: -6px;
    border-top: 1px solid #000;
    border-left: 1px solid #000;
}
.play-side-bottom .play-speech-bubble::after {
    bottom: -6px;
    border-bottom: 1px solid #000;
    border-right: 1px solid #000;
}
body.dark-mode .play-speech-bubble {
    background: #1f1d1d;
    color: #f5f5f5;
    border-color: #f5f5f5;
}
body.dark-mode .play-speech-bubble::after {
    background: #1f1d1d;
    border-color: #f5f5f5;
}
.play-player-avatar {
    width: 36px; height: 36px;
    border-radius: 50%;
    object-fit: cover;
    background: rgba(0,0,0,0.06);
    flex-shrink: 0;
}
body.dark-mode .play-player-avatar { background: rgba(255,255,255,0.08); }
.play-player-active .play-player-avatar {
    box-shadow: 0 0 0 2px #000;
}
body.dark-mode .play-player-active .play-player-avatar {
    box-shadow: 0 0 0 2px #f5f5f5;
}
.play-player-empty .play-player-avatar { opacity: 0.45; }
.play-player-info { display: flex; flex-direction: column; line-height: 1.2; }
.play-player-name { font-weight: 600; font-size: 0.95rem; }
.play-player-role { font-size: 0.78rem; opacity: 0.6; }
.play-player-clock {
    font-family: 'Junge', monospace, serif;
    font-variant-numeric: tabular-nums;
    font-size: 0.95rem;
    font-weight: 600;
    margin-top: 2px;
    opacity: 0.7;
}
.play-player-clock-running { opacity: 1; }
.play-player-clock-low { color: #b91c1c; }
body.dark-mode .play-player-clock-low { color: #f87171; }
.play-player-clock[hidden] { display: none; }

.play-time-control {
    position: relative;
    display: block;
    margin: 4px 0 12px;
    font-size: 0.92rem;
    width: 100%;
}
.play-time-control-label {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    pointer-events: none;
    opacity: 0.65;
    display: inline-flex;
    align-items: center;
}
.play-time-control-select {
    width: 100%;
    box-sizing: border-box;
    padding: 9px 32px 9px 36px; /* room for the leading icon and the native chevron */
    border: 1px solid rgba(0, 0, 0, 0.3);
    background: transparent;
    color: inherit;
    border-radius: 6px;
    font: inherit;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    /* Hand-drawn chevron via inline SVG so it inherits the text color. */
    background-image: url("data:image/svg+xml;charset=UTF-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    background-size: 14px 14px;
}
body.dark-mode .play-time-control-select { border-color: rgba(255, 255, 255, 0.3); }

.play-modal-primary {
    margin-top: 8px;
    padding: 9px 16px;
    border: 1px solid #000;
    background: #000;
    color: #fff;
    border-radius: 6px;
    font: inherit;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}
.play-modal-primary:hover { background: rgba(0, 0, 0, 0.85); }
.play-modal-primary:disabled { opacity: 0.5; cursor: wait; }
body.dark-mode .play-modal-primary { background: #f5f5f5; color: #000; border-color: #f5f5f5; }
body.dark-mode .play-modal-primary:hover { background: rgba(245, 245, 245, 0.85); }
/* Icon-only variant: pill that's just the play glyph. */
.play-modal-primary-icon {
    width: 100%;
    padding: 12px;
    gap: 0;
}
.play-modal-primary-icon svg { display: block; }

.play-modal-actions {
    display: flex;
    gap: 8px;
    margin-top: 8px;
    flex-wrap: wrap;
}
.play-modal-actions > .play-modal-primary,
.play-modal-actions > .play-modal-secondary {
    margin-top: 0;
    flex: 1;
    min-width: 0;
}
.play-modal-secondary {
    padding: 9px 16px;
    border: 1px solid rgba(0, 0, 0, 0.3);
    background: transparent;
    color: inherit;
    border-radius: 6px;
    font: inherit;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}
.play-modal-secondary:hover { background: rgba(0, 0, 0, 0.05); }
.play-modal-secondary:disabled { opacity: 0.5; cursor: wait; }
body.dark-mode .play-modal-secondary { border-color: rgba(255, 255, 255, 0.3); }
body.dark-mode .play-modal-secondary:hover { background: rgba(255, 255, 255, 0.06); }

/* Lobby cards (public matches/simul/tournament) lay out horizontally:
 * player/host info on the left, meta chips (TC, count, Join) pushed to
 * the right edge so the action chip is always reachable. */
.play-public-card {
    flex-direction: row;
    align-items: center;
    gap: 14px;
}
.play-public-card .play-recent-players {
    flex: 1;
    min-width: 0;
    width: auto;
}
.play-public-card .play-recent-meta {
    margin-left: auto;
    flex-shrink: 0;
}
.play-public-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    border-radius: 999px;
    font-size: 0.78rem;
    background: rgba(0, 0, 0, 0.06);
}
body.dark-mode .play-public-chip { background: rgba(255, 255, 255, 0.08); }
.play-public-chip-join {
    background: #000;
    color: #fff;
    font-weight: 600;
}
body.dark-mode .play-public-chip-join { background: #f5f5f5; color: #000; }
/* Icon-only chip variant: tighter padding, square aspect. */
.play-public-chip-icon {
    padding: 6px 10px;
    gap: 0;
}
.play-public-chip-icon svg { display: block; }

.play-hand {
    display: flex; flex-wrap: wrap; gap: 10px;
    min-height: 46px;
    padding: 4px 0;
}
.play-hand-piece {
    position: relative;
    display: inline-flex; align-items: center; justify-content: center;
    width: 42px; height: 42px;
    padding: 0;
    border: 1px solid #000;
    border-radius: 50%;
    background: #fff;
    color: #000;
    font: inherit;
    cursor: pointer;
    flex-shrink: 0;
    transition: background-color 0.12s ease, color 0.12s ease, transform 0.12s ease;
}
.play-hand-piece:hover { transform: translateY(-1px); }
body.dark-mode .play-hand-piece {
    background: #1a1a1a; color: #f5f5f5; border-color: #f5f5f5;
}
.play-hand-piece.play-hand-selected {
    background: #000; color: #fff;
}
body.dark-mode .play-hand-piece.play-hand-selected {
    background: #f5f5f5; color: #1a1a1a;
}
.play-hand-glyph {
    font-family: 'Noto', 'Junge', serif;
    font-size: 1.25rem;
    font-weight: 700;
    line-height: 1;
}
.play-hand-count {
    position: absolute;
    bottom: -2px;
    right: -2px;
    min-width: 18px; height: 18px;
    padding: 0 4px;
    display: inline-flex; align-items: center; justify-content: center;
    border-radius: 50%;
    background: #000;
    color: #fff;
    font-size: 0.7rem;
    font-weight: 700;
    line-height: 1;
    box-shadow: 0 0 0 2px #fff;
    pointer-events: none;
}
body.dark-mode .play-hand-count {
    background: #f5f5f5; color: #1a1a1a;
    box-shadow: 0 0 0 2px #1a1a1a;
}
.play-hand-piece.play-hand-selected .play-hand-count {
    background: #fff; color: #000;
    box-shadow: 0 0 0 2px #000;
}
body.dark-mode .play-hand-piece.play-hand-selected .play-hand-count {
    background: #1a1a1a; color: #f5f5f5;
    box-shadow: 0 0 0 2px #f5f5f5;
}
.play-hand-empty { font-size: 0.78rem; opacity: 0.5; }

.play-board-wrap { position: relative; width: 100%; max-width: 540px; }
/* Right-click board annotations (arrows + square highlights). The SVG
   overlay sits above the pieces but never intercepts clicks. */
.play-annot-overlay {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 4;
    overflow: visible;
}
.play-annot-square { fill: rgba(255, 152, 0, 0.45); }
.play-annot-arrow-line {
    stroke: rgba(255, 138, 0, 0.5);
    stroke-width: 0.22;
    stroke-linecap: round;
}
.play-annot-arrow-head { fill: rgba(255, 138, 0, 0.5); }
.play-board {
    display: grid;
    grid-template-columns: repeat(9, 1fr);
    grid-template-rows: repeat(9, 1fr);
    aspect-ratio: 1 / 1;
    width: 100%;
    background: transparent;
    border: 2px solid #000;
    box-shadow: none;
}
body.dark-mode .play-board {
    background: transparent;
    border-color: #f5f5f5;
}
.play-cell {
    border: 1px solid #000;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer;
    position: relative;
    user-select: none;
}
body.dark-mode .play-cell { border-color: #f5f5f5; }
.play-cell-selected { background: rgba(0,0,0,0.10); }
body.dark-mode .play-cell-selected { background: rgba(255,255,255,0.14); }
.play-cell-legal::after {
    content: ''; position: absolute;
    width: 28%; height: 28%;
    border-radius: 50%;
    background: rgba(0,0,0,0.30);
}
body.dark-mode .play-cell-legal::after { background: rgba(255,255,255,0.40); }
.play-cell-check { background: rgba(178, 34, 34, 0.18); }
body.dark-mode .play-cell-check { background: rgba(255, 80, 80, 0.25); }
.play-cell-last-from { background: rgba(255, 196, 0, 0.18); }
.play-cell-last-to { background: rgba(255, 165, 0, 0.32); }
body.dark-mode .play-cell-last-from { background: rgba(255, 196, 0, 0.16); }
body.dark-mode .play-cell-last-to { background: rgba(255, 165, 0, 0.28); }
.play-cell-castle { background: rgba(46, 204, 113, 0.22); }
.play-cell-castle.play-cell-last-to { background: rgba(46, 204, 113, 0.42); }
body.dark-mode .play-cell-castle { background: rgba(46, 204, 113, 0.22); }
body.dark-mode .play-cell-castle.play-cell-last-to { background: rgba(46, 204, 113, 0.4); }
.play-history-castle { color: #1a7f3a; font-weight: 600; }
body.dark-mode .play-history-castle { color: #4ade80; }
.play-history-opening { color: #1e40af; font-weight: 600; }
body.dark-mode .play-history-opening { color: #60a5fa; }

/* ------------------------------------------------------------------ */
/* Push subscription UI on /notifications                              */
/* ------------------------------------------------------------------ */

.notifications-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}
.push-subscribe-wrap {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    max-width: 520px;
}
.push-subscribe-wrap[hidden] { display: none; }
.push-subscribe-status {
    font-size: 0.85rem;
    opacity: 0.75;
    line-height: 1.35;
    text-align: right;
}
.push-subscribe-status-on { color: #1a7f3a; opacity: 1; font-weight: 600; }
body.dark-mode .push-subscribe-status-on { color: #4ade80; }
.push-subscribe-btn {
    padding: 6px 14px;
    border: 1px solid rgba(0,0,0,0.2);
    background: transparent;
    border-radius: 6px;
    font: inherit;
    color: inherit;
    font-size: 0.88rem;
    cursor: pointer;
    transition: background-color 0.12s ease, border-color 0.12s ease;
    white-space: nowrap;
}
body.dark-mode .push-subscribe-btn { border-color: rgba(255,255,255,0.25); }
.push-subscribe-btn:hover { background: rgba(0,0,0,0.05); }
body.dark-mode .push-subscribe-btn:hover { background: rgba(255,255,255,0.06); }
.push-subscribe-btn-on {
    background: #1a7f3a;
    border-color: #1a7f3a;
    color: #fff;
}
.push-subscribe-btn-on:hover { background: #166b30; }
.push-subscribe-btn-disabled,
.push-subscribe-btn:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

/* Head-to-head badge under each player's name in the play room. */
.play-player-h2h {
    display: inline-block;
    font-size: 0.78rem;
    opacity: 0.75;
    margin-top: 2px;
    padding: 1px 8px;
    background: rgba(0,0,0,0.05);
    border-radius: 999px;
    line-height: 1.45;
    white-space: nowrap;
}
body.dark-mode .play-player-h2h { background: rgba(255,255,255,0.06); }
.play-player-h2h[hidden] { display: none; }

/* ------------------------------------------------------------------ */
/* Simul session page                                                  */
/* ------------------------------------------------------------------ */

.simul-header {
    align-items: center;
}
.simul-header-info { flex: 1; min-width: 240px; }

/* Subtitle is a row of chips (host, time control, board count, status). */
.simul-subtitle {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin: 8px 0 0;
}
.simul-chip {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 10px;
    border-radius: 999px;
    border: 1px solid rgba(0, 0, 0, 0.10);
    background: transparent;
    font-size: 0.82rem;
    font-weight: 500;
    line-height: 1.6;
    opacity: 0.85;
}
body.dark-mode .simul-chip { border-color: rgba(255, 255, 255, 0.12); }
.simul-chip svg { flex-shrink: 0; opacity: 0.6; }
.simul-chip-status { opacity: 1; }
.simul-chip-dot {
    display: inline-block;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
    flex-shrink: 0;
    opacity: 0.6;
}

.simul-header-actions {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

/* Invite link: compact icon + faded inline link, mirrors tournament page. */
.simul-invite {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 12px 0 4px;
    padding: 0;
    background: transparent;
    border: none;
}
.simul-invite[hidden] { display: none; }
.simul-invite-btn {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    padding: 0;
    border: none;
    background: transparent;
    color: inherit;
    border-radius: 50%;
    cursor: pointer;
    opacity: 0.7;
    transition: opacity 0.12s ease, background-color 0.12s ease, color 0.12s ease;
}
.simul-invite-btn:hover { background: rgba(0, 0, 0, 0.07); opacity: 1; }
body.dark-mode .simul-invite-btn:hover { background: rgba(255, 255, 255, 0.08); }
.simul-invite-btn svg { display: block; }
.simul-invite-btn-ok {
    background: #1a7f3a;
    color: #fff;
    opacity: 1;
}
.simul-invite-btn-ok:hover { background: #166b30; }
body.dark-mode .simul-invite-btn-ok {
    background: #4ade80;
    color: #0d2818;
}
body.dark-mode .simul-invite-btn-ok:hover { background: #22c55e; }
.simul-invite-link {
    flex: 1;
    min-width: 0;
    font-size: 0.86rem;
    opacity: 0.55;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    user-select: all;
    cursor: text;
    font-family: 'Junge', sans-serif;
}

.simul-status-banner {
    margin: 12px 0 8px;
    padding: 10px 14px;
    border: 1px solid rgba(0, 0, 0, 0.10);
    border-radius: 8px;
    font-size: 0.92rem;
    opacity: 0.85;
}
body.dark-mode .simul-status-banner { border-color: rgba(255, 255, 255, 0.12); }

.simul-boards { margin-top: 0; }
.simul-error {
    padding: 24px;
    text-align: center;
    color: #b91c1c;
}
body.dark-mode .simul-error { color: #f87171; }

/* Reuses .pieces-index-card for hover/border behavior; only adds the
 * internal layout for the simul-specific number + opponent + status. */
.simul-board-card {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.simul-board-num {
    font-size: 0.78rem;
    opacity: 0.55;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-weight: 700;
}
.simul-board-opponent {
    font-size: 1.08rem;
    font-weight: 600;
}
.simul-board-status {
    font-size: 0.85rem;
    margin-top: 2px;
}
.simul-board-status-active { color: #1a7f3a; }
body.dark-mode .simul-board-status-active { color: #4ade80; }
.simul-board-status-finished {
    color: rgba(0,0,0,0.55);
    font-style: italic;
}
body.dark-mode .simul-board-status-finished { color: rgba(255,255,255,0.55); }
.simul-board-finished {
    opacity: 0.7;
}

/* Icon-only action buttons in simul / tournament headers and matchup
 * cards. Neutral by default (mirrors .wiki-icon-btn). The "primary" and
 * "danger" variants are kept very subtle - only a hint of colour at hover. */
.simul-icon-btn,
.tournament-icon-btn {
    background: transparent;
    border: 1px solid rgba(0, 0, 0, 0.2);
    color: inherit;
    cursor: pointer;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    transition: background-color 0.12s ease, border-color 0.12s ease;
}
.simul-icon-btn svg,
.tournament-icon-btn svg { display: block; }
body.dark-mode .simul-icon-btn,
body.dark-mode .tournament-icon-btn { border-color: rgba(255, 255, 255, 0.22); }
.simul-icon-btn:hover,
.tournament-icon-btn:hover {
    background: rgba(0, 0, 0, 0.05);
    border-color: currentColor;
}
body.dark-mode .simul-icon-btn:hover,
body.dark-mode .tournament-icon-btn:hover { background: rgba(255, 255, 255, 0.06); }
.simul-icon-btn-danger,
.tournament-icon-btn-danger { opacity: 0.7; }
.simul-icon-btn-danger:hover,
.tournament-icon-btn-danger:hover { opacity: 1; }

/* Public lobby card variants for simul/tournament. */
.play-public-card-simul .play-recent-name,
.play-public-card-tournament .play-recent-name { font-weight: 600; }

.play-recent-name-winner {
    font-weight: 700;
    color: #1a7f3a;
}
body.dark-mode .play-recent-name-winner { color: #4ade80; }

.play-public-tag {
    display: inline-block;
    margin-left: 8px;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    line-height: 1.4;
}
.play-public-tag-simul { background: rgba(30,64,175,0.14); color: #1e40af; }
.play-public-tag-tournament { background: rgba(146,64,14,0.14); color: #92400e; }
body.dark-mode .play-public-tag-simul { background: rgba(96,165,250,0.18); color: #60a5fa; }
body.dark-mode .play-public-tag-tournament { background: rgba(252,211,77,0.18); color: #fde68a; }

.play-visibility {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin: 12px 0;
}
.play-visibility-option {
    display: grid;
    grid-template-columns: auto 1fr;
    grid-template-rows: auto auto;
    column-gap: 10px;
    padding: 10px 12px;
    border: 1px solid rgba(0,0,0,0.14);
    border-radius: 8px;
    cursor: pointer;
    transition: background-color 0.12s ease, border-color 0.12s ease;
}
body.dark-mode .play-visibility-option { border-color: rgba(255,255,255,0.18); }
.play-visibility-option:hover { background: rgba(0,0,0,0.03); }
body.dark-mode .play-visibility-option:hover { background: rgba(255,255,255,0.04); }
.play-visibility-option input[type="radio"] {
    grid-row: 1 / span 2;
    align-self: center;
    margin: 0;
}
.play-visibility-option > span {
    grid-column: 2;
    grid-row: 1;
    font-weight: 600;
}
.play-visibility-option > small {
    grid-column: 2;
    grid-row: 2;
    font-size: 0.82rem;
    opacity: 0.7;
}
.play-visibility-option input[type="radio"]:checked ~ span {
    color: #1a7f3a;
}
body.dark-mode .play-visibility-option input[type="radio"]:checked ~ span {
    color: #4ade80;
}

/* ------------------------------------------------------------------ */
/* Tournament page                                                     */
/* ------------------------------------------------------------------ */

.tournament-header {
    align-items: center;
}
.tournament-header-info { flex: 1; min-width: 240px; }

/* Subtitle is a row of chips (host, time control, count, status).     */
.tournament-subtitle {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin: 8px 0 0;
}
.tournament-chip {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 10px;
    border-radius: 999px;
    border: 1px solid rgba(0, 0, 0, 0.10);
    background: transparent;
    font-size: 0.82rem;
    font-weight: 500;
    line-height: 1.6;
    opacity: 0.85;
}
body.dark-mode .tournament-chip { border-color: rgba(255, 255, 255, 0.12); }
.tournament-chip svg { flex-shrink: 0; opacity: 0.6; }
.tournament-chip-status { opacity: 1; }
.tournament-chip-dot {
    display: inline-block;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
    flex-shrink: 0;
    opacity: 0.6;
}

.tournament-header-actions {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}
.tournament-need-players,
.tournament-login-required {
    font-size: 0.86rem;
    opacity: 0.65;
    font-style: italic;
}

/* Status banner: neutral, borderless inline notice. */
.tournament-status-banner {
    margin: 12px 0 8px;
    padding: 4px 0;
    border: none;
    font-size: 0.92rem;
    opacity: 0.7;
}
.tournament-status-banner-winner {
    font-weight: 700;
    opacity: 1;
    text-align: center;
    padding: 16px 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    font-size: 1.05rem;
}
.tournament-winner-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}

/* Invite link: compact icon + faded inline link, no big card around. */
.tournament-invite {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 12px 0 4px;
    padding: 0;
    background: transparent;
    border: none;
}
.tournament-invite[hidden] { display: none; }
.tournament-invite-btn {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    padding: 0;
    border: none;
    background: transparent;
    color: inherit;
    border-radius: 50%;
    cursor: pointer;
    opacity: 0.7;
    transition: opacity 0.12s ease, background-color 0.12s ease, color 0.12s ease;
}
.tournament-invite-btn:hover { background: rgba(0, 0, 0, 0.07); opacity: 1; }
body.dark-mode .tournament-invite-btn:hover { background: rgba(255, 255, 255, 0.08); }
.tournament-invite-btn svg { display: block; }
.tournament-invite-btn-ok {
    background: #1a7f3a;
    color: #fff;
    opacity: 1;
}
.tournament-invite-btn-ok:hover { background: #166b30; }
body.dark-mode .tournament-invite-btn-ok {
    background: #4ade80;
    color: #0d2818;
}
body.dark-mode .tournament-invite-btn-ok:hover { background: #22c55e; }
.tournament-invite-link {
    flex: 1;
    min-width: 0;
    font-size: 0.86rem;
    opacity: 0.55;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    user-select: all;
    cursor: text;
    font-family: 'Junge', sans-serif;
}

/* Participants grid: reuses .pieces-index + .pieces-index-card so it
 * matches the wiki/match listing visuals exactly. The card holds the
 * same .play-recent-players row as lobby cards. */
.tournament-participants-list .play-recent-players {
    width: 100%;
    margin: 0;
}
.tournament-host-badge {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: rgba(146, 64, 14, 0.12);
    color: #92400e;
}
.tournament-host-badge svg { width: 12px; height: 12px; }
body.dark-mode .tournament-host-badge {
    background: rgba(252, 211, 77, 0.18);
    color: #fde68a;
}

/* Bracket: horizontal flex with each column taking equal share of the
 * available width. Cards inside are constrained so they stay compact
 * even when the column is wide. */
.tournament-bracket-wrap { margin-top: 20px; }
.tournament-bracket {
    display: flex;
    gap: 20px;
    align-items: stretch;
    padding: 4px 0 20px;
    width: 100%;
}
.tournament-bracket-col {
    flex: 1 1 0;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 14px;
    justify-content: space-around;
    align-items: stretch;
    max-width: 320px;
    margin: 0 auto;
}
.tournament-bracket-col-header {
    text-align: center;
    font-size: 0.76rem;
    text-transform: uppercase;
    letter-spacing: 0.10em;
    font-weight: 700;
    opacity: 0.55;
    padding: 0 0 10px;
}

/* Matchup card mirrors .pieces-index-card - thin border, hover darkens
 * the border, no fill or coloured glow. Natural rectangular height. */
.tournament-matchup {
    display: flex;
    flex-direction: column;
    border: 1px solid rgba(0, 0, 0, 0.12);
    border-radius: 8px;
    background: transparent;
    overflow: hidden;
    transition: border-color 0.15s ease;
}
body.dark-mode .tournament-matchup { border-color: rgba(255, 255, 255, 0.15); }
.tournament-matchup:hover { border-color: rgba(0, 0, 0, 0.3); }
body.dark-mode .tournament-matchup:hover { border-color: rgba(255, 255, 255, 0.3); }
.tournament-matchup-bye {
    border-style: dashed;
    opacity: 0.55;
}

.tournament-matchup-slot {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
}
body.dark-mode .tournament-matchup-slot { border-bottom-color: rgba(255, 255, 255, 0.10); }
.tournament-matchup-slot:last-of-type { border-bottom: none; }
.tournament-matchup-slot-empty { opacity: 0.4; font-style: italic; }
.tournament-matchup-slot-winner .tournament-matchup-name { font-weight: 700; }
.tournament-matchup-avatar {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}
.tournament-matchup-name {
    flex: 1;
    min-width: 0;
    font-size: 0.92rem;
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.tournament-matchup-name-tbd { opacity: 0.5; }
.tournament-matchup-trophy {
    flex-shrink: 0;
    opacity: 0.55;
    display: inline-flex;
    align-items: center;
}

.tournament-matchup-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 7px 10px;
    font-size: 0.78rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    text-decoration: none;
    color: inherit;
    opacity: 0.6;
    border-top: 1px solid rgba(0, 0, 0, 0.08);
    transition: opacity 0.12s ease;
}
body.dark-mode .tournament-matchup-link { border-top-color: rgba(255, 255, 255, 0.10); }
.tournament-matchup-link:hover { opacity: 1; }
.tournament-matchup-tag {
    display: block;
    padding: 6px 10px;
    text-align: center;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 600;
    opacity: 0.5;
    border-top: 1px solid rgba(0, 0, 0, 0.08);
}
body.dark-mode .tournament-matchup-tag { border-top-color: rgba(255, 255, 255, 0.10); }

.tournament-error {
    padding: 24px;
    text-align: center;
    color: #b91c1c;
}
body.dark-mode .tournament-error { color: #f87171; }

.tournament-modal-field {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 12px;
}
.tournament-modal-label {
    font-size: 0.85rem;
    opacity: 0.7;
    font-weight: 600;
}

.play-analysis-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    font-weight: 800;
    font-family: 'Junge', sans-serif;
    color: #fff;
    cursor: help;
    text-align: center;
    line-height: 1;
}
.play-analysis-badge-blunder { background: #b91c1c; }
.play-analysis-badge-brilliant { background: #16a34a; }
.play-analysis-badge-good { background: #2563eb; }

.play-analysis-badge-history {
    width: 22px; height: 22px;
    font-size: 0.7rem;
    margin-left: 2px;
    vertical-align: middle;
}

.play-analysis-badge-cell {
    position: absolute;
    top: -8px; right: -8px;
    width: 22px; height: 22px;
    font-size: 0.72rem;
    z-index: 4;
    box-shadow: 0 0 0 2px #fff, 0 1px 4px rgba(0,0,0,0.35);
}
body.dark-mode .play-analysis-badge-cell { box-shadow: 0 0 0 2px #1f1d1d, 0 1px 4px rgba(0,0,0,0.6); }
.play-piece {
    width: 100%; height: 100%;
    display: flex; align-items: center; justify-content: center;
    font-family: 'Noto', 'Junge', serif;
    font-size: clamp(0.95rem, 4vw, 1.85rem);
    font-weight: 700;
    color: #000;
    background: transparent;
    border: none;
    border-radius: 0;
    box-shadow: none;
    line-height: 1;
}
body.dark-mode .play-piece { color: #f5f5f5; }
.play-piece-promoted { color: #b91c1c; font-weight: 800; }
body.dark-mode .play-piece-promoted { color: #f87171; }
.play-piece-flipped { transform: rotate(180deg); }
.play-piece-western {
    font-family: 'Noto', 'Junge', serif;
    font-size: clamp(1.05rem, 4.5vw, 2rem);
}

/* Movement-diagram SVG for pieces without a chess glyph (gold, silver,
   lance, and promoted pieces). Sized in em so it scales with the piece
   font-size; inherits currentColor, so .play-piece-promoted tints it red
   as the promotion overlay. */
.piece-western-svg {
    display: block;
    width: 1.3em;
    height: 1.3em;
}

.settings-radio-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 6px;
}
.settings-radio-group .settings-toggle {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    border: 1px solid rgba(0, 0, 0, 0.12);
    border-radius: 8px;
    transition: border-color 0.15s ease, background-color 0.15s ease;
    margin-top: 0;
}
.settings-radio-group .settings-toggle:hover {
    border-color: rgba(0, 0, 0, 0.3);
}
.settings-radio-group .settings-toggle input[type="radio"] {
    appearance: none;
    -webkit-appearance: none;
    width: 16px;
    height: 16px;
    border: 1px solid rgba(0, 0, 0, 0.4);
    border-radius: 50%;
    margin: 0;
    cursor: pointer;
    position: relative;
    flex-shrink: 0;
}
.settings-radio-group .settings-toggle input[type="radio"]:checked {
    border-color: #000;
}
.settings-radio-group .settings-toggle input[type="radio"]:checked::after {
    content: '';
    position: absolute;
    top: 3px;
    left: 3px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #000;
}
.settings-radio-group .settings-toggle:has(input[type="radio"]:checked) {
    border-color: #000;
    background: rgba(0, 0, 0, 0.04);
}
body.dark-mode .settings-radio-group .settings-toggle {
    border-color: rgba(255, 255, 255, 0.15);
}
body.dark-mode .settings-radio-group .settings-toggle:hover {
    border-color: rgba(255, 255, 255, 0.35);
}
body.dark-mode .settings-radio-group .settings-toggle input[type="radio"] {
    border-color: rgba(255, 255, 255, 0.45);
}
body.dark-mode .settings-radio-group .settings-toggle input[type="radio"]:checked {
    border-color: #f5f5f5;
}
body.dark-mode .settings-radio-group .settings-toggle input[type="radio"]:checked::after {
    background: #f5f5f5;
}
body.dark-mode .settings-radio-group .settings-toggle:has(input[type="radio"]:checked) {
    border-color: #f5f5f5;
    background: rgba(255, 255, 255, 0.05);
}

.play-promotion {
    position: absolute; inset: 0;
    display: flex; align-items: center; justify-content: center;
    z-index: 10;
}
.play-promotion[hidden] { display: none; }
.play-promotion-backdrop {
    position: absolute; inset: 0;
    background: rgba(0,0,0,0.5);
    cursor: pointer;
}
.play-promotion-card {
    position: relative;
    background: #fff; color: #1d1f23;
    padding: 20px 24px; border-radius: 10px;
    text-align: center;
    box-shadow: 0 8px 30px rgba(0,0,0,0.3);
    min-width: 220px;
}
body.dark-mode .play-promotion-card { background: #2c2e34; color: #f5f5f5; }
.play-promotion-title {
    margin: 0 0 12px;
    font-weight: 600;
    font-size: 1rem;
    color: inherit;
}
.play-promotion-buttons { display: flex; gap: 10px; justify-content: center; }
.play-promotion-buttons button {
    padding: 8px 18px;
    border-radius: 6px;
    border: 1px solid rgba(0,0,0,0.2);
    background: rgba(0,0,0,0.05);
    color: inherit;
    cursor: pointer;
    font: inherit;
    font-size: 0.95rem;
    min-width: 96px;
}
body.dark-mode .play-promotion-buttons button {
    background: rgba(255,255,255,0.08);
    border-color: rgba(255,255,255,0.15);
}
.play-promotion-buttons button:first-child {
    background: #c2410c; color: #fff; border-color: #c2410c;
}
.play-promotion-cancel {
    position: absolute;
    top: 4px; right: 8px;
    background: transparent;
    border: none;
    font-size: 1.2rem;
    color: inherit;
    cursor: pointer;
    opacity: 0.6;
    line-height: 1;
    padding: 4px 6px;
}
.play-promotion-cancel:hover { opacity: 1; }

/* Match result banner sits at the top of the play room (just below the
 * page header). Neutral wiki-style colours; the green/red are reserved
 * for the viewer's own perspective so they read result at a glance. */
.play-result-banner {
    padding: 10px 16px;
    border: 1px solid rgba(0, 0, 0, 0.10);
    font-weight: 600;
    font-size: 0.95rem;
    text-align: center;
}
body.dark-mode .play-result-banner { border-color: rgba(255, 255, 255, 0.12); }
.play-result-banner[hidden] { display: none; }
.play-result-banner-win {
    color: #1a7f3a;
    border-color: rgba(26, 127, 58, 0.30);
    background: rgba(26, 127, 58, 0.06);
}
body.dark-mode .play-result-banner-win {
    color: #4ade80;
    border-color: rgba(74, 222, 128, 0.35);
    background: rgba(74, 222, 128, 0.07);
}
.play-result-banner-loss {
    color: #b91c1c;
    border-color: rgba(185, 28, 28, 0.30);
    background: rgba(185, 28, 28, 0.05);
}
body.dark-mode .play-result-banner-loss {
    color: #f87171;
    border-color: rgba(248, 113, 113, 0.35);
    background: rgba(248, 113, 113, 0.06);
}
.play-result-banner-neutral { opacity: 0.85; }

.play-piece-modal {
    position: absolute; inset: 0;
    display: flex; align-items: center; justify-content: center;
    z-index: 12;
}
.play-piece-modal[hidden] { display: none; }
.play-piece-modal-backdrop {
    position: absolute; inset: 0;
    background: rgba(0,0,0,0.45);
    cursor: pointer;
}
.play-piece-modal-card {
    position: relative;
    background: #fff; color: #1d1f23;
    padding: 20px 24px 16px;
    border-radius: 12px;
    text-align: center;
    box-shadow: 0 12px 40px rgba(0,0,0,0.25);
    max-width: 320px;
    width: calc(100% - 40px);
}
body.dark-mode .play-piece-modal-card {
    background: #2c2e34; color: #f5f5f5;
}
.play-piece-modal-kanji {
    font-family: 'Noto', 'Junge', serif;
    font-size: 3rem;
    font-weight: 700;
    line-height: 1;
    margin-bottom: 8px;
    color: inherit;
}
.play-piece-modal-promoted { color: #b91c1c; }
body.dark-mode .play-piece-modal-promoted { color: #f87171; }
.play-piece-modal-name {
    margin: 0 0 8px;
    font-size: 1.05rem;
    font-weight: 600;
}
.play-piece-modal-move {
    margin: 0 0 14px;
    font-size: 0.9rem;
    opacity: 0.85;
    line-height: 1.4;
}
.play-piece-modal-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-top: 4px;
    padding: 6px 12px;
    border: 1px solid currentColor;
    border-radius: 999px;
    font-size: 0.85rem;
    color: #c2410c;
    text-decoration: none;
    transition: background-color 0.12s ease;
}
.play-piece-modal-link:hover { background: rgba(194, 65, 12, 0.1); text-decoration: none; }
body.dark-mode .play-piece-modal-link { color: #fb923c; }
.play-piece-modal-close {
    position: absolute;
    top: 6px; right: 10px;
    background: transparent; border: none;
    font-size: 1.3rem;
    color: inherit;
    cursor: pointer;
    opacity: 0.55;
    line-height: 1; padding: 4px 8px;
}
.play-piece-modal-close:hover { opacity: 1; }

.play-controls { margin: 12px 0; display: flex; gap: 10px; align-items: center; }

.play-history-section { margin-top: 20px; }
.play-history-title { margin: 0 0 6px; font-size: 0.95rem; opacity: 0.8; }
.play-history {
    max-height: 220px; overflow-y: auto;
    border: 1px solid rgba(0, 0, 0, 0.1);
}
body.dark-mode .play-history { border-color: rgba(255, 255, 255, 0.1); }
.play-history-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.88rem;
}
.play-history-row {
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}
body.dark-mode .play-history-row { border-bottom-color: rgba(255, 255, 255, 0.06); }
.play-history-row:last-child { border-bottom: none; }
.play-history-clickable { cursor: pointer; }
.play-history-clickable:hover { background: rgba(0, 0, 0, 0.04); }
body.dark-mode .play-history-clickable:hover { background: rgba(255, 255, 255, 0.05); }
.play-history-current { background: rgba(255, 165, 0, 0.18); }
body.dark-mode .play-history-current { background: rgba(255, 165, 0, 0.22); }
.play-history-row td { padding: 6px 10px; vertical-align: middle; }
.play-history-num {
    width: 36px; text-align: right;
    font-variant-numeric: tabular-nums;
    opacity: 0.55; font-size: 0.82rem;
}
.play-history-desc { line-height: 1.4; }
.play-history-short {
    width: 1%; white-space: nowrap;
    font-family: 'Noto', 'Junge', serif;
    font-size: 0.95rem;
    opacity: 0.75;
    text-align: right;
}
.play-history-gote .play-history-num,
.play-history-gote .play-history-short { opacity: 0.5; }
.play-history-takenback .play-history-desc,
.play-history-takenback .play-history-short {
    text-decoration: line-through;
    opacity: 0.45;
}
.play-history-takeback {
    background: rgba(255, 165, 0, 0.10);
    font-style: italic;
}
body.dark-mode .play-history-takeback { background: rgba(255, 165, 0, 0.14); }
.play-history-takeback .play-history-num {
    font-style: normal;
    opacity: 0.8;
    text-align: center;
}
.play-history-empty { padding: 14px; opacity: 0.6; font-size: 0.9rem; text-align: center; }

.play-confirm-modal {
    position: fixed; inset: 0;
    display: flex; align-items: center; justify-content: center;
    z-index: 100;
}
.play-confirm-modal[hidden] { display: none; }
.play-confirm-backdrop {
    position: absolute; inset: 0;
    background: rgba(0, 0, 0, 0.5);
    cursor: pointer;
}
.play-confirm-card {
    position: relative;
    background: #fff;
    color: #1d1f23;
    padding: 22px 26px;
    border-radius: 10px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
    min-width: 280px;
    max-width: 92vw;
    text-align: center;
}
body.dark-mode .play-confirm-card { background: #2c2e34; color: #f5f5f5; }
.play-confirm-title {
    margin: 0 0 8px;
    font-weight: 600;
    font-size: 1.02rem;
}
.play-confirm-body {
    margin: 0 0 16px;
    font-size: 0.92rem;
    opacity: 0.85;
    line-height: 1.4;
}
.play-confirm-body[hidden] { display: none; }
.play-confirm-actions {
    display: flex; gap: 10px; justify-content: center;
    margin-top: 14px;
}
.play-confirm-btn {
    padding: 8px 18px;
    border-radius: 6px;
    border: 1px solid rgba(0, 0, 0, 0.2);
    background: rgba(0, 0, 0, 0.05);
    color: inherit;
    cursor: pointer;
    font: inherit;
    font-size: 0.95rem;
    min-width: 96px;
}
body.dark-mode .play-confirm-btn {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.15);
}
.play-confirm-btn-ok {
    background: #c2410c;
    color: #fff;
    border-color: #c2410c;
}
.play-confirm-btn-ok:hover { background: #9a3309; border-color: #9a3309; }

.play-takeback-incoming {
    box-shadow: 0 0 0 2px #c2410c, 0 0 8px rgba(194, 65, 12, 0.4);
    animation: play-takeback-pulse 1.4s ease-in-out infinite;
}
@keyframes play-takeback-pulse {
    0%, 100% { box-shadow: 0 0 0 2px #c2410c, 0 0 6px rgba(194, 65, 12, 0.4); }
    50% { box-shadow: 0 0 0 2px #c2410c, 0 0 14px rgba(194, 65, 12, 0.7); }
}
.play-replay-controls { display: flex; gap: 4px; margin-top: 10px; flex-wrap: wrap; align-items: center; }
.play-replay-controls[hidden] { display: none; }
.play-replay-live { color: #b91c1c; }
body.dark-mode .play-replay-live { color: #f87171; }

.play-chat-form {
    display: flex;
    gap: 0;
    margin: 0;
    width: 100%;
    align-items: stretch;
}
.play-chat-form[hidden] { display: none; }
.play-chat-form + .play-history { border-top: none; }
.play-chat-input {
    flex: 1;
    min-width: 0;
    padding: 10px 12px;
    border: 1px solid rgba(0, 0, 0, 0.15);
    border-bottom: none;
    border-radius: 0;
    background: transparent;
    color: inherit;
    font-family: inherit;
    font-size: 0.92rem;
    outline: none;
}
body.dark-mode .play-chat-input {
    border-color: rgba(255, 255, 255, 0.18);
}
.play-chat-send {
    flex-shrink: 0;
    width: 44px;
    border: 1px solid rgba(0, 0, 0, 0.15);
    border-left: none;
    border-bottom: none;
    border-radius: 0;
    background: transparent;
    color: inherit;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.play-chat-send:hover { background: rgba(0, 0, 0, 0.06); }
body.dark-mode .play-chat-send { border-color: rgba(255, 255, 255, 0.18); }
body.dark-mode .play-chat-send:hover { background: rgba(255, 255, 255, 0.08); }

.play-sync-indicator {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.8rem;
    opacity: 0.75;
    margin-left: 8px;
}
.play-sync-indicator[hidden] { display: none; }
.play-sync-indicator svg { animation: play-icon-spin 1.2s linear infinite; }

/* ------------------------------------------------------------------ */
/* Opening editor / viewer                                            */
/* ------------------------------------------------------------------ */

/* The viewer carries `wiki-editor-only`, which the global rule turns into
 * `display: inline-flex` for editors. Override to keep block layout. */
body.is-wiki-editor .opening-viewer.wiki-editor-only { display: block; }

.opening-viewer {
    margin: 18px 0 28px 0;
    padding: 20px 22px 18px;
    border: 1px solid rgba(0,0,0,0.08);
    border-radius: 14px;
    background: #fdfaf2;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04), 0 6px 16px rgba(0,0,0,0.04);
}
body.dark-mode .opening-viewer {
    border-color: rgba(255,255,255,0.10);
    background: #232020;
    box-shadow: 0 1px 3px rgba(0,0,0,0.4);
}

.opening-viewer-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
    padding-bottom: 14px;
    border-bottom: 1px solid rgba(0,0,0,0.08);
}
body.dark-mode .opening-viewer-header { border-bottom-color: rgba(255,255,255,0.10); }

.opening-viewer-toggle {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    margin-left: auto;
}
.opening-viewer-toggle-label {
    font-size: 0.82rem;
    opacity: 0.65;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 600;
}
.opening-viewer-toggle-btn {
    border: 1px solid rgba(0,0,0,0.16);
    background: transparent;
    padding: 6px 14px;
    font: inherit;
    color: inherit;
    font-size: 0.88rem;
    cursor: pointer;
    transition: background-color 0.12s ease, color 0.12s ease, border-color 0.12s ease;
}
.opening-viewer-toggle-btn:first-of-type {
    border-radius: 8px 0 0 8px;
}
.opening-viewer-toggle-btn:last-of-type {
    border-radius: 0 8px 8px 0;
    border-left: none;
}
body.dark-mode .opening-viewer-toggle-btn { border-color: rgba(255,255,255,0.20); }
body.dark-mode .opening-viewer-toggle-btn:last-of-type { border-left: none; }
.opening-viewer-toggle-btn:hover { background: rgba(0,0,0,0.04); }
body.dark-mode .opening-viewer-toggle-btn:hover { background: rgba(255,255,255,0.06); }
.opening-viewer-toggle-btn-active {
    background: #1f1d1d;
    color: #fdfaf2;
    border-color: #1f1d1d;
}
body.dark-mode .opening-viewer-toggle-btn-active {
    background: #fdfaf2;
    color: #1f1d1d;
    border-color: #fdfaf2;
}

.opening-viewer-side-tag {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 14px;
    border-radius: 999px;
    font-size: 0.82rem;
    font-weight: 700;
    letter-spacing: 0.02em;
}
.opening-viewer-side-sente { background: rgba(26,127,58,0.14); color: #1a7f3a; }
.opening-viewer-side-gote  { background: rgba(185,28,28,0.14); color: #b91c1c; }
body.dark-mode .opening-viewer-side-sente { background: rgba(74,222,128,0.18); color: #4ade80; }
body.dark-mode .opening-viewer-side-gote  { background: rgba(248,113,113,0.18); color: #f87171; }

.opening-viewer-layout {
    display: grid;
    grid-template-columns: minmax(280px, 380px) minmax(0, 1fr);
    gap: 20px;
    align-items: start;
}
@media (max-width: 720px) {
    .opening-viewer-layout { grid-template-columns: 1fr; }
}

.opening-viewer-board-col,
.opening-editor-board-col {
    display: flex;
    flex-direction: column;
    gap: 6px;
    align-items: stretch;
    min-width: 0;
}
.opening-viewer-board-col { max-width: 380px; }

.opening-viewer-hand,
.opening-editor-hand {
    min-height: 34px;
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    padding: 4px 6px;
    align-items: center;
    background: rgba(0,0,0,0.025);
    border-radius: 6px;
}
body.dark-mode .opening-viewer-hand,
body.dark-mode .opening-editor-hand { background: rgba(255,255,255,0.04); }

.opening-viewer-board.play-board,
.opening-board.play-board {
    max-width: 100%;
}

.opening-viewer-controls,
.opening-editor-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    align-items: center;
    padding-top: 6px;
    justify-content: center;
}
.opening-viewer-nav,
.opening-editor-nav {
    border: 1px solid rgba(0,0,0,0.18);
    background: transparent;
    padding: 6px 12px;
    font-size: 0.95rem;
    cursor: pointer;
    border-radius: 6px;
    line-height: 1;
    color: inherit;
    min-width: 38px;
    transition: background-color 0.12s ease;
}
body.dark-mode .opening-viewer-nav,
body.dark-mode .opening-editor-nav {
    border-color: rgba(255,255,255,0.22);
    color: #f5f5f5;
}
.opening-viewer-nav:hover,
.opening-editor-nav:hover { background: rgba(0,0,0,0.06); }
body.dark-mode .opening-viewer-nav:hover,
body.dark-mode .opening-editor-nav:hover { background: rgba(255,255,255,0.08); }

.opening-viewer-side-col,
.opening-editor-side-col {
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-width: 0;
}

.opening-viewer-status,
.opening-editor-status-line {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 600;
    font-size: 0.95rem;
    line-height: 1.3;
    padding: 8px 12px;
    background: rgba(0,0,0,0.03);
    border-radius: 8px;
}
body.dark-mode .opening-viewer-status,
body.dark-mode .opening-editor-status-line { background: rgba(255,255,255,0.04); }
.opening-viewer-status-label-muted { opacity: 0.55; font-weight: 500; font-style: italic; }
.opening-viewer-status-dot,
.opening-editor-turn-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}
.opening-viewer-status-dot-player,
.opening-editor-turn-dot-player { background: #1a7f3a; }
.opening-viewer-status-dot-opponent,
.opening-editor-turn-dot-opponent { background: #b91c1c; }
body.dark-mode .opening-viewer-status-dot-player,
body.dark-mode .opening-editor-turn-dot-player { background: #4ade80; }
body.dark-mode .opening-viewer-status-dot-opponent,
body.dark-mode .opening-editor-turn-dot-opponent { background: #f87171; }
.opening-editor-status-line.opening-status-error { color: #b91c1c; }
body.dark-mode .opening-editor-status-line.opening-status-error { color: #f87171; }

.opening-viewer-comment {
    font-size: 0.92rem;
    line-height: 1.55;
    opacity: 0.88;
    white-space: pre-wrap;
    padding: 8px 10px;
    background: rgba(0,0,0,0.04);
    border-left: 3px solid rgba(0,0,0,0.18);
    border-radius: 0 4px 4px 0;
}
body.dark-mode .opening-viewer-comment {
    background: rgba(255,255,255,0.05);
    border-left-color: rgba(255,255,255,0.25);
}
.opening-viewer-comment:empty { display: none; }

.opening-viewer-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
    max-height: 480px;
    overflow-y: auto;
    padding: 4px 6px 4px 0;
    margin-top: 4px;
}
.opening-viewer-list::-webkit-scrollbar { width: 6px; }
.opening-viewer-list::-webkit-scrollbar-thumb {
    background: rgba(0,0,0,0.18);
    border-radius: 3px;
}
body.dark-mode .opening-viewer-list::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.22); }

.opening-list-empty {
    margin: 24px 0;
    padding: 22px 16px;
    text-align: center;
    opacity: 0.6;
    font-style: italic;
    border: 1px dashed rgba(0,0,0,0.14);
    border-radius: 8px;
    font-size: 0.9rem;
}
body.dark-mode .opening-list-empty { border-color: rgba(255,255,255,0.18); }

.opening-list-step {
    display: grid;
    grid-template-columns: 26px 1fr;
    column-gap: 10px;
    row-gap: 2px;
    padding: 8px 10px;
    border-radius: 8px;
    transition: background-color 0.12s ease;
}
.opening-list-step:hover { background: rgba(0,0,0,0.03); }
body.dark-mode .opening-list-step:hover { background: rgba(255,255,255,0.04); }

.opening-list-num {
    font-weight: 700;
    color: rgba(0,0,0,0.4);
    text-align: right;
    font-size: 0.95rem;
    padding-top: 2px;
    font-variant-numeric: tabular-nums;
}
body.dark-mode .opening-list-num { color: rgba(255,255,255,0.45); }

.opening-list-player-line,
.opening-list-opp-line {
    display: flex;
    align-items: baseline;
    gap: 6px;
    flex-wrap: wrap;
    line-height: 1.5;
}
.opening-list-opp-line {
    grid-column: 2;
    margin-left: 4px;
    margin-top: 2px;
    opacity: 0.72;
    font-size: 0.86rem;
}
.opening-list-opp-arrow {
    color: rgba(0,0,0,0.35);
    flex-shrink: 0;
    font-weight: bold;
}
body.dark-mode .opening-list-opp-arrow { color: rgba(255,255,255,0.4); }
.opening-list-opp-label {
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    opacity: 0.55;
    font-weight: 600;
}

.opening-list-btn {
    border: none;
    background: transparent;
    padding: 3px 9px;
    border-radius: 5px;
    cursor: pointer;
    font: inherit;
    color: inherit;
    line-height: 1.4;
    transition: background-color 0.12s ease, transform 0.06s ease;
}
.opening-list-btn:active { transform: translateY(1px); }
.opening-list-player-move {
    font-weight: 700;
    font-size: 1.02rem;
    color: #1a7f3a;
}
body.dark-mode .opening-list-player-move { color: #4ade80; }
.opening-list-opp-move {
    font-weight: 500;
    color: rgba(0,0,0,0.72);
    font-size: 0.92rem;
}
body.dark-mode .opening-list-opp-move { color: rgba(255,255,255,0.78); }
.opening-list-btn:hover { background: rgba(0,0,0,0.08); }
body.dark-mode .opening-list-btn:hover { background: rgba(255,255,255,0.10); }
.opening-list-btn-current {
    background: rgba(255,165,0,0.32);
    box-shadow: 0 0 0 1px rgba(255,165,0,0.5) inset;
}
body.dark-mode .opening-list-btn-current { background: rgba(255,180,80,0.30); }

.opening-list-comment {
    font-size: 0.85rem;
    font-style: italic;
    opacity: 0.7;
}

.opening-list-opening {
    display: flex;
    align-items: baseline;
    gap: 6px;
    padding: 6px 10px;
    margin-bottom: 4px;
    background: rgba(0,0,0,0.04);
    border-radius: 6px;
    flex-wrap: wrap;
}
body.dark-mode .opening-list-opening { background: rgba(255,255,255,0.05); }
.opening-list-opening-label {
    font-size: 0.82rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    opacity: 0.65;
}

.opening-list-alts {
    display: inline-flex;
    align-items: baseline;
    gap: 4px;
    flex-wrap: wrap;
    margin-left: 4px;
    font-size: 0.82rem;
}
.opening-list-alts-label {
    opacity: 0.55;
    font-style: italic;
}
.opening-list-alt-chip {
    border: 1px dashed rgba(0,0,0,0.25);
    background: transparent;
    padding: 1px 6px;
    border-radius: 10px;
    font: inherit;
    color: inherit;
    font-size: 0.82rem;
    cursor: pointer;
    transition: background-color 0.12s ease, border-color 0.12s ease;
}
body.dark-mode .opening-list-alt-chip { border-color: rgba(255,255,255,0.30); }
.opening-list-alt-chip:hover {
    background: rgba(0,0,0,0.06);
    border-style: solid;
}
body.dark-mode .opening-list-alt-chip:hover { background: rgba(255,255,255,0.08); }
.opening-list-alt-chip-current {
    background: rgba(255,165,0,0.30);
    border-style: solid;
    border-color: rgba(255,165,0,0.6);
    font-weight: 600;
}

.opening-list-variation-banner {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    margin-top: 6px;
    background: rgba(255,165,0,0.10);
    border: 1px solid rgba(255,165,0,0.30);
    border-radius: 6px;
    font-size: 0.88rem;
    flex-wrap: wrap;
}
.opening-list-variation-icon {
    color: rgba(180,90,0,0.9);
    font-size: 1rem;
}
body.dark-mode .opening-list-variation-icon { color: rgba(255,180,80,0.9); }
.opening-list-variation-text { flex: 1; min-width: 0; }
.opening-list-back-mainline {
    border: 1px solid rgba(0,0,0,0.2);
    background: transparent;
    padding: 4px 10px;
    border-radius: 4px;
    cursor: pointer;
    font: inherit;
    color: inherit;
    font-size: 0.85rem;
}
body.dark-mode .opening-list-back-mainline { border-color: rgba(255,255,255,0.3); }

.opening-viewer-empty {
    margin: 16px 0;
    padding: 18px;
    text-align: center;
    opacity: 0.7;
    font-style: italic;
    border: 1px dashed rgba(0,0,0,0.18);
    border-radius: 6px;
}
body.dark-mode .opening-viewer-empty { border-color: rgba(255,255,255,0.22); }

/* Editor side toggle */
.opening-side-toggle {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
    padding: 6px 10px;
    background: rgba(0,0,0,0.04);
    border-radius: 8px;
}
body.dark-mode .opening-side-toggle { background: rgba(255,255,255,0.05); }
.opening-side-toggle-label {
    font-size: 0.85rem;
    opacity: 0.75;
}
.opening-side-toggle-btn {
    border: 1px solid rgba(0,0,0,0.18);
    background: transparent;
    padding: 4px 12px;
    border-radius: 6px;
    cursor: pointer;
    font: inherit;
    color: inherit;
    font-size: 0.88rem;
    transition: background-color 0.12s ease, border-color 0.12s ease;
}
body.dark-mode .opening-side-toggle-btn { border-color: rgba(255,255,255,0.25); }
.opening-side-toggle-btn:hover { background: rgba(0,0,0,0.06); }
body.dark-mode .opening-side-toggle-btn:hover { background: rgba(255,255,255,0.08); }
.opening-side-toggle-btn-active {
    background: #1a7f3a;
    border-color: #1a7f3a;
    color: #fff;
}
.opening-side-toggle-btn-active:hover { background: #166b30; }

/* Editor's full tree (kept tree-shaped for editing) */
.opening-tree-list {
    list-style: decimal;
    margin: 4px 0 4px 20px;
    padding: 0;
}
.opening-tree-li { margin: 2px 0; line-height: 1.5; }
.opening-tree-move {
    border: none; background: transparent;
    padding: 1px 6px; border-radius: 4px;
    cursor: pointer; font: inherit; color: inherit;
}
.opening-tree-move:hover { background: rgba(0,0,0,0.08); }
body.dark-mode .opening-tree-move:hover { background: rgba(255,255,255,0.12); }
.opening-tree-move-current {
    background: rgba(255,165,0,0.32);
    font-weight: 700;
}
body.dark-mode .opening-tree-move-current { background: rgba(255,165,0,0.32); }
.opening-tree-gote .opening-tree-move { font-style: italic; opacity: 0.85; }
.opening-tree-comment-inline { opacity: 0.75; font-size: 0.85rem; }
.opening-tree-variation {
    margin: 2px 0 4px 12px;
    padding-left: 8px;
    border-left: 2px solid rgba(255,165,0,0.4);
}
body.dark-mode .opening-tree-variation { border-left-color: rgba(255,180,80,0.4); }
.opening-tree-empty { opacity: 0.6; font-style: italic; }
.opening-tree-comment { font-size: 0.88rem; opacity: 0.8; }

/* Editor modal */
.opening-editor-modal {
    position: fixed;
    inset: 0;
    z-index: 1200;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}
.opening-editor-modal[hidden] { display: none; }
.opening-editor-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.45);
}
.opening-editor-card {
    position: relative;
    background: #fdfaf2;
    border: 1px solid rgba(0,0,0,0.2);
    border-radius: 10px;
    width: min(960px, 100%);
    max-height: 92vh;
    overflow-y: auto;
    padding: 18px 20px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.35);
}
body.dark-mode .opening-editor-card {
    background: #1f1d1d;
    border-color: rgba(255,255,255,0.18);
    color: #f5f5f5;
}
.opening-editor-close {
    position: absolute;
    top: 6px;
    right: 10px;
    background: transparent;
    border: none;
    font-size: 1.6rem;
    line-height: 1;
    cursor: pointer;
    color: inherit;
}
.opening-editor-title {
    font-size: 1.15rem;
    margin: 0 0 4px 0;
}
.opening-editor-hint {
    font-size: 0.88rem;
    opacity: 0.75;
    margin: 0 0 12px 0;
}
.opening-editor-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 16px;
    align-items: start;
}
@media (max-width: 760px) {
    .opening-editor-layout { grid-template-columns: 1fr; }
}
.opening-editor-board.play-board { max-width: 100%; }
.opening-editor-comment {
    width: 100%;
    min-height: 56px;
    resize: vertical;
    padding: 6px 8px;
    border: 1px solid rgba(0,0,0,0.2);
    border-radius: 4px;
    font: inherit;
    background: transparent;
    color: inherit;
    box-sizing: border-box;
}
body.dark-mode .opening-editor-comment { border-color: rgba(255,255,255,0.25); }
.opening-editor-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    flex-wrap: wrap;
}
.opening-editor-btn {
    padding: 6px 14px;
    border: 1px solid rgba(0,0,0,0.25);
    border-radius: 4px;
    background: transparent;
    cursor: pointer;
    font: inherit;
    color: inherit;
}
.opening-editor-btn:disabled { opacity: 0.5; cursor: not-allowed; }
body.dark-mode .opening-editor-btn { border-color: rgba(255,255,255,0.3); }
.opening-editor-btn-primary {
    background: #1a7f3a;
    color: #fff;
    border-color: #1a7f3a;
}
.opening-editor-btn-primary:hover { background: #166b30; }
.opening-editor-promotion {
    margin-top: 12px;
    padding: 10px 12px;
    border: 1px dashed rgba(0,0,0,0.25);
    border-radius: 6px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
body.dark-mode .opening-editor-promotion { border-color: rgba(255,255,255,0.3); }
.opening-editor-promotion-text { margin: 0; font-weight: 600; }
.opening-editor-promotion-actions { display: flex; gap: 8px; }
.opening-hand-piece { cursor: pointer; }
.opening-hand-empty { opacity: 0.4; font-size: 0.9rem; padding: 0 4px; }

/* --- Donation: sidebar button, floating pill, Pix modal --- */
.dropbutton-donate {
    background: none;
    border: none;
    font: inherit;
    color: inherit;
    text-align: left;
    cursor: pointer;
    padding: 8px;
    border-radius: 5px;
}
.dropbutton-donate:hover { color: #d33b6b; }

.donate-pill {
    position: fixed;
    right: 18px;
    bottom: 18px;
    z-index: 90;
    display: flex;
    align-items: stretch;
    background-color: #d33b6b;
    color: #fff;
    border-radius: 999px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.28);
    overflow: hidden;
    animation: donate-pop 0.35s ease;
}
@media (max-width: 900px) {
    .donate-pill {
        top: calc(10px + env(safe-area-inset-top, 0px));
        right: 10px;
        bottom: auto;
    }
}
@keyframes donate-pop {
    from { opacity: 0; transform: translateY(12px) scale(0.92); }
    to   { opacity: 1; transform: none; }
}
.donate-pill-main {
    background: none;
    border: none;
    color: inherit;
    cursor: pointer;
    font: inherit;
    font-weight: 600;
    padding: 11px 16px;
    white-space: nowrap;
}
.donate-pill-main:hover { background-color: rgba(255, 255, 255, 0.12); }
.donate-pill-close {
    background: none;
    border: none;
    border-left: 1px solid rgba(255, 255, 255, 0.3);
    color: inherit;
    cursor: pointer;
    display: flex;
    align-items: center;
    padding: 0 10px;
}
.donate-pill-close:hover { background-color: rgba(255, 255, 255, 0.18); }

.donate-dialog {
    width: min(420px, 100%);
    padding: 24px;
    text-align: center;
    align-items: center;
}
.donate-close { position: absolute; top: 10px; right: 10px; }
.donate-title { margin: 4px 0 8px; font-size: 1.3em; }
.donate-why { margin: 0 0 16px; opacity: 0.85; line-height: 1.5; font-size: 0.95em; }
.donate-qr {
    width: 220px;
    height: 220px;
    margin: 0 auto 8px;
    background: #fff;
    border-radius: 10px;
    padding: 8px;
    box-sizing: content-box;
    display: flex;
    align-items: center;
    justify-content: center;
}
.donate-qr:empty { display: none; }
.donate-scan { margin: 0 0 16px; font-size: 0.85em; opacity: 0.7; }
.donate-key-row {
    display: flex;
    align-items: stretch;
    gap: 8px;
    width: 100%;
    margin-bottom: 16px;
}
.donate-key-block {
    flex: 1;
    min-width: 0;
    text-align: left;
    border: 1px solid rgba(0, 0, 0, 0.15);
    border-radius: 8px;
    padding: 8px 12px;
}
body.dark-mode .donate-key-block { border-color: rgba(255, 255, 255, 0.2); }
.donate-key-label { display: block; font-size: 0.7em; text-transform: uppercase; letter-spacing: 0.04em; opacity: 0.6; }
.donate-key {
    display: block;
    font-family: monospace;
    font-size: 0.9em;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.donate-copy {
    background-color: #d33b6b;
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 0 16px;
    font: inherit;
    font-weight: 600;
    cursor: pointer;
    transition: filter 0.15s ease;
}
.donate-copy:hover { filter: brightness(1.08); }
.donate-thanks { margin: 0 0 14px; font-size: 0.9em; opacity: 0.8; }
.donate-dismiss {
    background: none;
    border: none;
    color: inherit;
    opacity: 0.55;
    cursor: pointer;
    font: inherit;
    font-size: 0.85em;
    text-decoration: underline;
}
.donate-dismiss:hover { opacity: 0.85; }

/* Mobile: the modal slides up as a bottom sheet ("slightly different"). */
.donate-modal--mobile { align-items: flex-end; padding: 0; }
.donate-modal--mobile .donate-dialog {
    width: 100%;
    border-radius: 18px 18px 0 0;
    max-height: 92vh;
    animation: donate-sheet-up 0.3s ease;
}
@keyframes donate-sheet-up {
    from { transform: translateY(100%); }
    to   { transform: none; }
}

