/* ======================================================
   TORAYA Standard Tribal Simulator — Styles
   ====================================================== */

.ts-root {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;
    color: #1a1a1a;
    max-width: 560px;
    margin: 0 auto;
    padding: 0;
    box-sizing: border-box;
}

/* ── Scroll wrapper（カスタマイズ横スクロールエリア） ── */
.ts-scroll-wrapper {
    position: relative;
    overflow: hidden;
    border-bottom: 1px solid #ebebeb;
}

/* ── モバイルオプションエリア（プレビュー下） ─────── */
.ts-mobile-opts-wrapper {
    position: relative;
    overflow: hidden;
    border-top: 1px solid #ebebeb;
    display: block;
}

.ts-cards-row {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding: 12px 16px 14px;
    align-items: stretch;
}

.ts-cards-row::-webkit-scrollbar { display: none; }

/* ── Compact Card ─────────────────────────────────────── */
.ts-card {
    flex-shrink: 0;
    width: 148px;
    background: #fafafa;
    border: 1px solid #e8e8e8;
    border-radius: 8px;
    padding: 10px 12px 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    box-sizing: border-box;
}

.ts-card-label {
    font-size: 10px;
    font-weight: 700;
    color: #888;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ts-card .ts-select {
    width: 100%;
    padding: 7px 26px 7px 9px;
    font-size: 12px;
    background-size: 10px 7px;
    background-position: right 9px center;
}

.ts-card-input {
    width: 100%;
    padding: 7px 8px;
    border: 2px solid #ddd;
    border-radius: 6px;
    font-size: 13px;
    box-sizing: border-box;
    outline: none;
    transition: border-color 0.12s;
    color: #1a1a1a;
}

.ts-card-input:focus { border-color: #1a1a1a; }

.ts-card .ts-toggle-label { margin-top: 2px; }

/* ── 右矢印インジケーター ────────────────────────────── */
.ts-scroll-arrow {
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    width: 56px;
    background: linear-gradient(to right, transparent, rgba(255,255,255,0.97));
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding-right: 10px;
    pointer-events: none;
    font-size: 26px;
    color: #888;
    transition: opacity 0.25s;
    line-height: 1;
    user-select: none;
}

.ts-scroll-arrow--hidden { opacity: 0; }

/* ── Preview area ─────────────────────────────────────── */
.ts-preview-area {
    padding: 16px 16px 0;
}

/* ── Tabs ────────────────────────────────────────────── */
.ts-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
}

.ts-tab {
    flex: 1;
    padding: 11px 8px;
    background: #ebebeb;
    border: none;
    cursor: pointer;
    font-size: 14px;
    font-weight: 700;
    letter-spacing: 0.06em;
    border-radius: 6px;
    transition: background 0.18s, color 0.18s;
}

.ts-tab:hover { background: #d8d8d8; }

.ts-tab--active {
    background: #1a1a1a;
    color: #fff;
}

/* ── Canvas ──────────────────────────────────────────── */
.ts-canvas-wrap {
    position: relative;
    background: #f0f0f0;
    border-radius: 8px;
    overflow: hidden;
    min-height: 200px;
}

.ts-canvas {
    display: block;
    width: 100%;
    height: auto;
}

.ts-canvas-loading {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    color: #888;
    pointer-events: none;
}

/* ── Section ─────────────────────────────────────────── */
.ts-section {
    margin-bottom: 16px;
    padding: 16px;
    background: #fafafa;
    border-radius: 8px;
    border: 1px solid #e8e8e8;
}

.ts-section-title {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.10em;
    color: #666;
    margin: 0 0 12px;
}

/* ── Fish Grid ───────────────────────────────────────── */
.ts-fish-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
}

.ts-fish-btn {
    padding: 5px 9px;
    background: #fff;
    border: 2px solid #ddd;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 500;
    transition: border-color 0.12s, background 0.12s, color 0.12s;
    white-space: nowrap;
    line-height: 1.4;
}

