/* style.css (Final Production Version) */

/* 基本的なリセットとフォント設定 */
html,
body {
    width: 100%;
    max-width: 100vw;
    overflow-x: hidden;
    /* 横スクロール防止 */
}

body {
    margin: 0;
    padding: 0;
    font-family: 'Noto Sans JP', sans-serif;
    background-color: #000;
    /* シンプルな黒背景に変更 */
    color: #f5f5f5;
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
    box-sizing: border-box;
}

/* コンテナ: シンプルにして余白/丸め/影を削除 */
.container {
    width: 100%;
    max-width: none;
    margin: 0;
    padding: 0;
    background-color: transparent;
    border-radius: 0;
    box-shadow: none;
    text-align: left;
}


/* Header */
.header h1 {
    font-size: 1.8em;
    margin-bottom: 16px;
    color: #ffffff;
    word-break: keep-all;
    font-weight: 700;
}

/* Slot list container with padding for breathing room */
#slotListContainer {
    padding: 8px;
    width: calc(100% - 16px);
}

/* アートワークコンテナ - スマホ専用サイズ */
.artwork-container {
    width: 100%;
    max-width: 240px;
    /* 実物サイズ（4cm）に近い */
    margin: 0 auto 30px;
    position: relative;
    aspect-ratio: 1 / 1;
    /* background-color: #f0f0f0; */
    /* background-color: #2c2c2c; */
    background-color: #1a1a1a;
    border-radius: 8px;
    overflow: hidden;
}

/* プレースホルダー */
.artwork-placeholder {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    /* background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); */
    /* background-color: #2c2c2c; */
    background-color: #1a1a1a;
    opacity: 1;
    transition: opacity 0.3s ease;
}

.artwork-placeholder.hidden {
    opacity: 0;
    pointer-events: none;
}

