/* Production visual layer for the public app. */
:root {
    --primary: #0f766e;
    --primary-strong: #0b5f59;
    --primary-soft: #e6f4f1;
    --accent: #f2b84b;
    --accent-soft: #fff6df;
    --success: #16845b;
    --danger: #c9443e;
    --warning: #d99a22;
    --draw: #675c9f;
    --avoid: #c86b3e;
    --dark: #172326;
    --gray: #63716f;
    --surface: #ffffff;
    --surface-muted: #f6f8f7;
    --line-soft: #d9e4e0;
    --line-strong: #bdcdc8;
    --student-bg: #ffffff;
    --adult-bg: #f1f5f3;
    --bg-waiting: #edf8f4;
    --bg-playing: #fff0ee;
    --bg-resting: #f5f7f6;
    --final-gold: #d99a22;
    --card-radius: 10px;
    --shadow-card: 0 8px 22px rgba(23, 35, 38, 0.08);
    --shadow-raised: 0 16px 34px rgba(23, 35, 38, 0.12);
    --control-height: 48px;
}

html {
    background: #eef4f1;
}

body {
    margin: 0;
    background:
        linear-gradient(180deg, rgba(255,255,255,0.88), rgba(255,255,255,0) 260px),
        linear-gradient(180deg, #eef7f3 0%, #f7faf8 42%, #eef3f0 100%);
    color: var(--dark);
    font-size: 17px;
    line-height: 1.45;
    letter-spacing: 0;
    padding-top: 76px;
}

.app-shell-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 90;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    min-height: 64px;
    padding: 10px max(14px, env(safe-area-inset-left)) 10px max(14px, env(safe-area-inset-right));
    background: rgba(255, 255, 255, 0.94);
    border-bottom: 1px solid var(--line-soft);
    box-shadow: 0 8px 22px rgba(23, 35, 38, 0.07);
    backdrop-filter: blur(14px);
}

.app-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.app-brand-mark {
    width: 40px;
    height: 40px;
    display: grid;
    place-items: center;
    flex: 0 0 auto;
    border-radius: 10px;
    background: linear-gradient(145deg, var(--primary), var(--primary-strong));
    color: #ffffff;
    font-weight: 900;
    box-shadow: 0 8px 18px rgba(15, 118, 110, 0.22);
}

.app-brand-title {
    font-size: 16px;
    font-weight: 900;
    line-height: 1.1;
    white-space: nowrap;
}

.app-brand-subtitle {
    margin-top: 3px;
    color: var(--gray);
    font-size: 12px;
    font-weight: 700;
    white-space: nowrap;
}

.app-status-panel {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    min-height: 34px;
    padding: 0 11px;
    border: 1px solid #cfe2dc;
    border-radius: 999px;
    background: var(--primary-soft);
    color: var(--primary-strong);
    font-size: 12px;
    font-weight: 900;
    white-space: nowrap;
}

.app-status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--success);
    box-shadow: 0 0 0 4px rgba(22, 132, 91, 0.13);
}

.container {
    width: 100%;
    max-width: 920px;
    padding: 16px;
}

.view-section {
    animation: app-fade-in 0.16s ease-out;
}

@keyframes app-fade-in {
    from { opacity: 0; transform: translateY(4px); }
    to { opacity: 1; transform: translateY(0); }
}

.page-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 48px;
    margin: 2px 0 14px;
    padding: 0 2px;
    color: var(--dark);
    font-size: 22px;
    font-weight: 900;
    line-height: 1.2;
    text-align: left;
}

.card {
    background: var(--surface);
    border: 1px solid var(--line-soft);
    border-radius: var(--card-radius);
    box-shadow: var(--shadow-card);
    padding: 18px;
    margin-bottom: 14px;
    overflow: hidden;
}

.card h3 {
    margin-bottom: 14px;
    color: #334340 !important;
    font-size: 15px !important;
    font-weight: 900;
    letter-spacing: 0;
}