.ts-fish-btn:hover { border-color: #888; }

.ts-fish-btn--active {
    background: #1a1a1a;
    border-color: #1a1a1a;
    color: #fff;
}

/* ── Select ──────────────────────────────────────────── */
.ts-select {
    width: 100%;
    padding: 10px 36px 10px 12px;
    border: 2px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
    background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23666' stroke-width='1.8' fill='none' stroke-linecap='round'/%3E%3C/svg%3E") no-repeat right 12px center;
    appearance: none;
    cursor: pointer;
    color: #1a1a1a;
    box-sizing: border-box;
}

.ts-select:focus {
    outline: none;
    border-color: #1a1a1a;
}

/* ── Size / Position Buttons ─────────────────────────── */
.ts-btn-group {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

/* ── Size horizontal scroll ──────────────────────────── */
.ts-size-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 6px;
    scrollbar-width: thin;
    scrollbar-color: #ccc transparent;
}

.ts-size-scroll::-webkit-scrollbar {
    height: 4px;
}

.ts-size-scroll::-webkit-scrollbar-track {
    background: transparent;
}

.ts-size-scroll::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 2px;
}

.ts-size-group {
    flex-wrap: nowrap;
}

.ts-pill-btn {
    padding: 8px 16px;
    background: #fff;
    border: 2px solid #ddd;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    transition: border-color 0.12s, background 0.12s, color 0.12s;
}

.ts-pill-btn:hover { border-color: #888; }

.ts-pill-btn--active {
    background: #1a1a1a;
    border-color: #1a1a1a;
    color: #fff;
}

/* ── Color Grid ──────────────────────────────────────── */
.ts-color-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
}

.ts-color-btn {
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 7px 8px;
    background: #fff;
    border: 2px solid #ddd;
    border-radius: 6px;
    cursor: pointer;
    font-size: 11px;
    font-weight: 500;
    text-align: left;
    transition: border-color 0.12s;
    white-space: nowrap;
    overflow: hidden;
}