/* Loading テキスト */
.loading-text {
    font-size: 14px;
    font-weight: 600;
    color: #ffffff;
    text-transform: uppercase;
    letter-spacing: 2px;
    animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {

    0%,
    100% {
        opacity: 0.6;
    }

    50% {
        opacity: 1;
    }
}

/* メインアートワーク */
.main-artwork {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
    opacity: 0;
    transition: opacity 0.5s ease;
}

.main-artwork.loaded {
    opacity: 1;
}

/* スロット一覧 */
.slot-list {
    display: flex;
    flex-direction: column;
    gap: 18px;
    margin-bottom: 30px;
}

.slot-item {
    display: flex;
    align-items: center;
    background: #232323;
    border-radius: 8px;
    padding: 10px 12px;
    gap: 16px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.slot-label {
    font-weight: 700;
    font-size: 1.1em;
    color: #fff;
    min-width: 60px;
}

.slot-thumb {
    width: 60px;
    height: 60px;
    object-fit: cover;
    border-radius: 6px;
    border: 1px solid #444;
    background: #111;
}

.slot-thumb-prev {
    width: 40px;
    height: 40px;
    object-fit: cover;
    border-radius: 4px;
    border: 1px dashed #888;
    background: #222;
    margin-left: 8px;
}

.slot-empty {
    color: #aaa;
    font-size: 1em;
    margin-right: 10px;
}

.slot-btn {
    background: #1DB954;
    color: #fff;
    border: none;
    border-radius: 6px;
    padding: 8px 18px;
    font-size: 1em;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

.slot-btn:hover {
    background: #159c43;
}

.group-footer {
    margin-top: 30px;
    text-align: center;
}

/* 設定変更セクション */
.settings-section {
    margin-top: 30px;
    border-top: 1px solid #444444;
    padding-top: 20px;
}

.settings-button {
    background-color: #5a5a5a;
    color: white;
    border: none;
    border-radius: 8px;
    padding: 10px 20px;
    cursor: pointer;
    font-size: 0.95em;
    transition: background-color 0.2s ease;
}

.settings-button:hover {
    background-color: #6a6a6a;
}

/* フッター */
.footer {
    margin-top: 40px;
    font-size: 0.8em;
    color: #888888;
}

.footer a {
    color: #888888;
    text-decoration: none;
}

.footer a:hover {
    text-decoration: underline;
}

/* エラー表示用コンテナ */
.error-display-container {
    display: none;
    /* 初期状態では完全に非表示 */
}

.error-display-container.active {
    display: flex;
    /* エラー時に表示 */
    flex-direction: column;
    justify-content: space-between;
    padding: 20px;
    text-align: center;
    background-color: #2c2c2c;
    color: #f5f5f5;
    border-radius: 12px;
    box-shadow: 0 4px 25px rgba(0, 0, 0, 0.4);
    margin: 20px auto;
    max-width: 600px;
    min-height: 300px;
}

.error-content-wrapper {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.error-title {
    font-size: 1.8em;
    margin-bottom: 8px;
    color: #ff0000;
    word-break: keep-all;
}

.error-message-text,
.error-suggestion-text {
    font-size: 1.1em;
    color: #cccccc;
    margin-bottom: 10px;
}

.footer-link {
    color: #888888;
    text-decoration: none;
}

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

/* レスポンシブ対応 */
@media (max-width: 480px) {

    .container,
    .error-display-container.active {
        margin: 0;
        padding: 0;
        max-width: 100vw;
        box-sizing: border-box;
        overflow-x: hidden;
    }

    .header h1,
    .error-title {
        font-size: 1.5em;
    }

    .slot-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
        padding: 10px 6px;
    }

    .slot-thumb {
        width: 48px;
        height: 48px;
    }

    .slot-thumb-prev {
        width: 32px;
        height: 32px;
    }

    .slot-label {
        min-width: 0;
    }

    .slot-btn {
        width: 100%;
        padding: 8px 0;
    }
}

/* style.css の末尾に追記 */

/* システムメッセージ用コンテナ (エラーコンテナを流用し、スタイルを上書き) */
.error-display-container.system-message {
    position: fixed;
    /* 画面に固定 */
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    width: 90%;
    max-width: 500px;
    /* メッセージの最大幅 */
    z-index: 1000;
    background-color: #1DB954;
    /* 成功を示す緑色 */
    color: #ffffff;
    padding: 15px;
    border-radius: 8px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    min-height: auto;
    /* 高さは自動 */
    display: block;
    text-align: center;
}

.system-message-content-wrapper .system-title {
    font-size: 1.2em;
    font-weight: bold;
    margin: 0 0 5px 0;
}

.system-message-content-wrapper .system-message-text {
    font-size: 1em;
    margin: 0;
}

/* 未紐付け時に表示する大きめ入力 */
.unlinked-group-id-input {
    font-size: 30px;
    line-height: 1.15;
    font-weight: 600;
    padding: 6px 14px;
    border: 2px solid #444;
    border-radius: 10px;
    background: #fff;
    color: #222;
    max-width: 100%;
    box-shadow: 0 2px 4px rgba(0, 0, 0, .08);
    letter-spacing: .5px;
}

.unlinked-group-id-input:focus {
    outline: 3px solid #3388ff33;
    border-color: #2266cc;
}

/* Inventory display (Big vertical slot + small row) */
.inventory-display {
    display: flex;
    flex-direction: column;
    gap: 28px;
    /* 大きめに間隔を空けて、ステッカーが重ならないように */
    align-items: stretch;
}

.big-slot {
    width: 100%;
    aspect-ratio: 3 / 4;
    /* 縦長に表示 */
    position: relative;
    overflow: hidden;
    /* Prevent overflow and horizontal scrolling */
    border-radius: 0;
    /* simplify corners */
    background: #111;
}

.big-slot .sticker-overlay {
    position: absolute;
    top: 0;
    /* スロットの枠の中に収める */
    left: 0;
    /* スロットの左端に合わせる */
    width: 33%;
    /* コンパクトにして目立つように */
    z-index: 80;
    /* 前面に出す */
    transform: translateX(0);
    opacity: 1;
    transition: opacity 1.5s ease;
}

.big-slot .sticker-overlay.bottom-right {
    top: auto;
    bottom: 0;
    /* 枠にぴったり合わせる */
    left: auto;
    right: 0;
    /* 枠にぴったり合わせる */
    opacity: 0;
    /* 最初は非表示 */
}

.inventory-display.sticker-bottom .big-slot .sticker-overlay.top-left {
    opacity: 0;
}

.inventory-display.sticker-bottom .big-slot .sticker-overlay.bottom-right {
    opacity: 1;
}

/* Sequential hide classes: first hide (both hidden), then show next */
.inventory-display.sticker-hide-top .big-slot .sticker-overlay.top-left,
.inventory-display.sticker-hide-top .small-slot .small-sticker.top-left {
    opacity: 0;
    /* fade out top */
}

/* ensure bottom stays hidden during hide-top phase */
.inventory-display.sticker-hide-top .big-slot .sticker-overlay.bottom-right,
.inventory-display.sticker-hide-top .small-slot .small-sticker.bottom-right {
    opacity: 0;
}

.inventory-display.sticker-hide-bottom .big-slot .sticker-overlay.bottom-right,
.inventory-display.sticker-hide-bottom .small-slot .small-sticker.bottom-right {
    opacity: 0;
    /* fade out bottom */
}

/* ensure top stays hidden during hide-bottom phase */
.inventory-display.sticker-hide-bottom .big-slot .sticker-overlay.top-left,
.inventory-display.sticker-hide-bottom .small-slot .small-sticker.top-left {
    opacity: 0;
}

/* Upload button styling */
.upload-button-container {
    width: 100%;
    margin-top: 0;
}

.upload-image-btn {
    width: 100%;
    padding: 12px 16px;
    background-color: #1DB954;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1em;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: background-color 0.2s ease;
}

.upload-image-btn:hover {
    background-color: #1ed760;
}

.upload-image-btn i {
    font-size: 1.1em;
}

/* Upload button footer (landscape only) */
#uploadButtonFooter {
    width: 100%;
    padding: 0 8px;
    margin-bottom: 12px;
    box-sizing: border-box;
}

#uploadButtonFooter .upload-button-container {
    width: 100%;
}

body.landscape #uploadButtonFooter {
    display: flex !important;
}