.list-header {
    display: flex;
    align-items: center;
    min-height: 32px;
    margin: 20px 0 8px;
    color: #3a4c49;
    font-size: 14px;
    font-weight: 900;
    letter-spacing: 0;
}

.list-header::after {
    content: "";
    height: 1px;
    flex: 1;
    margin-left: 10px;
    background: var(--line-soft);
}

.btn,
button {
    letter-spacing: 0;
}

.btn {
    min-height: var(--control-height);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    border-radius: 9px;
    border: 1px solid transparent;
    padding: 12px 14px;
    font-size: 16px;
    font-weight: 900;
    line-height: 1.2;
    box-shadow: none;
    transition: transform 0.12s ease, box-shadow 0.12s ease, background 0.12s ease;
}

.btn:active {
    opacity: 1;
    transform: translateY(1px) scale(0.99);
}

.btn-primary,
.btn-success {
    background: var(--primary);
    color: #ffffff;
    box-shadow: 0 8px 18px rgba(15, 118, 110, 0.18);
}

.btn-success {
    background: var(--success);
    box-shadow: 0 8px 18px rgba(22, 132, 91, 0.17);
}

.btn-dark {
    background: #233236;
    color: #ffffff;
}

.btn-danger {
    background: #fff1f0;
    color: var(--danger);
    border-color: #f2c6c3;
    box-shadow: none;
}

.btn-draw {
    background: var(--draw);
    color: #ffffff;
}

.btn-outline {
    background: #ffffff;
    border: 1px solid var(--line-strong);
    color: #485754;
    box-shadow: none;
}

input,
select,
textarea {
    min-height: var(--control-height);
    width: 100%;
    border: 1px solid var(--line-strong) !important;
    border-radius: 9px !important;
    background: #ffffff;
    color: var(--dark);
    font-size: 16px !important;
    line-height: 1.35;
    box-shadow: inset 0 1px 0 rgba(23, 35, 38, 0.03);
}

input:focus,
select:focus,
textarea:focus {
    outline: 3px solid rgba(15, 118, 110, 0.14);
    border-color: var(--primary) !important;
}

input::placeholder,
textarea::placeholder {
    color: #93a19d;
}

.tag-selector {
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 8px;
}

.tag-opt,
.status-btn,
.rest-toggle {
    border-radius: 9px;
    border-color: var(--line-strong);
    background: #ffffff;
    color: #43514f;
}

.tag-opt {
    height: 48px;
    font-size: 17px;
    box-shadow: none;
}

.tag-opt.active {
    background: var(--primary);
    border-color: var(--primary);
    color: #ffffff;
    box-shadow: 0 7px 16px rgba(15, 118, 110, 0.18);
}

#home-tournament-badge {
    background: var(--primary-soft) !important;
    color: var(--primary-strong) !important;
    border: 1px solid #cfe2dc;
    border-radius: 999px !important;
    padding: 7px 12px !important;
    font-size: 12px !important;
}

#home-stats {
    background: linear-gradient(180deg, #ffffff, #f8fbfa) !important;
    border-left: 4px solid var(--primary);
}

#first-guide-area > div {
    background: #ffffff !important;
    color: var(--dark) !important;
    border: 1px solid var(--line-soft) !important;
    border-left: 4px solid var(--accent) !important;
    border-radius: 10px !important;
    box-shadow: var(--shadow-card);
}

#first-guide-area > div > div:first-child {
    color: #8a5d0f !important;
}

#first-guide-area b {
    color: var(--primary-strong) !important;
}

#first-guide-area > div > div {
    color: #43514f !important;
    line-height: 1.75 !important;
}

.countdown-banner {
    background: #183136;
    border: 1px solid rgba(242, 184, 75, 0.45);
    border-radius: 10px;
    box-shadow: var(--shadow-card);
}

.countdown-number {
    color: var(--accent);
}

.proposal-group {
    padding: 14px;
    background: #183136;
    border: 1px solid #29494d;
    border-radius: 10px;
    box-shadow: var(--shadow-raised);
}

