* { box-sizing: border-box; }
body {
  font-family: -apple-system, "Hiragino Sans", "Yu Gothic", sans-serif;
  margin: 0;
  background: #f4f4f0;
  color: #222;
}
header {
  background: #1e4d2b;
  color: #fff;
  padding: 12px 20px;
}
header h1 { margin: 0 0 8px 0; font-size: 20px; }
nav { display: flex; gap: 4px; flex-wrap: wrap; }
.tab-btn {
  background: #2d6a3e;
  color: #fff;
  border: none;
  padding: 8px 16px;
  cursor: pointer;
  border-radius: 4px 4px 0 0;
  font-size: 14px;
}
.tab-btn.active { background: #f4f4f0; color: #1e4d2b; font-weight: bold; }

main { padding: 20px; max-width: 1100px; margin: 0 auto; }
.tab { display: none; }
.tab.active { display: block; }

h2 { margin-top: 0; color: #1e4d2b; }

.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}
@media (max-width: 720px) {
  .stats-grid { grid-template-columns: 1fr; }
}

table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}
th, td {
  padding: 8px 10px;
  text-align: right;
  border-bottom: 1px solid #e0e0e0;
  font-size: 14px;
}
th { background: #eaeae5; font-weight: bold; }
th:first-child, td:first-child { text-align: left; }
tr.rank-1 td:first-child::before { content: "🥇 "; }
tr.rank-2 td:first-child::before { content: "🥈 "; }
tr.rank-3 td:first-child::before { content: "🥉 "; }

form { background: #fff; padding: 16px; border-radius: 6px; box-shadow: 0 1px 3px rgba(0,0,0,0.08); }
.row { display: flex; gap: 16px; margin-bottom: 12px; flex-wrap: wrap; align-items: center; }
label { display: flex; flex-direction: column; font-size: 13px; gap: 4px; }
select, input[type=text], input[type=number] {
  padding: 8px;
  border: 1px solid #ccc;
  border-radius: 4px;
  font-size: 14px;
}
button[type=submit] {
  background: #1e4d2b;
  color: #fff;
  border: none;
  padding: 10px 20px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
}
button[type=submit]:hover { background: #2d6a3e; }

.stats-actions { margin-top: 24px; text-align: right; }
#reset-btn {
  background: #c33;
  color: #fff;
  border: none;
  padding: 8px 16px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 13px;
}
#reset-btn:hover { background: #a22; }

#entries .entry-row {
  display: grid;
  grid-template-columns: 60px 1fr 140px;
  gap: 12px;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid #eee;
}
.entry-row .seat-label {
  font-weight: bold;
  color: #1e4d2b;
  font-size: 16px;
}

#total-check { font-weight: bold; }
#total-check.ok { color: #1e4d2b; }
#total-check.ng { color: #c33; }

#input-message { margin-top: 10px; }
#input-message.ok { color: #1e4d2b; }
#input-message.ng { color: #c33; }

.history-item {
  background: #fff;
  padding: 12px 16px;
  margin-bottom: 10px;
  border-radius: 6px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}
.history-meta { font-size: 12px; color: #666; margin-bottom: 6px; }
.history-entries { display: flex; gap: 16px; flex-wrap: wrap; font-size: 14px; }
.history-entries .he {
  padding: 4px 8px;
  background: #f4f4f0;
  border-radius: 4px;
}
.history-entries .rank1 { background: #fff4cc; font-weight: bold; }

.del-btn {
  background: #c33;
  color: #fff;
  border: none;
  padding: 4px 10px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
  float: right;
}

#player-list { list-style: none; padding: 0; }
#player-list li {
  background: #fff;
  padding: 10px 14px;
  margin-bottom: 6px;
  border-radius: 4px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
