/* --- 全体スタイル・ダークモード設定 --- */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    /* タップ時のハイライトやテキスト選択を防止 */
    -webkit-tap-highlight-color: transparent;
    -webkit-user-select: none;
    user-select: none;
    touch-action: manipulation;/*横スクロール効かなかったのでpan-yから変更*/
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background-color: #121212;
    color: #E0E0E0;
    display: flex;
    flex-direction: column;
    height: 100vh; /*旧ブラウザ用フォールバック*/
    height: 100dvh; /*アドレスバー変動に対応*/
    overflow: hidden;
}

/* テキスト入力欄はテキスト選択を許可 */
input[type="text"] {
    -webkit-user-select: text;
    user-select: text;
}

/* --- ヘッダー・タブ切替 --- */
header {
    background-color: #1E1E1E;
    border-bottom: 1px solid #333;
    display: flex;
    justify-content: space-around;
    padding: 8px;
    flex-shrink: 0;
}

.tab-btn {
    flex: 1;
    padding: 12px;
    background: none;
    border: none;
    color: #888;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    border-bottom: 3px solid transparent;
    transition: all 0.2s;
}

.tab-btn.active {
    color: #4CAF50;
    border-bottom-color: #4CAF50;
}

/* --- メインコンテンツエリア --- */
main {
    flex: 1;
    overflow-y: auto;
    position: relative;
}

.tab-content {
    display: none;
    height: 100%;
    flex-direction: column;
}

.tab-content.active {
    display: flex;
}

/* --- シングルカウンター --- */
.single-container {
    display: flex;
    flex-direction: column;
    min-height: 100%;
}

.count-display-section {
    background-color: #1A1A1A;
    padding: 20px 15px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border-bottom: 2px solid #333;
    flex-shrink: 0;
}

.count-number {
    font-size: 64px;
    font-weight: bold;
    color: #FFFFFF;
    margin-bottom: 15px;
    font-variant-numeric: tabular-nums;
}

.btn-group {
    display: flex;
    gap: 10px;
    width: 100%;
    max-width: 400px;
}

.btn {
    flex: 1;
    padding: 14px;
    font-size: 18px;
    font-weight: bold;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    color: #FFF;
    transition: opacity 0.1s;
}

.btn:active {
    opacity: 0.7;
}

