@charset "utf-8";

html,
body {
    min-height: 100%;
    max-width: 100%;
    margin: 0;
    padding: 0;
    color: #1f2937;
    font-family: "ヒラギノ角ゴ Pro W3", "Hiragino Kaku Gothic Pro", "メイリオ", Meiryo, Osaka, "ＭＳ Ｐゴシック", "MS PGothic", sans-serif;
    font-size: 14px;
    line-height: 1.5;
    -webkit-text-size-adjust: none;
}

body {
    padding-bottom: 3em;
}

html {
    overflow-y: scroll;
    scrollbar-gutter: stable;
}

* {
    box-sizing: border-box;
    touch-action: manipulation;
}

h1,
h2,
p {
    margin: 0;
    padding: 0;
}

button,
input,
select {
    font-family: inherit;
}

#header {
    position: fixed;
    top: 0;
    z-index: 100;
    width: 100%;
    height: 60px;
    padding: 5px 0;
    color: #ffffff;
    text-align: center;
    background-color: #007FFF;
}

#header-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    padding-left: 72px;
    padding-right: 72px;
    font-weight: bold;
}

#logo-img {
    z-index: 110;
    width: 56px;
    height: 56px;
    object-fit: contain;
    position: fixed;
    left: 8px;
    top: 7px;
}

#header-title,
#version_header {
    z-index: 120;
}

#header-title {
    font-size: 18px;
    line-height: 1.2;
}

#version_header {
    font-size: 12px;
    line-height: 1.2;
}

#contents {
    width: min(max(80%, 1024px), 100%);
    margin: 60px auto 0;
    background: #ffffff;
    padding-bottom: 60px;
}

#contents h2 {
    margin-top: 5px;
    margin-bottom: 5px;
    clear: both;
    color: #ffffff;
    padding: 5px 15px;
    background: #007FFF;
    font-weight: bold;
    white-space: nowrap;
}

#entrance_controls_section {
    position: sticky;
    top: 60px;
    z-index: 80;
    margin-top: -1px;
    padding: 0;
    background: #ffffff;
    border-bottom: 1px solid #d1d5db;
}

.mode_tabs {
    display: flex;
    justify-content: center;
    box-sizing: border-box;
    border-bottom: 1px solid #ccc;
}

.mode_tab {
    min-width: 110px;
    padding: 9px 20px;
    cursor: pointer;
    color: #1f2937;
    background: #f1f1f1;
    border: 1px solid #ccc;
    border-bottom: 1px solid #ccc;
    border-radius: 5px 5px 0 0;
    font-size: 16px;
    font-weight: bold;
}

.mode_tab.active {
    color: #ffffff;
    background: #007FFF;
    border-bottom-color: #007FFF;
}

#top_actions {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 4px;
    padding: 4px 0;
}

input[type="number"] {
    text-align: right;
}

input[type="button"] {
    display: inline-block;
    min-height: 40px;
    margin: 5px;
    padding: 8px 20px;
    color: #ffffff;
    border: none;
    border-radius: 5px;
    background-color: #007FFF;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
}

input[type="button"]:hover {
    background-color: #0068d1;
}

#entrance_summary {
    display: grid;
    grid-template-columns: 240px 1fr 240px;
    align-items: stretch;
    gap: 12px;
}

.target_setting,
#count_summary,
#remaining_panel,
.counter_item {
    border: 2px solid #007FFF;
    border-radius: 8px;
    background: #ffffff;
}

.target_setting {
    display: grid;
    align-content: center;
    gap: 8px;
    padding: 14px;
    font-size: 18px;
    font-weight: bold;
}

#target_count {
    width: 100%;
    box-sizing: border-box;
    font-size: 28px;
    font-weight: bold;
    padding: 8px;
}

#remaining_panel {
    padding: 12px;
    text-align: center;
    color: #007FFF;
}

#remaining_label {
    font-size: 20px;
    font-weight: bold;
}

#remaining_count {
    font-size: 76px;
    line-height: 1;
    font-weight: bold;
}

#achievement_message {
    min-height: 28px;
    font-size: 20px;
    font-weight: bold;
}

#remaining_panel.achieved {
    color: #ffffff;
    background: #007FFF;
}

#count_summary {
    display: grid;
    align-content: center;
    gap: 10px;
    padding: 14px;
    font-size: 18px;
}

#count_summary div {
    display: flex;
    justify-content: space-between;
    gap: 12px;
}

.summary_label {
    font-weight: bold;
}

#counter_list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(190px, 260px));
    justify-content: center;
    gap: 12px;
}

.counter_item {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
    padding: 12px;
}

.counter_item.increase_item {
    border-color: #e04b4b;
}

.counter_item.increase_item .display_counter_name {
    color: #c73535;
}

.display_counter_name {
    display: block;
    text-align: center;
    color: #007FFF;
    font-size: 18px;
    font-weight: bold;
}

.counter_settings {
    display: grid;
    gap: 8px;
}

.counter_settings label {
    display: grid;
    gap: 3px;
    font-weight: bold;
}

.counter_setting_row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(78px, auto);
    align-items: stretch;
    gap: 10px;
}

.counter_setting_title {
    display: block;
    color: #374151;
    font-size: 13px;
    font-weight: bold;
    line-height: 1.2;
}

