body {
    background: #f0f4f8;
    color: #333;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

div.container {
    flex: 1; /* body flex-column 内でフッターを押し下げる */
}

#ad_top,
#ad_bottom {
    width: 100%;
    margin: 16px 0;
    text-align: center;
}

main {
    flex: 0 0 100%; /* スマホ: 横幅100%→asideが下に折り返す */
    min-width: 0;
}

@media (min-width: 768px) {
    main {
        flex: 1;        /* タブレット以上: 残り幅を占有 */
    }
    .right-column {
        flex-basis: 20%;
    }
}

header {
    background: black;
    color: white;
    padding: 16px 24px;
    font-size: 1.4rem;
    font-weight: bold;
    letter-spacing: 1px;
    display: flex;
    flex-direction: row;
    align-items: center;
}

header h1 {
    font-size: inherit;
}

#setup {
    max-width: 480px;
    margin: 40px auto;
    background: white;
    border-radius: 12px;
    padding: 28px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.1);
}

#setup h2 {
    margin-bottom: 16px;
    font-size: 1.1rem;
    color: #555;
}

#players-list {
    margin-bottom: 12px;
}

.player-row {
    display: flex;
    gap: 8px;
    margin-bottom: 8px;
}

.player-row input {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid #ccc;
    border-radius: 8px;
    font-size: 1rem;
}

.player-row input:focus {
    outline: none;
    border-color: #2c7be5;
}

.btn-remove {
    background: #e74c3c;
    color: white;
    border: none;
    border-radius: 8px;
    width: 36px;
    cursor: pointer;
    font-size: 1.1rem;
}

.btn-remove:hover {
    background: #c0392b;
}

#btn-add {
    background: #27ae60;
    color: white;
    border: none;
    border-radius: 8px;
    padding: 8px 18px;
    cursor: pointer;
    font-size: 0.95rem;
    margin-bottom: 20px;
}

#btn-add:hover {
    background: #219a52;
}

#btn-start {
    width: 100%;
    background: #2c7be5;
    color: white;
    border: none;
    border-radius: 10px;
    padding: 12px;
    font-size: 1.1rem;
    cursor: pointer;
    font-weight: bold;
}

#btn-start:hover {
    background: #1a63c8;
}

/* Tournament bracket */
#tournament {
    display: none;
    padding: 24px 16px;
    overflow-x: auto;
}

#bracket-wrap {
    display: flex;
    gap: 0;
    align-items: stretch;
    min-width: max-content;
}

.round-col {
    display: flex;
    flex-direction: column;
    justify-content: space-around;
    min-width: 190px;
    padding: 0 8px;
}

.round-label {
    text-align: center;
    font-weight: bold;
    color: #2c7be5;
    margin-bottom: 8px;
    font-size: 0.9rem;
    letter-spacing: 0.5px;
}

.match-cell {
    display: flex;
    flex-direction: column;
    justify-content: center;
    flex: 1;
}

.match-box {
    border: 2px solid #ccd6e3;
    border-radius: 10px;
    background: white;
    overflow: hidden;
    box-shadow: 0 1px 6px rgba(0, 0, 0, 0.07);
    margin: 4px 0;
}

.player-row-match {
    display: flex;
    align-items: center;
    padding: 10px 14px;
    border-bottom: 1px solid #eee;
    gap: 10px;
    transition: background 0.15s;
}

.player-row-match:last-child {
    border-bottom: none;
}

.player-row-match.winner {
    background: #d1fae5;
}

.player-row-match.winner .player-name {
    color: #065f46;
    font-weight: bold;
}

.player-row-match.loser {
    background: #f3f4f6;
}

.player-row-match.loser .player-name {
    color: #aaa;
    text-decoration: line-through;
}

.player-row-match.bye {
    background: #f9fafb;
}

.player-row-match.bye .player-name {
    color: #aaa;
    font-style: italic;
}

.player-name {
    flex: 1;
    font-size: 0.95rem;
}

.result-radio {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: #2c7be5;
    flex-shrink: 0;
}

.result-radio:disabled {
    cursor: default;
}

/* connector lines */
.connector-col {
    display: flex;
    flex-direction: column;
    width: 20px;
    flex-shrink: 0;
}

.conn-pair {
    display: flex;
    flex-direction: column;
    flex: 2;
}

.conn-seg {
    flex: 1;
}

.conn-seg-tr {
    border-top: 2px solid #b0bec5;
    border-right: 2px solid #b0bec5;
    border-top-right-radius: 3px;
}

.conn-seg-br {
    border-bottom: 2px solid #b0bec5;
    border-right: 2px solid #b0bec5;
    border-bottom-right-radius: 3px;
}

/* champion display */
#champion-banner {
    display: none;
    text-align: center;
    margin: 20px auto;
    max-width: 360px;
    background: linear-gradient(135deg, #f6d365, #fda085);
    border-radius: 14px;
    padding: 24px 20px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
    color: white;
}

#champion-banner h2 {
    font-size: 1.1rem;
    margin-bottom: 8px;
}

#champion-banner .name {
    font-size: 2rem;
    font-weight: bold;
}

.reset-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
    margin: 32px auto 0;
}

#btn-reset-bracket {
    background: white;
    color: #2c7be5;
    border: 2px solid #2c7be5;
    border-radius: 10px;
    padding: 10px 20px;
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: bold;
}

#btn-reset-bracket:hover {
    background: #2c7be5;
    color: white;
}

#btn-reset-all {
    background: white;
    color: #e74c3c;
    border: 2px solid #e74c3c;
    border-radius: 10px;
    padding: 10px 20px;
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: bold;
}

#btn-reset-all:hover {
    background: #e74c3c;
    color: white;
}

.match-footer {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-top: 1px;
    padding: 0 4px;
}

.btn-undo {
    background: none;
    border: none;
    color: #e74c3c;
    font-size: 0.65rem;
    cursor: pointer;
    text-decoration: underline;
    padding: 1px 2px;
    white-space: nowrap;
}

.btn-undo:hover {
    color: #c0392b;
}

.match-memo {
    flex: 1;
    min-width: 0;
    font-size: 0.65rem;
    padding: 1px 4px;
    border: 1px solid #ccc;
    border-radius: 4px;
    color: #555;
}

.match-memo:focus {
    outline: none;
    border-color: #2c7be5;
}

#introduction {
    max-width: 600px;
    margin: 40px auto;
    background: white;
    border-radius: 12px;
    padding: 28px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.1);
}
#introduction h2 {
    margin: 16px;
    font-size: 1.5rem;
    color: #555;
}
#introduction li {
    margin: 16px;
}