﻿/* Modern CSS Reset & Variables */
:root {
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --bg-body: #f3f4f6;
    --bg-card: #ffffff;
    --text-main: #1f2937;
    --text-muted: #6b7280;
    --border: #e5e7eb;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --radius: 12px;
    --win-color: #2563eb;
    --lose-color: #ef4444;
    
    /* Colors */
    --gold: #d97706; /* Adjusted Gold */
    --silver: #9ca3af;
    --bronze: #b45309;
    --iron: #4b5563;
    --diamond: #06b6d4;
    --goshugi: #db2777;

    --line-color: #06c755;
    --edit-bg: #fff7ed;
    --edit-border: #fdba74;
    --disabled-bg: #e5e7eb;
    --disabled-text: #9ca3af;
}

* { box-sizing: border-box; }
body {
    margin: 0;
    font-family: 'Inter', 'Noto Sans JP', sans-serif;
    background-color: var(--bg-body);
    color: var(--text-main);
    font-size: 12px;
    line-height: 1.5;
    padding-bottom: 60px;
}

.container {
    max-width: 800px;
    margin: 0 auto;
    padding: 12px;
    display: grid;
    gap: 12px;
    grid-template-columns: 1fr;
}

header { text-align: center; margin-bottom: 8px; padding-top:10px; }
h1 { font-size: 1.05rem; font-weight: 700; margin: 0; white-space: nowrap; }
.en-title { font-size: 0.72rem; color: #9ca3af; font-weight: 500; }

/* Menu Bar */
.menu-bar { display: flex; justify-content: center; gap: 4px; margin-bottom: 8px; flex-wrap: wrap; }
.menu-btn {
    background: #fff; border: 1px solid var(--primary); color: var(--primary);
    padding: 6px 10px; border-radius: 18px; font-size: 0.72rem; font-weight: 500;
    cursor: pointer; display: flex; align-items: center; gap: 4px; transition: all 0.2s;
    white-space: nowrap;
}
.menu-btn:hover { background: var(--primary); color: #fff; }
.menu-btn svg { width: 14px; height: 14px; fill: currentColor; }

/* Color variants for menu buttons */
.menu-btn.btn-share { border-color: #4338ca; color: #4338ca; background: #fff; }
.menu-btn.btn-share:hover { background: #4338ca; color: #fff; }

.menu-btn.btn-line { border-color: #06c755; color: #06c755; background: #fff; }
.menu-btn.btn-line:hover { background: #06c755; color: #fff; }

.menu-btn.btn-copy { border-color: #4b5563; color: #4b5563; background: #fff; }
.menu-btn.btn-copy:hover { background: #4b5563; color: #fff; }


/* Info Bar */
.info-bar {
    text-align: center; font-size: 0.72rem; color: #9ca3af;
    margin-bottom: 8px; padding: 0 12px; line-height: 1.45;
}
.info-highlight { color: #b45309; font-weight: 600; }

/* Components */
.card {
    background: var(--bg-card); border-radius: var(--radius); padding: 12px;
    box-shadow: var(--shadow); border: 1px solid var(--border);
    transition: all 0.3s ease; width: 100%;
}
.card.editing {
    background: var(--edit-bg); border-color: var(--edit-border);
    box-shadow: 0 0 0 4px rgba(253, 186, 116, 0.2);
}
.card-header {
    font-weight: 700; color: #374151; margin-bottom: 8px; padding-bottom: 6px;
    border-bottom: 1px solid var(--border); display: flex;
    justify-content: space-between; align-items: center;
    white-space: nowrap; font-size: 1rem;
}
.section-title-icon { 
    vertical-align: text-bottom; margin-right: 6px; 
    width: 24px; height: 24px; /* 固定サイズ指定 */
    fill: var(--primary); 
}
.section-title-wrap { display: flex; align-items: center; }

.course-badge{
    border: 1px solid #1e3a8a;
    border-radius: 999px;
    padding: 1px 8px;
    font-size: 0.7em;
    margin-left: 6px;
    vertical-align: middle;
    display: inline-block;
    color: #ffffff;
    background: #1e3a8a;
    font-weight: 700;
    letter-spacing: 0.02em;
}

.form-group { margin-bottom: 16px; }
label { 
    display: block; font-size: 0.85rem; font-weight: 700; margin-bottom: 6px; 
    color: var(--text-main); white-space: nowrap; 
}
.help-text { font-size: 0.75rem; color: var(--text-muted); margin-bottom: 6px; line-height: 1.4; }
.help-text-small { font-size: 0.7rem; color: #6b7280; margin-top: 2px; line-height: 1.2; }

input[type="text"], input[type="number"], select {
    width: 100%; padding: 10px 12px;
    border: 1px solid #d1d5db; border-radius: 6px;
    font-size: 0.95rem; background: #fff; color: var(--text-main);
}
select:disabled, input:disabled { 
    background: var(--disabled-bg); color: var(--disabled-text);
    cursor: not-allowed; border-color:#e5e7eb; 
}

/* Grid Layouts */
.player-grid, .score-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 10px;
}

.player-row-card {
    background: #f9fafb; border: 1px solid var(--border); border-radius: 8px;
    padding: 10px; position: relative;
    display: flex; flex-direction: column; gap: 8px;
}

/* UI Elements */
.role-badge {
    position: absolute; top: -8px; left: -8px;
    width: 24px; height: 24px;
    background: #374151; color: #fff; font-size: 0.75rem; font-weight: 700;
    border-radius: 50%; display: flex; align-items: center; justify-content: center;
    border: 2px solid #fff; box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}
.team-a .role-badge { background: var(--primary); }
.team-b .role-badge { background: var(--lose-color); }

.team-label { 
    font-size: 0.85rem; font-weight: 700; color: var(--text-main); 
    margin-bottom: 0px; padding-left: 16px; 
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis; 
}
.team-a { border-left: 4px solid var(--primary); }
.team-b { border-left: 4px solid var(--lose-color); }

.olympic-options { display: flex; gap: 4px; flex-wrap: wrap; }

.check-label {
    display: inline-flex; align-items: center; font-size: 0.8rem;
    background: #fff; border: 1px solid #d1d5db; padding: 8px 10px;
    border-radius: 6px; cursor: pointer; transition: all 0.2s;
    white-space: nowrap; 
}
.check-label input { margin-right: 6px; width: auto; transform: scale(1.1); }
.check-label.disabled {
    background: var(--disabled-bg); color: var(--disabled-text); border-color: #e5e7eb; cursor: not-allowed;
}

/* Special Status Text */
.special-status { color: var(--gold); font-weight: 800; font-size: 0.85rem; margin-left: 8px; animation: fadeIn 0.5s; white-space: nowrap; }
.special-status-blue { color: var(--primary); font-weight: 800; font-size: 0.85rem; margin-left: 8px; animation: fadeIn 0.5s; white-space: nowrap; }
.special-status-orange { color: #f97316; font-weight: 800; font-size: 0.85rem; margin-left: 8px; animation: fadeIn 0.5s; white-space: nowrap; }
.special-status-red { color: var(--lose-color); font-weight: 800; font-size: 0.85rem; margin-left: 8px; animation: fadeIn 0.5s; white-space: nowrap; }
@keyframes fadeIn { from { opacity:0; } to { opacity:1; } }

/* Badges for Header */
.badge-hole { background:#e0f2fe; color:#0369a1; padding:4px 8px; border-radius:4px; font-size:0.9rem; font-weight:bold; white-space: nowrap; }
.badge-mode { background:#f3f4f6; color:#4b5563; padding:4px 8px; border-radius:4px; font-size:0.8rem; font-weight:bold; border:1px solid #e5e7eb; white-space: nowrap; }

/* Order Badge */
.order-badge {
    display: inline-flex; align-items: center; justify-content: center;
    width: 24px; height: 24px; flex-shrink: 0;
    background: #e5e7eb; color: #4b5563;
    font-weight: 800; font-size: 0.8rem; border-radius: 50%;
}

/* Buttons */
.btn {
    width: 100%; padding: 12px; background-color: var(--primary); color: white;
    font-weight: 600; border: none; border-radius: 8px; cursor: pointer;
    font-size: 1rem; display: inline-flex; justify-content: center; align-items: center; gap: 8px;
    white-space: nowrap;
}
.btn:hover { background-color: var(--primary-hover); }
.btn-warning { background-color: #f97316; }
.btn-warning:hover { background-color: #ea580c; }
/* Cleaned up conflicting classes */
.btn-secondary { background-color: #fff; border: 1px solid #d1d5db; color: var(--text-main); }
.btn-secondary:hover { background-color: #f3f4f6; }
.toggle-btn {
    padding: 6px; font-size: 0.8rem; background: white; border: 1px solid var(--border);
    border-radius: 4px; cursor: pointer; flex: 1; white-space: nowrap;
}
.toggle-btn.active { background: var(--text-main); color: white; border-color: var(--text-main); }
.flex-row { display: flex; gap: 8px; align-items: center; }

/* Result Table */
.table-container { overflow-x: auto; margin-bottom: 20px; }
table { width: 100%; border-collapse: collapse; font-size: 0.85rem; white-space: nowrap; }
th, td { padding: 8px; text-align: center; border-bottom: 1px solid var(--border); }
th:first-child, td:first-child { text-align: left; }
th { background: #f9fafb; color: var(--text-muted); font-weight: 700; white-space: nowrap; }
.money-plus { color: var(--win-color); font-weight: 700; }
.money-minus { color: var(--lose-color); font-weight: 700; }
.badge-goshugi { color: var(--goshugi); font-weight: bold; background: #fce7f3; padding: 2px 4px; border-radius: 4px; font-size: 0.8em; }

/* Scorecard New Style */
.scorecard-table th, .scorecard-table td { border: 1px solid #e5e7eb; padding: 6px 4px; font-size: 0.8rem; }
.scorecard-table th.hole-header { background: #eff6ff; color: #1e3a8a; width: 40px; cursor: pointer; }
.scorecard-table th.player-header { background: #f9fafb; text-align: left; width: 100px; font-weight: 800 !important; }
.score-val { font-weight: 800; font-size: 1rem; }
.putt-val { font-size: 0.75rem; color: #6b7280; margin-left: 2px; }
.chipin-mark { color: #db2777; font-size: 0.7rem; vertical-align: top; margin-left: 1px; }
.order-mark { font-size: 0.75rem; vertical-align: top; margin-right: 2px; font-weight: 700; }
/* Order Colors */
.order-team-a { color: var(--win-color); }
.order-team-b { color: var(--lose-color); }

/* Colors for scores - Optimized */
.color-hio { color: var(--gold) !important; }
.color-alb { color: var(--gold) !important; }
.color-eagle { color: var(--lose-color) !important; }
.color-birdie { color: #f97316 !important; }
.color-par { color: var(--primary) !important; }

/* Vegas Matchup Box */
.vegas-matchup {
    background: #eff6ff; border: 1px solid #bfdbfe; color: #1e40af;
    padding: 12px; border-radius: 8px; margin-bottom: 12px;
    font-size: 0.95rem; font-weight: 700; text-align: center;
    box-shadow: 0 2px 4px rgba(37, 99, 235, 0.05);
}
.matchup-team-1 { color: var(--win-color); font-weight: 800; }
.matchup-team-2 { color: var(--lose-color); font-weight: 800; }
.matchup-vs { color: var(--text-muted); font-size: 0.85em; margin: 0 8px; font-weight: 400; }

#history_rows tr { cursor: pointer; transition: background 0.1s; }
#history_rows tr:hover { background-color: #fef3c7; }

/* Legend Box */
.legend-box {
    background: #f9fafb; padding: 10px; border-radius: 8px; font-size: 0.75rem; color: #4b5563; margin-bottom: 10px;
    border: 1px solid #e5e7eb;
}
.legend-item { display: inline-block; margin-right: 12px; }

/* Modal Styles */
.modal {
    display: none; position: fixed; z-index: 1000;
    left: 0; top: 0; width: 100%; height: 100%;
    background-color: rgba(0,0,0,0.5); overflow-y: auto;
}
.modal-content {
    background-color: #fff; margin: 5% auto; padding: 24px;
    border-radius: var(--radius); width: 95%; max-width: 640px;
    position: relative; animation: slideDown 0.3s ease;
}
@keyframes slideDown { from { transform: translateY(-20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.close-btn { position: absolute; top: 15px; right: 20px; font-size: 28px; font-weight: bold; color: #aaa; cursor: pointer; }
.modal h2 { margin-top: 0; border-bottom: 2px solid var(--border); padding-bottom: 12px; font-size: 1.3rem; white-space: nowrap; }
.rule-section { margin-bottom: 24px; border-bottom: 1px solid #eee; padding-bottom: 20px; }
.rule-section:last-child { border-bottom: none; padding-bottom: 0; margin-bottom: 0; }
.rule-title { font-weight: 800; color: var(--primary); margin-bottom: 10px; font-size: 1.1rem; border-left: 5px solid var(--primary); padding-left: 10px; white-space: nowrap; }

.rule-subtitle{margin-top:14px; font-weight:800; font-size:1.05rem; color:#111827;}
#modal_rule .rule-subtitle.game-title{font-size:1.08rem;}
.rule-text { font-size: 0.95rem; color: #374151; line-height: 1.7; }
.rule-list { margin: 8px 0 0 20px; padding: 0; list-style-type: disc; }
.rule-list li { margin-bottom: 6px; }
/* Manual (Rule) subtitles */
#modal_rule .rule-subtitle {
  margin-top: 14px;
  font-weight: 800;
  font-size: 1.05rem;
  color: #111827;
}
#modal_rule .rule-subtitle.game-title {
  font-size: 1.08rem;
}

.rule-badge { display: inline-block; padding: 2px 6px; border-radius: 4px; font-size: 0.85em; font-weight: bold; color: #fff; vertical-align: middle; }

/* Footer */
footer {
    position: fixed; bottom: 0; left: 0; width: 100%;
    background-color: rgba(255, 255, 255, 0.95); backdrop-filter: blur(5px);
    border-top: 1px solid var(--border); padding: 12px;
    display: flex; justify-content: center; align-items: center;
    font-size: 0.8rem; color: var(--text-muted); font-weight: 600;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.05); z-index: 100;
}
.history-link {
    background: #f3f4f6; color: var(--text-muted); padding: 4px 10px; 
    border-radius: 12px; cursor: pointer; font-size: 0.75rem; border: 1px solid #e5e7eb; white-space: nowrap;
    position: absolute; right: 12px;
}


/* ---- Disabled inputs with Chrome autofill (fix: grey-out not visible) ---- */
input:disabled:-webkit-autofill,
input:disabled:-webkit-autofill:hover,
input:disabled:-webkit-autofill:focus,
input:disabled:-webkit-autofill:active {
  -webkit-text-fill-color: var(--disabled-text) !important;
  box-shadow: 0 0 0px 1000px var(--disabled-bg) inset !important;
  caret-color: transparent !important;
}


/* ---- Autofill background fix (player name / HC fields look different) ---- */
input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus,
textarea:-webkit-autofill,
textarea:-webkit-autofill:hover,
textarea:-webkit-autofill:focus,
select:-webkit-autofill,
select:-webkit-autofill:hover,
select:-webkit-autofill:focus {
  -webkit-text-fill-color: var(--text-main) !important;
  box-shadow: 0 0 0px 1000px var(--bg-card) inset !important;
  transition: background-color 9999s ease-out 0s;
}


/* ---- Strong autofill override (some fields keep blue background) ---- */
input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus,
input:-webkit-autofill:active,
textarea:-webkit-autofill,
textarea:-webkit-autofill:hover,
textarea:-webkit-autofill:focus,
textarea:-webkit-autofill:active {
  -webkit-text-fill-color: var(--text-main) !important;
  -webkit-box-shadow: 0 0 0px 1000px #ffffff inset !important;
  box-shadow: 0 0 0px 1000px #ffffff inset !important;
  caret-color: auto !important;
}

/* Chrome internal autofill state (works on some versions) */
input:-internal-autofill-selected,
textarea:-internal-autofill-selected {
  -webkit-text-fill-color: var(--text-main) !important;
  -webkit-box-shadow: 0 0 0px 1000px #ffffff inset !important;
  box-shadow: 0 0 0px 1000px #ffffff inset !important;
}


/* ---- Option modal spacing ---- */
#modal_option .modal-content { max-width: 720px; }
#modal_option .form-group { margin: 14px 0 18px; }
#modal_option .player-grid { margin-top: 8px; }
#modal_option .section-title {
  font-weight: 700;
  margin: 6px 0 6px;
  padding: 8px 10px;
  background: rgba(0,0,0,0.04);
  border-radius: 10px;
  font-size: 16px;
  line-height: 1.2;
}
#modal_option label.sr-only { 
  position:absolute; width:1px; height:1px; padding:0; margin:-1px; overflow:hidden; clip:rect(0,0,0,0); white-space:nowrap; border:0;
}
#modal_option .no-label select { margin-top: 22px; }
#modal_option .player-grid input[type="text"] { padding: 10px; }

/* ---- Rule modal spacing ---- */
#modal_rule .rule-section { margin-bottom: 16px; }
#modal_rule .rule-title { margin-bottom: 8px; }
#modal_rule .rule-text { line-height: 1.55; }


/* ---- Underline for section headers (ranking/summary) ---- */
.card-header.card-header-underline{
  border-bottom: 1px solid var(--border) !important;
}


/* ---- Danger button (inverted / high visibility) ---- */
.btn-danger-invert{
  background: #ef4444;
  color: #ffffff !important;
  border: 1px solid #ef4444 !important;
  font-weight: 800;
}
.btn-danger-invert:hover{
  filter: brightness(0.95);
}


/* ---- Mobile vertical tables ---- */
@media (max-width: 640px){
  table.table-card{ width:100%; border-collapse: separate; border-spacing: 0; }
  table.table-card thead{ display:none; }
  table.table-card tbody,
  table.table-card tr{ display:block; width:100%; }
  table.table-card tr{
    margin: 10px 0;
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
    background: #fff;
  }
  table.table-card th,
  table.table-card td{
    display:flex;
    align-items:center;
    justify-content:space-between;
    gap: 12px;
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    width:100%;
    box-sizing:border-box;
    text-align:right;
  }
  table.table-card th:last-child,
  table.table-card td:last-child{ border-bottom:none; }

  table.table-card th::before,
  table.table-card td::before{
    content: attr(data-label);
    font-weight: 800;
    opacity: .85;
    text-align:left;
    white-space: nowrap;
  }

  /* keep tiny marks aligned on the right */
  table.table-card .order-mark,
  table.table-card .chipin-mark{
    margin-left: 6px;
  }
}


/* ---- Mobile: keep ranking/summary as tables (not cards) ---- */
@media (max-width: 640px){
  /* Keep ranking/summary styling consistent with desktop */
  .table-container table{ font-size: 0.85rem; }
  .table-container th, .table-container td{ padding: 8px; white-space: nowrap; }
}


/* ---- Mobile scorecard: vertical card layout (only scorecard) ---- */
@media (max-width: 640px){
  /* hide header row */
  table.scorecard-table thead{ display:none; }

  table.scorecard-table tbody,
  table.scorecard-table tr,
  table.scorecard-table td{ display:block; width:100%; }

  table.scorecard-table tr{
    margin: 10px 0;
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
    background: #fff;
  }

  table.scorecard-table td{
    display:flex;
    justify-content:space-between;
    gap: 12px;
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    white-space: normal;
  }
  table.scorecard-table td:last-child{ border-bottom:none; }

  table.scorecard-table td::before{
    content: attr(data-label);
    font-weight: 700;
    opacity: .85;
    white-space: nowrap;
  }
}


/* ---- Mobile: vertical tables (no cards) ---- */
@media (max-width: 640px){
  /* Force tables to remain tables (neutralize old card CSS) */
  table.scorecard-table thead{ display: table-header-group !important; }
  table.scorecard-table tbody{ display: table-row-group !important; }
  table.scorecard-table tr{ display: table-row !important; }
  table.scorecard-table th,
  table.scorecard-table td{ display: table-cell !important; }

  /* same for ranking/summary */
  table.ranking-table thead{ display: table-header-group !important; }
  table.ranking-table tbody{ display: table-row-group !important; }
  table.ranking-table tr{ display: table-row !important; }
  table.ranking-table th,
  table.ranking-table td{ display: table-cell !important; }

  #summary_table thead{ display: table-header-group !important; }
  #summary_table tbody{ display: table-row-group !important; }
  #summary_table tr{ display: table-row !important; }
  #summary_table th, #summary_table td{ display: table-cell !important; }

  /* Make mobile tables readable */
  /* Match desktop decorations for ranking/summary */
  .table-container table{ font-size: 0.85rem; }
  .table-container th, .table-container td{ padding: 8px; }
  .mobile-vert-table th, .mobile-vert-table td{ white-space: normal; }
  .mobile-player-row th{ background: #f3f4f6; font-weight: 800; }
}


/* ---- Mobile hole input: keep 2x2 grid but prevent overflow ---- */
@media (max-width: 520px){
  #input_card .score-grid{
    gap: 8px;
  }
  .player-row-card{
    padding: 8px;
  }
  .player-row-card .team-label{
    font-size: 0.8rem;
  }
  .player-row-card .flex-row{
    flex-wrap: wrap;
    row-gap: 6px;
  }
  /* Save horizontal space: remove inline left-margins on small screens */
  .player-row-card .check-label{
    margin-left: 0 !important;
    font-size: 12px;
  }
  /* Inline widths in HTML can cause overflow; relax them on mobile */
  .player-row-card .flex-row label[style*="width:40px"]{
    width: auto !important;
    min-width: 0 !important;
  }
  .player-row-card .flex-row div[style*="width:60px"]{
    width: 76px !important;
    min-width: 76px !important;
  }
  /* Ensure inputs/selects don't overflow their containers */
  .player-row-card input,
  .player-row-card select{
    width: 100% !important;
    box-sizing: border-box;
  }
}


/* ---- Prevent horizontal overflow on mobile ---- */
@media (max-width: 768px){
  html, body{ overflow-x: hidden; }
  .table-container{ max-width: 100%; }
}


/* ---- Mobile scorecard: fit-to-screen transposed table ---- */
@media (max-width: 520px){
  table.scorecard-table{
    width: 100%;
    table-layout: fixed;
  }
  table.scorecard-table th,
  table.scorecard-table td{
    padding: 6px 6px;
    font-size: 12px;
    white-space: normal !important;   /* override global nowrap */
    word-break: break-word;
  }
  table.scorecard-table th.hole-header{
    width: 44px;
  }
  table.scorecard-table th.player-header{
    text-align: center;
    font-size: 11px;
  }
  table.scorecard-table .putt-val{
    font-size: 0.75em;
  }
  table.scorecard-table .order-mark{
    margin-right: 2px;
  }
}

/* ---- Mobile: remove extra side padding & force grid items to shrink (Pixel/Chrome overflow fix) ---- */
@media (max-width: 520px){
  /* Less side margin on small screens */
  .container{ padding-left: 8px; padding-right: 8px; }
  .card{ padding: 12px; }

  /* Header badges may get long; allow wrapping */
  #input_card .card-header{ flex-wrap: wrap; gap: 8px; }
  #input_card .card-header > div:last-child{ flex-wrap: wrap; justify-content: flex-end; max-width: 100%; }
  #mode_display{ max-width: 100%; white-space: normal; overflow-wrap: anywhere; }

  /* Critical: grid/flex children must be allowed to shrink */
  #input_card .score-grid{ grid-template-columns: repeat(2, minmax(0, 1fr)) !important; }
  #input_card .player-row-card{ min-width: 0; }
  #input_card .player-row-card .flex-row{ min-width: 0; }
  #input_card .player-row-card .flex-row > *{ min-width: 0; }
  #input_card .player-row-card input,
  #input_card .player-row-card select{ min-width: 0; }
}


/* ===== Layout tweaks (OUT/IN no-wrap, item columns auto-fit) ===== */
.scorecard-table th.hole-header { white-space: nowrap; }
.scorecard-table th.hole-header .course-badge { margin-left: 0; white-space: nowrap; }

@media (max-width: 768px) {
  /* ensure OUT/IN badge and hole numbers share same fixed width */
  .scorecard-table th.hole-header { width: 40px; min-width: 40px; }
  .scorecard-table th.hole-header .course-badge { padding: 1px 6px; }
}

/* Ranking / Summary: first column width fits the longest label (no wrapping) */
table.ranking-table th:first-child,
#summary_table th:first-child {
  white-space: nowrap;
  width: 1%;
}


/* ===== Player name wrapping in tables ===== */
.scorecard-table th.player-header,
table.ranking-table thead th,
#summary_table thead th {
  white-space: normal;
  overflow: visible;
  text-overflow: clip;
  word-break: break-word;
  overflow-wrap: anywhere;
}

@media (max-width: 768px) {
  .scorecard-table th.player-header { font-size: 12px; line-height: 1.1; padding: 6px 4px; }
  table.ranking-table thead th,
  #summary_table thead th { font-size: 12px; line-height: 1.1; padding: 8px 4px; }
}

/* ===== Matchup label formatting on mobile ===== */
@media (max-width: 768px) {
  #vegas_matchup_display { text-align: center; }
  #vegas_matchup_display .matchup-vs { display: inline-block; margin: 2px 0; }
}


/* ===== Centering tweaks ===== */
.scorecard-table th.hole-header,
.scorecard-table td.hole-no,
.scorecard-table td.hole-number {
  text-align: center;
  vertical-align: middle;
}

/* Ranking + Summary: center item column (first column) */
table.ranking-table th:first-child,
table.ranking-table td:first-child,
#summary_table th:first-child,
#summary_table td:first-child {
  text-align: center;
}

/* Keep item column auto-fit but centered */
table.ranking-table th:first-child,
#summary_table th:first-child {
  white-space: nowrap;
  width: 1%;
}

@media (max-width: 768px) {
  #vegas_matchup_display { text-align: center; }
  #vegas_matchup_display .matchup-hole { display:block; text-align:left; margin-bottom:2px; }
  #vegas_matchup_display .matchup-body { display:block; text-align:center; }
}


/* ===== Center item labels (ranking/summary) ===== */
table.ranking-table tbody th.item-col,
#summary_table tbody th.item-col {
  text-align: center !important;
}


@media (max-width: 768px) {
  .player-grid { grid-template-columns: 1fr !important; }
}


/* Olympic extra rules should match other option sections */
#oly_extra_rules .section-title { margin-bottom: 6px; }
#oly_extra_rules .help-text { margin-bottom: 8px; }


/* Scorecard hole par display */
/* Par is a secondary label: not bold, and tinted. */
.hole-par { font-weight: 400; color: #6b7280; }
.hole-par.mobile-only { display:none; }
.hole-par.desktop-only { display:inline; font-size:0.8rem; margin-left:4px; }
@media (max-width: 768px) {
  .hole-par.desktop-only { display:none; }
  .hole-par.mobile-only { display:block; font-size:0.7rem; line-height:1.0; }
  table.scorecard-table td.total-label { text-align:center; }
}

/* Goshugi limit select */
.goshugi-limit { min-width:78px; }


/* ===== Round complete lock & overlay (added) ===== */
.gpc-input-locked { opacity: 0.6; }

.gpc-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}
.gpc-overlay.hidden { display: none; }
.gpc-overlay-box {
  background: #fff;
  border-radius: 12px;
  padding: 16px;
  width: min(90vw, 420px);
  box-shadow: 0 10px 30px rgba(0,0,0,0.35);
}
.gpc-overlay-title { font-weight: 700; margin-bottom: 8px; }
.gpc-overlay-text { margin-bottom: 12px; line-height: 1.45; }


/* Scorecard notes */
.scorecard-notes { font-size: 0.72rem; color: #9ca3af; }

.scorecard-notes .note-line { display:block; }
.scorecard-notes .note-breakdown { color: #6b7280; }
.scorecard-notes .note-edit { color: #6b7280; }
@media (max-width: 768px) {
  .scorecard-notes .note-line { padding-left: 1.1em; text-indent: -1.1em; }
}




/* --- Scorecard notes typography --- */
.scorecard-notes{
  font-size: 13px;
  line-height: 1.45;
  color: var(--text-muted);
}
.scorecard-notes .note-line{ margin: 2px 0; }
@media (max-width: 768px){
  .scorecard-notes{ font-size: 13px; }
}
/* --- Unified font sizes (Scorecard / Ranking / Summary) --- */
:root{ --gpc-table-font: 14px; }
@media (max-width: 768px){ :root{ --gpc-table-font: 15px; } }

.scorecard-table th, .scorecard-table td,
table.ranking-table th, table.ranking-table td,
#summary_table th, #summary_table td{
  font-size: var(--gpc-table-font) !important;
}
.score-val{ font-size: var(--gpc-table-font) !important; font-weight: 800; }



/* Fix: scorecard player names bold */
.scorecard-table td.sc-player-name {
  font-weight: 700;
}

/* Fix: unify section title sizes */
.section-title-wrap { font-size: 16px; }


/* Par未選択時の入力ロック */
.player-row-card.par-locked {
  opacity: 0.45;
}
.player-row-card.par-locked * {
  pointer-events: none;
}
#par_select {
  pointer-events: auto;
}
.btn.btn-disabled {
  opacity: 0.5;
  cursor: not-allowed;
}


/* --- Scorecard point color (plus/minus) --- */
.sc-pt-plus { color: #2563eb; }
.sc-pt-minus { color: #dc2626; }
.sc-pt-zero { color: #6b7280; }



/* Highlight best (min/max) values in ranking table */
.best-blue{ color: var(--win-color); font-weight:700; }

#summary_table .money-plus, #summary_table .money-minus { font-weight: 400; }

.summary-total-th { font-weight: 700; }


/* --- Visual emphasis for ampersand in mode/matchup displays --- */
.badge-mode .amp { font-size: 0.75em; opacity: 0.85; }
.amp-small { font-size: 0.75em; opacity: 0.85; }

/* Scorecard point weights: default normal, total only bold */
.sc-pt { font-weight: 400; }
.sc-pt-total { font-weight: 700 !important; }



/* Changelog button */
.btn-changelog{padding:6px 10px;font-size:0.78rem;opacity:0.9;}
.btn-changelog svg{width:16px;height:16px;}


/* 更新履歴ボタン（コピー右側） */
.menu-btn-changelog{
  padding: 6px 10px;
  font-size: 12px;
  line-height: 1;
  min-height: 28px;
}
.menu-btn { gap: 0 !important; padding: 6px 10px; font-size: 12px !important; }
.menu-buttons { gap: 8px !important; }
.info-bar { font-size: 11px !important; }
h1 { font-size: 24px !important; }
h2 { font-size: 18px !important; }
body { font-size: 12px !important; }

.build-tag{font-size:11px; opacity:0.65; margin-left:6px;}

/* Summary header: allow multi-line notes under title */
#summary_section_header{flex-direction:column;align-items:flex-start;justify-content:flex-start;white-space:normal;gap:6px;}


/* --- UI tweak: only hide icon + compact for 更新履歴 button --- */
.menu-btn.btn-changelog svg{ display:none; }
.menu-btn.btn-changelog{
  padding: 6px 10px;
  font-size: 12px;
  line-height: 1.1;
}



/* ================================
   UI Adjustments (Smartphone & Changelog)
   - Make main menu buttons finger-friendly
   - Make 更新履歴 button compact & simple (icon hidden)
   ================================ */
.menu-bar{ gap: 10px !important; margin-bottom: 12px !important; }

.menu-btn{
  padding: 10px 14px !important;
  font-size: 0.92rem !important;
  min-height: 44px !important;
  border-radius: 18px !important;
  gap: 8px !important;
}

.menu-btn svg{
  width: 18px !important;
  height: 18px !important;
}

@media (max-width: 520px){
  .menu-bar{ gap: 8px !important; }
  .menu-btn{
    padding: 11px 14px !important;
    min-height: 46px !important;
  }
}

/* 更新履歴だけ：枠を変えて、コンパクトでシンプルに */
.menu-btn.btn-changelog{
  padding: 6px 10px !important;
  min-height: 32px !important;
  font-size: 0.78rem !important;
  border: 1px solid #d1d5db !important;
  background: #f9fafb !important;
  color: #374151 !important;
  border-radius: 10px !important;
  gap: 0 !important;
}

.menu-btn.btn-changelog:hover{
  background: #f3f4f6 !important;
  color: #111827 !important;
}

.menu-btn.btn-changelog svg{
  display: none !important;
}



/* ---- Ranking table: show rank labels above player names on mobile ---- */
@media (max-width: 768px){
  table.ranking-table thead tr.rank-row th{
    font-size: 11px;
    padding-top: 6px;
    padding-bottom: 4px;
    opacity: 0.9;
  }
}


/* --- UI polish: top menu buttons --- */
.top-menu button,
.top-menu .btn,
#topMenu button,
#topMenu .btn{
  border-radius: 9999px !important; /* full pill */
  padding-top: 6px !important;
  padding-bottom: 6px !important;
}

/* Make "更新履歴" button smaller than others */
#btnHistory,
button[data-action="history"],
.top-menu .btn-history,
#topMenu .btn-history{
  font-size: 11px !important;
  padding-top: 4px !important;
  padding-bottom: 4px !important;
  padding-left: 10px !important;
  padding-right: 10px !important;
}

/* Keep spacing tidy on small screens too */
@media (max-width: 768px){
  .top-menu button,
  .top-menu .btn,
  #topMenu button,
  #topMenu .btn{
    padding-top: 6px !important;
    padding-bottom: 6px !important;
  }
  #btnHistory,
  button[data-action="history"],
  .top-menu .btn-history,
  #topMenu .btn-history{
    font-size: 11px !important;
    padding-top: 4px !important;
    padding-bottom: 4px !important;
  }
}



/* ===== Force visible menu improvement ===== */
#topMenu button,
#topMenu .menu-btn,
.top-menu button{
  border-radius: 9999px !important;
  padding: 4px 12px !important;
  line-height: 1.2 !important;
}

/* History button: clearly smaller */
#btnHistory{
  font-size: 10px !important;
  padding: 2px 8px !important;
}


/* --- Menu button polish (v1.0.0) --- */
.menu-btn{
  border-radius: 9999px !important;          /* full semicircle ends */
  padding: 6px 12px !important;              /* tighter vertical padding */
  min-height: 36px !important;
  font-size: 0.86rem !important;
  gap: 8px !important;
}
.menu-btn svg{
  width: 18px !important;
  height: 18px !important;
}

/* Changelog button: smaller */
.menu-btn.btn-changelog{
  padding: 4px 10px !important;
  min-height: 30px !important;
  font-size: 0.78rem !important;
}

/* Mobile */
@media (max-width: 768px){
  .menu-btn{
    border-radius: 9999px !important;
    padding: 7px 12px !important;
    min-height: 40px !important;
    font-size: 0.92rem !important;
  }
  .menu-btn.btn-changelog{
    padding: 5px 10px !important;
    min-height: 32px !important;
    font-size: 0.80rem !important;
  }
}


/* --- Menu vertical alignment fix --- */
.menu-btn{
  display: inline-flex !important;
  align-items: center !important;
  line-height: 1 !important;
}

/* Tighten changelog button padding further */
.menu-btn.btn-changelog{
  padding-top: 3px !important;
  padding-bottom: 3px !important;
  line-height: 1 !important;
}

@media (max-width:768px){
  .menu-btn{
    align-items: center !important;
    line-height: 1 !important;
  }
  .menu-btn.btn-changelog{
    padding-top: 4px !important;
    padding-bottom: 4px !important;
  }
}


/* --- Changelog padding: half --- */
.menu-btn.btn-changelog{
  padding-top: 1px !important;
  padding-bottom: 1px !important;
  min-height: 22px !important;
}

@media (max-width:768px){
  .menu-btn.btn-changelog{
    padding-top: 2px !important;
    padding-bottom: 2px !important;
    min-height: 24px !important;
  }
}


/* --- Changelog spacing fix (ensure applied) --- */
.menu-bar .menu-btn.btn-changelog{
  padding-top: 2px !important;
  padding-bottom: 2px !important;
  min-height: 24px !important;
  line-height: 1 !important;
}
@media (max-width: 768px){
  .menu-bar .menu-btn.btn-changelog{
    padding-top: 3px !important;
    padding-bottom: 3px !important;
    min-height: 26px !important;
  }
}


/* --- Force apply: history button vertical padding (cache-bust v1.0.0.1) --- */
#btnHistory,
.menu-bar #btnHistory,
.menu-bar .menu-btn.btn-changelog{
  padding-top: 0px !important;
  padding-bottom: 0px !important;
  padding-left: 10px !important;
  padding-right: 10px !important;
  min-height: 20px !important;
  line-height: 1 !important;
  display: inline-flex !important;
  align-items: center !important;
}

@media (max-width: 768px){
  #btnHistory,
  .menu-bar #btnHistory,
  .menu-bar .menu-btn.btn-changelog{
    padding-top: 1px !important;
    padding-bottom: 1px !important;
    min-height: 22px !important;
  }
}


/* --- Restore history font size (keep tight padding) --- */
#btnHistory,
.menu-bar #btnHistory,
.menu-bar .menu-btn.btn-changelog{
  font-size: 0.86rem !important; /* same as .menu-btn */
  font-weight: 500 !important;
}
@media (max-width: 768px){
  #btnHistory,
  .menu-bar #btnHistory,
  .menu-bar .menu-btn.btn-changelog{
    font-size: 0.92rem !important; /* same as mobile .menu-btn */
  }
}


/* --- History padding tighter (override min-height) --- */
#btnHistory,
.menu-bar #btnHistory,
.menu-bar .menu-btn.btn-changelog{
  padding-top: 0px !important;
  padding-bottom: 0px !important;
  min-height: 0 !important;
  height: auto !important;
  line-height: 1 !important;
}


/* --- History button: explicit height to eliminate extra space (v1.0.0.2) --- */
#btnHistory{
  font-size: 0.86rem !important;         /* restore */
  font-weight: 500 !important;
  padding: 0 10px !important;            /* no vertical padding */
  height: 24px !important;               /* explicit */
  min-height: 24px !important;
  line-height: 1 !important;
  display: inline-flex !important;
  align-items: center !important;
}
#btnHistory svg{ display:none !important; } /* safety: if any icon sneaks in */

@media (max-width: 768px){
  #btnHistory{
    font-size: 0.92rem !important;
    height: 26px !important;
    min-height: 26px !important;
    padding: 0 10px !important;
  }
}