.btn-plus { background-color: #2E7D32; font-size: 24px; }
.btn-minus { background-color: #C62828; font-size: 24px; }
.btn-save { background-color: #1565C0; }
.btn-reset { background-color: #424242; color: #AAA; }

/* 履歴テーブルエリア */
.history-section {
    flex: 1;
    padding: 15px;
    padding-bottom: calc(80px + env(safe-area-inset-bottom)); /* 広告分 + Safe Area */
    overflow-y: auto;
    background-color: #121212;
}

.history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    padding-bottom: 5px;
    border-bottom: 1px solid #333;
}

.history-title {
    font-size: 14px;
    color: #888;
}

.clear-history-btn {
    background: none;
    border: none;
    color: #E57373;
    font-size: 12px;
    cursor: pointer;
}

/* テーブル基本デザイン */
.custom-table-wrapper {
    width: 100%;
    overflow-x: auto;
    background-color: #1A1A1A;
    border-radius: 8px;
    border: 1px solid #2A2A2A;
}

.custom-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    text-align: left;
}

.custom-table th, .custom-table td {
    padding: 10px 10px;
    border-bottom: 1px solid #2A2A2A;
    white-space: nowrap;
}

.custom-table th {
    background-color: #1E1E1E;
    color: #888;
    font-weight: normal;
    position: sticky;
    top: 0;
    z-index: 1;
}

.custom-table td.val-cell {
    font-weight: bold;
    color: #4CAF50;
    text-align: right;
}

.custom-table td.no-cell {
    color: #4CAF50;
    font-weight: bold;
    width: 45px;
}

.table-label-input {
    background: none;
    border: none;
    border-bottom: 1px dashed #555;
    color: #FFF;
    font-size: 13px;
    padding: 2px 4px;
    width: 110px;
}

.table-label-input:focus {
    outline: none;
    border-bottom-color: #4CAF50;
}

/* --- マルチカウンター --- */
.multi-container {
    padding: 15px;
    padding-bottom: calc(80px + env(safe-area-inset-bottom)); /* 広告分 + Safe Area */
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.multi-controls {
    display: flex;
    gap: 10px;
    flex-shrink: 0;
}

.add-counter-btn {
    flex: 1;
    padding: 12px;
    background-color: #1E1E1E;
    border: 1px dashed #4CAF50;
    color: #4CAF50;
    border-radius: 10px;
    font-size: 14px;
    font-weight: bold;
    cursor: pointer;
}

.save-score-btn {
    flex: 1;
    padding: 12px;
    background-color: #1565C0;
    border: none;
    color: #FFF;
    border-radius: 10px;
    font-size: 14px;
    font-weight: bold;
    cursor: pointer;
}

.multi-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.multi-card {
    background-color: #1E1E1E;
    border-radius: 12px;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.multi-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.multi-label-input {
    background: none;
    border: none;
    border-bottom: 1px solid #444;
    color: #FFF;
    font-size: 15px;
    padding: 2px 4px;
    width: 65%;
}

.multi-label-input:focus {
    outline: none;
    border-bottom-color: #4CAF50;
}

.btn-delete {
    background: none;
    border: none;
    color: #E57373;
    font-size: 12px;
    cursor: pointer;
}

.multi-card-body {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.multi-val {
    font-size: 28px;
    font-weight: bold;
    min-width: 60px;
    text-align: center;
    font-variant-numeric: tabular-nums;
}

.multi-btn-group {
    display: flex;
    gap: 8px;
}

.sm-btn {
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 8px;
    font-size: 18px;
    font-weight: bold;
    color: #FFF;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.sm-btn:active {
    opacity: 0.7;
}

.sm-btn-plus { background-color: #2E7D32; }
.sm-btn-minus { background-color: #C62828; }
.sm-btn-reset { background-color: #424242; font-size: 11px; color: #AAA; }

/* 保存履歴エリア */
.history-board-section {
    margin-top: 10px;
    background-color: #1A1A1A;
    border-radius: 12px;
    padding: 12px;
    border: 1px solid #333;
}

.history-board-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.history-board-title {
    font-size: 14px;
    font-weight: bold;
    color: #4CAF50;
}

.history-table {
    width: 100%;
}

.history-table th, .history-table td {
    text-align: center;
}

.history-table th.time-col, .history-table td.time-col {
    text-align: left;
}

.history-table tfoot td {
    background-color: #242424;
    font-weight: bold;
    color: #FFB74D;
    border-top: 2px solid #444;
}

.empty-msg {
    text-align: center;
    color: #666;
    padding: 20px 0;
    font-size: 13px;
}

/* ========================================
   Fixed Advertisement
======================================== */

.ad-banner {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: #121212;
    z-index: 1000;
    padding-top: 1px;
    padding-bottom: calc(1px + env(safe-area-inset-bottom));
    border-top: 1px solid #333;
}

/* ========================================
   Footer Link (MRS TOOLS)
======================================== */

.footer-link-container {
    width: 100%;
    margin-top: 24px;
    margin-bottom: 12px;
    text-align: center;
}

.btn-footer-link {
    display: inline-block;
    color: #888888;
    font-size: 0.85rem;
    font-weight: normal;
    text-decoration: underline;
    background: none;
    border: none;
    border-radius: 0;
    min-height: auto;
    padding: 4px 8px;
    transition: color 0.2s;
}

.btn-footer-link:active,
.btn-footer-link:hover {
    color: #cccccc;
    background-color: transparent;
    transform: none;
}