body.landscape #uploadButtonFooter .upload-button-container {
    width: 49%;
    max-width: 49%;
}

/* main を真四角にする */
.big-slot .main-artwork,
.main-artwork {
    border-radius: 0 !important;
}

.big-slot .sticker-overlay img {
    width: 100%;
    height: auto;
    display: block;
    border-radius: 0 !important;
    /* 角を丸めない */
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.45);
}

.big-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.25s ease;
}

.rotate-landscape {
    transform: rotate(90deg) scale(1.1);
    object-fit: cover;
}

.small-row {
    display: flex;
    gap: 8px;
    align-items: flex-start;
    /* 上のはみ出しに合わせる */
}

/* 10枚パック用グリッドレイアウト */
.small-grid {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}

.small-slot {
    flex: 1 1 0;
    position: relative;
    overflow: visible;
    /* ステッカーが上にはみ出すので visible に */
    border-radius: 8px;
    background: #121212;
    aspect-ratio: 3 / 4;
    /* 縦長に統一 */
    min-height: 120px;
    /* フォールバック */
    display: flex;
    align-items: center;
    justify-content: center;
}

.small-thumb,
.big-image {
    transform-origin: center center;
}

.small-sticker {
    position: absolute;
    top: -55%;
    /* より上にはみ出す */
    left: 6px;
    /* 左寄せにして上部がはみ出す */
    width: 50%;
    /* 指示どおり50% */
    z-index: 70;
    /* 大きめにして常に見えるように */
    transform: translateY(0);
    border: 2px solid rgba(255, 255, 255, 0.06);
}

.small-sticker img {
    width: 100%;
    height: auto;
    display: block;
    border-radius: 0 !important;
    /* 真四角 */
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}

.small-slot .small-sticker {
    position: absolute;
    top: 0;
    /* スロット内に収める（はみ出さない） */
    left: 0;
    /* 左にぴったり合わせる */
    width: 40%;
    /* 小さめにして40% */
    z-index: 75;
    opacity: 1;
    transition: opacity 1.5s ease;
}