.ts-color-btn:hover { border-color: #888; }

.ts-color-btn--active {
    border-color: #1a1a1a;
    border-width: 2px;
    background: #f5f5f5;
}

.ts-color-dot {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    flex-shrink: 0;
    border: 1px solid rgba(0,0,0,0.12);
}

.ts-color-dot--black      { background: #111; }
.ts-color-dot--white      { background: #fff; border-color: #aaa; }
.ts-color-dot--gold       { background: linear-gradient(135deg, #c8961a 0%, #f5d26b 50%, #c8961a 100%); }
.ts-color-dot--silver     { background: linear-gradient(135deg, #999 0%, #e0e0e0 50%, #999 100%); }
.ts-color-dot--normal-camo  { background: linear-gradient(135deg, #4a5a3a, #7a8a60, #3a4a2a); }
.ts-color-dot--pink-camo    { background: linear-gradient(135deg, #d97090, #f4b8c8, #c05070); }
.ts-color-dot--blue-camo    { background: linear-gradient(135deg, #3a5a80, #6090b8, #2a4060); }
.ts-color-dot--black-camo   { background: linear-gradient(135deg, #1a1a1a, #4a4a4a, #1a1a1a); }
.ts-color-dot--hagoromo-kou   { background: conic-gradient(#FFD700, #FF8C00, #FF1493, #9400D3, #0000FF, #00FF00, #FFFF00, #FFD700); }
.ts-color-dot--hagoromo-honoo { background: linear-gradient(135deg, #8B0000, #FF4500, #FF8C00); }
.ts-color-dot--hagoromo-ai    { background: linear-gradient(135deg, #0d1a40, #1a3a80, #4169E1); }
.ts-color-dot--hagoromo-guren { background: linear-gradient(135deg, #6B0000, #CC0040, #FF1493); }

/* ── Toggle ──────────────────────────────────────────── */
.ts-toggle-row {
    display: flex;
    align-items: center;
}

.ts-toggle-label {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    user-select: none;
}

.ts-toggle-cb { display: none; }

.ts-toggle-track {
    width: 46px;
    height: 26px;
    background: #ccc;
    border-radius: 13px;
    position: relative;
    flex-shrink: 0;
    transition: background 0.2s;
}

.ts-toggle-track::after {
    content: '';
    position: absolute;
    width: 22px;
    height: 22px;
    background: #fff;
    border-radius: 50%;
    top: 2px;
    left: 2px;
    transition: transform 0.2s;
    box-shadow: 0 1px 4px rgba(0,0,0,0.25);
}

.ts-toggle-cb:checked + .ts-toggle-track { background: #1a1a1a; }
.ts-toggle-cb:checked + .ts-toggle-track::after { transform: translateX(20px); }

.ts-toggle-text {
    font-size: 14px;
    font-weight: 600;
}

/* ── Form Fields ─────────────────────────────────────── */
.ts-fields {
    margin-top: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.ts-hidden { display: none !important; }

.ts-label {
    font-size: 12px;
    font-weight: 600;
    color: #555;
    margin: 4px 0 2px;
    display: block;
}

.ts-input {
    width: 100%;
    padding: 10px 12px;
    border: 2px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
    box-sizing: border-box;
    transition: border-color 0.12s;
}

.ts-input:focus {
    outline: none;
    border-color: #1a1a1a;
}

/* ── Order Summary ───────────────────────────────────── */
.ts-summary {
    margin: 24px 16px 16px;
    padding: 24px;
    background: #1a1a1a;
    color: #fff;
    border-radius: 10px;
}

.ts-summary-title {
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: #aaa;
    margin: 0 0 16px;
}

.ts-sum-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    line-height: 1.4;
}

.ts-sum-table tr { border-bottom: 1px solid #333; }
.ts-sum-table tr:last-child { border-bottom: none; }

.ts-sum-table th,
.ts-sum-table td {
    padding: 7px 4px;
    text-align: left;
    vertical-align: top;
}

.ts-sum-table th {
    color: #888;
    font-weight: 400;
    width: 38%;
    padding-right: 8px;
}

.ts-sum-table td { color: #f0f0f0; }

.ts-total-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 18px;
    padding-top: 16px;
    border-top: 2px solid #333;
}

.ts-total-label {
    font-size: 15px;
    font-weight: 600;
    color: #ccc;
}

.ts-total-val {
    font-size: 26px;
    font-weight: 700;
    color: #FFD700;
    letter-spacing: -0.02em;
}

/* ── Layer Overlay ───────────────────────────────────── */
.ts-layer-overlay {
    position: absolute;
    display: none;
    box-sizing: border-box;
    border: 2px dashed rgba(255, 255, 255, 0.4);
    cursor: grab;
    touch-action: none;
    pointer-events: none;
}

.ts-layer-overlay--visible {
    display: block;
    pointer-events: auto;
}

.ts-layer-overlay--active {
    border-color: rgba(255, 255, 255, 0.9);
}

.ts-dragging { cursor: grabbing !important; }

.ts-layer-resize {
    position: absolute;
    bottom: -12px;
    right: -12px;
    width: 24px;
    height: 24px;
    background: rgba(255, 255, 255, 0.92);
    border: 2px solid #444;
    border-radius: 4px;
    cursor: ew-resize;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
    color: #333;
    pointer-events: auto;
    touch-action: none;
    z-index: 2;
    line-height: 1;
    user-select: none;
}

/* ── Layer Tabs ──────────────────────────────────────── */
.ts-layer-tabs {
    display: flex;
    gap: 6px;
    margin-bottom: 12px;
}

.ts-layer-tab {
    flex: 1;
    padding: 8px 6px;
    background: #f0f0f0;
    border: 2px solid #ddd;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.ts-layer-tab:hover { border-color: #888; }

.ts-layer-tab--active {
    background: #1a1a1a;
    border-color: #1a1a1a;
    color: #fff;
}

/* ── Arc controls ────────────────────────────────────── */
.ts-arc-ctrls {
    margin-top: 10px;
    padding: 10px 12px;
    background: #f4f4f4;
    border-radius: 6px;
    border: 1px solid #e0e0e0;
}

/* ── Slider ──────────────────────────────────────────── */
.ts-slider {
    width: 100%;
    height: 6px;
    -webkit-appearance: none;
    appearance: none;
    background: #ddd;
    border-radius: 3px;
    outline: none;
    cursor: pointer;
    margin: 6px 0 2px;
    display: block;
}

.ts-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #1a1a1a;
    cursor: pointer;
    border: none;
}

.ts-slider::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #1a1a1a;
    cursor: pointer;
    border: none;
}

/* ── Arc start angle row ─────────────────────────────── */
.ts-start-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.ts-start-row .ts-slider {
    flex: 1;
    margin: 0;
}

.ts-arc-val {
    font-size: 12px;
    font-weight: 600;
    color: #555;
    min-width: 36px;
    text-align: right;
    white-space: nowrap;
}

/* ── Back design position row ────────────────────────── */
.ts-back-pos-wrap {
    margin-bottom: 10px;
    padding: 8px 12px;
    background: #f0f0f0;
    border-radius: 6px;
}

.ts-back-pos-label {
    display: block;
    font-size: 11px;
    font-weight: 700;
    color: #666;
    margin-bottom: 4px;
    letter-spacing: 0.05em;
}

.ts-back-pos-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.ts-back-pos-row .ts-slider {
    flex: 1;
    margin: 0;
}

.ts-back-pos-edge {
    font-size: 12px;
    font-weight: 700;
    color: #555;
    white-space: nowrap;
    min-width: 16px;
    text-align: center;
}

/* ── Font Grid ────────────────────────────────────────── */
.ts-font-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 6px;
    max-height: 320px;
    overflow-y: auto;
}

.ts-font-btn {
    padding: 8px 10px;
    background: #fff;
    border: 2px solid #ddd;
    border-radius: 6px;
    cursor: pointer;
    text-align: center;
    transition: border-color 0.12s, background 0.12s;
    overflow: hidden;
}

.ts-font-btn:hover { border-color: #888; }

.ts-font-btn--active {
    border-color: #1a1a1a;
    background: #f5f5f5;
}

.ts-font-sample {
    display: block;
    font-size: 20px;
    line-height: 1.5;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: #1a1a1a;
}

.ts-font-label {
    display: block;
    font-size: 10px;
    color: #888;
    margin-top: 2px;
    font-family: -apple-system, sans-serif;
}

/* ── Textarea & Hint ──────────────────────────────────── */
.ts-textarea {
    resize: vertical;
    min-height: 56px;
    line-height: 1.5;
    font-family: inherit;
}

.ts-hint {
    font-size: 11px;
    color: #888;
    margin: 4px 0 0;
    line-height: 1.5;
}

/* ── Option sub-sections ─────────────────────────────── */
.ts-opt-sub-section {
    margin: 10px 0 4px 20px;
    padding: 12px 14px;
    background: #f5f5f5;
    border-left: 3px solid #bbb;
    border-radius: 4px;
}
.ts-opt-sub-title {
    font-size: 12px;
    font-weight: bold;
    color: #555;
    margin: 0 0 6px;
    letter-spacing: 0.03em;
}

/* ── Options checkboxes ──────────────────────────────── */
.ts-option-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 8px;
}
.ts-option-cb {
    width: 18px;
    height: 18px;
    cursor: pointer;
    flex-shrink: 0;
}
.ts-option-label {
    font-size: 14px;
    color: #333;
    cursor: pointer;
    line-height: 1.4;
}

/* ── Divider ─────────────────────────────────────────── */
.ts-divider {
    border: none;
    border-top: 1px solid #e0e0e0;
    margin: 16px 0 12px;
}

/* ── Card sub-button & font display ─────────────────── */
.ts-card-sub-btn {
    width: 100%;
    padding: 5px 8px;
    background: #ebebeb;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 11px;
    font-weight: 600;
    color: #444;
    transition: background 0.15s;
    text-align: center;
}

.ts-card-sub-btn:hover { background: #d8d8d8; }

.ts-card-font-display {
    width: 100%;
    padding: 7px 9px;
    background: #fff;
    border: 2px solid #ddd;
    border-radius: 6px;
    cursor: pointer;
    font-size: 12px;
    text-align: left;
    color: #1a1a1a;
    transition: border-color 0.12s;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    box-sizing: border-box;
}

.ts-card-font-display:hover { border-color: #888; }

/* ── Popup (bottom sheet) ─────────────────────────────── */
.ts-popup-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.45);
    z-index: 500;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.2s;
    pointer-events: none;
}

.ts-popup-overlay--open {
    opacity: 1;
    pointer-events: auto;
}

.ts-popup {
    background: #fff;
    border-radius: 16px 16px 0 0;
    width: 100%;
    max-width: 560px;
    padding: 20px 20px 32px;
    box-sizing: border-box;
    transform: translateY(24px);
    transition: transform 0.25s;
}

.ts-popup-overlay--open .ts-popup { transform: translateY(0); }

.ts-popup-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 18px;
    padding-bottom: 12px;
    border-bottom: 1px solid #ebebeb;
}

.ts-popup-title {
    font-size: 15px;
    font-weight: 700;
    color: #1a1a1a;
}

.ts-popup-close {
    width: 28px;
    height: 28px;
    border: none;
    background: #f0f0f0;
    border-radius: 50%;
    cursor: pointer;
    font-size: 14px;
    line-height: 1;
    color: #555;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.ts-popup-close:hover { background: #ddd; }

.ts-popup-body {
    max-height: 58vh;
    overflow-y: auto;
}

.ts-popup-label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: #555;
    margin: 0 0 8px;
}

.ts-popup-label + .ts-slider { margin-top: 0; }

/* ── Color card display button ───────────────────────── */
.ts-card-color-display {
    width: 100%;
    padding: 7px 9px;
    background: #fff;
    border: 2px solid #ddd;
    border-radius: 6px;
    cursor: pointer;
    font-size: 12px;
    text-align: left;
    color: #1a1a1a;
    font-weight: 500;
    transition: border-color 0.12s;
    display: flex;
    align-items: center;
    gap: 6px;
    box-sizing: border-box;
    font-family: inherit;
}
.ts-card-color-display:hover { border-color: #888; }

.ts-color-dot-sm {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    flex-shrink: 0;
    border: 1px solid rgba(0,0,0,0.14);
    display: inline-block;
}

/* ── Color popup grid ────────────────────────────────── */
.ts-color-popup-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
}

.ts-color-popup-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    background: #fff;
    border: 2px solid #e8e8e8;
    border-radius: 8px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    text-align: left;
    transition: border-color 0.12s, background 0.12s;
    font-family: inherit;
}
.ts-color-popup-btn:hover { border-color: #888; }
.ts-color-popup-btn--active {
    border-color: #1a1a1a;
    background: #f5f5f5;
}
.ts-color-popup-btn .ts-color-dot {
    flex-shrink: 0;
}

/* ── Desktop (PC) layout ─────────────────────────────── */
.ts-desktop-sections { display: none; }

@media (min-width: 768px) {
    .ts-root { max-width: 1040px; }

    .ts-main-layout {
        display: grid;
        grid-template-columns: 1fr 360px;
        column-gap: 28px;
        align-items: start;
    }
    /* モバイルカード行・モバイルオプションを非表示 */
    .ts-scroll-wrapper      { display: none !important; }
    .ts-mobile-opts-wrapper { display: none !important; }

    .ts-preview-area {
        grid-column: 1;
        padding: 24px 0 0;
        position: sticky;
        top: 16px;
    }
    .ts-desktop-sections {
        display: block;
        grid-column: 2;
        padding: 20px 0 32px;
    }
    .ts-summary {
        margin: 24px 16px 32px;
    }
}

/* ── Responsive (small mobile) ───────────────────────── */
@media (max-width: 420px) {
    .ts-color-grid { grid-template-columns: repeat(2, 1fr); }
    .ts-total-val  { font-size: 22px; }
    .ts-nav-tab    { padding: 7px 12px; font-size: 12px; }
}
