/* ベース設定 */
html {
    height: 100%;
    background: #090A0F;
    overflow-x: hidden !important;
}

body {
    background: radial-gradient(ellipse at bottom, #1B2735 0%, #090A0F 100%);
    background-attachment: fixed;
    background-size: cover;
    color: #f0f0f0;
    font-family: "Hiragino Kaku Gothic Pro", "メイリオ", Meiryo, 'Poppins', sans-serif;
    line-height: 1.6;
    min-height: 100vh;
    height: 100%;
    margin: 0;
    position: relative;
    overflow-x: hidden !important;
}

body::before {
    content: '';
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='400' height='400' viewBox='0 0 800 800'%3E%3Cg fill='none' stroke='%23404' stroke-width='1'%3E%3Cpath d='M769 229L1037 260.9M927 880L731 737 520 660 309 538 40 599 295 764 126.5 879.5 40 599-197 493 102 382-31 229 126.5 79.5-69-63'/%3E%3Cpath d='M-31 229L237 261 390 382 603 493 308.5 537.5 101.5 381.5M370 905L295 764'/%3E%3Cpath d='M520 660L578 842 731 737 840 599 603 493 520 660 295 764 309 538 390 382 539 269 769 229 577.5 41.5 370 105 295 -36 126.5 79.5 237 261 102 382 40 599 -69 737 127 880'/%3E%3Cpath d='M520-140L578.5 42.5 731-63M603 493L539 269 237 261 370 105M902 382L539 269M390 382L102 382'/%3E%3Cpath d='M-222 42L126.5 79.5 370 105 539 269 577.5 41.5 927 80 769 229 902 382 603 493 731 737M295-36L577.5 41.5M578 842L295 764M40-201L127 80M102 382L-261 269'/%3E%3C/g%3E%3Cg fill='%23505'%3E%3Ccircle cx='769' cy='229' r='5'/%3E%3Ccircle cx='539' cy='269' r='5'/%3E%3Ccircle cx='603' cy='493' r='5'/%3E%3Ccircle cx='731' cy='737' r='5'/%3E%3Ccircle cx='520' cy='660' r='5'/%3E%3Ccircle cx='309' cy='538' r='5'/%3E%3Ccircle cx='295' cy='764' r='5'/%3E%3Ccircle cx='40' cy='599' r='5'/%3E%3Ccircle cx='102' cy='382' r='5'/%3E%3Ccircle cx='127' cy='80' r='5'/%3E%3Ccircle cx='370' cy='105' r='5'/%3E%3Ccircle cx='578' cy='42' r='5'/%3E%3Ccircle cx='237' cy='261' r='5'/%3E%3Ccircle cx='390' cy='382' r='5'/%3E%3C/g%3E%3C/svg%3E");
    opacity: 0.3;
    z-index: -2 !important;
}

/* パソコン版で背景全面に星を表示するための追加スタイル */
@media (min-width: 769px) {
    html {
        height: 100%;
        background: #090A0F;
        scrollbar-color: #4a5568 #121820;
        scrollbar-width: thin;
    }

    html::-webkit-scrollbar {
        width: 11px;
        height: 11px;
    }

    html::-webkit-scrollbar-track {
        background: #121820;
        border-radius: 6px;
    }

    html::-webkit-scrollbar-thumb {
        background: linear-gradient(180deg, #3d4d62 0%, #2f3a4a 100%);
        border-radius: 6px;
        border: 2px solid #121820;
    }

    html::-webkit-scrollbar-thumb:hover {
        background: linear-gradient(180deg, #55667a 0%, #3d4d62 100%);
    }

    html::-webkit-scrollbar-corner {
        background: #121820;
    }

    body {
        background: radial-gradient(ellipse at bottom, #1B2735 0%, #090A0F 100%);
        background-attachment: scroll;
        background-size: 100% 100%;
        background-repeat: repeat-y;
        min-height: 100vh;
        height: auto;
    }

    body::before {
        position: absolute !important;
        top: 0 !important;
        left: 0 !important;
        width: 100% !important;
        height: 100% !important;
        min-height: 100vh !important;
        background-size: 400px 400px;
        background-repeat: repeat;
    }

    /* 星コンテナをより確実に全面表示 */
    .stars {
        position: absolute !important;
        top: 0 !important;
        left: 0 !important;
        width: 100% !important;
        height: 100% !important;
        min-height: 100vh !important;
        z-index: -1 !important;
        overflow: visible !important;
        pointer-events: none !important;
    }
}

/* Stars animation */
@keyframes fallingStar {
    from {
        transform: translate(0, 0);
    }

    to {
        transform: translate(-2000px, 2000px);
    }
}

@keyframes twinkle {

    0%,
    100% {
        opacity: 0.3;
    }

    50% {
        opacity: 1;
    }
}

.stars {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    z-index: 0 !important;
    overflow: hidden !important;
    pointer-events: none !important;
}

.star {
    position: absolute !important;
    border-radius: 50% !important;
    background-color: #fff !important;
    box-shadow: 0 0 10px rgba(255, 255, 255, 0.8), 0 0 20px rgba(255, 255, 255, 0.5) !important;
    pointer-events: none !important;
    z-index: 1 !important;
    animation: fallingStar linear infinite, twinkle ease-in-out infinite !important;
}

.star.small {
    width: 1px !important;
    height: 1px !important;
    animation-duration: 50s, 3s !important;
}

.star.medium {
    width: 2px !important;
    height: 2px !important;
    animation-duration: 100s, 5s !important;
}

.star.large {
    width: 3px !important;
    height: 3px !important;
    animation-duration: 150s, 7s !important;
}

.shooting-star {
    position: absolute !important;
    width: 100px !important;
    height: 1px !important;
    background: linear-gradient(to right, rgba(255, 255, 255, 0), rgba(255, 255, 255, 1)) !important;
    transform: rotate(135deg) !important;
    animation: shootingStar 5s linear infinite !important;
    opacity: 0 !important;
    pointer-events: none !important;
    z-index: 1 !important;
}

@keyframes shootingStar {
    0% {
        transform: translateX(-100px) translateY(0) rotate(135deg);
        opacity: 0;
    }

    10% {
        opacity: 1;
    }

    20% {
        transform: translateX(calc(100vw + 100px)) translateY(calc(100vh + 100px)) rotate(135deg);
        opacity: 0;
    }

    100% {
        opacity: 0;
    }
}

/* 共通スタイル */
a {
    color: #58a9ef;
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 10px;
    z-index: 1;
    overflow-x: hidden;
    box-sizing: border-box;
    width: 100%;
}

main {
    padding-bottom: 20px;
    margin-top: 60px;
}

.boardWrap {
    background-color: rgba(10, 25, 41, 0.6);
    border-radius: 5px;
    padding: 20px;
    margin-bottom: 10px;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    position: relative;
    overflow: hidden;
    box-sizing: border-box;
    width: 100%;
    max-width: 100%;
}

.boardWrap::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 5px;
    padding: 1px;
    background: linear-gradient(45deg, rgba(153, 130, 242, 0.3), rgba(79, 23, 135, 0.3), rgba(153, 130, 242, 0.3));
    -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    pointer-events: none;
}

.boardHeader {
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.boardHeader h1 {
    font-size: 1.5rem;
    margin: 10px 0;
    color: #fff;
}

.boardDescription,
.categoryDescription {
    color: #aaa;
    margin-bottom: 15px;
}

/* カテゴリー一覧 */
.categoryList {
    display: grid;
    gap: 15px;
}

.categoryItemLink {
    text-decoration: none;
    color: inherit;
    cursor: pointer;
    display: block;
}

.categoryItem {
    background-color: rgba(20, 20, 20, 0.7);
    border-radius: 5px;
    padding: 15px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    transition: all 0.2s ease;
}

.categoryItemLink:hover .categoryItem {
    border-color: rgba(153, 130, 242, 0.5);
    background-color: rgba(30, 30, 30, 0.7);
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
}

.categoryInfo h2 {
    font-size: 1.3rem;
    margin: 0 0 10px;
    color: #58a9ef;
}

.categoryStats {
    color: #999;
    font-size: 0.9rem;
    margin-top: 10px;
}

/* スレッド一覧 */
.threadList {
    display: grid;
    gap: 10px;
}

.threadItemLink {
    text-decoration: none;
    color: inherit;
    cursor: pointer;
    display: block;
}

.threadItem {
    background-color: rgba(20, 20, 20, 0.7);
    border-radius: 5px;
    padding: 15px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    transition: all 0.2s ease;
}

.threadItemLink:hover .threadItem {
    border-color: rgba(153, 130, 242, 0.5);
    background-color: rgba(30, 30, 30, 0.7);
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
}

.threadItem.sticky {
    border-left: 3px solid #9982F2;
}

.stickyLabel,
.lockedLabel {
    display: inline-block;
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 0.8rem;
    margin-right: 5px;
}

.stickyLabel {
    background-color: #9982F2;
    color: white;
}

.lockedLabel {
    background-color: #7f8c8d;
    color: white;
}

.threadInfo h2 {
    font-size: 1.2rem;
    margin: 0 0 10px;
    color: #58a9ef;
}

.threadMeta {
    color: #999;
    font-size: 0.9rem;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

/* 投稿一覧 */
.postList {
    display: grid;
    gap: 15px;
    margin-bottom: 20px;
}

.postItem {
    background-color: rgba(20, 20, 20, 0.7);
    border-radius: 5px;
    padding: 15px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.postHeader {
    display: flex;
    align-items: center;
    margin-bottom: 10px;
    padding-bottom: 5px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.postNumber {
    background-color: #333;
    color: white;
    border-radius: 3px;
    padding: 2px 8px;
    font-size: 0.9rem;
    margin-right: 10px;
}

.posterInfo {
    display: flex;
    gap: 10px;
    align-items: center;
}

.posterName {
    font-weight: bold;
    color: #58a9ef;
}

.postDate {
    color: #999;
    font-size: 0.9rem;
}

.postContent {
    line-height: 1.6;
    word-break: break-all;
    overflow-wrap: break-word;
    max-width: 100%;
    overflow-x: hidden;
}

.replyToPost {
    margin-top: 10px;
    padding: 10px;
    background-color: rgba(40, 40, 40, 0.7);
    border-radius: 5px;
    border-left: 3px solid #58a9ef;
}

.replyHeader {
    font-size: 0.9rem;
    color: #999;
    margin-bottom: 5px;
}

.postActions {
    margin-top: 10px;
    display: flex;
    gap: 10px;
}

/* フォーム */
.threadForm,
.postForm {
    background-color: rgba(20, 20, 20, 0.7);
    border-radius: 5px;
    padding: 20px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    margin-top: 20px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

.formGroup {
    margin-bottom: 15px;
}

.formGroup label {
    display: block;
    margin-bottom: 5px;
    font-weight: bold;
}

.formGroup input[type="text"],
.formGroup textarea {
    width: 100%;
    padding: 10px;
    border-radius: 5px;
    border: 1px solid #444;
    background-color: rgba(10, 10, 10, 0.7);
    color: #f0f0f0;
    font-family: inherit;
    font-size: 16px;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    touch-action: manipulation;
}

.formGroup input[type="text"]:focus,
.formGroup textarea:focus {
    outline: none;
    border-color: #9982F2;
    box-shadow: 0 0 5px rgba(153, 130, 242, 0.5);
    font-size: 16px;
    transform: none;
    -webkit-transform: none;
}

.formGroup small {
    display: block;
    color: #999;
    margin-top: 5px;
    font-size: 0.9rem;
}

.formActions {
    display: flex;
    gap: 10px;
    margin-top: 15px;
}

button.btn-primary,
a.btn-primary {
    display: inline-block;
    background-color: #9982F2;
    color: white;
    border: none;
    border-radius: 5px;
    padding: 8px 16px;
    cursor: pointer;
    font-weight: bold;
    transition: all 0.2s ease;
    box-shadow: 0 0 10px rgba(153, 130, 242, 0.3);
}

button.btn-primary:hover,
a.btn-primary:hover {
    background-color: #7B5FE9;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(153, 130, 242, 0.5);
    text-decoration: none;
}

button.btn-secondary,
a.btn-secondary {
    display: inline-block;
    background-color: #333;
    color: white;
    border: none;
    border-radius: 5px;
    padding: 8px 16px;
    cursor: pointer;
    font-weight: bold;
    transition: background-color 0.2s ease;
}

button.btn-secondary:hover,
a.btn-secondary:hover {
    background-color: #444;
    text-decoration: none;
}

.replyButton {
    background-color: #333;
    color: white;
    border: none;
    border-radius: 3px;
    padding: 4px 8px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.replyButton:hover {
    background-color: #9982F2;
}

.replyForm {
    background-color: rgba(30, 30, 30, 0.7);
    border-radius: 5px;
    padding: 15px;
    margin-top: 10px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
    -webkit-text-size-adjust: 100%;
}

.quotePost {
    background-color: rgba(40, 40, 40, 0.7);
    padding: 10px;
    border-radius: 3px;
    margin-bottom: 10px;
    border-left: 3px solid #58a9ef;
    font-size: 16px;
}

.quoteHeader {
    font-size: 0.9rem;
    color: #999;
    margin-bottom: 5px;
}

/* アラート */
.alert {
    padding: 15px;
    border-radius: 5px;
    margin-bottom: 15px;
}

.alert-danger {
    background-color: rgba(231, 76, 60, 0.2);
    border: 1px solid #e74c3c;
    color: #e74c3c;
}

.alert ul {
    margin: 0;
    padding-left: 20px;
}

/* ページネーション */
.pagination {
    margin-top: 20px;
    margin-bottom: 10px;
    display: flex;
    justify-content: center;
}

.pagination nav {
    display: flex;
    justify-content: center;
}

.pagination .flex.justify-between {
    display: none;
}

.pagination .relative.inline-flex {
    margin: 0 2px;
}

.pagination span[aria-current] span {
    background-color: #9982F2 !important;
    color: white !important;
    border-color: #9982F2 !important;
}

.pagination a,
.pagination span {
    display: inline-block;
    padding: 5px 10px;
    border-radius: 3px;
    background-color: rgba(30, 30, 30, 0.7);
    color: #f0f0f0;
    border: 1px solid rgba(255, 255, 255, 0.1);
    transition: all 0.2s ease;
}

.pagination a:hover {
    background-color: rgba(50, 50, 50, 0.7);
    border-color: rgba(153, 130, 242, 0.5);
    text-decoration: none;
}

/* ページネーション情報 */
.paginationInfo {
    margin-top: 10px;
    font-size: 0.9rem;
    color: #aaa;
    background-color: rgba(30, 30, 30, 0.5);
    padding: 5px 10px;
    border-radius: 3px;
    display: inline-block;
}

.maxPostsWarning {
    color: #e74c3c;
    font-weight: bold;
    margin-left: 5px;
}

/* ============================================================
   Safari/iOS 背景対策・モバイル共通スタイル
   （各 board ビューから統合）
   ============================================================ */

*,
*::before,
*::after {
    -webkit-tap-highlight-color: transparent;
}

/* Safari 白画面対策 - 全デバイス対応 */
html, body {
    background: radial-gradient(ellipse at bottom, #1B2735 0%, #090A0F 100%) !important;
    background-color: #090A0F !important;
    background-attachment: fixed !important;
    background-repeat: no-repeat !important;
    background-size: cover !important;
    min-height: 100vh !important;
    min-height: -webkit-fill-available !important;
    height: 100% !important;
    width: 100% !important;
}

/* iOS Safari 用追加対策 */
@supports (-webkit-touch-callout: none) {
    html, body {
        min-height: -webkit-fill-available !important;
        background-attachment: scroll !important;
    }
}

/* モバイル：オーバースクロール防止（上下の白い部分対策） */
@media (max-width: 768px) {
    html {
        overscroll-behavior: none !important;
        -webkit-overscroll-behavior: none !important;
        overscroll-behavior-y: none !important;
        -webkit-overscroll-behavior-y: none !important;
        -webkit-overflow-scrolling: touch !important;
        overflow-x: hidden !important;
        background-attachment: scroll !important;
        background-repeat: no-repeat !important;
        background-size: 100% 100% !important;
        background-position: center center !important;
    }

    body {
        overscroll-behavior: none !important;
        -webkit-overscroll-behavior: none !important;
        overscroll-behavior-y: none !important;
        -webkit-overscroll-behavior-y: none !important;
        -webkit-overflow-scrolling: touch !important;
        overflow-x: hidden !important;
        background-attachment: scroll !important;
        background-repeat: no-repeat !important;
        background-size: 100% 100% !important;
        background-position: center center !important;
        transform: translateZ(0) !important;
        backface-visibility: hidden !important;
    }

    .container {
        overscroll-behavior: none !important;
        -webkit-overscroll-behavior: none !important;
        overflow-x: hidden !important;
    }

    main {
        overscroll-behavior: none !important;
        -webkit-overscroll-behavior: none !important;
        overflow-x: hidden !important;
    }

    .gMenu {
        background: #000000 !important;
        -webkit-tap-highlight-color: transparent !important;
    }
}

/* gmenu 分の余白確保 */
body.mobile-optimized {
    padding-bottom: calc(64px + var(--safe-area-bottom, 0px) + 20px);
}

.mobile-optimized .container {
    min-height: calc(100vh - 64px - var(--safe-area-bottom, 0px) - 20px);
    padding-bottom: 20px;
}

.mobile-optimized main {
    padding-bottom: 20px;
}

/* アドレスバーが隠れた時の調整 */
body.mobile-optimized.address-bar-hidden {
    padding-bottom: calc(64px + var(--safe-area-bottom, 0px) + 20px - var(--address-bar-height, 0px));
}

body.mobile-optimized.address-bar-hidden .container {
    min-height: calc(100vh - 64px - var(--safe-area-bottom, 0px) - 20px + var(--address-bar-height, 0px));
}

/* モバイルデバイス向けの調整 */
@media (max-width: 767px) {

    /* Safari特有の問題を修正 */
    html {
        overflow-x: hidden !important;
        -webkit-overflow-scrolling: touch !important;
        -webkit-text-size-adjust: 100% !important;
    }

    body {
        overflow-x: hidden !important;
        -webkit-overflow-scrolling: touch !important;
        -webkit-text-size-adjust: 100% !important;
        position: relative !important;
        width: 100% !important;
        max-width: 100% !important;
    }

    /* 入力フィールドの拡大防止 */
    input,
    textarea,
    select {
        font-size: 16px !important;
        max-height: none !important;
        -webkit-text-size-adjust: 100%;
        -webkit-appearance: none !important;
    }

    /* タップハイライトの無効化 */
    * {
        -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
    }

    /* ピンチズームの制御 */
    body {
        touch-action: pan-x pan-y;
    }

    /* 入力フィールドのフォーカス防止 */
    input:focus,
    textarea:focus,
    select:focus {
        transform: none !important;
        -webkit-transform: none !important;
    }

    /* フォーカス時にgmenuを非表示にする */
    .hide-gmenu .gMenu {
        display: none !important;
    }

    /* 掲示板でもランキングと同じgMenuスタイルを使用 */
    /* style.cssの.gMenuスタイルがベースになります */

    /* コンテナの調整 */
    .container {
        width: 100% !important;
        max-width: 100% !important;
        overflow-x: hidden !important;
        position: relative !important;
    }

    .boardWrap {
        width: 100% !important;
        max-width: 100% !important;
        overflow-x: hidden !important;
        box-sizing: border-box !important;
    }

    /* モバイルでの余分な灰色の線を修正 */
    .boardWrap {
        border-bottom: none !important;
        padding-bottom: 20px;
        border-color: transparent;
        /* モバイルでのボーダーを透明に */
        box-shadow: none;
        /* モバイルでの余計な影を削除 */
    }

    /* gmenu用の下部スペースを確保（iPhoneのSafe Area対応） */
    main {
        padding-bottom: 80px !important;
        padding-bottom: calc(64px + env(safe-area-inset-bottom, 20px)) !important;
    }

    .pagination {
        border: none !important;
        background: none !important;
    }

    .postList {
        margin-bottom: 15px;
    }

    .postForm {
        margin-top: 25px;
        border-top: none !important;
        border-color: rgba(255, 255, 255, 0.05);
        /* 薄いボーダーに */
        box-shadow: none;
        /* 余計な影を削除 */
    }

    /* スレッド項目のスタイル調整 */
    .threadItem {
        border-color: rgba(255, 255, 255, 0.05);
        /* 薄いボーダーに */
    }

    /* 投稿項目のスタイル調整 */
    .postItem {
        border-color: rgba(255, 255, 255, 0.05);
        /* 薄いボーダーに */
    }

    /* コンテナ間のギャップを調整 */
    .container {
        padding: 5px;
        /* パディングを少なく */
    }

    main {
        padding-bottom: 20px;
        /* 下部のパディングを最小限に */
    }

    /* ページネーション情報の調整 */
    .paginationInfo {
        background-color: transparent;
        /* 背景を透明に */
        border: none;
        /* ボーダーを削除 */
    }
}

/* PC表示時のレイアウト調整（gMenuと整合させる） */
@media screen and (min-width: 769px) {

    /* gMenuが左サイドバーになるため、コンテンツを右に寄せる */
    .container {
        margin-left: 240px !important;
        margin-right: 0 !important;
        width: calc(100% - 240px) !important;
        max-width: calc(100% - 240px) !important;
        padding: 20px !important;
    }

    main {
        margin-top: 0;
    }

    .boardWrap {
        max-width: 1000px;
        margin: 0 auto;
    }
}