* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue", sans-serif;
  background: #f0f4f8;
  min-height: 100vh;
  color: #333;
}

header {
  background: #3b82f6;
  color: #fff;
  padding: 14px 16px;
  text-align: center;
}

header h1 {
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: 0.05em;
}

main {
  padding: 16px 8px 40px;
}

.table-wrapper {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: 10px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
  min-width: 320px;
}

thead th {
  background: #3b82f6;
  color: #fff;
  padding: 10px 4px;
  font-size: 0.85rem;
  text-align: center;
  font-weight: 600;
}

thead th.period-col {
  background: #1d4ed8;
  width: 42px;
  min-width: 42px;
}

tbody tr:nth-child(even) {
  background: #f8fafc;
}

tbody td {
  border: 1px solid #e2e8f0;
  padding: 0;
  text-align: center;
  vertical-align: middle;
}

tbody td.period-label {
  background: #eff6ff;
  color: #1d4ed8;
  font-size: 0.78rem;
  font-weight: 700;
  padding: 6px 2px;
  width: 42px;
  min-width: 42px;
}

.cell-btn {
  display: block;
  width: 100%;
  min-height: 56px;
  padding: 6px 4px;
  background: transparent;
  border: none;
  cursor: pointer;
  font-size: 0.78rem;
  color: #333;
  line-height: 1.3;
  text-align: center;
  word-break: break-all;
  transition: background 0.15s;
}

.cell-btn:hover,
.cell-btn:focus {
  background: #dbeafe;
  outline: none;
}

.cell-btn.has-content {
  color: #1e3a8a;
  font-weight: 600;
  background: #eff6ff;
}

.cell-btn.has-content:hover {
  background: #bfdbfe;
}

.cell-btn.empty {
  color: #cbd5e1;
}

.hint {
  text-align: center;
  font-size: 0.75rem;
  color: #94a3b8;
  margin-top: 12px;
}

/* モーダル */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 100;
}

.modal {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: #fff;
  border-radius: 14px;
  padding: 24px 20px 20px;
  width: 90%;
  max-width: 340px;
  z-index: 200;
  box-shadow: 0 8px 30px rgba(0,0,0,0.2);
}

.modal h2 {
  font-size: 1rem;
  color: #1e3a8a;
  margin-bottom: 14px;
  text-align: center;
}

.modal input[type="text"] {
  width: 100%;
  padding: 10px 12px;
  font-size: 1rem;
  border: 1.5px solid #93c5fd;
  border-radius: 8px;
  outline: none;
  margin-bottom: 16px;
  color: #333;
}

.modal input[type="text"]:focus {
  border-color: #3b82f6;
}

.modal-actions {
  display: flex;
  gap: 8px;
  justify-content: center;
  flex-wrap: wrap;
}

button {
  cursor: pointer;
  border: none;
  border-radius: 8px;
  padding: 9px 18px;
  font-size: 0.9rem;
  font-weight: 600;
  transition: opacity 0.15s;
}

button:active {
  opacity: 0.75;
}

.btn-primary {
  background: #3b82f6;
  color: #fff;
  flex: 1;
}

.btn-danger {
  background: #ef4444;
  color: #fff;
}

.btn-cancel {
  background: #e2e8f0;
  color: #475569;
}

.hidden {
  display: none !important;
}

@media (max-width: 400px) {
  .cell-btn {
    font-size: 0.72rem;
    min-height: 50px;
  }

  thead th {
    font-size: 0.78rem;
    padding: 8px 2px;
  }

  .modal {
    padding: 20px 14px 16px;
  }
}