.small-slot .small-sticker.bottom-right {
    top: auto;
    bottom: 0;
    /* 枠にぴったり合わせる */
    left: auto;
    right: 0;
    /* 枠にぴったり合わせる */
    opacity: 0;
    /* 初期は非表示 */
}

.inventory-display.sticker-bottom .small-slot .small-sticker.top-left {
    opacity: 0;
}

.inventory-display.sticker-bottom .small-slot .small-sticker.bottom-right {
    opacity: 1;
}

.small-thumb {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.empty-slot {
    display: flex;
    align-items: center;
    justify-content: center;
    color: #bbb;
}

.plus-btn {
    background: rgba(0, 0, 0, 0.5);
    color: #fff;
    border: 1px dashed #666;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    font-size: 28px;
    cursor: pointer;
}

.promo-section {
    width: calc(100% - 36px);
    max-width: 100%;
    margin: 20px auto;
    padding: 18px;
    background: linear-gradient(180deg, #232323, #1a1a1a);
    border-radius: 12px;
    text-align: center;
    color: #fff;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4);
}

.promo-section .promo-link {
    display: inline-block;
    margin-top: 10px;
    background: #1DB954;
    color: #fff;
    padding: 10px 16px;
    border-radius: 8px;
    text-decoration: none;
}

@media (max-width: 480px) {
    .big-slot {
        aspect-ratio: 3 / 4;
    }

    .big-slot .sticker-overlay {
        width: 34%;
    }
}

/* Landscape layout: 左50%ビッグスロット、右50%にスモールグリッド */
body.landscape .inventory-display {
    display: flex;
    flex-direction: row;
    gap: 2%;
    padding: 0;
    align-items: stretch;
    height: auto;
}

body.landscape .big-slot {
    flex: 0 0 49% !important;
    width: 49% !important;
    aspect-ratio: 3 / 4;
}

/* 右側コンテナ: 49%幅で内部に3×3グリッド */
body.landscape .small-grid {
    flex: 0 0 49% !important;
    width: 49% !important;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(3, 1fr);
    gap: 8px;
    align-content: stretch;
}

body.landscape .small-grid .small-slot {
    aspect-ratio: 3 / 4;
    width: 100%;
    height: auto;
}

/* 横向き時、プロモはフルWidth */
body.landscape .promo-section {
    width: 100%;
    max-width: 100%;
    margin: 0 auto;
    padding: 18px 0;
}

/* お試しセット用スモールロー（横向き時、右50%に3×3グリッド） */
body.landscape .small-row {
    flex: 0 0 49% !important;
    width: 49% !important;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(1, 1fr);
    gap: 8px;
    align-content: stretch;
}

body.landscape .small-row .small-slot {
    aspect-ratio: 3 / 4;
    width: 100%;
    height: auto;
}

/* In landscape place stickers at corners without rotation */
body.landscape .big-slot .sticker-overlay.top-left {
    top: 0;
    left: 0;
    width: 34% !important;
}

body.landscape .big-slot .sticker-overlay.bottom-right {
    bottom: 0;
    right: 0;
    width: 34% !important;
}

body.landscape .small-slot .small-sticker.top-left {
    top: 0;
    left: 0;
    width: 34% !important;
}

body.landscape .small-slot .small-sticker.bottom-right {
    bottom: 0;
    right: 0;
    width: 34% !important;
}

/* Ensure internal slot images fill their slot and do not shrink */
body.landscape .big-image,
body.landscape .small-thumb {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transform: none !important;
}

/* Do NOT rotate sticker images in landscape; keep orientation consistent */
body.landscape .sticker-overlay img,
body.landscape .small-sticker img {
    transform: none !important;
    -webkit-transform: none !important;
    width: 100%;
    /* fill the sticker container */
    height: auto;
    display: block;
}

/* ensure promo sits below right column */
body.landscape .group-footer {
    margin-top: 12px;
}

/* portrait padding: add some breathing room when not landscape */
body:not(.landscape) .container {
    padding: 12px;
    /* add small padding on portrait to avoid touching edges */
}

/* center footer text */
.footer {
    text-align: center;
}

/* Landscape grid: main + sub + sub in one row, each 1/3 width; overflow handled */
body.landscape .big-slot,
body.landscape .small-slot,
body.landscape .empty-slot {
    aspect-ratio: 3 / 4;
    width: 100% !important;
    height: auto !important;
    overflow: hidden !important;
}

/* Ensure images fully fill slots */
body.landscape .big-slot .big-image,
body.landscape .small-slot .small-thumb,
body.landscape .empty-slot {
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important;
    display: block !important;
    position: relative !important;
}

/* Stickers scaled down in landscape (half of portrait sizes) and anchored to corners */
body.landscape .big-slot .sticker-overlay.top-left {
    top: 0;
    left: 0;
    width: 34% !important;
}

body.landscape .big-slot .sticker-overlay.bottom-right {
    bottom: 0;
    right: 0;
    width: 34% !important;
}

body.landscape .small-slot .small-sticker.top-left {
    top: 0;
    left: 0;
    width: 34% !important;
}

body.landscape .small-slot .small-sticker.bottom-right {
    bottom: 0;
    right: 0;
    width: 34% !important;
}

/* Do NOT force top-left opacity in landscape; allow JS swap logic to control visibility */

/* Add breathing room for landscape so images don't touch the screen edge */
body.landscape .container {
    padding: 0;
}

/* Modal styling for image expansion */
.image-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-content {
    position: relative;
    width: 90%;
    max-width: 400px;
    aspect-ratio: 3 / 4;
    background-color: #1a1a1a;
    border-radius: 8px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

#modalImage {
    flex: 1;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.modal-close-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    background-color: rgba(0, 0, 0, 0.5);
    color: white;
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    font-size: 1.5em;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1001;
}

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

.modal-visibility-btn {
    position: absolute;
    bottom: 16px;
    left: 50%;
    transform: translateX(-50%);
    background-color: rgba(0, 0, 0, 0.6);
    color: white;
    border: 1px solid #666;
    padding: 10px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.95em;
    font-weight: 500;
    transition: background-color 0.2s ease;
}

.modal-visibility-btn:hover {
    background-color: rgba(0, 0, 0, 0.8);
}

/* Small slot visibility styling for hidden items */
.small-slot.slot-hidden {
    opacity: 0.15;
}

/* Image Modal Styling */
#imageModal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

#imageModal.show {
    display: flex;
}

.modal-content {
    position: relative;
    width: 90vw;
    height: 90vh;
    max-width: 100%;
    max-height: 100%;
    background: #000;
    border-radius: 8px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

#modalImage {
    max-width: 90%;
    max-height: 85%;
    object-fit: contain;
}

/* Modal Sticker Overlays */
.modal-sticker {
    position: absolute;
    width: 34%;
    z-index: 1001;
    opacity: 1;
    transition: opacity 1.5s ease;
}

.modal-sticker.top-left {
    top: 0;
    left: 0;
}

.modal-sticker.bottom-right {
    bottom: 0;
    right: 0;
}

body.landscape .modal-sticker {
    width: 20%;
}

.modal-sticker img {
    width: 100%;
    height: auto;
    display: block;
    border-radius: 0;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.45);
}

.modal-close-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    border: none;
    font-size: 24px;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    z-index: 1001;
    transition: background 0.2s ease;
}

.modal-close-btn:hover {
    background: rgba(0, 0, 0, 0.9);
}

.modal-visibility-btn {
    position: absolute;
    bottom: 12px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.7);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9em;
    transition: background 0.2s ease;
    z-index: 1001;
}

.modal-visibility-btn:hover {
    background: rgba(0, 0, 0, 0.9);
}

/* Hide the + button in landscape in the small-row (4th slot will be pushed to next row) */
body.landscape .small-row .empty-slot .plus-btn {
    display: none !important;
}

/* Auto-wrap: any fourth slot (+) will go to second row automatically using grid */