.match-card {
    min-height: 74px;
    align-items: stretch;
    gap: 10px;
    padding: 12px;
    background: #ffffff;
    border: 1px solid #dce8e4;
    border-radius: 9px;
    box-shadow: 0 6px 14px rgba(23, 35, 38, 0.08);
}

.match-card.is-final {
    background: var(--accent-soft);
    border: 1px solid #efd28c;
    animation: none;
}

.match-info {
    min-width: 0;
    font-size: 20px;
    line-height: 1.22;
}

.match-wins-sub {
    margin-top: 3px;
    color: var(--success);
    font-size: 12px;
}

.vs-label {
    color: var(--danger);
    font-weight: 900;
}

.table-badge {
    min-width: 42px;
    height: auto;
    min-height: 42px;
    margin-right: 0;
    border-radius: 9px;
    background: var(--primary);
    color: #ffffff;
}

.final-badge {
    background: var(--accent);
    color: #422f0d;
    border-radius: 999px;
}

.p-item {
    min-height: 62px;
    gap: 12px;
    padding: 13px 14px;
    background: #ffffff;
    border-bottom: 1px solid var(--line-soft);
}

.p-item.is-adult {
    background: var(--adult-bg);
}

.p-item.selected {
    background: #fff7df !important;
    outline: 2px solid var(--accent);
    border-radius: 9px;
}

.family-label {
    color: var(--primary);
    font-size: 12px;
    font-weight: 900;
}

.p-warn-text,
.avoid-label {
    border-radius: 999px;
}

.avoid-label {
    background: #fff1e9;
    color: #a94d24;
    padding: 3px 8px;
}

.rank-card {
    border: 1px solid var(--line-soft) !important;
    background: #ffffff !important;
    box-shadow: var(--shadow-card);
}

.rank-table {
    min-width: 600px;
    background: #ffffff;
}

.rank-table th {
    position: sticky;
    top: 0;
    z-index: 1;
    background: #f0f6f4 !important;
    color: #445451 !important;
    border-bottom: 1px solid var(--line-soft);
    padding: 11px 8px;
    font-size: 12px;
    font-weight: 900;
    white-space: nowrap;
}

.rank-table td {
    background: #ffffff !important;
    color: var(--dark) !important;
    border-bottom: 1px solid var(--line-soft);
    padding: 12px 8px;
    font-size: 15px;
    vertical-align: middle;
}

.rank-table td:nth-child(2) {
    text-align: left;
    font-weight: 900;
}

.rank-table tr:first-child td,
.rank-table .row-rank-1 td {
    background: #fff8e6 !important;
    color: #1d2b2e !important;
    font-weight: 900;
}

.rank-table a,
.rank-table b[onclick] {
    color: var(--primary-strong) !important;
    text-decoration-color: rgba(15, 118, 110, 0.35) !important;
}

.rank-table .row-adult-rank td {
    background: #f5f7f6 !important;
    color: #687674 !important;
}

.points-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 34px;
    min-height: 24px;
    background: var(--primary-soft);
    color: var(--primary-strong);
    border-radius: 999px;
    padding: 2px 9px;
    font-size: 13px;
}

#rank-target-toggle-bar,
#view-home > div[style*="display:flex"],
#view-results > div[style*="display:flex"],
.card div[style*="display:grid"] {
    gap: 8px !important;
}

button[onclick^="setRankTarget"],
button[onclick^="setRematch"],
button[onclick^="setFinalThresh"],
button[onclick^="setAdultPenaltyPreset"] {
    min-height: 44px;
    border-radius: 9px !important;
    font-weight: 900 !important;
    box-shadow: none !important;
}

#manual-bar {
    border: 1px solid #edd18b !important;
    background: #fff8e6 !important;
}

#active-matches:empty::before,
#proposal-area:empty::before,
#waiting-list:empty::before,
#resting-list:empty::before {
    display: block;
    padding: 18px;
    color: var(--gray);
    font-size: 14px;
    text-align: center;
}