.counter_direction_block {
    display: grid;
    gap: 4px;
}

.direction_segment {
    display: grid;
    grid-template-columns: 1fr 1fr;
    overflow: hidden;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    background: #f8fafc;
}

.direction_option {
    min-width: 0;
    min-height: 36px;
    padding: 6px 8px;
    color: #1f2937;
    border: none;
    border-right: 1px solid #cbd5e1;
    background: transparent;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
}

.direction_option:last-child {
    border-right: none;
}

.direction_option.active {
    color: #ffffff;
    background: #007FFF;
}

.increase_item .direction_option.active {
    background: #e04b4b;
}

.counter_settings .counter_total_setting {
    display: grid;
    grid-template-columns: auto auto;
    grid-template-rows: auto 1fr;
    align-items: center;
    justify-content: center;
    gap: 4px 6px;
    min-height: 56px;
    padding: 4px 8px;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    background: #f8fafc;
    white-space: nowrap;
}

.counter_total_setting .counter_setting_title {
    grid-column: 1 / -1;
    text-align: center;
}

.counter_total_setting input {
    width: 18px;
    height: 18px;
    margin: 0;
}

input.counter_name,
input.counter_weight {
    width: 100%;
    box-sizing: border-box;
    font-size: 18px;
    padding: 6px;
}

input.counter_weight {
    text-align: right;
}

.counter_button_area {
    display: grid;
    grid-template-rows: auto 1fr auto;
    gap: 8px;
}

.count_button {
    min-height: 112px;
    border: none;
    border-radius: 8px;
    color: #ffffff;
    background: #007FFF;
    font-size: 44px;
    font-weight: bold;
    cursor: pointer;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
    transition: background-color 0.2s, transform 0.2s;
}

.count_button:hover {
    background-color: #0068d1;
    transform: scale(1.03);
}

.count_button:active,
.count_button.long_pressing {
    background: #0059b3;
}

.increase_item .count_button {
    background: #e04b4b;
}

.increase_item .count_button:hover {
    background: #c73535;
}

.increase_item .count_button:active,
.increase_item .count_button.long_pressing {
    background: #ad2727;
}

.remove_button {
    width: 100%;
    padding: 7px;
    color: #ffffff;
    border: none;
    border-radius: 8px;
    background: #999999;
    font-weight: bold;
    cursor: pointer;
}

input[type="button"].danger_button {
    background-color: #e04b4b;
}

input[type="button"].danger_button:hover {
    background-color: #c73535;
}

body.entrance_use_mode .target_setting,
body.entrance_use_mode .counter_settings,
body.entrance_use_mode .remove_button,
body.entrance_use_mode .setting_action {
    display: none;
}

body.entrance_use_mode #top_actions {
    display: none;
}

body.entrance_use_mode #entrance_controls_section {
    border-bottom: none;
}

body.entrance_use_mode .setting_heading_text,
body.entrance_setting_mode .use_heading_text {
    display: none;
}

body.entrance_setting_mode .counter_button_area {
    display: none;
}

body.entrance_use_mode #entrance_summary {
    grid-template-columns: 1fr;
}

body.entrance_use_mode #remaining_panel {
    min-height: 160px;
}

body.entrance_use_mode #remaining_count {
    font-size: 108px;
}

body.entrance_use_mode .count_button {
    min-height: 120px;
    font-size: 56px;
}

body.entrance_setting_mode #counter_list {
    grid-template-columns: repeat(auto-fit, minmax(260px, 360px));
}

@media (max-width: 800px) {
    #entrance_summary {
        grid-template-columns: 1fr;
    }

    .count_button {
        min-height: 96px;
    }
}

@media (max-width: 480px) {
    #header-content {
        padding-left: 58px;
        padding-right: 12px;
        align-items: flex-start;
    }

    #header-title {
        font-size: 15px;
    }

    #version_header {
        font-size: 10px;
    }

    #logo-img {
        width: 44px;
        height: 44px;
        top: 13px;
        left: 8px;
    }

    #remaining_count {
        font-size: 64px;
    }

    body.entrance_use_mode #remaining_count {
        font-size: 72px;
    }

    body.entrance_use_mode #remaining_panel {
        min-height: 140px;
    }

    #counter_list,
    body.entrance_setting_mode #counter_list {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 8px;
    }

    .counter_item {
        padding: 8px;
    }

    .display_counter_name {
        font-size: 15px;
    }

    .count_button {
        min-height: 86px;
        font-size: 34px;
    }

    body.entrance_use_mode .count_button {
        min-height: 92px;
        font-size: 38px;
    }

    input.counter_name,
    input.counter_weight {
        font-size: 16px;
        padding: 5px;
    }

    .counter_setting_row {
        grid-template-columns: minmax(0, 1fr) minmax(70px, auto);
        gap: 6px;
    }

    .counter_setting_title {
        font-size: 12px;
    }

    .counter_settings .counter_total_setting {
        min-height: 52px;
        padding: 4px 6px;
        gap: 3px 5px;
    }

    .direction_option {
        min-height: 34px;
        padding: 5px 4px;
        font-size: 15px;
    }

    input[type="button"] {
        min-height: 36px;
        padding: 7px 12px;
        font-size: 14px;
    }
}