#active-matches:empty::before { content: "現在、対戦中の試合はありません。"; }
#proposal-area:empty::before { content: "参加者を登録すると、ここに推奨ペアが表示されます。"; }
#waiting-list:empty::before { content: "待機中の参加者はいません。"; }
#resting-list:empty::before { content: "休憩中の参加者はいません。"; }

.bottom-nav {
    left: 50%;
    transform: translateX(-50%);
    width: min(100%, 920px);
    background: rgba(255, 255, 255, 0.96);
    border: 1px solid var(--line-soft);
    border-bottom: 0;
    border-top-left-radius: 14px;
    border-top-right-radius: 14px;
    box-shadow: 0 -10px 28px rgba(23, 35, 38, 0.10);
    backdrop-filter: blur(14px);
}

.nav-item {
    min-height: 58px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    border-radius: 10px;
    color: #6b7875;
    font-weight: 800;
}

.nav-item i {
    margin-bottom: 0;
    font-size: 23px;
}

.nav-item.active {
    color: var(--primary);
    background: var(--primary-soft);
}

.overlay {
    background: rgba(246, 248, 247, 0.98);
}

.overlay .card,
#dup-modal > div,
#share-text-modal > div {
    border: 1px solid var(--line-soft);
    border-radius: 14px !important;
    box-shadow: 0 24px 60px rgba(23, 35, 38, 0.18) !important;
}

#call-screen {
    background: #f6f8f7;
}

#call-screen .call-name {
    color: var(--dark);
    line-height: 1.08;
}

.final-overlay {
    background: linear-gradient(160deg, #183136, #0f766e);
}

.final-overlay .call-name {
    color: #ffffff;
}

hr {
    border-top-color: var(--line-soft) !important;
}

details summary {
    min-height: 38px;
    display: flex;
    align-items: center;
}

@media (min-width: 760px) {
    body {
        padding-top: 84px;
    }

    .app-shell-header {
        min-height: 70px;
        padding-left: max(24px, env(safe-area-inset-left));
        padding-right: max(24px, env(safe-area-inset-right));
    }

    .container {
        padding: 22px;
    }

    .card {
        padding: 20px;
        margin-bottom: 16px;
    }

    .page-title {
        font-size: 24px;
    }

    .btn {
        min-height: 50px;
    }
}

@media (max-width: 560px) {
    body {
        padding-top: 72px;
        padding-bottom: 132px;
        font-size: 16px;
    }

    .app-shell-header {
        min-height: 60px;
        padding-top: 8px;
        padding-bottom: 8px;
    }

    .app-brand-mark {
        width: 36px;
        height: 36px;
        border-radius: 9px;
    }

    .app-brand-title {
        font-size: 15px;
    }

    .app-brand-subtitle {
        display: none;
    }

    .app-status-panel {
        min-height: 30px;
        padding: 0 9px;
        font-size: 11px;
    }

    .container {
        padding: 12px;
    }

    .page-title {
        min-height: 42px;
        margin-bottom: 10px;
        font-size: 20px;
    }

    .card {
        padding: 14px;
        margin-bottom: 12px;
        border-radius: 10px;
    }

    .btn {
        min-height: 52px;
        padding: 11px 12px;
        font-size: 16px;
    }

    .tag-selector {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .tag-opt {
        height: 52px;
    }

    .match-card {
        min-height: 70px;
        padding: 11px;
    }

    .match-info {
        font-size: 18px;
    }

    .rank-table {
        min-width: 560px;
    }

    .rank-table th,
    .rank-table td {
        padding: 10px 7px;
        font-size: 14px;
    }

    .bottom-nav {
        border-top-left-radius: 12px;
        border-top-right-radius: 12px;
    }

    .nav-item {
        min-height: 58px;
        font-size: 11px;
    }

    .nav-item i {
        font-size: 21px;
    }
}

@media (max-width: 380px) {
    .app-status-panel span:last-child {
        display: none;
    }

    .app-status-panel {
        width: 32px;
        justify-content: center;
        padding: 0;
    }

    .btn {
        font-size: 15px;
    }
}
